<? 
//-----------------------------------------------------------------------------
//    ID002同学录 单班级 (PHP & MySQL) 1.0 标准版
//-----------------------------------------------------------------------------
//    Copyright(C) aNErG, 2003. All rights reserved
//
//    技术支持 http://anerg.126.com
//-----------------------------------------------------------------------------
//    本软件对个人完全免费使用
//
//    如用于商业用途,您必须与我联系并支付RMB ￥20
//-----------------------------------------------------------------------------

include ('conn.php') ;
require('java.js');
if ($HTTP_COOKIE_VARS["class_username"]){
$classuser=$HTTP_COOKIE_VARS["class_username"];
$query="select stat from classuser where username='$classuser'";
$result=mysql_db_query("$dbname",$query);
$r=mysql_fetch_array($result);
$stat=$r["stat"];
$query="select count(*) from classmsg";
$result=mysql_db_query("$dbname",$query);
$arr=mysql_fetch_array($result);
$num=$arr["count(*)"];
if (($num/8)-intval($num/8)==0){$num2=$num/8;}
else{
$num2=intval($num/8)+1;}

if(!empty($page)){$offset=($page=$HTTP_POST_VARS["page"]-1)*8;}
elseif(empty($offset)){
$offset=0;}

$query="SELECT classmsgid,classmsg,author,msgtime FROM classmsg ORDER BY classmsgid DESC LIMIT $offset,8";
$result=mysql_db_query("$dbname",$query);

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>留言内容</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  
    <?php 
	$query="SELECT count(*) FROM u2u where u2uto='$classuser'";
	$u2uresult=mysql_db_query("$dbname",$query);
	$arr=mysql_fetch_array($u2uresult);
    $u2unum=$arr["count(*)"];
	if($u2unum!=0){
	echo"<p><a href=\"###\" onclick=\"Popup('showu2u.php','u2u',430,200);\">您有 $u2unum 条新消息，请点此查看<a><p>";
	}
	while($r=mysql_fetch_array($result))
      {
	  $classmsg=$r["classmsg"];
       $author=$r["author"];
       $msgtime=$r["msgtime"];
	   $classmsgid=$r["classmsgid"];
	     echo"<tr>";
	echo "<td>";
	if($stat==1){
	 echo "<a href=\"###\" onclick=\"Popup('edit.php?mod=admindel&classmsgid=$classmsgid','del',200,100);\">";
	            }
	echo "⊙";
	echo "</a>";
	echo"&nbsp;&nbsp;&nbsp;&nbsp;$classmsg";
	echo"</td>";
	echo"</tr>";
	echo"<tr>";
	echo"<td><div align='right'>";
	echo"<a href=\"###\" onclick=\"Popup('sendu2u.php?u2u_to=$author','send',400,200);\">----</a><a href=\"###\" onclick=\"Popup('listuser.php?name=$author','listuser',450,300);\">$author</a> &nbsp;&nbsp;&nbsp;($msgtime)&nbsp;&nbsp;";
	if($HTTP_COOKIE_VARS["class_username"]==$author){
	echo"<a href=\"###\" onclick=\"Popup('edit.php?classmsgid=$classmsgid','edit',550,350);\"><img src='images/edit.gif' width='16' height='16' border='0'></a>&nbsp;&nbsp;&nbsp;&nbsp;";
	echo"<a href=\"###\" onclick=\"Popup('edit.php?mod=del&classmsgid=$classmsgid','del',300,200);\"><img src='images/del.gif' width='16' height='16' border='0'></a>";
	}
	echo "<br>";
	echo "<div align='center'>";
	echo "<hr align='RIGHT' width='80%' size='1'>";
	echo "</div>";
	echo"</td>";	
    echo"</tr>";
	echo"<tr>";
    echo"<td>&nbsp;</td>";
	echo"</tr>";

}?>
</table>
	<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
	<?php echo"<td><div align='right'>";
	echo"共有".$num2."页留言&nbsp;&nbsp;&nbsp;&nbsp;";
	if($offset!=0){
	$page_up=$offset-8;
	echo"<a href=$PHP_SELF?offset=$page_up>上一页</a>";
	}
	if($offset+8<$num){
	$page_next=$offset+8;
	echo"<a href=$PHP_SELF?offset=$page_next>下一页</a>";
	}?>
</div></td><tr><td><div align='right'>
	<form name="form1" method="post" action="<? $PHP_SELF; ?>">
  转到第 
  <input name="page" type="text" value="<? echo ++$page; ?>" size="3">
  页&nbsp;
  <input type="submit" name="Submit" value="确定">
</form>
	</div></td>
	</tr>
	</table>
<?php }
else{echo "请先<a herf=index.php>登录</a>！";exit;}
?>