⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.php

📁 用php语言编写地留言本模块。这个模块实现了留言地强大功能。
💻 PHP
📖 第 1 页 / 共 4 页
字号:
<?
############ ZTSKY留言簿1.0版本 ########################################################
# 版权所有: ztsky
# E-mail : yangyuyan@sina.com
# OICQ  : 605202
# 主页地址: http://www.zthouse.com/
#
# 【版权声明】
# 本程序提供个人网站免费使用,请勿非法修改,
# 转载,散播,或用于其他图利行为,并请勿删除版权声明以及我的主页地址!!!
# 如果您的网站正式起用了这个脚本,请您通知我们,以便我能够知晓,
# 如果可能,请在您的网站做上我们的链接,希望能给予合作。谢谢!
#
# 【程序功能】
#1. 支持多用户,功能强大 
#2. 界面美观,模仿UGB风格
#3. 支持OICQ在线显示
#4. 在线申请留言簿在线开通
#5. 版主在线修改, 即时生效
#6. 超级管理可以随时删除申请留言簿的用户
#7. 可显示访客IP及留言时间。
#8. 每个版主都可以管理自己版内的留言,包括了删除留言和回复留言。
#9. 提供搜索留言资料,速度快、功能强。
#10.斑竹可以自定义留言簿头部显示信息和尾部显示信息。
#11.可以设定是否支持ubb码和html码
#12.只是使用文本作为数据库,穷人有福!
#
#   还有就是一些公用的函数都放在了函数部分,大家可以很方便的修改,呵呵
#   对于程序的安装设置也是非常简单,如果大家怕麻烦,可以运行run.php
# 她会帮你修改所有文件的属性!对于变量的设置请参见设置部分。
# 这里是留言簿的演示:2hu.net/free/gb
#########################################################################################
# 请您尊重我们的劳动和版权,不要删除以上的版权声明部分,谢谢合作!!
#########################################################################################
####################################设置部分#############################################
$admin[path]="./data";				##数据库文件的路径
$admin[home]="http://www.zthouse.com";		##主页地址
$admin[password]="123";				##管理员密码
$admin[email]="yangyuyan@sina.com";			##管理员邮箱
$admin[name]="ztsky";				##管理员帐号
$admin[homename]="紫桐工作室";			##主页名称
$admin[ubb]=1;					##是否支持UBB代码,0=否
$admin[html]=0;					##是否支持HTML代码,0=否
$admin[up]="";					##留言簿上部HTML代码
$admin[down]="";				##留言簿下部HTML代码
$admin[page]=5;					##每页默认显示留言数目
$admin[img]="image";				##图片文件储存URL
$admin[gb]="http://ztasp.host.wayall.com/gb/index.php";	##留言簿主页主程序URL
####################################设置完成#############################################
if(empty($home))$home=$admin[home];
$pass=$admin[password];
if(empty($email))$email=$admin[email];
#########################################################################################
####################################公用函数#############################################
function oicq($uin){
 if($uin=="")return 1;else
 if(strlen($uin)<=8 and !eregi("([^0-9])",$uin))return 1;else return 0;
}
function getline($file){
  $data=Chop(fgets($file,5000));
  return $data;
}
function nowtime(){
  $date=date("Y-m-d.G:i:s");
  return $date;
}
function getid(){
  $id=date("YmdHis");
  return $id;
}
function ubb($Text) { 
  $Text=htmlspecialchars($Text); 
  $Text=ereg_replace("\r\n","<br>",$Text); 
  $Text=ereg_replace("\r","<br>",$Text); 
  $Text=nl2br($Text); 
  $Text=preg_replace("/\\t/is","  ",$Text); 
  $Text=preg_replace("/\[h1\](.+?)\[\/h1\]/is","<h1>\\1</h1>",$Text); 
  $Text=preg_replace("/\[h2\](.+?)\[\/h2\]/is","<h2>\\1</h2>",$Text); 
  $Text=preg_replace("/\[h3\](.+?)\[\/h3\]/is","<h3>\\1</h3>",$Text); 
  $Text=preg_replace("/\[h4\](.+?)\[\/h4\]/is","<h4>\\1</h4>",$Text); 
  $Text=preg_replace("/\[h5\](.+?)\[\/h5\]/is","<h5>\\1</h5>",$Text); 
  $Text=preg_replace("/\[h6\](.+?)\[\/h6\]/is","<h6>\\1</h6>",$Text); 

  $Text=preg_replace("/\[url\](http:\/\/.+?)\[\/url\]/is","<a href=\\1>\\1</a>",$Text); 
  $Text=preg_replace("/\[url\](.+?)\[\/url\]/is","<a href=\"http://\\1\">http://\\1</a>",$Text); 
  $Text=preg_replace("/\[url=(http:\/\/.+?)\](.*)\[\/url\]/is","<a href=\\1>\\2</a>",$Text); 
  $Text=preg_replace("/\[url=(.+?)\](.*)\[\/url\]/is","<a href=http://\\1>\\2</a>",$Text); 

  $Text=preg_replace("/\[img\](.+?)\[\/img\]/is","<img src=\\1>",$Text); 
  $Text=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/is","<font color=\\1>\\2</font>",$Text); 
  $Text=preg_replace("/\[size=(.+?)\](.+?)\[\/size\]/is","<font size=\\1>\\2</font>",$Text); 
  $Text=preg_replace("/\[sup\](.+?)\[\/sup\]/is","<sup>\\1</sup>",$Text); 
  $Text=preg_replace("/\[sub\](.+?)\[\/sub\]/is","<sub>\\1</sub>",$Text); 
  $Text=preg_replace("/\[pre\](.+?)\[\/pre\]/is","<pre>\\1</pre>",$Text); 
  $Text=preg_replace("/\[email\](.+?)\[\/email\]/is","<a href=\\1>\\1</a>",$Text); 
  $Text=preg_replace("/\[i\](.+?)\[\/i\]/is","<i>\\1</i>",$Text); 
  $Text=preg_replace("/\[b\](.+?)\[\/b\]/is","<b>\\1</b>",$Text); 
  $Text=preg_replace("/\[quote\](.+?)\[\/quote\]/is","<blockquote><font size='1' face='Courier New'>quote:</font><hr>\\1<hr></blockquote>", $Text); 
   $Text=preg_replace("/\[code\](.+?)\[\/code\]/is","<blockquote><font size='1' face='Times New Roman'>code:</font><hr color='lightblue'><i>\\1</i><hr color='lightblue'></blockquote>", $Text); 
   $Text=preg_replace("/\[sig\](.+?)\[\/sig\]/is","<div style='text-align: left; color: darkgreen; margin-left: 5%'><br><br>--------------------------<br>\\1<br>--------------------------</div>", $Text); 
return $Text; 
} 
function str($msg){
  global $admin;
  if(!$admin[html]) $msg=htmlspecialchars($msg);
  if($admin[ubb]) $msg=ubb($msg);
  $msg=nl2br($msg); #处理message
  $msg= str_replace("\n","",$msg); #处理message
  $msg= str_replace("\r","",$msg); #处理message
  return $msg;
}
function error($msg){
global $admin;
?>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="<?echo$admin[img];?>/style.css"><title>留言簿出错</title></head>
<body background="image/bgmc.gif"><html><head></head><body bgcolor="#FFFFFF"> 
<center><table border="0" width="100%" height="100%" cellspacing="0" cellpadding="0">
<tr><td width="100%"><table border="0" width="100%" bgcolor="#000000" cellspacing="0" cellpadding="0">
<tr><td width="100%">
              <table border="0" cellspacing="2" width="100%" align=left height="320" bordercolor="#000000" bgcolor="#339966">
                <tr bgcolor="#339966"> 
                  <td width="100%" align=center height="31"><font color="#804000"><span style="font-size: 11pt"><font color="#FFFFFF">留言本发生错误</font></span></font></td>
                </tr>
                <tr>
                  <td width="100%" align=left height="247" bgcolor="#F7F7F7"><span style="font-size: 11pt">
                    <p align="center"> 出错原因:<font color="#FF0000"><? echo $msg;?></font></p>
                    <p align="center"><a href="javascript:history.go(-1);"><font color="#000000">请点这里返回上一页检查你的输入是否有误</font></a></p>
                    <p align="center">[ <a href="javascript:history.go(-1);">返回上一页</a> 
                      ]</p>
                    </span></td>
                </tr>
                <tr bgcolor="#339966" bordercolor="#000000"> 
                  <td width="100%" height="30"> 
                    <p align="right"><font color="#339966"><span  
style="font-size: 9pt">Copyright 200x ztsky <font face="Arial">.Allrights reserved.</font></span> 
                      </font>
                  </td>
                </tr>
              </table>
            </td></tr></table></td></tr></table></center></body></html>
<?
}
function output($line,$no){
$info=explode("|!:!|",$line);
global $name;
global $admin;
global $user;
?>
<center><TABLE a bgColor=#000000 border=0 cellPadding=0 cellSpacing=0 height=1 width='90%'>
<TR bgColor=#ffffff width="100%"><TD bgColor=#000000 height=1 width="100%">
<TABLE border=0 cellPadding=3 cellSpacing=1 height=8 width="100%"><TBODY><TR>
<TD bgColor=#f7f7f7 height=8 rowSpan=3 vAlign=top width=155>
<TABLE><font color="#000000">留言:NO.<?echo$no;?></font>
<TBODY></TBODY></TABLE><div align="center"><center><TABLE border=0 cellPadding=0 cellSpacing=0>
<TBODY><TR><TD align=middle><font color="#000000"><img src="<?echo$info[3];?>" width="32" height="32"></font></TD></TR></TBODY></TABLE></center></div>
<P>姓名:<font color="#000000"><?echo$info[2];?></font><BR>来自:<font color="#000000"><?echo$info[7];?></font><BR>邮件:<a href="mailto:<?echo$info[4];?>" title="给<?echo$info[2];?>发信"><IMG border=0 src="<?echo$admin[img];?>/mail.gif">&nbsp;邮件</a><BR>主页:<a href="<?echo$info[5];?>" target="_blank" title="访问<?echo$info[2];?>的主页"><IMG border=0 src="<?echo$admin[img];?>/home.gif">&nbsp;主页</a> <BR></P></TD>
<TD bgColor=#ffffff height=1 width=503><IMG src="<?echo$admin[img];?>/1.gif" width="18" height="18"> 发表于:<?echo$info[8];?> 
<TR><TD bgColor=#ffffff height=95 width=503><TABLE border=0 cellPadding=3 cellSpacing=0 height="100%" width="100%"><TBODY><TR><TD vAlign=top width="100%" height="94"><font color="#0080FF"><?echo$info[1];?></font></TD></TR></TBODY></TABLE><TR>
<TD bgColor=#f7f7f7 height=10 width=503>&nbsp; <a href="mailto:<?echo$info[4];?>" title="给<?echo$info[2];?>发信"><IMG border=0 src="<?echo$admin[img];?>/mail.gif">&nbsp;邮件</a>&nbsp; <a href="<?echo$info[5];?>" target="_blank" title="访问<?echo$info[2];?>的主页"><IMG border=0 src="<?echo$admin[img];?>/home.gif">&nbsp;主页</a>&nbsp; <img src=http://icon.tencent.com/<?echo$info[6];?>/s/00/ alt=<?echo$info[2];?>的OICQ:<?echo$info[6];?> width=16 height=16>&nbsp;OICQ&nbsp;<IMG alt=<?echo$info[2];?>的IP地址是:<?echo$info[7];?> border=0 src="<?echo$admin[img];?>/ip.gif" width="13" height="15">&nbsp;IP
&nbsp;<a href="<?echo$PHP_SELF;?>?action=reply&user=<?echo$user;?>&id=<?echo$info[0];?>" title="回复该留言(只有版主才有回复的权利!)"><IMG border=0 src="<?echo$admin[img];?>/replay.gif">&nbsp;回复</a>
&nbsp;<a href="<?echo$PHP_SELF;?>?action=del&user=<?echo$user;?>&id=<?echo$info[0];?>" title="删除该留言"><IMG border=0 src="<?echo$admin[img];?>/del.gif">&nbsp;删除</a></TD></TR></TBODY></TABLE></TR></TABLE></CENTER>
<?
}
####################################函数完成#############################################
#########################################################################################
####################################程序部分#############################################
if(empty($user))$user="main";
$file="$admin[path]/$user.dat";
if(!file_exists($file)) error("对不起,没有找到这个用户的留言簿,<a href=$PHP_SELF>不如您申请一个吧</a>!");
else{
if($user<>"main") include("$admin[path]/$user.php");
if($action=="add"){
if($addsub){
  $name=Chop($name);
  $msg=str($msg);
  if($msg=="" or $name=="")error("不是吧,你的名字和留言都不写,还叫做什么“留言”啊!");
  elseif(!oicq($oicq))error("你的OICQ好像有错啊!");
  else{
    if($sex=="boy")$sex="$admin[img]/01.gif";
	   else $sex="$admin[img]/02.gif";
	if($oicq=="")$oicq="未知";
	if($home=="")$home="未知";
	if($mail=="")$mail="未知";
    $data=fopen("$admin[path]/$user.dat","r");
    $num=Chop(fgets($data,15));
	$num++;
    $old=fread($data,filesize($file));
    fclose($data);
	$id=getid();
	$time=nowtime();
	$ip=$REMOTE_ADDR;$ip2=explode(".",$ip);$ip="$ip2[0].$ip2[1].$ip2[2].xxx";
	$writemsg="$num\n$id|!:!|$msg|!:!|$name|!:!|$sex|!:!|$email|!:!|$home|!:!|$oicq|!:!|$ip|!:!|$time\n$old";
	$data=fopen($file,"w");
	fwrite($data,$writemsg);
	fclose($data);
	$cookietime=time()+31536000;
	setcookie(ex_user_home,$home,$cookietime);
	setcookie(ex_user_mail,$email,$cookietime);
	setcookie(ex_user_name,$name,$cookietime);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -