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

<?php
	$defaultid="U".strval(time()-strtotime("2005-01-01 01:01:01"));
	$defaultword="";
	for ($i=1;$i<=10;$i++) {				//生成10位随机密码字符串，密码全部是数字
		$defaultword=$defaultword.chr(rand(48,57));
	}
?>

<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">
<script language="javascript">
function InputGP()
{
    cancelBubble=true;
    var n=document.form1.gp_name.selectedIndex;
    if (n>=0) {
	    document.form1.gpname.value=document.form1.gp_name.options(n).text;
    }
}
function InputDP()
{
    cancelBubble=true;
    var n=document.form1.dp_name.selectedIndex;
    if (n>=0) {
	    document.form1.userdept.value=document.form1.dp_name.options(n).text;
    }
}
</script>
<title>注册用户</title>
</head>

<body background="bkg.bmp">

<p align="center"><font size="5"><b>注册用户</b></font></p>
<hr color="#999966">
<div align="center">
<center>
<form method="POST" name="form1" action="adduser_result.php">
<table border="1" width="626" bordercolor="#008080" cellspacing="0" cellpadding="0">
<tr>
   <td width="173" align="center" height="46">用户ID</td>
   <td width="439" align="left" height="46">&nbsp;&nbsp;   
	   <input type="text" name="loginname" size="20" maxlength="20" value="<?php echo $defaultid; ?>">
   </td>
</tr>
<tr>
   <td width="173" align="center" height="46">用户密码</td>
   <td width="439" align="left" height="46">&nbsp;&nbsp; <input type="text" name="password" size="20" value="<?php echo $defaultword; ?>">   
   </td>
</tr>
<tr>
   <td width="173" align="center" height="56">用户组别</td>
   <td width="439" align="left" height="56">&nbsp;&nbsp;   
	   <input type="text" name="gpname" size="8" value="" maxlength="50">&nbsp;&nbsp;   
	   <select size="1" name="gp_name" onclick="InputGP();">
<?php
		$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 from groups order by gpname",$db);
        while ($row = mysql_fetch_array($rs)) {
	        echo("<option value=".chr(34).$row["gpname"].chr(34).">".$row["gpname"]."</option>");
        }
		mysql_free_result($rs);
?>
       </select>
       <br><font size="2">&nbsp; &nbsp;新用户组请直接输入,为空为无组别<br>&nbsp;&nbsp;   
    已有的用户组请从右边的下拉菜单中选择</font>
   </td>
</tr>
<tr>
   <td width="173" align="center" height="46">用户名称</td>
   <td width="439" align="left" height="46">&nbsp;&nbsp;   
	   <input type="text" name="username" size="20" maxlength="50">
   </td>
</tr>
<tr>
   <td width="173" align="center" height="46">联系方式</td>
   <td width="439" align="left" height="46">&nbsp;&nbsp;   
       <input type="text" name="usertel" size="20" maxlength="50"> </td>
</tr>
<tr>
   <td width="173" align="center" height="56">用户部门</td>
   <td width="439" align="left" height="56">&nbsp;&nbsp;   
	   <input type="text" name="userdept" size="20" value="" maxlength="50">&nbsp;&nbsp;   
	   <select size="1" name="dp_name" onclick="InputDP();">
<?php
        $rs = mysql_query("select distinct userdept from users where userdept!=''",$db);
        while ($row = mysql_fetch_array($rs)) {
           echo("<option value=".chr(34).$row["userdept"].chr(34).">".$row["userdept"]."</option>");
        }
		mysql_free_result($rs);
		mysql_close($db);
?>
       </select>
       <br><font size="2">&nbsp; &nbsp;新部门请直接输入,为空为无部门<br>&nbsp;&nbsp;   
    已有的部门请从右边的下拉菜单中选择</font>
   </td>
</tr>
<tr>
   <td width="173" align="center" height="46">备注说明</td>
   <td width="439" align="left" height="46">&nbsp;&nbsp;   
       <input type="text" name="comment" size="20" maxlength="100">
   </td>
</tr>
<tr>
   <td width="173" align="center" height="46">使用IP地址</td>
   <td width="439" align="left" height="46">&nbsp;&nbsp;   
       <input type="text" name="ipaddr" size="15"><br>&nbsp;&nbsp; 设置该IP后，用户只能使用具有该IP的客户机登录上网。不填则用户可以使用任意IP地址的客户机登录。   
   </td>
</tr>
<tr>
   <td width="173" align="center" height="46">使用MAC地址</td>
   <td width="439" align="left" height="46">&nbsp;&nbsp;    
       <input type="text" name="mac" size="20">(格式：xx-xx-xx-xx-xx-xx)<br>&nbsp;&nbsp; 
    设置该MAC后，用户只能使用具有该MAC地址的客户机登录上网。不填则用户可以使用任意MAC地址的客户机登录。MAC地址格式必须为：xx-xx-xx-xx-xx-xx，否则客户机不能上网。例如，12-4f-6a-08-2d-e0为有效MAC地址，12-4f-6a-8-2d-e0则为无效MAC地址。   
   </td>
</tr>
<tr>
   <td width="173" align="center" height="46">每月时间限制</td>
   <td width="439" align="left" height="46">&nbsp;&nbsp;   
	<input type="text" name="timelength" size="8" value="">小时（空或零则为不限制）
   </td>
</tr>
<tr>
   <td width="173" align="center" height="46">每月流量限制</td>
   <td width="439" align="left" height="46">&nbsp;&nbsp;  
       <input type="text" name="datalength" size="8" value="">M（空或零则为不限制） 
   </td>
</tr>
<tr>
   <td width="173" align="center" height="46">每天时间限制</td>
   <td width="439" align="left" height="46">&nbsp;&nbsp;   
	<input type="text" name="daytime" size="8" value="">小时（空或零则为不限制）
   </td>
</tr>
<tr>
   <td width="173" align="center" height="46">每天流量限制</td>
   <td width="439" align="left" height="46">&nbsp;&nbsp;  
       <input type="text" name="daydata" size="8" value="">M（空或零则为不限制） 
   </td>
</tr>
<tr>
   <td colspan="2" width="566" align="center" height="57">
       <input type="submit" value="提交" name="B1">
   </td>
</tr>
</table>
</form>
</center>
</div>
<hr>
<p align="center">SIP企业上网管理系统</p>
<p align="center">作者：<b>深圳市飞沃软件有限公司</b></p>

</body>

</html>
