<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>丫丫留言板-YaYa MessageBoard</title> <style type="text/css"> <? if(phpversion()>="4.1.0"){ extract($_REQUEST); extract($_COOKIE); } /*欢迎使用"丫丫留言板(YaYa MessageBoard )"*/ define(WENJIAN,"index.php");//留言板主文件名
define(PASS, '123'); define(LOGFILE, 'liuyan.txt');//留言存放文件
define(YE, '10');//每页显示留言数目
$jzusername=array("whl","whl204","丫丫"); //开头
function head($head) { $head= '
'; echo $head; } //form 显示
$msge=' WENJIAN.'">
'; function bb2html($st,$woimg) { //global $woimg;
$st = preg_replace("/\[b\](.*?)\[\/b\]/si", "\\1", $st); $st = preg_replace("/\[i\](.*?)\[\/i\]/si", "\\1", $st); $st = preg_replace("/\[u\](.*?)\[\/u\]/si", "\\1", $st); $st = preg_replace("/\[p\](.*?)\[\/p\]/si", "\\1 ", $st); $st = preg_replace("/\[color=(\S+?)\](.*?)\[\/color\]/si", "\\2", $st); $st = preg_replace("/\[s([1-7])\](.*?)\[\/s([1-7])\]/si", "\\2", $st); $st = preg_replace("/\[pre\](.*?)\[\/pre\]/si", "\\1 ", $st); $st = preg_replace("/\[quote\](.*?)\[\/quote\]/si", "\\1 ", $st); $st = preg_replace("/(^|[^=\]h])(ttp:)/si", "\\1http:", $st); $st = preg_replace("/(^|[^=\]])(http|https|ftp)(:\/\/[\!-;\=\?-\~]+)/si", "\\1\\2\\3", $st); $st = preg_replace("/(^|[^=\]\/])(www\.[\!-;\=\?-\~]+)/si", "\\1\\2", $st); $st = preg_replace("/\[url\](http|https|ftp)(:\/\/\S+?)\[\/url\]/si", "\\1\\2", $st); $st = preg_replace("/\[url\](\S+?)\[\/url\]/si", "\\1", $st); $st = preg_replace("/\[url=(http|https|ftp)(:\/\/\S+?)\](.*?)\[\/url\]/si", "\\3", $st); $st = preg_replace("/\[url=(\S+?)\](\S+?)\[\/url\]/si", "\\2", $st); $st = preg_replace("/\[email\](\S+?@\S+?\\.\S+?)\[\/email\]/si", "\\1", $st); $st = preg_replace("/\[email=(\S+?@\S+?\\.\S+?)\](.*?)\[\/email\]/si", "\\2", $st); if($woimg){ $st = preg_replace("/\[img\](mailto:)?(\S+?)(\.jpe?g|\.gif|\.png)\[\/img\]/si", "", $st); } $st = str_replace("&heart;","♥",$st); return $st; } //写入信息
function xie($name,$txt,$pass) { global $jzusername; //,$panduan, $woimg;
//完成提示
$wan='
'; $shicha = 0;//时差
$time=strftime("%Y-%m-%d %H:%M:%S",time()+$shicha*3600); global $REQUEST_METHOD; if(empty($name)) error("姓名不能为空"); if(empty($txt)) error("内容不能为空"); if(strlen($name) > 14) error("姓名不能超过7个汉字"); if(strlen($name) > 1000) error("内容不能超过500汉字"); $line = file(LOGFILE); list($lastno,$ltime,$lname,$ltxt) = explode(",", $line[0]); $no=$lastno+1; $name=CleanStr($name); $txt=CleanStr($txt); if(ereg("[ \r]",$name)) error("用户名中间不能用空格"); if(!$pass==PASS) { for($m=0;$m<count($jzusername);$m++) { if($jzusername[$m]==$name) error("留言板保留用户名"); } } if($pass==PASS) { $name="".$name.""; $woimg=1; } $txt = str_replace( "\r\n", "\n", $txt); $txt = str_replace( "\r", "\n", $txt); $txt = ereg_replace("\n(( | )*\n){3,}","\n",$txt); $txt = nl2br($txt); $txt = str_replace("\n", "", $txt); $txt = bb2html($txt,$woimg); $newline = "$no,$time,$name,$txt\n"; $fp = fopen(LOGFILE, "w"); flock($fp, 2); fputs($fp, $newline); fputs($fp, implode('', $line)); fclose($fp); echo $wan; echo ".WENJIAN." \">"; } //字符串过滤
function CleanStr($str)
{ $str = trim($str); if (get_magic_quotes_gpc()) { $str = stripslashes($str); } $str = htmlspecialchars($str); $str = str_replace("&", "&", $str); return str_replace(",", ",", $str); } //上一页下一页显示
function pagexianshi($gongjl,$gongye,$diye,$shangye,$xiaye) { global $no,$nextint,$j; if(isset($no)) { if ($no==1&&$nextint==0){} else { if($no>$nextint or $no <=0 ) error("没有该页"); } } else {$no=1;} $gongjl = "共$j\0条留言 "; $gongye = "共$nextint\0页 "; $diye = "第$no\0页  ";
if($no==1&&$nextint==1) { } else{ if($no==1&&$nextint>$no) { $no1=$no+1; $xiaye=".WENJIAN."?no=$no1\">下一页"; } else { if($no==$nextint) { $no1=$no-1; $shangye=".WENJIAN."?no=$no1\">上一页"; } else { $no1=$no-1; $shangye=".WENJIAN."?no=$no1\">上一页  "; $no1=$no1+2; $xiaye=".WENJIAN."\">下一页"; } } } $dat1.='WENJIAN.'">'; $dat1.="$gongjl $gongye $diye $shangye $xiaye 第页 "; $dat1.='.WENJIAN.'?act=admin">管理'; echo $dat1; } //错误跳出
function error($err){ echo "
$err
"; die("
|