PHP+TEXT留言本(五)

时间:2010-01-09 08:30:04   来源:第二电脑网  作者:第二电脑网

  第二电脑网导读: ($i=0;$i<$len;$i++){if (ord($txt[$i])<128)  { $count=$count+1;}  if (ord($txt[$i])==10 or ord($txt[$i])==32)  {$count=0;}  if ($count>=60)   {  $txt[$i]="n";  $count=0;  }}  return $txt;}function encode ($txt){$txt=strip_tags($txt);
  正文:

现在我们来讲一下reply.PHP代码:
---------------------------------
//reply.php

<?


  function check_strlen_long($txt)
{
$len=strlen($txt);
$count=0;
for ($i=0;$i<$len;$i++)
{
if (ord($txt[$i])<128)
  { $count=$count+1;}
  if (ord($txt[$i])==10 or ord($txt[$i])==32)
  {$count=0;}
  if ($count>=60) 
  {
  $txt[$i]="n";
  $count=0;
  }
}
  return $txt;
}

function encode ($txt)
{
$txt=strip_tags($txt);
$txt=htmlspecialchars($txt);
$message=Striphotoshop/ target=_blank class=infotextkey>pslashes($txt);
return $message;
}

  $content=file("guest.txt");
  $disptext=$content[$record-1];
  
if ($job=="addreply" and $replyname!="" and $replycontent!="")
{
$content=file("guest.txt");
$count=count($content);
$time = date(Y年m月d日H小时i分);
$ip=$REMOTE_ADDR;
$replycontent=StripSlashes($replycontent);
$replyname=encode($replyname);
$replycontent=htmlspecialchars($replycontent);
  $replycontent=check_strlen_long($replycontent);
$replycontent=nl2br($replycontent);
$replycontent=ereg_replace(chr(10),"",$replycontent);
$content[$record-1]=substr($content[$record-1],0,strlen($content[$i])-1); $content[$record-1]=$content[$record-1]."<!--reply><tr><td colspan=4><ul><font color=#AB00E1>回复内容:</font><br>".$replycontent."<br>回复人大名:".$replyname."<br><font color=#CC33FF>时间:$time 来自:$ip</font></ul><hr size=1 color=blue></td></tr>n";
$fp=fopen("guest.txt","w");
for ($i=0;$i<$count;$i++)
  {
   fputs($fp,$content[$i],strlen($content[$i]));
  }
  echo "<meta http-equiv=Refresh content=1;url=guest.php>";
  exit;

}
  ?> 
<title>zihanonline</title>
<style>
<!--
A:link {text-decoration: none ; color:0000ff}
A:visited {text-decoration: none; color:004080}
A:active {text-decoration: none}
A:hover {text-decoration: underline; color:ff0000}
BODY {FONT-SIZE: 10p}
TH {FONT-SIZE: 10pt}
TD {FONT-SIZE: 10pt}
-->
</style>
<body bgcolor="#FFFFFF" background="back.gif">
<div align=center >
  <? include('head.htm');?>
  <table border= 1  width= 65%  height= 169 cellpadding="8" cellspacing="0" bordercolor="#E3E3E3" >
    <form method= POST  action=reply.php >
      <?
      if ($Submit)
       {
        if ($replyname=="" or $replycontent=="")
        {
      echo"<tr align=left valign=middle bgcolor=#F0F0F0> ";
      echo"<td width= 100%  height= 31 > ";
      echo "<font color=red>出错了</font>回复人姓名和回复内容必填!";
      echo"</td>";
      echo"</tr>";
       }
       }
      ?>
      <? echo $disptext ?> 
      <tr align="left" valign="middle" bgcolor="#F0F0F0"> 
        <td width= 100%  height= 31 bgcolor="#FFFFFF" > 回复大名 
          <input type= text  name= replyname  size= 20 >
        </td>
      </tr>
      <tr valign="middle"> 
来源:http://www.002pc.com/master/College/Programming/PHP/11693.html

收藏到:

关于《PHP+TEXT留言本(五)》文章的评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面

随机文章

    SQL Error: select * from ***_ecms_article where classid='86' and checked=1 order by rand() limit 10

顶出来的热门

    SQL Error: select * from ***_ecms_article where classid='86' and checked=1 order by diggtop desc,id desc limit 10
站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td