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


<?php
		$timestr=strftime("%Y-%m-%d %H:%M:%S");
		$operator=$_REQUEST["operator"];
		if ($operator=="") {
			echo("必须输入操作员ID！");
			exit;
		}
		$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 opername from operators where operator='".$operator."'",$db);
		if ($row = mysql_fetch_array($rs)) {
			mysql_free_result($rs);
			mysql_close($db);
			echo("已经存在此操作员ID，不能重复！");
			exit;
		}
		mysql_free_result($rs);
		$opername=trim($_REQUEST["opername"]);
		$password=trim($_REQUEST["password"]);
		$acl="";
		$rs = mysql_query("select appcode from module order by appcode",$db);
		while ($row = mysql_fetch_array($rs)) {
			if ($_REQUEST["var".$row["appcode"]]=="on") {
				$acl=$acl."1";
			}
			else {
				$acl=$acl."0";
			}
		}
		mysql_free_result($rs);
		mysql_query( "insert into operators values('".$operator."','".$opername."','".$password."','".$acl."')",$db );
		mysql_query( "insert into operation values('".$_SESSION["operator"]."','".$timestr."','新增操作员：".$operator."')",$db );
?>

<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>操作响应</title>
</head>

<body background="../bkg.bmp">

<p align="center"><font size="5"><b>操作响应</b></font></p>
<hr color="#999966">
<form>
  <p align="center">
  成功添加操作员！
  </p>
  <p align="center">
  &nbsp;   
  <select size="10" name="operator">
<?php
		$rs = mysql_query("select operator,opername from operators",$db);
		while ($row = mysql_fetch_array($rs)) {
	           echo("<option value=".chr(34).$row["operator"].chr(34).">".$row["operator"]."->".$row["opername"]."</option>");
		}
		mysql_free_result($rs);
		mysql_close($db);
?>
  </select>
  </p>
</form>

<hr>
<p align="center">SIP企业上网管理系统</p>
  <p align="center">作者：<b>深圳市飞沃软件有限公司</b></p>

</body>

</html>
