作者:疾风灬浪 | 来源:互联网 | 2018-03-18 12:57
上一次我们研究了guest.php文件.具体的问题还要求读者朋友自己深入的去实践,而且需要一些工具书来学习,如果您一点php的知识都没有,笔者奉劝您就不要想下看了,笔者没有太多的时间和篇幅去逐句探究一个php文件的用途和意义.好的,接下来我们来作edit.php这个文件.
-----------
//edit.php
if ($Submit)
{
if ($SavePassword=="on")
{setCOOKIE("TxtPassword","$TxtPassword",time()+30*24*3600);}
else
{setCOOKIE("TxtPassword");}
}
?>
require("sys.php");
function readvalue($tags,$tage)
{
global $message,$long,$reply;
$StrStart=strlen(strstr($message,$tags))-strlen($tags);//去除标记后变量所在字串的起始位置.
$StrEnd=strlen(strstr($message,$tage));
$len=$StrStart-$StrEnd;
$StrStart=$long-$StrStart;//起始字符.
$StrString=substr($message,$StrStart,$len);
return $StrString;
}
function save($record)
{
global $TxtContent,$TxtEmail,$TxtHomepage,$TxtEmail,$TxtName,$TxtFrom,$TxtReply,$REMOTE_ADDR,$guestfile;
$cOntent=file($guestfile,"r");
$space = " ";
$time = date(Y年m月d日H小时i分);
$ip=$REMOTE_ADDR;
$TxtReply=StripSlashes($TxtReply);
$TxtCOntent=StripSlashes($TxtContent);
$TxtCOntent=htmlspecialchars($TxtContent);
$TxtCOntent=check_strlen_long($TxtContent);
$TxtCOntent=nl2br($TxtContent);
$WcOntent= "
留言内容: $TxtContent "; $WcOntent=$Wcontent." 留言人大名:$TxtName "; if ($TxtEmail !="") {$WcOntent=$Wcontent." 电子信箱$TxtEmail"."$space";} if ($TxtHomepage !="http://") {$WcOntent=$Wcontent."主页:$TxtHompage$TxtHomepage";} $WcOntent=$Wcontent." 时间:$time 来自:$TxtFrom ".$ip.""; $WcOntent=ereg_replace(chr(10),"",$Wcontent); $WcOntent=$Wcontent."
|
";
$TxtReply=ereg_replace(chr(10),"",$TxtReply);
$WCOntent=$Wcontent.$TxtReply."n";
$count=count($content);
$fp=fopen($guestfile,"w");
for ($i=0;$i<$count;$i++)
{
if ($i==$record-1)
{$content[$i]=$WContent;}
fputs($fp,$content[$i]);
}
fclose($fp);
}
$cOntent=file($guestfile,"r");
$message=$content[$record-1];
$lOng=strlen($message);
$txtcOntent=readvalue('','');
$txtname=readvalue('','');
$txtfrom=readvalue('','');
$txtemail=readvalue('','');
$txthomepage=readvalue('','');
$txtcOntent=strip_tags($txtcontent);
$tags="";
$txtreply=strstr($message,$tags);
$txtreply=ereg_replace(""",""",$txtreply);
if ($Submit)
{
if ($TxtPassword==$managepwd)
{
if ($TxtName!="" and $TxtContent!="")
{
save($record);
echo "";
exit;
}else {$errorm="留言人姓名和内容必填!!";}
}
else {$errorm="密码错误,只有管理员有权修改!!";}
}
?>
include('head.htm');?>
----------
该注明的地方我已作了诠释.php可以嵌入html代码中,这样写起代码很惬意.
待续...