<?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 conver($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)<=8 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=#0066CC>
 <tr>
 <td>
  <table width=100% border=0 cellspacing=1 cellpadding=3>
   <tr bgcolor=#0066CC> 
    <td bgcolor=#90c8ff background=img/skinbg.gif>$title</td>
   </tr>
   <tr > 
    <td bgcolor=#000000 background=img/bg.gif><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:#0066CC;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=#0066CC 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='#0066CC'>
    <tr><td>
      <table width="100%" border=0 cellspacing=1 cellpadding=2>
    <tr>
          <td bgcolor=#90c8ff 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=#ffffff>$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=conver($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");
?>
<FORM name=form action="write.php?action=add" 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');
}
function ctlent(eventobject){
	if(event.altKey && window.event.keyCode == 83)
		this.document.form.submit();
}


</SCRIPT>

<SCRIPT src="img/code.js"></SCRIPT>
 <BR>
<TABLE cellSpacing=0 cellPadding=0 width="70%" align=center bgColor=#0066CC 
border=0>
  <TBODY>
  <TR>
    <TD>
      <TABLE height="100%" cellSpacing=1 cellPadding=4 width="100%" border=0>
        <TBODY>
        <TR>
          <TD bgColor=#90c8ff  background=img/skinbg.gif colSpan=2>
            <DIV align=center><FONT color=#0066CC><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=#90c8ff background=img/skinbg.gif 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>

<?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=conver($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].="<br><TABLE cellSpacing=0 cellPadding=1 width=\"100%\" align=center bgColor=#0066CC border=0><TBODY><TR><TD><TABLE height=\"100%\" cellSpacing=0 cellPadding=2 width=\"100%\" border=0><TBODY><TR><TD width=\"100%\" bgColor=#f9f3f5>〖管理员〗：$supadmin 〖回复时间〗：$nowtime &nbsp;<HR width=\"100%\" color=#0066CC SIZE=1>内容：$msg </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>";
		  $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>";
	}
}?>