一个php作的文本留言本的例子(四)

这一节我们将dele.php和sys.php放上来.
---------
//dele.php

 1<html>
 2<head>
 3<title>删除留言</title>
 4<style>   
 5<!--   
 6A:link {text-decoration: none ; color:0000ff}   
 7A:visited {text-decoration: none; color:004080}   
 8A:active {text-decoration: none}   
 9A:hover {text-decoration: underline; color:ff0000}   
10BODY {FONT-SIZE:10pt}   
11TH {FONT-SIZE:10 pt}   
12TD {FONT-SIZE: 10pt}   
13\-->   
14</style>
15<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
16</head>
17<?   
18  
19require("sys.php");   
20if ($Submit)   
21{   
22  
23if ($password<>$managepwd)   
24{$errorm="<font color="red">密码错误</font>.无权操作..";}   
25  
26else   
27{   
28$content=file($guestfile);   
29$message=$content[$record-1];   
30$count=count($content);   
31if ($dele=="delreply")   
32{   
33$replylen=strlen(strstr($message,"&lt;!--reply&gt;"));   
34$long=strlen($message);   
35$len=$long-$replylen;   
36$message=substr($message,0,$len);   
37}   
38else   
39{$message="";}   
40//writefile   
41$fp=fopen($guestfile,"w");   
42for ($i=0;$i&lt;$count;$i++)   
43{   
44if ($i==($record-1)){$content[$i]=$message;}   
45fputs($fp,$content[$i],strlen($content[$i]));   
46}//end for   
47fclose($fp);   
48echo "<meta content="1;url=guest.php" http-equiv="Refresh"/>";   
49exit;   
50}   
51}// end ifSubmit   
52$content=file($guestfile);   
53$message=$content[$record-1];   
54$found=ereg("&lt;!--reply&gt;",$message);   
55?&gt;   
56<body background="back.gif" bgcolor="#FFFFFF">
57<? include("head.htm"); ?>
58<table align="center" border="1" bordercolor="#F2F2F2" cellpadding="5" cellspacing="0" width="68%">
59<form action="dele.php" method="post">
60<?   
61if ($errorm)   
62{   
63echo "<tr>";   
64echo "<td height="27">$errorm</td>";   
65echo "";   
66}   
67?&gt;   
68<? echo $message ?>
69<tr align="center">
70<td bgcolor="#f0f0f0" height="37">
71<?   
72if ($found)   
73{   
74echo "<input type=radio name=dele value=delall>";   
75echo "全部删除 ";   
76echo "<input checked="" name="dele" type="radio" value="delreply"/>";   
77echo "仅删除回复";   
78}   
79?&gt;   
80<font color="#000000">管理密码</font>
81<input name="password" size="10" type="password"/>
82<input "$record";?="" echo="" name="record" type="hidden" value="&lt;?"/>&gt;   
83<input name="Submit" type="submit" value="我要删除了"/>
84</td>
85</tr>
86</form>
87</table>
88<? include("bottom.htm"); ?>
89</body>
90</html>

------
//sys.php

1<title>zihanonline</title>
=70) { for ($j=$i;$j<$len;$j++) { $txt[$j+1]=$arrtemp[$j]; } $txt[$i]="n"; $len=$len+1; $txt[$len]=$arrtemp[$len-1]; $count=0; $arrtemp=$txt; }//end if count } $txt=trim($txt); return $txt; }//end function function encode ($txt) { $txt=strip_tags($txt); $txt=htmlspecialchars($txt); $message=StripSlashes($txt); return $message; } function ubb($txt) { } ?> ```\---------- 注意sys.php中的" $managepwd='zihanonline' "一栏中等号后的是留言本的管理密码号,此时是默认的zihanonline.您可以修改为自己的号码. 未完待续...```
Published At
Categories with Web编程
Tagged with
comments powered by Disqus