<? 
//-----------------------------------------------------------------------------
//    ID002同学录 单班级 (PHP & MySQL) 1.0 标准版
//-----------------------------------------------------------------------------
//    Copyright(C) aNErG, 2003. All rights reserved
//
//    技术支持 http://anerg.126.com
//-----------------------------------------------------------------------------
//    本软件对个人完全免费使用
//
//    如用于商业用途,您必须与我联系并支付RMB ￥20
//-----------------------------------------------------------------------------
if (empty($HTTP_COOKIE_VARS["class_username"])){echo "请先<a herf=index.php>登录</a>！";exit;}
include ('conn.php') ;
require('java.js');
if($mod==""){
$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 classuser";
$result=mysql_db_query("$dbname",$query);
$r=mysql_fetch_array($result);
$usernum=$r["count(*)"];

$query="select username,useremail,sex,userqq,usermsn,add_date from classuser";
$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="10" marginwidth="0" marginheight="0">
<table width="780" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#7597B0">
  <tr>
    <td align="center" valign="top">目前共有<? echo $usernum; ?>位成员<br>
      <table width="90%" border="1" cellspacing="0" cellpadding="0" bordercolor="#7597B0">
        <tr>
         <td align='center'>用户名</td>
         <td align='center'>E-mail</td>
         <td align='center'>B or G</td>
         <td align='center'>QQ</td>
         <td align='center'>MSN</td>
		 <td align='center'>加入时间</td>
        </tr>
	<? while($arr=mysql_fetch_array($result))
		{ 
		 $username=$arr["username"];
		 $useremail=$arr["useremail"];
		 $sex=$arr["sex"];
		 $userqq=$arr["userqq"];
		 $usermsn=$arr["usermsn"];
		 $add_date=$arr["add_date"];
    echo "<tr>" ;
	if($stat==1){
	echo "<td align='center'><a href='$PHP_SELF?mod=del_user&username=$username'><img src='images/del.gif' width='16' height='16' border='0'></a>";
	}
    echo "<a href=\"###\" onclick=\"Popup('listuser.php?name=$username','listuser',450,300);\">$username</a></td>";
    echo "<td align='center'><a href=mailto:$useremail>$useremail</a></td>";
	echo "<td align='center'>$sex</td>";
    echo "<td align='center'>$userqq</td>";
    echo "<td align='center'>$usermsn</td>";
    echo "<td align='center'>$add_date</td>";
	}echo "</tr>"; 
  ?>
      </table> 
      <br>
    </td>
  </tr>
</table>
<? }
if($mod==deluser){
$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;}
$username=$HTTP_POST_VARS["username"];
$query="delete from classuser where username='$username'";
$result=mysql_db_query("$dbname",$query);
if(mysql_affected_rows()==1)
  {
   echo"用户 $username 已删除!";
  } 
  
}
if($mod==del_user){ ?>
<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="<? echo"$PHP_SELF?mod=deluser"; ?>">
    <p>？确认删除？</p>
	  <input name="username" type="hidden" value="<? echo $username ?>">
      <input type="submit" name="Submit" value="删除">
    </p>
    </form>
</div>
<? } ?>

<?php require("bottom.php"); ?>