PHP+MYSQL的文章管理系统(二) 

###############index.php######################

1<script language="javascript">   
2function opwin(filename)   
3{ window.open("read_article.php?id="+filename,"","height=500,width=585,resizable=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");   
4}   
5  
6</script>
  1<body bgcolor="#FFFFFF" leftmargin="0" text="#000000" topmargin="0">
  2<table bgcolor="#003399" border="0" cellpadding="0" cellspacing="0" height="23" width="100%">
  3<tr>
  4<td width="80">
  5<div id="Layer2" style="position:absolute; left:7px; top:17px; width:43px; height:44px; z-index:2"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" height="60" width="80">
  6<param name="movie" value="images/logo.swf"/>
  7<param name="quality" value="high"/>
  8<param name="wmode" value="transparent"/>
  9<embed height="60" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" quality="high" src="images/logo.swf" type="application/x-shockwave-flash" width="80" wmode="transparent"/>
 10</object></div>
 11<div id="Layer1" style="position:absolute; left:-5px; top:61px; width:49px; height:37px; z-index:1"><img height="55" src="images/11.gif" width="58"/></div>
 12</td>
 13<td width="539"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" height="60" width="468">
 14<param name="movie" value="images/ti1.swf"/>
 15<param name="quality" value="high"/>
 16<param name="wmode" value="transparent"/>
 17<embed height="60" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" quality="high" src="images/ti1.swf" type="application/x-shockwave-flash" width="468" wmode="transparent"/>
 18</object> </td>
 19</tr>
 20</table>
 21<table border="0" cellpadding="0" cellspacing="0" width="100%">
 22<tr>
 23<td background="images/211.gif" height="2"> </td>
 24</tr>
 25</table>
 26<table><form action="search.php" method="post" name="form1" target="_blank">
 27<table align="center" bgcolor="#009933" border="0" cellpadding="0" cellspacing="0" width="80%">
 28<tr>
 29<td align="center">
 30<input name="key" type="text"/>
 31<select name="type">
 32<option value="">全部类别</option>
 33<? $typ=file("list.txt");   
 34$num=count($typ);   
 35for($i=2;$i<=$num;$i++)   
 36{   
 37echo"<option value=$typ[$i]>$typ[$i]";}   
 38?&gt;   
 39</select>
 40<select name="whe">
 41<option value="">全部内容</option>
 42<option value="1">文章内容</option>
 43<option value="2">文章标题</option>
 44<option value="3">加入时间</option>
 45</select>
 46<input name="submit" type="hidden" value="1"/>
 47<input name="submit" type="submit" value="提交查询"/>
 48</td>
 49</tr>
 50</table>
 51</form></table>
 52<?   
 53$type=trim($type);   
 54if($comm)   
 55{   
 56$sec="and comm=1";   
 57$fir="where comm=1";   
 58}   
 59if(!empty($type))   
 60$query="select count(*) from $table where type='$type' $sec";   
 61else   
 62$query="select count(*) from $table $fir";   
 63$res=mysql_db_query("$database",$query);   
 64if(@mysql_num_rows($res)>0)   
 65$tot=mysql_fetch_array($res);   
 66$total=$tot[0];   
 67$total_page=ceil($total/$pagenum);   
 68echo "<table align="center" border="0" cellpadding="0" cellspacing="0" width="80%">";   
 69echo "<tr><td>共:".$total."篇".$total_page."页</td></tr>";   
 70if(empty($page))   
 71$page=0;   
 72if(empty($offset))   
 73$offset=0;   
 74$offset=$pagenum*$page;   
 75if(!empty($type))   
 76$query="select * from $table where type='$type' $sec order by id desc limit $offset,$pagenum";   
 77else   
 78$query="select * from $table $fir order by id desc limit $offset,$pagenum";   
 79$res=mysql_db_query("$database",$query);   
 80if(@mysql_num_rows($res)&gt;0)   
 81while($topic=mysql_fetch_array($res))   
 82{   
 83if(strlen($topic[title])&gt;40)   
 84{   
 85$topic[title]=substr($topic[title],0,40) ;   
 86$topic[title]=$topic[title].".....";   
 87}   
 88if(trim($topic[time])==date(Y年m月d日))   
 89$topic[time]="<font color="#FF9900">$topic[time]</font>";   
 90echo" <tr><td>[$topic[type]]<a ;="" href="#" onclick="opwin($topic[id])">$topic[title]</a><font size="1">($topic[time])</font>";   
 91if($topic[comm]==1)   
 92echo "<img alt="精品文章" src="./images/comm.gif"/>";   
 93if($topic[locked]==1)   
 94echo "<img alt="文章已锁定" src="./images/locked.gif"/>";   
 95echo "</td>
 96<td>阅读:$topic[hits] 次;评论:$topic[p_num]次</td>
 97</tr>";   
 98}   
 99else   
100echo " 对不起,本栏 目暂没有任何文章!!!";   
101echo "</table>";   
102?&gt;   
103  
104<br/>
105<table align="center" border="0" cellpadding="0" cellspacing="0" width="80%">
106<tr>
107<td>
108<?   
109$pre=$page-1;   
110$next=$page+1;   
111if($page>0)   
112echo "<a href="$php_self?page=$pre&amp;type=$type">上一页</a><br/><br/>";   
113else   
114echo "上一页<br/><br/>"; ?&gt;</td>
115<td><?if($page<$total_page-1)   
116echo " <a href="$php_self?page=$next&type=$type">下一页<br/><br/>";   
117else echo " 下一页<br/><br/>";?&gt;</td>
118<td>
119<form> 跳转到:   
120<select class="border" name="page" onchange="top.location='&lt;? echo $php_self;?&gt;?page='+document.forms[1].elements[0].value+'&amp;type=&lt;?echo $type;?&gt;';">
121<?   
122for($i=0;$i<$total_page;$i++)   
123{   
124$p=$i+1;   
125echo "<option value=$i";   
126if($page==$i) echo " selected" ;   
127echo ">第".$p."页n";   
128}   
129?&gt;   
130</select> </form>
131</td>
132<td>
133<form>选择栏目:   
134<select +'&comm="1'&quot;;?" name="type" onchange="top.location='&lt;? echo $php_self;?&gt;?type='+document.forms[2].elements[0].value&lt;?if($comm) echo">;" &gt;   
135<? $typ=file("list.txt");   
136$num=count($typ);   
137for($i=0;$i<$num;$i++)   
138{   
139echo"<option value=$typ[$i] "; if(trim($typ[$i])==$type) { echo " selected"; } echo ">$typ[$i]";}   
140?&gt;   
141</select>
142</form>
143</td><td><form $php_self;?="" action="&lt;?" echo="" method="post">?type=<?echo $type;?> target="_balnk"&gt;<input class="border" name="comm" type="submit" value="精品文章"/></form></td>
144</tr>
145</table>
146<?require "./inc/footer.inc";?>   
147#####################read_article.php#########################   
148<?   
149require"./inc/func.php";   
150if(!$id)   
151{   
152echo"<script>window.close();";   
153exit();   
154}   
155mscon();   
156$query="select * from $table where id='$id'";   
157$res=mysql_db_query("$database",$query);   
158if(!$res)   
159{   
160echo "this article has been deleted or no this article!!";   
161exit();   
162}   
163$data=mysql_fetch_array($res);   
164add_hits($data[id]);   
165$pre=$data[id]-1;   
166$next=$data[id]+1;   
167?&gt;   
168<html>
169<head>
170<title>
171<? echo "$data[title]--[$data[type]]";?>
172</title>
173<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
174<style type="text/css">   
175<!--   
176body,table,td,input,textarea { font-family: "宋体"; font-size: 9pt}   
177select { font-family: "宋体"; font-size: 9pt}   
178code {font-family: "Courier" ; font-size: 10pt}   
179a { color: #005500}   
180a:hover { color: #CC0000}   
181.border {border: 1px #000000 solid; background-color:transparent; list-style-position: inside; list-style-type: square}   
182\-->   
183</style>
184<script language="javascript">   
185function name()   
186{   
187var theResult = true;   
188var elem4 = null;   
189  
190if (document.forms[0].elements[0].value == "" || document.forms[0].elements[0].value == "undefined" || document.forms[0].elements[0].value == "null")   
191{   
192elem4 = prompt("请输入您的姓名:","");   
193theResult = false;   
194document.forms[0].elements[0].value = elem4;   
195}   
196return theResult;   
197}   
198function mail()   
199{   
200var theResult = true;   
201var elem1 = null   
202if ((document.forms[0].elements[1].value.indexOf('@') == -1 || document.forms[0].elements[1].value == "" || document.forms[0].elements[1].value.indexOf('.') == -1))   
203{   
204elem1 = prompt("请输入您的正确的电子邮件地址。谢谢!!","");   
205theResult = false;   
206document.forms[0].elements[1].value = elem1;   
207}   
208return theResult;   
209}   
210function go()   
211{   
212var theResult=true;   
213theResult = name()&&mail();   
214return theResult;   
215}   
216</script>
217</head>
218<body bgcolor="#ffffff" text="#000000">
219<table align="center" border="1" bordercolor="#339933" bordercolordark="#ffffff" bordercolorlight="#000000" cellpadding="0" cellspacing="0" width="545">
220<tbody>
221<tr bgcolor="#009900" valign="center">
222<td background="images/third-back3.gif">
223<table border="0" cellpadding="0" cellspacing="0" width="100%">
224<tbody>
225<tr>
226<td width="17"> </td>
227<td width="590">
228<table align="center" border="0" width="36%">
229<tbody>
230<tr>
231<td bgcolor="#009900">
232<div align="center"><font color="#ffffff" face="Verdana, Arial, Helvetica, sans-serif"><b>
233<? echo $data[title];?>
234</b></font></div>
235</td></tr></tbody></table></td>
236<td width="19">
237<div align="center"><a href="javascript:window.close()"><img align="absMiddle" border="0" height="17" name="content_r03_c28" src="images/third-close.gif" width="17"/></a></div>
238</td></tr></tbody></table></td></tr>
239<tr align="left" bgcolor="#cccccc" valign="center">
240<td>
241<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
242<tbody>
243<tr>
244<td>
245<div align="left"><a class="whitetxt" href="read_article.php?id=&lt;? echo $pre;?&gt;"><img border="0" height="12" src="images/prethread.gif" width="48"/></a></div>
246</td>
247<td>
248<div align="left"><a class="whitetxt" href="read_article.php?id=&lt;? echo $next;?&gt;"><img border="0" height="12" src="images/nextthread.gif" width="48"/></a></div>
249</td>
250<td><img height="16" src="images/mail.gif" width="16"/></td>
251<td class="myfont"><a $data[id]&title='$data[title]";?' class="redtxt" href="commend.php?id=&lt;? echo ">"&gt;推荐给朋友</a></td>
252<td> 发表时间:   
253<? echo $data[time];?>   
254阅读次数:   
255<? echo $data[hits];?>
256</td>
257<td>  </td>
258</tr>
259</tbody>
260</table>
261</td></tr>
262<tr valign="top">
263<td class="tenpt">
264<?   
265if($data[locked]<>0)   
266{   
267echo "<img src="images/lock.gif"/>对不起!本文已经被管理员锁定!";   
268}   
269else   
270if($data[html]==1)   
271highlight_string($data[cont]);   
272else   
273echo nl2br($data[cont]);   
274?&gt;   
275</td>
276</tr>
277</tbody></table>
278<table align="center" border="1" bordercolor="#339933" bordercolordark="#ffffff" bordercolorlight="#000000" cellpadding="0" cellspacing="0" width="545">
279<tbody>
280<tr bgcolor="#cccccc">
281<th>
282<div align="center">发表评论</div>
283</th>
284</tr>
285<tr>
286<td>
287<form action="ping.php" method="post" name="form1" onsubmit="return go()">   
288您的姓名:   
289<input class="border" name="name" type="text"/>   
290  您的电子邮件:   
291<input class="border" name="mail" size="20" type="text"/>   
292仅站长可见:<input name="pub" type="checkbox" value="&lt;? echo $data[title];?&gt;"/>
293<input name="p_id" type="hidden" value="&lt;? echo $id;?&gt;"/>
294<br/>   
295发表评论:   
296<textarea cols="85" name="cont" rows="8"></textarea>
297<br/>
298<br/>
299<center>
300<input class="border" name="Submit" type="submit" value="提交"/>
301<input class="border" name="Submit2" type="reset" value="重写"/>
302</center></form>
303</td>
304</tr>
305<tr bgcolor="#cccccc">
306<th>
307<div align="center">相关评论</div>
308</th>
309</tr>
310<tr>
311<td>
312<? $query="select * from $ping_tab where p_id='$id' order by time desc";   
313$res=mysql_db_query("$database",$query);   
314if(mysql_num_rows($res)>0)   
315{$i=1;   
316while($ping=mysql_fetch_array($res))   
317echo "评论人:$ping[name] 电子邮件:$ping[mail]<br/>  ".nl2br($ping[p_cont])."<br/>时间:$ping[time] 来自:$ping[ip]<hr size="1"/>n" ;   
318}   
319else   
320echo "暂时没有本文章的相关评论!";   
321?&gt;   
322</td>
323</tr>
324<tr bgcolor="#cccccc">
325<td>
326<div align="center"><a href="javascript:window.close()">关闭窗口</a></div>
327</td>
328</tr>
329</tbody>
330</table>
331<?require "./inc/footer.inc";?></body></html></body>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus