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

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="jscript">
function setresult()
{
   parent.gp.location.href="querygp.php";
   parent.gpinfo1.location.href="gpdetail.php?gpid="+document.form1.gpid.value.toString();
}
</script>
<title>修改用户组响应</title>
<body background="bkg.bmp" onload="setresult();" style="background-attachment: fixed; background-position-y:130;">
<p align="center"><font size="3"><b>修改用户组响应</b></font></p>
<center>
<?php
$gpid=$_REQUEST["gpid"];
$gpname=trim($_REQUEST["gpname"]);
$comment=trim($_REQUEST["comment"]);
if (gpname<>"" and 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 gpname,comment from groups where gpid=".$gpid,$db);
   if ($row = mysql_fetch_array($rs)) {
      $oldgpname=$row["gpname"];
      $oldcomment=$row["comment"];
      mysql_free_result($rs);
      if ($gpname!=$oldgpname || $comment!=$oldcomment) {
         mysql_query("update groups set gpname='".$gpname."',comment='".$comment."' where gpid=".$gpid,$db);
         echo("修改成功");
         mysql_query( "insert into operation values('".$_SESSION["operator"]."','".$timestr."','修改用户组，组号：".$gpid.",组名：".$gpname."')",$db );
	  }
      else {
         echo("没有改变不用修改");
      }
   }
   else {
      mysql_free_result($rs);
      echo("要修改的组不存在");
   }
   mysql_close($db);
}
else {
   echo("提供的修改信息不全");
}
?>
<form name="form1" method="get" action="revisegp3.php">
<input type="hidden" name="gpid" value="<?php echo $gpid; ?>">
</form>
</center>

</body>

</html>
