一个php作的文本留言本的例子(四)


Posted in PHP onOctober 09, 2006

这一节我们将dele.php和sys.php放上来.
---------
//dele.php<html>

<head>
<title>删除留言</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:10pt}
TH {FONT-SIZE:10 pt}
TD {FONT-SIZE: 10pt}
-->
</style>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<?

require("sys.php");
if ($Submit)
{

if ($password<>$managepwd)
  {$errorm="<font color=red>密码错误</font>.无权操作..";}

else  
{
$content=file($guestfile);
$message=$content[$record-1];
$count=count($content);
if ($dele=="delreply")
     {
     $replylen=strlen(strstr($message,"<!--reply>"));
     $long=strlen($message);
     $len=$long-$replylen;
     $message=substr($message,0,$len);
     }
     else
     {$message="";}
//writefile
$fp=fopen($guestfile,"w");
for ($i=0;$i<$count;$i++)
  {
  if ($i==($record-1)){$content[$i]=$message;}
  fputs($fp,$content[$i],strlen($content[$i]));
  }//end for
fclose($fp);
echo "<meta http-equiv=Refresh content="1;url=guest.php">";
exit;
}
}// end ifSubmit
$content=file($guestfile);
$message=$content[$record-1];
$found=ereg("<!--reply>",$message);
?>
<body bgcolor="#FFFFFF" background="back.gif">
<? include("head.htm"); ?>
<table width="68%" border="1" cellpadding="5" align="center" cellspacing="0" bordercolor="#F2F2F2">
<form action=dele.php method=post>
<?
  if ($errorm)
  {
echo "<tr>";  
echo "<td height=27>$errorm</td>";
echo "</tr>";
  }
?>
  <? echo $message ?>
    <tr align="center">  
      <td height="37" bgcolor="#f0f0f0">  
        <?
     if ($found)
     {
     echo "<input type=radio name=dele value=delall>";
     echo "全部删除 ";
     echo "<input type=radio name=dele value=delreply checked>";
     echo "仅删除回复";
     }
     ?>
        <font color="#000000">管理密码</font>  
        <input type="password" name="password" size="10">
      <input type=hidden name=record value=<? echo "$record";?>>
        <input type="submit" name="Submit" value="我要删除了">
      </td>
  </tr>
  </form>
</table>
<? include("bottom.htm"); ?>
</body>
</html>

------
//sys.php
<title>zihanonline</title><?

$managepwd='zihanonline';
$guestfile="guest.txt";

function check_strlen_long($txt)
{

$count=0;
$arrtemp=$txt;
$len=strlen($txt);
$txt=$txt.'            ';
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>=70)  
  {
    for ($j=$i;$j<$len;$j++)
    {
    $txt[$j+1]=$arrtemp[$j];
    }
  $txt[$i]="n";
  $len=$len+1;
  $txt[$len]=$arrtemp[$len-1];
  $count=0;
  $arrtemp=$txt;
  }//end if count
}
  $txt=trim($txt);
  return $txt;
}//end function

function encode ($txt)
{
$txt=strip_tags($txt);
$txt=htmlspecialchars($txt);
$message=StripSlashes($txt);
return $message;
}

function ubb($txt)
{

}
?>
<body bgcolor="#FFFFFF" background="back.gif">
----------
注意sys.php中的" $managepwd='zihanonline' "一栏中等号后的是留言本的管理密码号,此时是默认的zihanonline.您可以修改为自己的号码.
未完待续...

PHP 相关文章推荐
安装PHP可能遇到的问题“无法载入mysql扩展” 的解决方法
Apr 16 PHP
php数组函数序列之prev() - 移动数组内部指针到上一个元素的位置,并返回该元素值
Oct 31 PHP
php使用exec shell命令注入的方法讲解
Nov 12 PHP
ThinkPHP3.1新特性之命名范围的使用
Jun 19 PHP
PHP中unset,array_splice删除数组中元素的区别
Jul 28 PHP
php程序总是提示验证码输入有误解决方案
Jan 07 PHP
PHP json_encode() 函数详解及中文乱码问题
Nov 05 PHP
微信开发之网页授权获取用户信息(二)
Jan 08 PHP
PHP实现的构造sql语句类实例
Feb 03 PHP
PHP判断json格式是否正确的实现代码
Sep 20 PHP
laravel excel 上传文件保存到本地服务器功能
Nov 14 PHP
php在linux环境中如何使用redis详解
Dec 15 PHP
一个php作的文本留言本的例子(五)
Oct 09 #PHP
一个php作的文本留言本的例子(一)
Oct 09 #PHP
PHP的类 功能齐全的发送邮件类
Oct 09 #PHP
以文本方式上传二进制文件的PHP程序
Oct 09 #PHP
用户的详细注册和判断
Oct 09 #PHP
PHP编程与应用
Oct 09 #PHP
谈谈PHP语法(2)
Oct 09 #PHP
You might like
一个PHP日历程序
2006/12/06 PHP
在Ubuntu 14.04上部署 PHP 环境及 WordPress
2014/09/02 PHP
php链表用法实例分析
2015/07/09 PHP
php打包压缩文件之ZipArchive方法用法分析
2016/04/30 PHP
Javascript让DEDECMS告别手写Tag
2014/09/01 Javascript
javascript实现树形菜单的方法
2015/07/17 Javascript
canvas 画布在主流浏览器中的尺寸限制详细介绍
2016/12/15 Javascript
详解利用 Express 托管静态文件的方法
2017/09/18 Javascript
javascript中的隐式调用
2018/02/10 Javascript
vue计算属性computed、事件、监听器watch的使用讲解
2019/01/21 Javascript
bootstrap-paginator服务器端分页使用方法详解
2020/02/13 Javascript
使用nodejs实现JSON文件自动转Excel的工具(推荐)
2020/06/24 NodeJs
浅谈使用nodejs搭建web服务器的过程
2020/07/20 NodeJs
Vue左滑组件slider使用详解
2020/08/21 Javascript
原生JS实现京东查看商品点击放大
2020/12/21 Javascript
Python实现针对含中文字符串的截取功能示例
2017/09/22 Python
Python实现string字符串连接的方法总结【8种方式】
2018/07/06 Python
Windows下安装Scrapy
2018/10/17 Python
Python中@property的理解和使用示例
2019/06/11 Python
Django在pycharm下修改默认启动端口的方法
2019/07/26 Python
python selenium爬取斗鱼所有直播房间信息过程详解
2019/08/09 Python
鞋子女王塔玛拉·梅隆同名奢侈品牌:Tamara Mellon
2017/11/22 全球购物
高级电工工作职责
2013/11/21 职场文书
三好学生自我鉴定
2013/12/17 职场文书
学年末自我鉴定
2014/01/21 职场文书
质量标语大全
2014/06/12 职场文书
助人为乐好少年事迹材料
2014/08/18 职场文书
学生会竞选演讲稿怎么写
2014/08/26 职场文书
幼儿园六一儿童节活动方案
2014/08/26 职场文书
晋江市委常委班子四风问题整改工作方案
2014/10/26 职场文书
2015年乡镇残联工作总结
2015/05/13 职场文书
2015年高三毕业班班主任工作总结
2015/10/22 职场文书
Python如何导出导入所有依赖包详解
2021/06/08 Python
SQLServer中exists和except用法介绍
2021/12/04 SQL Server
KVM基础命令详解
2022/04/30 Servers
OpenFeign实现远程调用
2022/08/14 Java/Android