代码<?php$Board=array(array(1081410332,'测试','测试留言本','http://www.piscdong.com'));?>index.php是留言显示和提交页面。
代码<?phprequire_once('board.php');function htmlencode($content){$content=htmlspecialchars($content);$content=preg_replace("//r/i","<br />",$content);return $content;}if($HTTP_SERVER_VARS['REQUEST_METHOD']=='POST'){$configpath_parts1 = pathinfo($SCRIPT_FILENAME);$time=time();$name=$HTTP_POST_VARS['name'];$url=(preg_match("/^[//w-]+(//.[//w-]+)*@[//w-]+(//.[//w-]+)+$/i",$HTTP_POST_VARS['url']) || $HTTP_POST_VARS['url']=='')?$HTTP_POST_VARS['url']:'http://'.htmlspecialchars(preg_replace("/https?/://///i",'',$HTTP_POST_VARS['url']),ENT_QUOTES);$info=htmlencode($HTTP_POST_VARS['info']);if($name!='' && $info!=''){$Board[]=array($time,$name,$info,$url);}for($i=0;$i<count($Board);$i++){$bd=current($Board);$s[]="/tarray(".$bd[0].",'".$bd[1]."','".$bd[2]."','".$bd[3]."')";next($Board);}$content="<?php/n/$Board=array(/n".join($s,",/n")."/n);/n?>";$filename=$configpath_parts1['dirname'].'/'.'board.php';if(is_writable($filename) || !file_exists($filename)){if(!$handle=fopen($filename,'w')){return false;}if(!fwrite($handle,$content)){return false;}fclose($handle);}else{return false;}header('Location:.');}else{?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>留言本</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /></head><body><form method="post" name="form1" action=""><table border="0" cellspacing="5" cellpadding="0" align="center"><tr><td><div style="overflow:auto;height:250px;border:1px dotted #999999;padding:5px;word-wrap:break-word;width:400px;"><?php end($Board);for($i=0;$i<count($Board);$i++){$bd=current($Board);$s[]='<strong>'.($bd[3]!=''?'<a href="':'').(preg_match("/^[//w-]+(//.[//w-]+)*@[//w-]+(//.[//w-]+)+$/i",$bd[3])?'mailto:':'').$bd[3].(($bd[3]!='' && !preg_match("/^[//w-]+(//.[//w-]+)*@[//w-]+(//.[//w-]+)+$/i",$bd[3]))?'" target="_blank':'').($bd[3]!=''?'">':'').$bd[1].($bd[3]!=''?'</a>':'').':</strong> '.$bd[2].'<br/><em>-'.date("G:i, M j, Y",$bd[0]).'</em>';prev($Board);}echo join($s,'<br/><br/>');?></div></td></tr><tr><td align="center">名称:<input type="text" name="name"/> URL/Email:<input type="text" name="url"/><br/><textarea name="info" cols="40" rows="8"></textarea><br/><input type="submit" value="发布"/></td></tr></table></form></body></html><?php } ?>config.php中存放的是管理留言本的密码,把密码放在单独一个文件中方便修改。
代码<?php $password='123456'; ?>admin.php是管理页面,功能很简单,只能删除留言。在删除时需要输入管理密码,管理密码存放在config.php中。
代码<?phprequire_once('board.php');require_once('config.php');if(isset($HTTP_POST_VARS['id']) && $HTTP_POST_VARS['id']!='' && addslashes($HTTP_POST_VARS['password'])==$password){if(count($Board)>1){unset($Board[intval($HTTP_POST_VARS['id'])]);for($i=0;$i<count($Board);$i++){$bd=current($Board);$s[]="/tarray(".$bd[0]."<p>此新闻共有<font color=red><b>2</font></b>页 上一页 <a href=185938.html>1</a> <a href=185938-2.html>2</a> 下一页</TD></TR></TBODY></TABLE></DIV><TABLE class=pageSpaceNewsSeparator cellSpacing=0 cellPadding=1 width="100%" border=0><TBODY><TR><TD width="71%" height=24><a href=/sendmail.asp?filename=185938 target=_blank class=a01>推荐好友</a> <SPAN class=pageIcon>| <a href=/member/add_favorite.asp?filename=185938 target=_blank class=a01>频道收藏</a> | <A class=a01 onclick=javascript:doPrint() href="">打印文档</A> | <a href=/senderror.asp?filename=185938 target=_blank class=a01>报告错误</a> </SPAN></TD><TD align=right width="29%"> <A href="javascript:window.close()"><IMG height=15 src="http://www.163design.net/p/uploadfile/200506/2005622153824725.gif" width=48 border=0></A><A href="http://www.channel7.cn/admin/Templet_textbox.asp?action=Modify&ID=3#top"><IMG height=15 src="http://www.163design.net/p/uploadfile/200506/2005622153824209.gif" width=38 border=0></A></TD></TR></TBODY></TABLE><TABLE height=117 cellSpacing=2 cellPadding=0 width="100%" border=0><TBODY><TR><TD class=titleNewsRemark id=fontzoom vAlign=top width="56%" height=40><TABLE cellSpacing=0 cellPadding=5 width="100%" border=0><TBODY><TR><TD class=titleListNews><STRONG>相关连接</STRONG></TD></TR><TR><TD>・<a href= http://www.channel7.cn/2005/1-1/18847.html target=_blank>用PHP调用数据库的存贮过程</a><br>・<a href= http://www.channel7.cn/2004/12-31/11570.html target=_blank>php注入2</a><br>・<a href= http://www.channel7.cn/2004/12-31/115612.html target=_blank>php注入!</a><br>・<a href= http://www.channel7.cn/2004/12-30/175521.html target=_blank>php上传、管理照片示例</a><br>・<a href= http://www.channel7.cn/2004/12-30/175141.html target=_blank>php文本站内全文检索</a><br>・<a href= http://www.channel7.cn/2004/12-30/17482.html target=_blank>全面考察“禁用浏览器后退按钮”</a><br>・<a href= http://www.channel7.cn/2004/12-30/174713.html target=_blank>PHP中的Java扩展</a><br>・<a href= http://www.channel7.cn/2004/12-24/1266.html target=_blank>PHP-Push技术实现刷新功能</a><br></TD></TR></TBODY></TABLE><!--Content Start--><!--Content End--></TD><TD class=titleNewsRemark id=fontzoom vAlign=top width="44%"><TABLE cellSpacing=0 cellPadding=5 width="100%" border=0><TBODY><TR><TD class=titleListNews><STRONG>同一专题</STRONG></TD></TR><TR><TD>・无相关专题</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><TABLE class=titleNewsRemark cellSpacing=0 cellPadding=1 width="100%" border=0><TBODY><TR><TD class=pageSpaceNewsSeparator width="56%" height=26><SPAN class=style1><FONT color=#ff6347>■<STRONG>发表评论</STRONG></FONT></SPAN></TD><TD align=left width="44%" rowSpan=2><SPAN class=titleNewsRemark><FONT color=#f26c4f>版权声明:</FONT>除部分特别声明不要转载,或者授权我站独家播发的文章外,大家可以自由转载我站点的原创文章,但原作者和来自我站的链接必须保留(非我站原创的,按照原来自一节,自行链接)。文章版权归我站和作者共有<BR><FONT color=#f26c4f>转载</FONT></SPAN><SPAN style="BACKGROUND-COLOR: #f9f9f9" #invalid_attr_id="16px"><FONT color=#f26c4f>要求</FONT></SPAN><SPAN class=titleNewsRemark><FONT color=#f26c4f>:</FONT>转载之图片、文件,链接请不要盗链到本站,且不准打上各自站点的水印,亦不能抹去我站点水印。</SPAN></TD></TR><TR><TD height=118><SPAN class=style2><form method=post action=http://www.channel7.cn/add_review.asp><input type=hidden Name=FileName value=185938>共有评论<font color=red><script src=http://www.channel7.cn/reviewcount.asp?filename=185938></script></font>篇 <a href=185938.asp>查看评论</a><br>姓名:<input type=text name=Name><input type=submit name=Submit value=发表评论><br><textarea name=Content cols=30 rows=4 title=不支持HTML,支持UBB代码>