<?php
	$acl=$_SESSION["acl"];
	if (strlen($acl)<1 || !strpos($acl,"<23>")) {	//没有权限
		ob_clean();
		header("Location: accesserror.html");
		exit;
	}
?>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>添加用户组成员</title>
<base target="_self">

<body background="bkg.bmp" style="background-attachment: fixed; background-position-y:130;">
<p align="center"><font size="3"><b>添加用户组成员</b></font></p>
<center>
<?php
$gpid=$_REQUEST["gpid"];
if ($gpid=="") {
   $gpid=$_REQUEST["gpid"];
}
$loginname=trim($_REQUEST["loginname"]);
$ispostback=$_REQUEST["ispostback"];
if ($ispostback=="y") {
   if ($loginname!="" && $gpid!="") {
 	  $timestr=strftime("%Y-%m-%d %H:%M:%S");
      $db=mysql_pconnect(get_cfg_var("SIPSERVER"),get_cfg_var("SIPUSER"),get_cfg_var("SIPPWD"));
      mysql_select_db(get_cfg_var("SIPDB"),$db);
      $rs=mysql_query("select userid from users where loginname='".$loginname."' and checked='n'",$db);
      if ($row = mysql_fetch_array($rs)) {
         $userid=$row["userid"];
         mysql_query("update users set gpid=".$gpid." where userid='".$userid."'",$db);
         mysql_query( "insert into operation values('".$_SESSION["operator"]."','".$timestr."','添加组别成员,组号：".$gpid.",用户ID：".$userid."')",$db );
         echo("添加成功");
	  }
      else {
         echo("无效ID");
      }
      mysql_free_result($rs);
      mysql_close($db);
   }
   else {
      echo("输入的信息不全");
   }
}
?>
<form method="POST" action="usertogp.php" target="_self">
<table border="1" bordercolor="#008080" cellspacing="0" cellpadding="0" width="266">
   <tr>
      <td align="center" width="65">
      用户ID
      </td>
      <td align="left" width="195">&nbsp;
      <input type="text" name="loginname" size="10">
      </td>
   </tr>
   <tr>
      <td align="center" width="262" colspan="2">
      <input type="hidden" name="gpid" value="<?php echo $gpid; ?>">
      <input type="hidden" name="ispostback" value="y">
      <input type="submit" name="b1" value="确认">
      </td>
   </tr>
</table>
</form>
<a href="nogpuser.php?gpid=<?php echo $gpid; ?>">查询所有无组别用户</a>
</center>
</body>

</html>
