返回   CHF站长论坛 > 综合讨论区 > 网站开发与设计

网站开发与设计 网页设计、网站开发、网站维护与调试交流区。

双至强仅二千,企商在线,最早租用商 传世私服 魔域私服 亿恩1元帮您升级服务器! 天龙八部私服 传奇世界私服
传奇私服 仙境私服 天龙八部私服 传奇私服 传世私服 完美世界私服 魔域私服 传奇私服
发表新主题 回复
 
主题工具 主题评分 显示模式
旧 2006-10-13, 17:01   #1 (页面定位)
lane©
A dministrator
 
lane 的头像
 
注册日期: 2005-09-05
住址: 辽宁 大连
帖子: 4846
lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀
默认 谁帮我个忙,帮我在这里加入个随机验证码,谢谢了,PHP的

HTML 代码:
<?php
//write.php
require("config.php");

function smeil($htmlcode){
	  $htmlcode=str_replace(":em10:","<IMG SRC=img/emotion/10.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em11:","<IMG SRC=img/emotion/11.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em12:","<IMG SRC=img/emotion/12.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em13:","<IMG SRC=img/emotion/13.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em14:","<IMG SRC=img/emotion/14.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em15:","<IMG SRC=img/emotion/15.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em16:","<IMG SRC=img/emotion/16.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em17:","<IMG SRC=img/emotion/17.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em18:","<IMG SRC=img/emotion/18.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em19:","<IMG SRC=img/emotion/19.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em20:","<IMG SRC=img/emotion/20.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em21:","<IMG SRC=img/emotion/21.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em22:","<IMG SRC=img/emotion/22.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em23:","<IMG SRC=img/emotion/23.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em24:","<IMG SRC=img/emotion/24.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em25:","<IMG SRC=img/emotion/25.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em26:","<IMG SRC=img/emotion/26.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em27:","<IMG SRC=img/emotion/27.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em28:","<IMG SRC=img/emotion/28.gif border=0>",$htmlcode);
	  $htmlcode=str_replace(":em29:","<IMG SRC=img/emotion/29.gif border=0>",$htmlcode);
	  return $htmlcode;
}

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=str_replace("|"," ",$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("/\[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=smeil($Text);
    return $Text;
   }
   function readfrom($file_name) {
	$filenum=@fopen($file_name,"r");
	@flock($filenum,LOCK_SH);
	$file_data=@fread($filenum,filesize($file_name));
	@fclose($filenum);
	return $file_data;
}

  function checkqq($uin){
 if($uin=="")return 1;else
 if(strlen($uin)<=10 and !eregi("([^0-9])",$uin))return 1;else return 0;
}
 function checkmail($add){
  if(ereg("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+",$add)) $ttt=true;
      else $ttt=false;
   return $ttt;
 }
  function getid(){
  $id=date("YmdHis");
  return $id;
}
   function nowtime(){
	   $time=date("Y-m-d H:i:s");
	   return $time;
   }

function msg_box($title,$content) {
print <<<EOT
	<html><head><title>出错了!,</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><link rel="stylesheet" href="img/css.css"></head><body background="img/bg.gif">
<table width=70% border=0 cellspacing=0 cellpadding=0 align=center bgcolor=#985478>
 <tr>
 <td>
  <table width=100% border=0 cellspacing=1 cellpadding=3>
   <tr bgcolor=#f8d8e0> 
    <td bgcolor=#f8d8e0 background=img/skinbg.gif>$title</td>
   </tr>
   <tr bgcolor=#f8d8e0> 
    <td><br>$content
	<br><a href="javascript:history.go(-1);">单击这里返回</a>
		<BR><a href="index.php">单击这里返回首页</a></td>
   </tr>

  </table>
 </td>
 </tr>
</table>
EOT;

}
function jump_page($URL,$title,$content) {
global $bbstitle;
print <<<EOT
	<html>
	<head>
	<style type="text/css">
	<!--
	a {color:#333333;font-size: 9pt;text-decoration:none; }
	a:hover {color:#000066;text-decoration:underline overline;}
	td{FONT-SIZE: 9pt; color:#333333; font-family:宋体}
	-->
	</style>
	<title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
	<meta HTTP-EQUIV=REFRESH CONTENT="1; url=$URL">
	<script language="Javascript">
		function Show(divid) {
		divid.filters.revealTrans.apply(); 
		divid.style.visibility = "visible"; 
		divid.filters.revealTrans.play(); 
	}
	function Hide(divid) {
		divid.filters.revealTrans.apply();
		divid.style.visibility = "hidden";
		divid.filters.revealTrans.play();
	}
	</script>
	</head>

	<body bgColor=#f8d8e0 background=img/bg.gif Onload="Show(msgboard)">

	<div id="msgboard" style="FILTER: revealTrans(transition=23,duration=0.5) blendTrans(duration=0.5); position:absolute; left:260px; top:150px; width:350px; height:100px; z-index:1; visibility: hidden">
      <table width="100%" border=0 cellspacing=0 cellpadding=0 bgcolor='#FF99CC'>
    <tr><td>
      <table width="100%" border=0 cellspacing=1 cellpadding=2>
    <tr>
          <td bgcolor=#985478 align=center background=img/skinbg.gif>
    <table border=0 width="100%"><tr><td align=left>$title</td><td align=right>欢迎光临{$bbstitle}</td>
        </tr></table></td>
       <tr>
        <td bgcolor=#FFE1FF>$content</td>
      </tr>
    </table></td>
      </tr>
    </table>
	</div>
	<script>
	setTimeout('Hide(msgboard)',3000);
	</script>
	</body>
	</html>
EOT;
exit;
}
if(empty($action))$action="add";
if ($action=="add"){
 if($addsub){
  if(!checkmail($email)) {msg_box("email出错了","email必须是这样的格式:例 wxjhope@163.com");exit;}
  elseif(!checkqq($qq)) {msg_box("QQ出错","qq号码不对吧?");exit;}
  
  elseif($name=="" || $msg=="" || $timu=="") {msg_box("你有一项没有填写","必需填写标题,名字,内容!");exit;}
  else{
	   $time=nowtime();
       $msg=ubb($msg);
	   if(strlen($timu)>50){msg_box("字数太多了","写的标题字数超过50个了");exit;}
	   if(strlen($msg)>$zishu){msg_box("字数太多了","写的留言太多了");exit;}
	   elseif($qq=="")$qq="不告诉你";
	   $homepage=htmlspecialchars($homepage);
	   if(!ereg("^http://",$homepage)){$homepage="http://" . $homepage;}
	   if($homepage=="")$homepage="http://";
	   $id=getid();
	   $reply="";
	   $replyindex=0;
	   $ip=getenv("REMOTE_ADDR");
	   $name=htmlspecialchars($name);
	   $timu=htmlspecialchars($timu);
	   //if($timu==""){$timu="无";}
	   $writemsg="$id|$name|$time|$email|<IMG SRC=img/emotion/$posticon border=0>&nbsp;$msg|$timu|$sex|$replyindex|$reply|$qq|$homepage|$ip|||\n";
	   $fp=fopen($datafile,"a");
	   fwrite($fp,$writemsg);
	   fclose($fp);
	   jump_page("index.php","留言成功","恭喜您已经成功留言! <br><br>程式已经为您自动登录<br><br>如果程式无法登陆首页请点击这<br><ul><li><a href=index.php>点击这里进入首页</a></li></ul>");
	
  }
 }else{
	
include("headinfo.inc");
 ?>
 <script>
function ctlent(eventobject){if(event.altKey && window.event.keyCode == 83){this.document.FORM.submit();}}
 </SCRIPT>
<FORM name=form action="write.php" method=post>
<SCRIPT>
function emoticon(theSmilie){
document.form.msg.value += theSmilie + ' ';
document.form.msg.focus();
}
function openScript(theURL, W, H) {
var bIsIE5 = 0;
var Win=window.open(theURL,"openScript",'width='+W+',height='+H+',resizable=1,scrollbars=yes,menubar=yes,status=yes');
}

</SCRIPT>

<SCRIPT src="img/code.js"></SCRIPT>
 <BR>
<TABLE cellSpacing=0 cellPadding=0 width="70%" align=center bgColor=#985478 
border=0>
  <TBODY>
  <TR>
    <TD>
      <TABLE height="100%" cellSpacing=1 cellPadding=4 width="100%" border=0>
        <TBODY>
        <TR>
          <TD bgColor=#f8d8e0 colSpan=2>
            <DIV align=center><FONT color=#985478><B><?=$writetitle?></B></FONT></DIV></TD></TR>
        <TR bgColor=#fdfcfc>
          <TD width="23%"><B><?=$writetimu?></B></TD>
          <TD width="77%">&nbsp; <INPUT class=input2 maxLength=40 size=35 
            name=timu> * 不得超过 50 个汉字 </TD></TR>
        <TR bgColor=#fdfcfc>
          <TD width="23%"><B>您的名字:</B></TD>
          <TD width="77%">&nbsp; <INPUT class=input2 maxLength=50 size=25 
            name=name> * </TD></TR>
        <TR bgColor=#fdfcfc>
          <TD width="23%"><B>电子邮件:</B></TD>
          <TD width="77%">&nbsp; <INPUT class=input2 maxLength=30 size=25 
            name=email>* </TD></TR>
        <TR bgColor=#fdfcfc>
          <TD width="23%"><B>OICQ号码:</B></TD>
          <TD width="77%">&nbsp; <INPUT class=input2 maxLength=50 size=25 
            name=qq> </TD></TR>
        <TR bgColor=#fdfcfc>
          <TD width="23%"><B>主页地址:</B></TD>
          <TD width="77%">&nbsp; <INPUT class=input2 maxLength=50 size=25 
            value=http:// name=homepage> </TD></TR>
        <TR bgColor=#fdfcfc>
          <TD width="23%"><B>当前心情:</B><BR>贴图方法:点击相应的心情图标即可</TD>
          <TD vAlign=top width="77%"><INPUT type=radio 
            value=10.gif name=posticon><A 
            href="javascript:emoticon(':em10:');"><IMG src="img/emotion/10.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=11.gif name=posticon><A 
            href="javascript:emoticon(':em11:');"><IMG src="img/emotion/11.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=12.gif name=posticon><A 
            href="javascript:emoticon(':em12:');"><IMG src="img/emotion/12.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=13.gif name=posticon><A 
            href="javascript:emoticon(':em13:');"><IMG src="img/emotion/13.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=14.gif name=posticon><A 
            href="javascript:emoticon(':em14:');"><IMG src="img/emotion/14.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=15.gif name=posticon><A 
            href="javascript:emoticon(':em15:');"><IMG src="img/emotion/15.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=16.gif name=posticon><A 
            href="javascript:emoticon(':em16:');"><IMG src="img/emotion/16.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=17.gif name=posticon><A 
            href="javascript:emoticon(':em17:');"><IMG src="img/emotion/17.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=18.gif name=posticon><A 
            href="javascript:emoticon(':em18:');"><IMG src="img/emotion/18.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=19.gif name=posticon><A 
            href="javascript:emoticon(':em19:');"><IMG src="img/emotion/19.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<BR><INPUT type=radio 
            value=20.gif name=posticon><A 
            href="javascript:emoticon(':em20:');"><IMG src="img/emotion/20.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=21.gif name=posticon><A 
            href="javascript:emoticon(':em21:');"><IMG src="img/emotion/21.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=22.gif name=posticon><A 
            href="javascript:emoticon(':em22:');"><IMG src="img/emotion/22.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=23.gif name=posticon><A 
            href="javascript:emoticon(':em23:');"><IMG src="img/emotion/23.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=24.gif name=posticon><A 
            href="javascript:emoticon(':em24:');"><IMG src="img/emotion/24.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=25.gif name=posticon><A 
            href="javascript:emoticon(':em25:');"><IMG src="img/emotion/25.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio CHECKED
            value=26.gif name=posticon><A 
            href="javascript:emoticon(':em26:');"><IMG src="img/emotion/26.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=27.gif name=posticon><A 
            href="javascript:emoticon(':em27:');"><IMG src="img/emotion/27.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=28.gif name=posticon><A 
            href="javascript:emoticon(':em28:');"><IMG src="img/emotion/28.gif" 
            width=15 border=0 hight="15"></A>&nbsp;<INPUT type=radio 
            value=29.gif name=posticon><A 
            href="javascript:emoticon(':em29:');"><IMG src="img/emotion/29.gif" 
            width=15 border=0 hight="15"></A>&nbsp;</TD></TR>
      <TR bgColor=#fdfcfc>
          <TD width="23%"><B>选择头像:</B></TD>
          <TD width="77%">&nbsp; <SELECT name=sex> <OPTION value=00.gif 
              selected>选择头像</OPTION><OPTION value=01.gif>01</OPTION><OPTION 
              value=02.gif>02</OPTION><OPTION value=03.gif>03</OPTION><OPTION 
              value=04.gif>04</OPTION><OPTION value=05.gif>05</OPTION><OPTION 
              value=06.gif>06</OPTION><OPTION value=07.gif>07</OPTION><OPTION 
              value=08.gif>08</OPTION><OPTION value=09.gif>09</OPTION><OPTION 
              value=10.gif>10</OPTION><OPTION value=11.gif>11</OPTION><OPTION 
              value=12.gif>12</OPTION><OPTION value=13.gif>13</OPTION><OPTION 
              value=14.gif>14</OPTION><OPTION value=15.gif>15</OPTION><OPTION 
              value=16.gif>16</OPTION><OPTION value=17.gif>17</OPTION><OPTION 
              value=18.gif>18</OPTION><OPTION value=19.gif>19</OPTION><OPTION 
              value=20.gif>20</OPTION><OPTION value=21.gif>21</OPTION><OPTION 
              value=22.gif>22</OPTION><OPTION value=23.gif>23</OPTION><OPTION 
              value=24.gif>24</OPTION></SELECT>&nbsp; 总头像个数: 24 个。<a href="javascript:openScript('listpic.php?dir=face',400,300)">查看头像列表</A> </TD></TR>
         <TR bgColor=#fdfcfc>
          <TD width="23%"><B><?=$writeneirong?></B><BR><BR>
            <LI>文字特效&nbsp;&nbsp;&nbsp;&nbsp;: <?if($texiao==1)echo"<B>允许</B>";else echo"<B>禁止</B>";?>
            <LI>贴图标签   : <?if($wdbcode_post['pic']==1)echo"<B>允许</B>";else echo"<B>禁止</B>";?>
			<LI>sound 音乐 &nbsp;: <?if($wdbcode_post['mpeg']==1)echo"<B>允许</B>";else echo"<B>禁止</B>";?> 
            <LI>Flash 标签 &nbsp;: <?if($wdbcode_post['flash']==1)echo"<B>允许</B>";else echo"<B>禁止</B>";?>  
            <LI>电影标签 &nbsp;&nbsp;&nbsp;: <?if($wdbcode_post['mpeg']==1)echo"<B>允许</B>";else echo"<B>禁止</B>";?> 
            <LI>最大留言字数: <B><?=$zishu?></B> </LI>
          <TD align=life width="77%"><INPUT class=input2 title=加粗 onclick=YBBCbold() type=button value=" B " name=bold> 
<INPUT class=input2 title=倾斜 onclick=YBBCitalic() type=button value=" I " name=italic> 
<INPUT class=input2 title=下划线 onclick=YBBCunder() type=button value=" U " name=under> 
<INPUT class=input2 title=超链接 onclick=YBBCurl() type=button value="链 接"> 
<INPUT class=input2 title=图片 onclick=YBBCimage() type=button value="图 片">
<INPUT class=input2 title=背景音乐 onclick=bgsound() type=button value="音 乐">
<INPUT class=input2 title=realone电影 onclick=realone() type=button value="电影"> 
<INPUT class=input2 title=mediaplay音乐 onclick=mediaplay() type=button value="mp3"> 
<INPUT class=input2 title=Flash onclick=flash() type=button value=Flash> 
<INPUT class=input2 title=使文字飞行 onclick=fly() type=button value=" 飞 "> 
<INPUT class=input2 title=使文字产生移动效果 onclick=move() type=button value=" 移 "> 
<INPUT class=input2 title=产生光晕效果的文字 onclick=glow() type=button value=" 光 "> 
            <BR><TEXTAREA  onkeydown=ctlent() class=input3 name=msg rows=6 cols=79></TEXTAREA> 
          </TD></TR>
       
        <TR>
          <TD bgColor=#f8d8e0 colSpan=2>
            <DIV align=center><input type="submit" value="确认提交" name="addsub" style="height:20px;background-color:#f3f3f3;border:1 solid black" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#f3f3f3'">&nbsp;&nbsp; 
<input type="button" value="回到首页" style="height:20px;background-color:#f3f3f3;border:1 solid black" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#f3f3f3'" onclick="location.href='index.php'"> &nbsp;&nbsp;<input type="reset" value="重新来过" style="height:20px;background-color:#f3f3f3;border:1 solid black" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#f3f3f3'"></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></FORM>
<P align=center>
 <?include("footer.inc")?>
<SCRIPT>var tc_user="hhhsy";var tc_class="2";</SCRIPT></P>


</BODY></HTML>
lane 当前离线   回复时引用此帖
旧 2006-10-13, 17:02   #2 (页面定位)
lane©
A dministrator
 
lane 的头像
 
注册日期: 2005-09-05
住址: 辽宁 大连
帖子: 4846
lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀
默认

限制了发帖字数,这个是接下来的代码。
HTML 代码:
<?php
 }
}elseif($action=="edit"){
    if($chgadd){
	   $dh=opendir("user/");$i=0;
	while ($userfile=readdir($dh)) {
		if (($userfile!=".") && ($userfile!="..") && ($userfile!="") && strpos($userfile,".php")) {
			$useri=explode("|",readfrom("user/$userfile"));
		if($subpass==$useri[2] && $supadmin==$useri[1])
			$i=1;}}if($i!=1){msg_box("操作错误","管理员或密码错了!");exit;}
	  else{$nowtime=nowtime();
$msg.="[align=right][color=gray][此贴被 $supadmin 在{$nowtime}修改过][/color][/align]";
$article=file($datafile);
$xiugai=explode("|",$article[$id]);
$msg=ereg_replace("\n","<br>",$msg);
$xiugai[4]=$msg;
$article[$id]=implode('|',$xiugai);
$article=implode("",$article);
$f = fopen($datafile,"w");
fputs($f,$article);
jump_page("index.php","修改留言成功","恭喜版主成功修改留言! <br><br>程式已经为您自动登录<br><br>如果程式无法登陆首页请点击这<br><ul><li><a href=index.php>点击这里进入首页</a></li></ul>");}}
else {$txt=file($datafile);$detail=explode("|",$txt[$id]);
	echo"<html><head><title>修改留言</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\"><link rel=\"stylesheet\" href=\"img/css.css\"></head><body background=img/bg.gif><center><form method=\"post\" action=\"write.php?action=edit&id=$id\"><table><tr><td>&nbsp;斑竹:&nbsp;</td><td><input type=\"text\" name=\"supadmin\"></td></tr><tr><td>斑竹密码:</td><td><input type=\"password\" name=\"subpass\"></td></tr><tr><td>原贴内容:</td><td><textarea name=\"msg\" cols=\"50\" rows=\"10\">$detail[4]</textarea></td></tr><tr><td><input  class=input2  type=\"submit\" name=\"chgadd\" value=\"确定修改\" style=\"height:20px;background-color:#f3f3f3;border:1 solid black\" onMouseOver =\"this.style.backgroundColor='#FFC864'\" onMouseOut =\"this.style.backgroundColor='#f3f3f3'\"></td></tr></table></form></center>";
	}
}elseif($action=="reply"){
    if($repsub){
	   $dh=opendir("user/");
		$i=0;
	while ($userfile=readdir($dh)) {
		if (($userfile!=".") && ($userfile!="..") && ($userfile!="") && strpos($userfile,".php")) {
			$useri=explode("|",readfrom("user/$userfile"));
		if($subpass==$useri[2] && $supadmin==$useri[1])
			$i=1;}
		}
		 if($i!=1){msg_box("密码错误","管理员或密码错了!");exit;}
	  else{
		  $msg=ubb($msg);
		 $nowtime=nowtime();
		 $fp=fopen($datafile,"r");
		  $headmsg="";$check=1;$temp="";
		  while($check){
			  $headmsg=$headmsg.$temp;
			  $nowline=fgets($fp,5000);
			  $temp=$nowline;
			  $nowmsg=explode("|",$nowline);
			  if($nowmsg[0]==$id){$check=0;}
		  }
		  $footmsg=fread($fp,filesize($datafile));
		  fclose($fp);
		  $nowmsg[7]++;
		  $nowmsg[8].="<tr><td bgcolor=#f9f3f5 width=25%  align=center>版主<font color=#FF33CC>$supadmin</font>回复:</td><td bgcolor=#f9f3f5 >$msg</td></tr>";
		  $nowmsg2=implode("|",$nowmsg);
		  $writemsg="$headmsg$nowmsg2$footmsg";
		  $fp=fopen($datafile,"w");
		  fwrite($fp,$writemsg);
		  fclose($fp);
	 jump_page("index.php","回复留言成功","恭喜您已经成功回复留言! <br><br>程式已经为您自动登录<br><br>如果程式无法登陆首页请点击这<br><ul><li><a href=index.php>点击这里进入首页</a></li></ul>");
		
	  }
	}
	else {
	echo"<html><head><title>发表回复</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\"><link rel=\"stylesheet\" href=\"img/css.css\"></head><body background=img/bg.gif><center><form method=\"post\" action=\"write.php?action=reply&id=$id\"><table><tr><td>&nbsp;斑竹:&nbsp;</td><td><input type=\"text\" name=\"supadmin\"></td></tr><tr><td>斑竹密码:</td><td><input type=\"password\" name=\"subpass\"></td></tr><tr><td>回复内容:</td><td><textarea name=\"msg\" cols=\"50\" rows=\"10\"></textarea></td></tr><tr><td><input  class=input2  type=\"submit\" name=\"repsub\" value=\"确定回复\" style=\"height:20px;background-color:#f3f3f3;border:1 solid black\" onMouseOver =\"this.style.backgroundColor='#FFC864'\" onMouseOut =\"this.style.backgroundColor='#f3f3f3'\"></td></tr></table></form></center>";
	}
}elseif($action=="del"){
	if($delsub){
		$dh=opendir("user/");
		$i=0;
	while ($userfile=readdir($dh)) {
		if (($userfile!=".") && ($userfile!="..") && ($userfile!="") && strpos($userfile,".php")) {
			$useri=explode("|",readfrom("user/$userfile"));
		if($subpass==$useri[2] && $supadmin==$useri[1])
			$i=1;}
		}
		 if($i!=1){msg_box("密码错误","管理员或密码错了!");exit;}
		else{
			 $notelist=file($datafile);
            unset($notelist[$id]);
            $notelist=implode("",$notelist);
            $f=fopen($datafile,"w");
            fputs($f,$notelist);
			jump_page("index.php","删除成功","帖子已经成功删除! <br><br>程式已经为您自动登录<br><br>如果程式无法登陆首页请点击这<br><ul><li><a href=index.php>点击这里进入首页</a></li></ul>");
		}
	}
	else{
		echo"<html><head><title>删除留言</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\"><link rel=\"stylesheet\" href=\"img/css.css\"></head><body background=img/bg.gif><center><form method=\"post\" action=\"write.php?action=del&id=$id&delsub=1\"><BR><BR><br>&nbsp;斑竹:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"text\" name=\"supadmin\"><BR><BR><BR>斑竹密码:&nbsp;&nbsp;&nbsp;<input type=\"password\" name=\"subpass\"><BR><BR>&nbsp;&nbsp;&nbsp;<input type=\"submit\" name=\"delsub\" value=\"删除\"style=\"height:20px;background-color:#f3f3f3;border:1 solid black\" onMouseOver =\"this.style.backgroundColor='#FFC864'\" onMouseOut =\"this.style.backgroundColor='#f3f3f3'\"><!--<input type=\"hidden\" name=\"id\" value=\"$id\">--></form>";
	}
}
function writeto($file_name,$infoata,$method="w") {
	$filenum=@fopen($file_name,$method);
	flock($filenum,LOCK_EX);
	$file_data=fwrite($filenum,$infoata);
	fclose($filenum);
	return $file_data;
}?>
lane 当前离线   回复时引用此帖
旧 2006-10-13, 17:07   #3 (页面定位)
lane©
A dministrator
 
lane 的头像
 
注册日期: 2005-09-05
住址: 辽宁 大连
帖子: 4846
lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀
默认 找到这个,怎么往里加呢?

找到这个,怎么往里加呢?
引用:
目前,不少网站为了防止用户利用机器人自动注册、登录、灌水,都采用了验证码技术。所谓验证码,就是将一串随机产生的数字或符号,生成一幅图片,图片里加上一些干扰象素(防止OCR),由用户肉眼识别其中的验证码信息,输入表单提交网站验证,验证成功后才能使用某项功能。

我们这里展示了如何编写PHP程序实现验证码功能:

代码一: 

  <?php
/*
*  Filename:  authpage.php
  *  Author:  hutuworm
  *  Date:  2004-09-26
  *  @Copyleft  hutuworm.org
  */

  srand((double)microtime()*1000000);

  //验证用户输入是否和验证码一致
    if(isset()) 
    {
        if(strcmp(,)==0)
            echo "验证成功!";
        else
            echo "验证失败!";
    }
  
  //生成新的四位整数验证码
    while((=rand()%10000)<1000); 
  ?>
    <form action=authpage.php method=post>
    <table>
        请输入验证码:<input type=text name=authinput style="width: 80px"><br>
        <input type=submit name="验证" value="提交验证码">
        <input type=hidden name=authnum value=<? echo ; ?>>
        <img src=authimg.php?authnum=<? echo ; ?>>
    </table>
    </form>

代码二:

<?php
  /*
  *  Filename:  authimg.php
  *  Author:  hutuworm
  *  Date:  2003-04-28
  *  @Copyleft  hutuworm.org
  */

  //生成验证码图片
    Header("Content-type: image/PNG"); 
    srand((double)microtime()*1000000);
     = imagecreate(58,28);
     = ImageColorAllocate(, 0,0,0);
     = ImageColorAllocate(, 255,255,255);
     = ImageColorAllocate(, 200,200,200);
    imagefill(,68,30,);

  //将四位整数验证码绘入图片
    imagestring(, 5, 10, 8, , );

    for(=0;<50;++)  //加入干扰象素
    {
        imagesetpixel(, rand()%70 , rand()%30 , );
    }

    ImagePNG();
    ImageDestroy();
?>

本文程序在Apache 2.0.45 + PHP 4.3.1环境下运行通过。

  上文只是对验证码功能的一个简单实现,并没有考虑商用安全性问题。如果要增强安全性,将此功能投入商业应用,则可以通过以下几个步骤实现:

  1. 启用Session。
  2. authnum在authimg.php中生成,并计算md5sum,存入session。
  3. authpage.php将authinput计算md5sum后,与session中的authnum(md5sum)对比得出验证结果。

  本站注:作者使用了简单的代码实现了很酷的功能。不过在添加干扰像素时的效果不是太好,大家可以看一下雨声论坛登录时的效验码(http://ror.cn/perl/ut/user_login.cgi...的效果。

  修改后的代码如下:

  <?php
  /*
   *  Filename: authimg.php
  *  Author:  hutuworm
  *  Date:   2004-09-26
  *  @Copyleft hutuworm.org
  */
//生成验证码图片
  Header("Content-type: image/PNG"); 
  srand((double)microtime()*1000000);
   = imagecreate(62,20);
  = ImageColorAllocate(, 0,0,0);
   = ImageColorAllocate(, 255,255,255);
= ImageColorAllocate(, 200,200,200);
  imagefill(,68,30,);
  while((=rand()%100000)<10000);
  //将四位整数验证码绘入图片
imagestring(, 5, 10, 3, , );
  for(=0;<200;++)  //加入干扰象素
{
   = ImageColorallocate(,rand(0,255),rand(0,255),rand(0,255));
  imagesetpixel(, rand()%70 , rand()%30 , );
  }
  ImagePNG();
  ImageDestroy();
  ?>
lane 当前离线   回复时引用此帖
旧 2006-10-13, 17:38   #4 (页面定位)
lane©
A dministrator
 
lane 的头像
 
注册日期: 2005-09-05
住址: 辽宁 大连
帖子: 4846
lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀lane 星途闪耀
默认

热情点热情点
lane 当前离线   回复时引用此帖
回复

书签

标签

主题工具
显示模式 对此主题评分
对此主题评分:



所有时间均为北京时间。现在的时间是 12:07