<? 
//-----------------------------------------------------------------------------
//    ID002同学录 单班级 (PHP & MySQL) 1.0 标准版
//-----------------------------------------------------------------------------
//    Copyright(C) aNErG, 2003. All rights reserved
//
//    技术支持 http://anerg.126.com
//-----------------------------------------------------------------------------
//    本软件对个人完全免费使用
//
//    如用于商业用途,您必须与我联系并支付RMB ￥20
//-----------------------------------------------------------------------------
include ('conn.php');
require('function.php');?>
<? if($mod==""){ ?>
<? if (!$HTTP_COOKIE_VARS["class_username"]){
echo "请先<a herf=index.php>登录</a>！";exit;}
$query="select classmsg,author from classmsg where classmsgid='$classmsgid'";
$result=mysql_db_query("$dbname",$query);
$r=mysql_fetch_array($result);
$classmsg=$r["classmsg"];
$author=$r["author"];
?><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>编辑留言</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>


<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td><form name="form1" method="post" action="edit.php?mod=post">
        <p> 
          <textarea name="classmsg" cols="60" rows="15" id="classmsg"><? echo checkinfo_show($classmsg); ?></textarea>
        </p>
        <p align="center"> 
		<input name="classmsgid" type="hidden" value="<? echo $classmsgid; ?>">
          <input type="submit" name="Submit" value="改好了">
        
          
        </p>
      </form></td>
  </tr>
</table>
<?php require("bottom.php"); ?>
<? }
if($mod==post){
$msgtime=date("y-m-j H:i:U");
$classmsg=$HTTP_POST_VARS["classmsg"];
$classmsg=checkinfo($classmsg);
$classmsgid=$HTTP_POST_VARS["classmsgid"];
$query="update classmsg set classmsg='$classmsg',msgtime='$msgtime' where classmsgid='$classmsgid'";
$result=mysql_db_query("$dbname",$query);

if($result==1)
  {
   echo"留言成功更改!";
   echo"<br>刷新首页才能看到更新后的内容！";
   ?>
   <head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>修改留言</title>
<meta http-equiv=Refresh content="2; url=javascript:window.close()">
<link href="css.css" rel="stylesheet" type="text/css">
</head>
 <?  
} 
else {echo"更新不成功，出错了！";}
?>

<? } if($mod==del){?>
<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="10" marginwidth="0" marginheight="0">
<div align="center">
  <form name="form1" method="post" action="edit.php?mod=delmsg">
    <p>？确认删除？</p>
    <p>USER: 
      <input name="username" type="text" value="<? echo $HTTP_COOKIE_VARS["class_username"] ?>" size="12">
    </p>
    <p>PASS: 
      <input name="userpwd" type="password" size="12">
      <br>
	  <input name="classmsgid" type="hidden" value="<? echo $classmsgid ?>">
      <input type="submit" name="Submit" value="删除">
    </p>
    </form>
</div>
<? } if($mod==delmsg){?>
<? include ('conn.php') ;
$checkusername=$HTTP_POST_VARS["username"];
$checkuserpwd=$HTTP_POST_VARS["userpwd"];
$checkuserpwd=encrypt($checkuserpwd);
$classmsgid=$HTTP_POST_VARS["classmsgid"];
$query="select userpwd from classuser where username='$checkusername'";
$result=mysql_db_query("$dbname",$query);
if(!empty($result)){
$r=mysql_fetch_array($result);
$userpwd=$r["userpwd"];
if($checkuserpwd==$userpwd){
$query="delete from classmsg where classmsgid='$classmsgid'";
$result=mysql_db_query("$dbname",$query);
if(mysql_affected_rows()==1)
  {
   echo"留言已删除!";
   ?>
   <head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>删除留言</title>
<meta http-equiv=Refresh content="2; url=javascript:window.close()">
<link href="css.css" rel="stylesheet" type="text/css">
</head>
 <?  
} 
else {echo"删除不成功，出错了！";}
?>
<? }else{echo"密码错误，请核实你的密码！";}
}else{echo"没有这个用户！";}
?>
<? } if($mod==admindel){
$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"];
if($stat!=1){
echo "你不是管理员！";exit;}
?>
<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="10" marginwidth="0" marginheight="0">
<div align="center">
  <form name="form1" method="post" action="edit.php?mod=admindelmsg">
    <p>？确认删除？</p>
	  <input name="classmsgid" type="hidden" value="<? echo $classmsgid ?>">
      <input type="submit" name="Submit" value="删除">
    </p>
    </form>
</div>
<? } ?>
<? if($mod==admindelmsg){
$classmsgid=$HTTP_POST_VARS["classmsgid"];
$query="delete from classmsg where classmsgid='$classmsgid'";
$result=mysql_db_query("$dbname",$query);
if(mysql_affected_rows()==1)
  {
   echo"留言已删除!";
   ?>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>删除留言</title>
<meta http-equiv=Refresh content="2; url=javascript:window.close()">
<link href="css.css" rel="stylesheet" type="text/css">
 <?  
} 
else {echo"删除不成功，出错了！";}?>

<? } ?>
