当前位置: 编程技术>php
本页文章导读:
▪关于文本留言本的分页代码
<? //在写文件的时候用"|||"来分离每条记录,"||"用来分离记录中的各个字段 //如记录一表示为 $str1=$name."||".$pass."||".$title."||".$message."||".……… //然后连接记录一和记录二时用,$str=$str1."|||.........
▪支持oicq头像的留言簿(二)
addnote.php <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <TITLE>添加留言</TITLE> <style type="text/css"> <!-- .white12 { font-size: 12pt; color: #FFFFFF; text-decora.........
▪一个ubbcode的函数,速度很快.
前面见到有人发表 但是速度比较慢,也非常长 这里给出一种 function ubb($str) { $color=Array('red','blue','green'); $str=eregi_replace('\[url\]([a-zA-Z0-9@:%_.~#-\?&]+)\[\/url\]','<a href=http://\\1>\\1</a>'.........
[1]关于文本留言本的分页代码
来源: 互联网 发布时间: 2013-11-30
<?
//在写文件的时候用"|||"来分离每条记录,"||"用来分离记录中的各个字段
//如记录一表示为 $str1=$name."||".$pass."||".$title."||".$message."||".………
//然后连接记录一和记录二时用,$str=$str1."|||".$str2."|||.………
//最后生成的文件如下
//飞天狐狸||450948643||这是主题||这是留言内容||1|||飞天狐狸||450948643||这是主题||这是留言内容||2|||飞天狐狸||450948643||这是主题||这是留言内容||3|||飞天狐狸||450948643||这是主题||这是留言内容||4|||飞天狐狸||450948643||这是主题||这是留言内容||5|||飞天狐狸||450948643||这是主题||这是留言内容||6|||飞天狐狸||450948643||这是主题||这是留言内容||7|||飞天狐狸||450948643||这是主题||这是留言内容||8|||飞天狐狸||450948643||这是主题||这是留言内容||9|||飞天狐狸||450948643||这是主题||这是留言内容||10|||飞天狐狸||450948643||这是主题||这是留言内容||11|||飞天狐狸||450948643||这是主题||这是留言内容||12|||飞天狐狸||450948643||这是主题||这是留言内容||13|||飞天狐狸||450948643||这是主题||这是留言内容||14|||飞天狐狸||450948643||这是主题||这是留言内容||15|||飞天狐狸||450948643||这是主题||这是留言内容||16|||飞天狐狸||450948643||这是主题||这是留言内容||17|||飞天狐狸||450948643||这是主题||这是留言内容||18|||飞天狐狸||450948643||这是主题||这是留言内容||19|||飞天狐狸||450948643||这是主题||这是留言内容||20|||飞天狐狸||450948643||这是主题||这是留言内容||21|||飞天狐狸||450948643||这是主题||这是留言内容||22|||飞天狐狸||450948643||这是主题||这是留言内容||23|||
//然后就开始取文件中的数据,程序清单如下
$end="|||"; //记录分隔符,视写文件时用的符号定
$mid="||"; //字段分隔符,同上
$temp=file("messageboard.info"); //把文件内容读入数组
$temp=join("",$temp); //将读出的数组变成字串
$mess=explode($end,$temp); //分割出记录
$num=count($mess); //计算分割出的字串数组元素数量,就是记录数
if (!$dpage) $dpage=1; //存放当前页数
$row=15; //你每页想显示的行数
if ($num/$row==floor($num/$row)) $page=$num/$row; //看是否能得整数,可以就取整
else if ($num/$row>=floor($num/$row)) $page=floor($num/$row)+1; //如果总数除每页行娄比取事数大,就取整后加一。
else if ($num/$row<=floor($num/$row)) $page=floor($num/$row); //如果比取整小,就取整
$minnum=($dpage-1)*$row; //当前页从此数开始取记录
$maxnum=$row*$dpage; //当前页要取的最大记录数
for($i=$minnum;$i<$maxnum;$i++)
{
$message=explode($mid,$mess[$i]); //分割出记录中的字段
$num1=count($message); //计算数组中元素的数量用于控制循环
for ($j=0;$j<$num1;$j++)
{
echo $message[$j]." "; //每次显示数组内的一个元素。
}
echo "<br>";
}
//下面开始分页
if ($page>=2&&$dpage==1) //如果总页数大于两页,并且当前在第一页的话
{ $paged=$dpage+1; echo "<font color='aaaaaa'>上一页 <a href='/blog_article/2/dpage/.html".$paged."'>下一页</a><br>"; }
else if ($page>=2&&$dpage>=$page) //如果总页数大于两页,并且当前页小于总页数
{ $pageu=$dpage-1; echo "<a href='/blog_article/2/dpage/.html".$pageu."'>上一页</a> <font color='aaaaaa'>下一页</font><br>"; }
else if ($page>=2&&$dpage>=1&&$dpage<$page) //如果总页数大于两页,并且当前页大于一又小于总页数
{ $pageu=$dpage-1;$paged=$dpage+1;echo "<a href='/blog_article/2/dpage/.html".$pageu."'>上一页</a> <a href='/blog_article/2/amp;dpage/.html".$paged."'>上一页</a><br>";}
//如果只有一页
else echo "<font color='aaaaaa'>上一页 上一页</font><br>";
?>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
//在写文件的时候用"|||"来分离每条记录,"||"用来分离记录中的各个字段
//如记录一表示为 $str1=$name."||".$pass."||".$title."||".$message."||".………
//然后连接记录一和记录二时用,$str=$str1."|||".$str2."|||.………
//最后生成的文件如下
//飞天狐狸||450948643||这是主题||这是留言内容||1|||飞天狐狸||450948643||这是主题||这是留言内容||2|||飞天狐狸||450948643||这是主题||这是留言内容||3|||飞天狐狸||450948643||这是主题||这是留言内容||4|||飞天狐狸||450948643||这是主题||这是留言内容||5|||飞天狐狸||450948643||这是主题||这是留言内容||6|||飞天狐狸||450948643||这是主题||这是留言内容||7|||飞天狐狸||450948643||这是主题||这是留言内容||8|||飞天狐狸||450948643||这是主题||这是留言内容||9|||飞天狐狸||450948643||这是主题||这是留言内容||10|||飞天狐狸||450948643||这是主题||这是留言内容||11|||飞天狐狸||450948643||这是主题||这是留言内容||12|||飞天狐狸||450948643||这是主题||这是留言内容||13|||飞天狐狸||450948643||这是主题||这是留言内容||14|||飞天狐狸||450948643||这是主题||这是留言内容||15|||飞天狐狸||450948643||这是主题||这是留言内容||16|||飞天狐狸||450948643||这是主题||这是留言内容||17|||飞天狐狸||450948643||这是主题||这是留言内容||18|||飞天狐狸||450948643||这是主题||这是留言内容||19|||飞天狐狸||450948643||这是主题||这是留言内容||20|||飞天狐狸||450948643||这是主题||这是留言内容||21|||飞天狐狸||450948643||这是主题||这是留言内容||22|||飞天狐狸||450948643||这是主题||这是留言内容||23|||
//然后就开始取文件中的数据,程序清单如下
$end="|||"; //记录分隔符,视写文件时用的符号定
$mid="||"; //字段分隔符,同上
$temp=file("messageboard.info"); //把文件内容读入数组
$temp=join("",$temp); //将读出的数组变成字串
$mess=explode($end,$temp); //分割出记录
$num=count($mess); //计算分割出的字串数组元素数量,就是记录数
if (!$dpage) $dpage=1; //存放当前页数
$row=15; //你每页想显示的行数
if ($num/$row==floor($num/$row)) $page=$num/$row; //看是否能得整数,可以就取整
else if ($num/$row>=floor($num/$row)) $page=floor($num/$row)+1; //如果总数除每页行娄比取事数大,就取整后加一。
else if ($num/$row<=floor($num/$row)) $page=floor($num/$row); //如果比取整小,就取整
$minnum=($dpage-1)*$row; //当前页从此数开始取记录
$maxnum=$row*$dpage; //当前页要取的最大记录数
for($i=$minnum;$i<$maxnum;$i++)
{
$message=explode($mid,$mess[$i]); //分割出记录中的字段
$num1=count($message); //计算数组中元素的数量用于控制循环
for ($j=0;$j<$num1;$j++)
{
echo $message[$j]." "; //每次显示数组内的一个元素。
}
echo "<br>";
}
//下面开始分页
if ($page>=2&&$dpage==1) //如果总页数大于两页,并且当前在第一页的话
{ $paged=$dpage+1; echo "<font color='aaaaaa'>上一页 <a href='/blog_article/2/dpage/.html".$paged."'>下一页</a><br>"; }
else if ($page>=2&&$dpage>=$page) //如果总页数大于两页,并且当前页小于总页数
{ $pageu=$dpage-1; echo "<a href='/blog_article/2/dpage/.html".$pageu."'>上一页</a> <font color='aaaaaa'>下一页</font><br>"; }
else if ($page>=2&&$dpage>=1&&$dpage<$page) //如果总页数大于两页,并且当前页大于一又小于总页数
{ $pageu=$dpage-1;$paged=$dpage+1;echo "<a href='/blog_article/2/dpage/.html".$pageu."'>上一页</a> <a href='/blog_article/2/amp;dpage/.html".$paged."'>上一页</a><br>";}
//如果只有一页
else echo "<font color='aaaaaa'>上一页 上一页</font><br>";
?>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
[2]支持oicq头像的留言簿(二)
来源: 互联网 发布时间: 2013-11-30
addnote.php
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>添加留言</TITLE>
<style type="text/css">
<!--
.white12 { font-size: 12pt; color: #FFFFFF; text-decoration: none}
-->
</style>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<table width="98%" border="0" cellspacing="0" cellpadding="0" height="61">
<tr>
<td height="62" width="34%"><a href="http://www.medguider.com"><img src="/blog_article/image/logo.gif" width="243" height="60" alt="医学导航网" border="0"></a></td>
<td height="62" width="66%">
<div align="center"><img src="/blog_article/image/note.gif" width="410" height="60"><img src="/blog_article/image/y1.gif" width="60" height="60"></div>
</td>
</tr>
</table>
<?php
include ("config.php");
if ($submit){
$time=date("Y年m月d日 H:i:s A");
$ip=$REMOTE_ADDR;//留言人ip地址
$name=trim($name);
$email=trim($email);
$title=strip_tags($top);
$nnote=nl2br(strip_tags($content));//先去掉html标记,再将换行符转成 <br>。
if (!$name||!$email||!$title||!$nnote){ //检查是否填写完整
echo "对不起,您必须填所有内容!<BR>"."<a href='javascript:history.back()'>返回</a>";
exit; }elseif(!ereg('^[-!#$%&'*+./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&'*+\/0-9=?A-Z^_`a-z{|}~]+.'.'[-!#$%&'*+\./0-9=?A-Z^_`a-z{|}~]+$',$email) //email合法性验证
){
echo "email不合法!<BR>"."<a href='javascript:history.back()'>返回</a>";
exit;
}
//写入数据库
$sql="INSERT INTO notebook (name,email,time,face,ip,title,nnote) VALUES ('$name','$email','$time','$face','$ip','$title','$nnote')";
$result = mysql_query($sql,$db);
mysql_close($db);
echo "留言成功!";
}
?>
<table width="99%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#3366FF">
<tr bgcolor="#3366FF">
<td width="81%" height="26"><a href="/index.html" >首页</a>
> <a href="/blog_article/index.html" >留言簿</a>
> 添加留言</td>
<td width="19%" height="26"><a href='index.php' >查看留言</a>
</td>
</tr>
<tr>
<td colspan="2">
<form name="form1" method="post" action="/blog_article/addnote.html">
<table width="99%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="54%"> </td>
<td rowspan="2" width="46%">选择一个自己喜欢的头像:<br>
<img src="/blog_article/image/face/icon1.gif" width="32" height="32">
<input type="radio" name="face" value="1" checked>
<img src="/blog_article/image/face/icon2.gif" width="32" height="32">
<input type="radio" name="face" value="2">
<img src="/blog_article/image/face/icon3.gif" width="32" height="32">
<input type="radio" name="face" value="3">
<img src="/blog_article/image/face/icon4.gif" width="32" height="32">
<input type="radio" name="face" value="4">
<img src="/blog_article/image/face/icon5.gif" width="32" height="32">
<input type="radio" name="face" value="5">
<img src="/blog_article/image/face/icon6.gif" width="32" height="32">
<input type="radio" name="face" value="6">
<img src="/blog_article/image/face/icon7.gif" width="32" height="32">
<input type="radio" name="face" value="7">
<img src="/blog_article/image/face/icon8.gif" width="32" height="32">
<input type="radio" name="face" value="8">
<img src="/blog_article/image/face/icon9.gif" width="32" height="32">
<input type="radio" name="face" value="9">
<img src="/blog_article/image/face/icon10.gif" width="32" height="32">
<input type="radio" name="face" value="10">
<img src="/blog_article/image/face/icon11.gif" width="32" height="32">
<input type="radio" name="face" value="11">
<img src="/blog_article/image/face/icon12.gif" width="32" height="32">
<input type="radio" name="face" value="12">
<img src="/blog_article/image/face/icon13.gif" width="32" height="32">
<input type="radio" name="face" value="13">
<img src="/blog_article/image/face/icon14.gif" width="32" height="32">
<input type="radio" name="face" value="14">
<img src="/blog_article/image/face/icon15.gif" width="32" height="32">
<input type="radio" name="face" value="15">
<img src="/blog_article/image/face/icon16.gif" width="32" height="32">
<input type="radio" name="face" value="16">
<img src="/blog_article/image/face/icon17.gif" width="32" height="32">
<input type="radio" name="face" value="17">
<img src="/blog_article/image/face/icon18.gif" width="32" height="32">
<input type="radio" name="face" value="18">
<img src="/blog_article/image/face/icon19.gif" width="32" height="32">
<input type="radio" name="face" value="19">
<img src="/blog_article/image/face/icon20.gif" width="32" height="32">
<input type="radio" name="face" value="20">
<img src="/blog_article/image/face/icon21.gif" width="32" height="32">
<input type="radio" name="face" value="21">
<img src="/blog_article/image/face/icon22.gif" width="32" height="32">
<input type="radio" name="face" value="22">
<img src="/blog_article/image/face/icon23.gif" width="32" height="32">
<input type="radio" name="face" value="23">
<img src="/blog_article/image/face/icon24.gif" width="32" height="32">
<input type="radio" name="face" value="24">
<img src="/blog_article/image/face/icon25.gif" width="32" height="32">
<input type="radio" name="face" value="25">
<img src="/blog_article/image/face/icon26.gif" width="32" height="32">
<input type="radio" name="face" value="26">
<img src="/blog_article/image/face/icon27.gif" width="32" height="32">
<input type="radio" name="face" value="27">
<img src="/blog_article/image/face/icon28.gif" width="32" height="32">
<input type="radio" name="face" value="28">
<img src="/blog_article/image/face/icon29.gif" width="32" height="32">
<input type="radio" name="face" value="29">
<img src="/blog_article/image/face/icon30.gif" width="32" height="32">
<input type="radio" name="face" value="30">
<img src="/blog_article/image/face/icon31.gif" width="32" height="32">
<input type="radio" name="face" value="31">
<img src="/blog_article/image/face/icon32.gif" width="32" height="32">
<input type="radio" name="face" value="32">
<img src="/blog_article/image/face/icon33.gif" width="32" height="32">
<input type="radio" name="face" value="33">
<img src="/blog_article/image/face/icon34.gif" width="32" height="32">
<input type="radio" name="face" value="34">
<img src="/blog_article/image/face/icon35.gif" width="32" height="32">
<input type="radio" name="face" value="35">
<img src="/blog_article/image/face/icon36.gif" width="32" height="32">
<input type="radio" name="face" value="36">
<img src="/blog_article/image/face/icon37.gif" width="32" height="32">
<input type="radio" name="face" value="37">
<img src="/blog_article/image/face/icon38.gif" width="32" height="32">
<input type="radio" name="face" value="38">
<img src="/blog_article/image/face/icon39.gif" width="32" height="32">
<input type="radio" name="face" value="39">
<img src="/blog_article/image/face/icon40.gif" width="32" height="32">
<input type="radio" name="face" value="40">
<img src="/blog_article/image/face/icon41.gif" width="32" height="32">
<input type="radio" name="face" value="41">
<img src="/blog_article/image/face/icon42.gif" width="32" height="32">
<input type="radio" name="face" value="42">
<img src="/blog_article/image/face/icon43.gif" width="32" height="32">
<input type="radio" name="face" value="43">
<img src="/blog_article/image/face/icon44.gif" width="32" height="32">
<input type="radio" name="face" value="44">
<img src="/blog_article/image/face/icon45.gif" width="32" height="32">
<input type="radio" name="face" value="45">
<img src="/blog_article/image/face/icon46.gif" width="32" height="32">
<input type="radio" name="face" value="46">
<img src="/blog_article/image/face/icon47.gif" width="32" height="32">
<input type="radio" name="face" value="47">
<img src="/blog_article/image/face/icon48.gif" width="32" height="32">
<input type="radio" name="face" value="48">
<img src="/blog_article/image/face/icon49.gif" width="32" height="32">
<input type="radio" name="face" value="49">
<img src="/blog_article/image/face/icon50.gif" width="32" height="32">
<input type="radio" name="face" value="50">
<img src="/blog_article/image/face/icon51.gif" width="32" height="32">
<input type="radio" name="face" value="51">
<img src="/blog_article/image/face/icon52.gif" width="32" height="32">
<input type="radio" name="face" value="52">
<img src="/blog_article/image/face/icon53.gif" width="32" height="32">
<input type="radio" name="face" value="53">
<img src="/blog_article/image/face/icon54.gif" width="32" height="32">
<input type="radio" name="face" value="54">
<img src="/blog_article/image/face/icon55.gif" width="32" height="32">
<input type="radio" name="face" value="55">
<img src="/blog_article/image/face/icon56.gif" width="32" height="32">
<input type="radio" name="face" value="56">
<img src="/blog_article/image/face/icon57.gif" width="32" height="32">
<input type="radio" name="face" value="57">
<img src="/blog_article/image/face/icon58.gif" width="32" height="32">
<input type="radio" name="face" value="58">
<img src="/blog_article/image/face/icon59.gif" width="32" height="32">
<input type="radio" name="face" value="59">
<img src="/blog_article/image/face/icon60.gif" width="32" height="32">
<input type="radio" name="face" value="60">
<img src="/blog_article/image/face/icon61.gif" width="32" height="32">
<input type="radio" name="face" value="61">
<img src="/blog_article/image/face/icon62.gif" width="32" height="32">
<input type="radio" name="face" value="62">
<img src="/blog_article/image/face/icon63.gif" width="32" height="32">
<input type="radio" name="face" value="63">
<img src="/blog_article/image/face/icon64.gif" width="32" height="32">
<input type="radio" name="face" value="64">
</td>
</tr>
<tr>
<td width="54%">名字
<input type="text" name="name">
<br>
Email
<input type="text" name="email">
<br>
标题
<input type="text" name="top" size="50">
<br>
内容<br>
<textarea name="content" cols="50" rows="20"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="submit" value="确定">
<input type="reset" name="cancel" value="重写">
</div>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<p><a href="/blog_article/main/user/lt; echo $user/gt;.html" ><br>
</a></p>
</BODY>
</HTML>
delnote.php
<?php
include ("config.php");
if ($superadmin){ //如果已经进行管理员登陆,进行密码验证
if (!($user==$username)||!($psw==$password)){
echo "密码错误";
exit;
}
}else{ //管理员登陆
echo "<form name='form1' method='post' action='/blog_article/$PHP_SELF/index.html'>";
echo "<div align='center'> 请输入管理员密码<br>";
echo "管理员";
echo "<input type='text' name='user'><br>";
echo "密码";
echo "<input type='password' name='psw'><br>";
echo "<input type='submit' name='superadmin' value='进入'><br>";
echo "<input type='reset' name='cancel' value='重写'></div>";
echo "</form>";
exit;
}
if($del==1){ //判断是否要删除
mysql_query("delete from notebook where time='$time'",$db); //以留言时间为删除标志
echo "删除成功!";
}
?>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>删除留言</TITLE>
<style type="text/css">
<!--
.blue9 { font-size: 9pt; color: #0099FF; text-decoration: none}
.black9 { font-size: 9pt; text-decoration: none}
.purple10 { font-size: 10pt; color: #9900FF; text-decoration: none}
.white12 { font-size: 12pt; color: #FFFFFF; text-decoration: none}
a:visited { color: #FFFFFF}
a:link { color: #FFFFFF}
-->
</style>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<?php
$result = mysql_query("SELECT * FROM notebook ",$db);
$row=mysql_num_rows($result);//查看结果有多少行
$max=$row; //帖子总数
//设每页显示10篇,$p总页数,$page第几页,$low 从第几行开始读,$x 读取几行
if (!$page){$page=1;}
$p=ceil($max/10);
$low=10*($page-1);
if($page==$p&&($max%10)<>0){$x=($max%10);} else {$x=10;}//如果是最后一页,且不是10的整倍数,读取$max除以10的余数,否则取10
if($max==0){$x=0;}//如果没有帖子,$x取0
$result = mysql_query("select * from notebook ORDER BY time DESC limit $low,$x",$db);
?>
<table width="98%" border="0" cellspacing="0" cellpadding="0" height="61">
<tr>
<td height="62" width="34%"><a href="http://www.medguider.com"><img src="/blog_article/image/logo.gif" width="243" height="60" alt="医学导航网" border="0"></a></td>
<td height="62" width="66%">
<div align="center"><img src="/blog_article/image/note.gif" width="410" height="60"><img src="/blog_article/image/y1.gif" width="60" height="60"></div>
</td>
</tr>
</table>
<table width="95%" border="1" cellspacing="0" cellpadding="0" height="253" bordercolordark="#FFFFFF" bordercolorlight="#003399" align="center">
<tr>
<td height="250">
<table width="95%" border="0" cellspacing="0" cellpadding="0" height="32" bgcolor="#3366FF">
<tr>
<td width="28%" >首页
> <a href="/blog_article/index.html" >留言簿</a></td>
<td width="56%" >
<?php
echo "帖子总数: ",$max," 第";
for ($n=1;$n<=$p;$n++){
echo "<a href=/blog_article/index/page/$n/gt;$n/lt;/a/gt;.html";
}
echo "页";
?>
</td>
<td width="16%"><a href="/blog_article/index.html" >查看留言</a></td>
</tr>
</table>
<?php
for ($i=0;$i<=($x-1);$i++) {
$email=mysql_result($result,$i,'email');
$face=mysql_result($result,$i,'face');
$face='image/face/icon'.$face;
$name=mysql_result($result,$i,'name');
$time=mysql_result($result,$i,'time');
$ip=mysql_result($result,$i,'ip');
$title=mysql_result($result,$i,'title');
$nnote=mysql_result($result,$i,'nnote');
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0' height=107' bordercolor='#FFFFFF'> <tr bgcolor='#eeeeee'>";
echo "<td width='10%' height='33' bgcolor='#eeeeee' > <img src='/blog_article/$face.gif' width='32' height='32'></td>";
echo "<td width='16%' height='33' bgcolor='#eeeeee' >留言人:$name</td>";
echo "<td width='41%' height='33' bgcolor='#eeeeee' >发表于:$time</td>";
echo "<td width='12%' height='33' bgcolor='#eeeeee' ><a href='mailto:$email'><img src='/blog_article/image/email.gif' width='16' height='16' border=0></a></td>";
echo "<td width='21%' height='33' ><img src='/blog_article/image/ip.gif' width='13' height='15'> $ip <a href='/blog_article/$PHP_SELF/del/1/amp;time/$time/amp;superadmin/$superadmin/amp;user/$user/amp;psw/$psw.html'><img src='/blog_article/image/del.gif' width='16' height='16' border=0></a></td> </tr> <tr>";
echo "<td colspan='5' height='33'>标题:$title</td> </tr>";
echo "<tr bgcolor='#ffffff'><td colspan='5' height='37'>留言内容:$nnote</td></tr></table>";
}
mysql_close($db);
?>
</td>
</tr>
</table>
</BODY>
</HTML>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>添加留言</TITLE>
<style type="text/css">
<!--
.white12 { font-size: 12pt; color: #FFFFFF; text-decoration: none}
-->
</style>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<table width="98%" border="0" cellspacing="0" cellpadding="0" height="61">
<tr>
<td height="62" width="34%"><a href="http://www.medguider.com"><img src="/blog_article/image/logo.gif" width="243" height="60" alt="医学导航网" border="0"></a></td>
<td height="62" width="66%">
<div align="center"><img src="/blog_article/image/note.gif" width="410" height="60"><img src="/blog_article/image/y1.gif" width="60" height="60"></div>
</td>
</tr>
</table>
<?php
include ("config.php");
if ($submit){
$time=date("Y年m月d日 H:i:s A");
$ip=$REMOTE_ADDR;//留言人ip地址
$name=trim($name);
$email=trim($email);
$title=strip_tags($top);
$nnote=nl2br(strip_tags($content));//先去掉html标记,再将换行符转成 <br>。
if (!$name||!$email||!$title||!$nnote){ //检查是否填写完整
echo "对不起,您必须填所有内容!<BR>"."<a href='javascript:history.back()'>返回</a>";
exit; }elseif(!ereg('^[-!#$%&'*+./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&'*+\/0-9=?A-Z^_`a-z{|}~]+.'.'[-!#$%&'*+\./0-9=?A-Z^_`a-z{|}~]+$',$email) //email合法性验证
){
echo "email不合法!<BR>"."<a href='javascript:history.back()'>返回</a>";
exit;
}
//写入数据库
$sql="INSERT INTO notebook (name,email,time,face,ip,title,nnote) VALUES ('$name','$email','$time','$face','$ip','$title','$nnote')";
$result = mysql_query($sql,$db);
mysql_close($db);
echo "留言成功!";
}
?>
<table width="99%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#3366FF">
<tr bgcolor="#3366FF">
<td width="81%" height="26"><a href="/index.html" >首页</a>
> <a href="/blog_article/index.html" >留言簿</a>
> 添加留言</td>
<td width="19%" height="26"><a href='index.php' >查看留言</a>
</td>
</tr>
<tr>
<td colspan="2">
<form name="form1" method="post" action="/blog_article/addnote.html">
<table width="99%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="54%"> </td>
<td rowspan="2" width="46%">选择一个自己喜欢的头像:<br>
<img src="/blog_article/image/face/icon1.gif" width="32" height="32">
<input type="radio" name="face" value="1" checked>
<img src="/blog_article/image/face/icon2.gif" width="32" height="32">
<input type="radio" name="face" value="2">
<img src="/blog_article/image/face/icon3.gif" width="32" height="32">
<input type="radio" name="face" value="3">
<img src="/blog_article/image/face/icon4.gif" width="32" height="32">
<input type="radio" name="face" value="4">
<img src="/blog_article/image/face/icon5.gif" width="32" height="32">
<input type="radio" name="face" value="5">
<img src="/blog_article/image/face/icon6.gif" width="32" height="32">
<input type="radio" name="face" value="6">
<img src="/blog_article/image/face/icon7.gif" width="32" height="32">
<input type="radio" name="face" value="7">
<img src="/blog_article/image/face/icon8.gif" width="32" height="32">
<input type="radio" name="face" value="8">
<img src="/blog_article/image/face/icon9.gif" width="32" height="32">
<input type="radio" name="face" value="9">
<img src="/blog_article/image/face/icon10.gif" width="32" height="32">
<input type="radio" name="face" value="10">
<img src="/blog_article/image/face/icon11.gif" width="32" height="32">
<input type="radio" name="face" value="11">
<img src="/blog_article/image/face/icon12.gif" width="32" height="32">
<input type="radio" name="face" value="12">
<img src="/blog_article/image/face/icon13.gif" width="32" height="32">
<input type="radio" name="face" value="13">
<img src="/blog_article/image/face/icon14.gif" width="32" height="32">
<input type="radio" name="face" value="14">
<img src="/blog_article/image/face/icon15.gif" width="32" height="32">
<input type="radio" name="face" value="15">
<img src="/blog_article/image/face/icon16.gif" width="32" height="32">
<input type="radio" name="face" value="16">
<img src="/blog_article/image/face/icon17.gif" width="32" height="32">
<input type="radio" name="face" value="17">
<img src="/blog_article/image/face/icon18.gif" width="32" height="32">
<input type="radio" name="face" value="18">
<img src="/blog_article/image/face/icon19.gif" width="32" height="32">
<input type="radio" name="face" value="19">
<img src="/blog_article/image/face/icon20.gif" width="32" height="32">
<input type="radio" name="face" value="20">
<img src="/blog_article/image/face/icon21.gif" width="32" height="32">
<input type="radio" name="face" value="21">
<img src="/blog_article/image/face/icon22.gif" width="32" height="32">
<input type="radio" name="face" value="22">
<img src="/blog_article/image/face/icon23.gif" width="32" height="32">
<input type="radio" name="face" value="23">
<img src="/blog_article/image/face/icon24.gif" width="32" height="32">
<input type="radio" name="face" value="24">
<img src="/blog_article/image/face/icon25.gif" width="32" height="32">
<input type="radio" name="face" value="25">
<img src="/blog_article/image/face/icon26.gif" width="32" height="32">
<input type="radio" name="face" value="26">
<img src="/blog_article/image/face/icon27.gif" width="32" height="32">
<input type="radio" name="face" value="27">
<img src="/blog_article/image/face/icon28.gif" width="32" height="32">
<input type="radio" name="face" value="28">
<img src="/blog_article/image/face/icon29.gif" width="32" height="32">
<input type="radio" name="face" value="29">
<img src="/blog_article/image/face/icon30.gif" width="32" height="32">
<input type="radio" name="face" value="30">
<img src="/blog_article/image/face/icon31.gif" width="32" height="32">
<input type="radio" name="face" value="31">
<img src="/blog_article/image/face/icon32.gif" width="32" height="32">
<input type="radio" name="face" value="32">
<img src="/blog_article/image/face/icon33.gif" width="32" height="32">
<input type="radio" name="face" value="33">
<img src="/blog_article/image/face/icon34.gif" width="32" height="32">
<input type="radio" name="face" value="34">
<img src="/blog_article/image/face/icon35.gif" width="32" height="32">
<input type="radio" name="face" value="35">
<img src="/blog_article/image/face/icon36.gif" width="32" height="32">
<input type="radio" name="face" value="36">
<img src="/blog_article/image/face/icon37.gif" width="32" height="32">
<input type="radio" name="face" value="37">
<img src="/blog_article/image/face/icon38.gif" width="32" height="32">
<input type="radio" name="face" value="38">
<img src="/blog_article/image/face/icon39.gif" width="32" height="32">
<input type="radio" name="face" value="39">
<img src="/blog_article/image/face/icon40.gif" width="32" height="32">
<input type="radio" name="face" value="40">
<img src="/blog_article/image/face/icon41.gif" width="32" height="32">
<input type="radio" name="face" value="41">
<img src="/blog_article/image/face/icon42.gif" width="32" height="32">
<input type="radio" name="face" value="42">
<img src="/blog_article/image/face/icon43.gif" width="32" height="32">
<input type="radio" name="face" value="43">
<img src="/blog_article/image/face/icon44.gif" width="32" height="32">
<input type="radio" name="face" value="44">
<img src="/blog_article/image/face/icon45.gif" width="32" height="32">
<input type="radio" name="face" value="45">
<img src="/blog_article/image/face/icon46.gif" width="32" height="32">
<input type="radio" name="face" value="46">
<img src="/blog_article/image/face/icon47.gif" width="32" height="32">
<input type="radio" name="face" value="47">
<img src="/blog_article/image/face/icon48.gif" width="32" height="32">
<input type="radio" name="face" value="48">
<img src="/blog_article/image/face/icon49.gif" width="32" height="32">
<input type="radio" name="face" value="49">
<img src="/blog_article/image/face/icon50.gif" width="32" height="32">
<input type="radio" name="face" value="50">
<img src="/blog_article/image/face/icon51.gif" width="32" height="32">
<input type="radio" name="face" value="51">
<img src="/blog_article/image/face/icon52.gif" width="32" height="32">
<input type="radio" name="face" value="52">
<img src="/blog_article/image/face/icon53.gif" width="32" height="32">
<input type="radio" name="face" value="53">
<img src="/blog_article/image/face/icon54.gif" width="32" height="32">
<input type="radio" name="face" value="54">
<img src="/blog_article/image/face/icon55.gif" width="32" height="32">
<input type="radio" name="face" value="55">
<img src="/blog_article/image/face/icon56.gif" width="32" height="32">
<input type="radio" name="face" value="56">
<img src="/blog_article/image/face/icon57.gif" width="32" height="32">
<input type="radio" name="face" value="57">
<img src="/blog_article/image/face/icon58.gif" width="32" height="32">
<input type="radio" name="face" value="58">
<img src="/blog_article/image/face/icon59.gif" width="32" height="32">
<input type="radio" name="face" value="59">
<img src="/blog_article/image/face/icon60.gif" width="32" height="32">
<input type="radio" name="face" value="60">
<img src="/blog_article/image/face/icon61.gif" width="32" height="32">
<input type="radio" name="face" value="61">
<img src="/blog_article/image/face/icon62.gif" width="32" height="32">
<input type="radio" name="face" value="62">
<img src="/blog_article/image/face/icon63.gif" width="32" height="32">
<input type="radio" name="face" value="63">
<img src="/blog_article/image/face/icon64.gif" width="32" height="32">
<input type="radio" name="face" value="64">
</td>
</tr>
<tr>
<td width="54%">名字
<input type="text" name="name">
<br>
<input type="text" name="email">
<br>
标题
<input type="text" name="top" size="50">
<br>
内容<br>
<textarea name="content" cols="50" rows="20"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="submit" value="确定">
<input type="reset" name="cancel" value="重写">
</div>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<p><a href="/blog_article/main/user/lt; echo $user/gt;.html" ><br>
</a></p>
</BODY>
</HTML>
delnote.php
<?php
include ("config.php");
if ($superadmin){ //如果已经进行管理员登陆,进行密码验证
if (!($user==$username)||!($psw==$password)){
echo "密码错误";
exit;
}
}else{ //管理员登陆
echo "<form name='form1' method='post' action='/blog_article/$PHP_SELF/index.html'>";
echo "<div align='center'> 请输入管理员密码<br>";
echo "管理员";
echo "<input type='text' name='user'><br>";
echo "密码";
echo "<input type='password' name='psw'><br>";
echo "<input type='submit' name='superadmin' value='进入'><br>";
echo "<input type='reset' name='cancel' value='重写'></div>";
echo "</form>";
exit;
}
if($del==1){ //判断是否要删除
mysql_query("delete from notebook where time='$time'",$db); //以留言时间为删除标志
echo "删除成功!";
}
?>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>删除留言</TITLE>
<style type="text/css">
<!--
.blue9 { font-size: 9pt; color: #0099FF; text-decoration: none}
.black9 { font-size: 9pt; text-decoration: none}
.purple10 { font-size: 10pt; color: #9900FF; text-decoration: none}
.white12 { font-size: 12pt; color: #FFFFFF; text-decoration: none}
a:visited { color: #FFFFFF}
a:link { color: #FFFFFF}
-->
</style>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<?php
$result = mysql_query("SELECT * FROM notebook ",$db);
$row=mysql_num_rows($result);//查看结果有多少行
$max=$row; //帖子总数
//设每页显示10篇,$p总页数,$page第几页,$low 从第几行开始读,$x 读取几行
if (!$page){$page=1;}
$p=ceil($max/10);
$low=10*($page-1);
if($page==$p&&($max%10)<>0){$x=($max%10);} else {$x=10;}//如果是最后一页,且不是10的整倍数,读取$max除以10的余数,否则取10
if($max==0){$x=0;}//如果没有帖子,$x取0
$result = mysql_query("select * from notebook ORDER BY time DESC limit $low,$x",$db);
?>
<table width="98%" border="0" cellspacing="0" cellpadding="0" height="61">
<tr>
<td height="62" width="34%"><a href="http://www.medguider.com"><img src="/blog_article/image/logo.gif" width="243" height="60" alt="医学导航网" border="0"></a></td>
<td height="62" width="66%">
<div align="center"><img src="/blog_article/image/note.gif" width="410" height="60"><img src="/blog_article/image/y1.gif" width="60" height="60"></div>
</td>
</tr>
</table>
<table width="95%" border="1" cellspacing="0" cellpadding="0" height="253" bordercolordark="#FFFFFF" bordercolorlight="#003399" align="center">
<tr>
<td height="250">
<table width="95%" border="0" cellspacing="0" cellpadding="0" height="32" bgcolor="#3366FF">
<tr>
<td width="28%" >首页
> <a href="/blog_article/index.html" >留言簿</a></td>
<td width="56%" >
<?php
echo "帖子总数: ",$max," 第";
for ($n=1;$n<=$p;$n++){
echo "<a href=/blog_article/index/page/$n/gt;$n/lt;/a/gt;.html";
}
echo "页";
?>
</td>
<td width="16%"><a href="/blog_article/index.html" >查看留言</a></td>
</tr>
</table>
<?php
for ($i=0;$i<=($x-1);$i++) {
$email=mysql_result($result,$i,'email');
$face=mysql_result($result,$i,'face');
$face='image/face/icon'.$face;
$name=mysql_result($result,$i,'name');
$time=mysql_result($result,$i,'time');
$ip=mysql_result($result,$i,'ip');
$title=mysql_result($result,$i,'title');
$nnote=mysql_result($result,$i,'nnote');
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0' height=107' bordercolor='#FFFFFF'> <tr bgcolor='#eeeeee'>";
echo "<td width='10%' height='33' bgcolor='#eeeeee' > <img src='/blog_article/$face.gif' width='32' height='32'></td>";
echo "<td width='16%' height='33' bgcolor='#eeeeee' >留言人:$name</td>";
echo "<td width='41%' height='33' bgcolor='#eeeeee' >发表于:$time</td>";
echo "<td width='12%' height='33' bgcolor='#eeeeee' ><a href='mailto:$email'><img src='/blog_article/image/email.gif' width='16' height='16' border=0></a></td>";
echo "<td width='21%' height='33' ><img src='/blog_article/image/ip.gif' width='13' height='15'> $ip <a href='/blog_article/$PHP_SELF/del/1/amp;time/$time/amp;superadmin/$superadmin/amp;user/$user/amp;psw/$psw.html'><img src='/blog_article/image/del.gif' width='16' height='16' border=0></a></td> </tr> <tr>";
echo "<td colspan='5' height='33'>标题:$title</td> </tr>";
echo "<tr bgcolor='#ffffff'><td colspan='5' height='37'>留言内容:$nnote</td></tr></table>";
}
mysql_close($db);
?>
</td>
</tr>
</table>
</BODY>
</HTML>
[3]一个ubbcode的函数,速度很快.
来源: 互联网 发布时间: 2013-11-30
前面见到有人发表
但是速度比较慢,也非常长
这里给出一种
function ubb($str) {
$color=Array('red','blue','green');
$str=eregi_replace('\[url\]([a-zA-Z0-9@:%_.~#-\?&]+)\[\/url\]','<a href=http://\\1>\\1</a>',$str);//url
$str=eregi_replace('\[url=http://([a-zA-Z0-9@:%_.~#-\?&]+)\](.+)\[\/url\]','<a href=\\1 target=_blank>\\2</a>',$str);
$str=eregi_replace('\[url=([a-zA-Z0-9@:%_.~#-\?&]+)\](.+)\[\/url\]','<a href=http://\\1 target=_blank>\\2</a>',$str);
$str=eregi_replace('\[img\]([a-zA-Z0-9@:%_.~#-\?&]+)\[\/img\]','<img src=http://\\1>\\1</img>',$str);//img
$str=eregi_replace('\[h([1-6])\](.+)\[\/h[1-6]\]','<h\\1>\\2</h\\1>',$str);//h1-6
$str=eregi_replace('\[email\]([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})\[\/email\]','<a href=mailto:\\1>\\1</a>',$str);//email
$str=eregi_replace('\[email=([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})\](.+)\[\/email\]','<a href=mailto:\\1>\\2</a>',$str);
$str=eregi_replace('\[b\](.+)\[\/b\]','<b>\\1</b>',$str);
$str=eregi_replace('\[i\](.+)\[\/i\]','<i>\\1</i>',$str);
$str=eregi_replace('\[size=(.+)\](.+)\[\/size\]','<font size=\\1>\\2</font>',$str);
$str=eregi_replace('\[color=(.+)\](.+)\[\/color\]','<font color=\\1>\\2</font>',$str);
$str=eregi_replace('\[sub\](.+)\[\/sub\]','<sub>\\1</sup>',$str);//下裱
$str=eregi_replace('\[sup\](.+)\[\/sup\]','<sup>\\1</sup>',$str);//上标
for($i=0;$i<=count($color);$i++)$str=eregi_replace('\['.$color[$i].'\](.+)\[\/'.$color[$i].'\]','<font color='.$color[$i].'>\\1</font>',$str);
$str=preg_replace("/\[quote\](.+?)\[\/quote\]/is","<blockquote><font size='1' face='Courier New'>quote:</font><hr>\\1<hr></blockquote>", $str);
$str=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>", $str);
$str=preg_replace("/\[sig\](.+?)\[\/sig\]/is","<div ><br><br>--------------------------<br>\\1<br>--------------------------</div>", $str);
return $str;
}
但是速度比较慢,也非常长
这里给出一种
function ubb($str) {
$color=Array('red','blue','green');
$str=eregi_replace('\[url\]([a-zA-Z0-9@:%_.~#-\?&]+)\[\/url\]','<a href=http://\\1>\\1</a>',$str);//url
$str=eregi_replace('\[url=http://([a-zA-Z0-9@:%_.~#-\?&]+)\](.+)\[\/url\]','<a href=\\1 target=_blank>\\2</a>',$str);
$str=eregi_replace('\[url=([a-zA-Z0-9@:%_.~#-\?&]+)\](.+)\[\/url\]','<a href=http://\\1 target=_blank>\\2</a>',$str);
$str=eregi_replace('\[img\]([a-zA-Z0-9@:%_.~#-\?&]+)\[\/img\]','<img src=http://\\1>\\1</img>',$str);//img
$str=eregi_replace('\[h([1-6])\](.+)\[\/h[1-6]\]','<h\\1>\\2</h\\1>',$str);//h1-6
$str=eregi_replace('\[email\]([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})\[\/email\]','<a href=mailto:\\1>\\1</a>',$str);//email
$str=eregi_replace('\[email=([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})\](.+)\[\/email\]','<a href=mailto:\\1>\\2</a>',$str);
$str=eregi_replace('\[b\](.+)\[\/b\]','<b>\\1</b>',$str);
$str=eregi_replace('\[i\](.+)\[\/i\]','<i>\\1</i>',$str);
$str=eregi_replace('\[size=(.+)\](.+)\[\/size\]','<font size=\\1>\\2</font>',$str);
$str=eregi_replace('\[color=(.+)\](.+)\[\/color\]','<font color=\\1>\\2</font>',$str);
$str=eregi_replace('\[sub\](.+)\[\/sub\]','<sub>\\1</sup>',$str);//下裱
$str=eregi_replace('\[sup\](.+)\[\/sup\]','<sup>\\1</sup>',$str);//上标
for($i=0;$i<=count($color);$i++)$str=eregi_replace('\['.$color[$i].'\](.+)\[\/'.$color[$i].'\]','<font color='.$color[$i].'>\\1</font>',$str);
$str=preg_replace("/\[quote\](.+?)\[\/quote\]/is","<blockquote><font size='1' face='Courier New'>quote:</font><hr>\\1<hr></blockquote>", $str);
$str=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>", $str);
$str=preg_replace("/\[sig\](.+?)\[\/sig\]/is","<div ><br><br>--------------------------<br>\\1<br>--------------------------</div>", $str);
return $str;
}
最新技术文章: