<?php
//流星のstudy
//版权所有 快乐的流星 
require("config.php");
require("wdbcode.lib");
$txt=file($datafile);
$index=count($txt)-1;
$startline=$index-($page-1)*$perpage;
$endline=$startline-$perpage;
$howmanypages=ceil(($index+1)/$perpage);
include("headinfo.inc");
?>
<CENTER>
<P align=center>
<TABLE cellSpacing=0 cellPadding=0 width="70%" border=0>
  <TR>
    <TD width="2%">&nbsp;<IMG height=17 alt="本留言本的公告！" 
      src="img/announce.gif" width=17></TD>
    <TD width="45%">&nbsp;
      <MARQUEE scrollAmount=3><B><FONT color=#0066CC><?=$announce?></FONT></B></MARQUEE></TD>
    <TD align=right width="15%"><FONT color=#0066CC>共 
      <FONT color=red><?=$index+1?></FONT> 条留言 <FONT color=red><?=$howmanypages?></FONT>页
    <TD align=right width="38%"><FONT 
  color=#0066CC>版主：
<?
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;
}
$dh=opendir("user/");
	while ($userfile=readdir($dh)) {
			$useri=explode("|",readfrom("user/$userfile"));
			$userpwd=md5($useri[2]);
			if($pwd==$userpwd)$lxcheck=1;
echo"$useri[1]&nbsp;";
		}
?>
</FONT>&nbsp;</TD></TR></TABLE>
<TABLE cellSpacing=0 cellPadding=1 width="70%" align=center bgColor=#0066CC 
border=0>
  <TR>
    <TD>
      <TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#90c8ff 
      background=img/skinbg.gif border=0>
        <TR>
          <TD width="25%"><FONT color=#0066CC>作者信息</FONT></TD>
          <TD align=middle width=1 background=img/skinbg.gif 
          bgColor=#90c8ff>
            <TABLE height=15 cellSpacing=0 cellPadding=0 width=1 
bgColor=#0066CC>
              <TR>
                <TD width=1></TD></TR></TABLE></TD>
          <TD width="68%"><FONT color=#0066CC>留言信息</FONT></TD>
          <TD width="7%"><A href="javascript:this.location.reload()"><IMG 
            height=12 alt=刷新 src="img/refresh.gif" width=40 
            border=0></A></TD></TR></TABLE></TD></TR></TABLE>
<table border="0" cellspacing="1" width="70%">
<?php


function msg_box($title,$content) {
print <<<EOT
	<html><head><title>出错了！,</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></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=#0066CC 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 show(){
	global $t,$wxjhope,$detail,$i,$admin,$lxcheck;
echo "
	<center>
	<TABLE 
style=\"BORDER-RIGHT: #0066CC 1px solid; BORDER-TOP: #0066CC 0px solid; BORDER-LEFT: #0066CC 1px solid; BORDER-BOTTOM: #0066CC 1px solid\" 
cellSpacing=0 cellPadding=0 width=\"70%\" align=center bgColor=#0066CC border=0>
  <TBODY>
  <TR>
    <TD>
      <TABLE height=\"100%\" cellSpacing=0 cellPadding=4 width=\"100%\" border=0>
        <TBODY>
        <TR><TD vAlign=top align=middle width=\"25%\" bgColor=#f9f3f5 rowSpan=4>
            <TABLE style=\"FILTER: glow(color=#66bbff,direction=75)\">&nbsp; 
              $detail[1]
              </TABLE><IMG src=img/face/$detail[6]><BR><BR>第 
            <FONT color=#0066CC>$t</FONT> 条留言</TD>
          <TD align=middle width=1 bgColor=#f9f3f5 rowSpan=4>
            <TABLE height=\"100%\" cellSpacing=0 cellPadding=0 width=1 
            bgColor=#0066CC>
              <TBODY><TR><TD width=1></TD></TR></TBODY>
			  </TABLE></TD>
          <TD width=\"60%\" bgColor=#f9f3f5><FONT 
            color=#0066CC><B>标题：</B>$detail[5]</FONT>&nbsp;&nbsp;<A title=访问$detail[1]的主页 href=$detail[10] target=_blank><IMG 
            height=15 alt=访问$detail[1]的主页 src=\"img/homepage.gif\" 
            width=16 align=absMiddle border=0><FONT 
            color=#0066CC>主页</FONT></A>&nbsp;<A title=给$detail[1]发信 
            href=\"mailto:$detail[3]\" target=_blank><IMG height=15 
            alt=给$detail[1]发信 src=\"img/email.gif\" width=16 
            align=absMiddle border=0><FONT 
            color=#0066CC>信箱</FONT></A>&nbsp;&nbsp;<IMG height=15 alt=$detail[1]的QQ号码:$detail[9] 
            src=\"img/oicq.gif\" width=16 align=absMiddle 
            border=0><FONT color=#0066CC>$detail[9]</FONT>
            <HR width=\"100%\" color=#0066CC SIZE=1>
          </TD></TR>
        <TR>
          <TD width=\"75%\" bgColor=#f9f3f5>
            <TABLE height=\"100%\" cellSpacing=0 cellPadding=3 width=\"100%\" 
            border=0>
              <TBODY>
              <TR>
                
                <TD 
                  style=\"LEFT: 0px; WIDTH: 100%; WORD-WRAP: break-word; 130: \"><FONT 
                  color=#0066CC>$wxjhope</FONT> <BR>";
				if($detail[7]<>"0"){
		echo"$detail[8]";
	}
echo"</TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD width=\"75%\" bgColor=#f9f3f5>
            <HR width=\"100%\" color=#0066CC SIZE=1>
            <IMG height=15 alt='留言时间' src=\"img/posttime.gif\" width=16 
            align=absMiddle>：<FONT color=#0066CC>$detail[2]</FONT>&nbsp;&nbsp;<a href=write.php?action=del&id=$i title='删除留言'><IMG 
            height=15 alt='删除留言' src=\"img/del.gif\" width=16 
            align=absMiddle border=0><FONT 
        color=#0066CC>删除</font></a>&nbsp;&nbsp;<A 
            href=write.php?action=reply&id=$detail[0] title='回复留言'><IMG 
            height=15 alt='回复留言' src=\"img/replynow.gif\" width=16 
            align=absMiddle border=0><FONT 
        color=#0066CC>回复</FONT></A>";
if($admin && $lxcheck)echo"&nbsp;&nbsp;<A title=修改留言 href=write.php?action=edit&id=$i style=\"text-decoration: none\"><IMG height=15 alt=修改留言 src=img/edit.gif width=16 align=absMiddle border=0>修改</A>&nbsp;&nbsp;<IMG height=15 alt=查看IP src=img/ip.gif width=16 align=absMiddle border=0>&nbsp;IP:$detail[11]";
else
	echo"&nbsp;&nbsp;<IMG height=15 alt=您不是管理员不可查看IP src=img/ip.gif width=16 align=absMiddle border=0>&nbsp;:IP已记录";
echo"</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>";
}
if(empty($action)){$action="show";}
if($action=="show"){
if(empty($page)) $page=1;
$txt=file($datafile);
$index=count($txt)-1;
$startline=$index-($page-1)*$perpage;
$endline=$startline-$perpage;
$howmanypages=ceil(($index+1)/$perpage);
if($endline<0){$endline=-1;}
for($i=$startline;$i>$endline;$i--){
	$t=$i+1;
$detail=explode("|",$txt[$i]);

 if($texiao==1)
	$wxjhope=wdbconvert($detail[4],$wdbcode_post);
	
	show($txt[$i]);
}
echo"<br>";
}elseif($action=="search"){
	if($searchsub or $key){
		if($key=="" or $key==" "){msg_box("您没有输入文字","请输入关键字");exit;}
	    else{
			$txt=file($datafile);
			$index=count($txt)-1;
			for($i=0;$i<=$index;$i++){
				$nowmsg=explode("|",$txt[$i]);
				if(@eregi("$key",$nowmsg[4])){$result[]=$txt[$i];}
			}
			$index=count($result)-1;
			if($index==-1){msg_box("无法查找","没有找到记录");include("footer.inc");exit;}
			$ttt=$index+1;
			
			$startline=$index-($page-1)*$perpage;
			$endline=$startline-$perpage;
			$howmanypages=ceil(($index+1)/$perpage);
			if($endline<0){$endline=-1;}
			for($i=$startline;$i>$endline;$i--){
	                 $t=$i+1;
					 $detail=explode("|",$result[$i]);
           if($texiao==1)
	$wxjhope=wdbconvert($detail[4],$wdbcode_post);
                     show($result[$i]);
            }
			echo"<td><tr>共找到&nbsp;" . $ttt . "&nbsp;条包含关键字\"" . $key . "\"的记录&nbsp;&nbsp;&nbsp;<a href=\"index.php\">点击这里返回首页</a></td></tr>";
		}
	}
}elseif($action=="look"){
	$fuck=$id-1;
	$t=$id;
	//$datafile=yeye_1985713;
	$liuxing=file($datafile);
	$detail=explode("|",$liuxing[$fuck]);
           if($texiao==1)
	$wxjhope=wdbconvert($detail[4],$wdbcode_post);
                     show($liuxing[$fuck]);
					 echo"<br>";
}

?>
</table>
<TABLE cellSpacing=0 cellPadding=1 width="70%" align=center bgColor=#0066CC 
border=0>
    <TD >
      <TABLE cellSpacing=0 cellPadding=4 width="100%"  border=0>
        <TR >
          <form method=post action=index.php?action=search&page=1>
          <TD align=middle bgColor=#90c8ff width="45%" background=img/skinbg.gif ><FONT 
            color=#0066CC>关键字：</FONT><INPUT class=input2 
            name=key>&nbsp;&nbsp;&nbsp; <INPUT class=input2 type=submit value=搜索 name=searchsub style="height:20px;background-color:#f3f3f3;border:1 solid black" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#f3f3f3'"> </TD></FORM>
         <TD align=right bgColor=#90c8ff width="45%" background=img/skinbg.gif ><? 
		 $nextpage=$page+1;
      $previouspage=$page-1;
	if ($page>=2) echo "<a href=\"index.php?page=1\" title=第一页><font face=webdings >9</font></a> ";
      else echo "<font face=webdings >9</font>";
    if ($page>=2) echo "<a href=\"index.php?page=$previouspage\" title=上一页><font face=webdings >7</font></a> ";
      else echo "<font face=webdings >7</font>";
	  echo"[";
				$flag=0;
		if($page==2)
		echo"<a href=index.php?page=1>&nbsp;第". 1 . "页</a>";
		if($page>2){
			for($i=$page-2;$i<=$page-1;$i++){ 
 	        echo"<a href=index.php?page=$i>&nbsp;第". $i . "页</a>";
           }}
        if($page<$howmanypages){
			for($i=$page+1;$i<=$howmanypages;$i++){ 
 	        echo"<a href=index.php?page=$i>&nbsp;第". $i . "页</a>";
           $flag++;
		   if($flag==2) break; }}
	  echo"] ";
	if ($page<$howmanypages) echo "<a href=\"index.php?page=$nextpage\" title=下一页><font face=webdings >8</font></a> ";
      else echo "<font face=webdings >8</font>";
	if ($page<$howmanypages) echo "<a href=\"index.php?page=$howmanypages\" title=最后一页><font face=webdings >:</font></a> ";
      else echo "<font face=webdings >:</font>";
			?>
			</TD>
          <TD align=right bgColor=#90c8ff width="10%" background=img/skinbg.gif><A title=顶端 
            href="javascript:scroll(0,0)"><IMG height=15 
            src="img/gotop.gif" width=15 align=absMiddle 
            border=0><FONT 
  color=#0066CC>顶端</FONT></A></TD></TR></TABLE></TD></TABLE>
<BR>
 <?include("footer.inc")?>