[phpdbg]php+dbfile开发小型留言本

时间:2013-11-28  来源:留言  阅读:
board.php用来存储数据,可以先在里面添加了一条留言纪录。
代码
$Board=array(
array(1081410332,"测试","测试留言本","http://www.piscdong.com")
);
?>
index.php是留言显示和提交页面。
代码
require_once("board.php");
function htmlencode($content){
$content=htmlspecialchars($content);
$content=preg_replace("//i","
",$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$bd=current($Board);
$s[]=" array(".$bd[0].","".$bd[1]."","".$bd[2]."","".$bd[3]."")";
next($Board);
}
$content="";
$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{
?>



留言本





[phpdbg]php+dbfile开发小型留言本

http://m.bbyears.com/zhufuduanxin/2321.html

推荐访问:php db
相关阅读 猜你喜欢
本类排行 本类最新