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

<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>

<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 setmoney1()
{
    cancelBubble=true;
	var str=document.form1.price.value;
    var price=parseFloat(str);
    var buylength=document.form1.buylength.value;
    var money1=Math.round(price*parseInt(buylength,"10")*10)/10;
	document.all.money12.innerText=" "+money1.toString()+"元";
	document.form1.money.value=money1.toString();
}

function IsInt(obj)
{   
    var str=obj.value;
    var tmpstr=parseInt(str,"10");
    if (tmpstr!=str)
        return(false);
    else
       {
        obj.value=tmpstr;
        return(true);
       }
}

function checkData()
{
         obj=document.form1.onlines;
         cansub=IsInt(obj);
         if (cansub&&obj.value>=1)
         {
             obj=document.form1.buylength;
             cansub=IsInt(obj);
             if (cansub&&obj.value>=0)
             {
		document.form1.submit();
             }
             else
             {
                 alert("购买数量只能是整数且大于等于0");
                 document.form1.buylength.focus();
                 document.form1.buylength.select();
             } 
         }
         else
         {
             alert("允许同时在线人数只能是整数且大于等于1");
             document.form1.onlines.focus();
             document.form1.onlines.select();
         } 
}
</script>

</head>

<body id="myid1" background="bkg.bmp">

<p id="myid2" align="center"><font size="5"><b>自助注册用户确认生效</b></font></p>
<hr id="myid3" color="#999966">

<?php
	$loginname=trim($_REQUEST["loginname"]);
	if ($loginname=="") {
		$loginname=trim($_REQUEST["loginname"]);
	}
	if ($loginname!="") {
		$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 loginname,password,username,usertel,comment,type,tmpusers.price,length,money,name from tmpusers,types where tmpusers.type=types.typeid and loginname='".$loginname."'",$db);		//检查是否已有该用户ID
		if ($row = mysql_fetch_array($rs)) {
				echo("<div align='center'>");
				echo("<center>");
				echo("<form name=form1 method=POST action=activereg_result.php>");
				echo("<input type=hidden name=loginname value=".$row["loginname"].">");
				echo("<input type=hidden name=price value=".$row["price"].">");
				echo("  <table border=1 width=626 bordercolor=#008080 cellspacing=0 cellpadding=0>");
				echo("  <tr>");
				echo("     <td width=173 align=center height=46>用户ID</td>");
				echo("     <td width=439 align=left height=46>&nbsp;&nbsp;".$row["loginname"]."</td>");
				echo("  </tr>");
				echo("  <tr>");
				echo("     <td width=173 align=center height=46>用户密码</td>");
				echo("     <td width=439 align=left height=46>&nbsp;&nbsp;<input type=text name=password size=20 value=".$row["password"].">");
				echo("     </td>");
				echo("  </tr>");
				echo("  <tr>");
				echo("     <td width=173 align=center height=46>用户类型</td>");
				echo("     <td width=439 align=left height=46>&nbsp;&nbsp;".$row["name"]."</td>");
				echo("  </tr>");
				echo("  <tr>");
				echo("     <td width=173 align=center height=46>单价</td>");
				echo("     <td width=439 align=left height=46>&nbsp;&nbsp;".$row["price"]."元</td>");
				echo("  </tr>");
				echo("  <tr>");
				echo("     <td width=173 align=center height=56>用户组别</td>");
				echo("     <td width=439 align=left height=56>&nbsp;&nbsp;");
				echo("  	   <input type=text name=gpname value='' size=8 maxlength=50>&nbsp;&nbsp;");
				echo("  	   <select size=1 name=gp_name onclick='InputGP();'>");
		        $rs1 = mysql_query("select gpname from groups order by gpname",$db);
		       while ($row1 = mysql_fetch_array($rs1)) {
	    		   echo("<option value=".chr(34).$row1["gpname"].chr(34).">".$row1["gpname"]."</option>");
		       }
				mysql_free_result($rs1);
				echo("         </select>");
				echo("         <br><font size=2>&nbsp; &nbsp;新用户组请直接输入,为空为无组别<br>&nbsp;&nbsp; 已有的用户组请从右边的下拉菜单中选择</font>");
				echo("     </td>");
				echo("  </tr>");
				echo("  <tr>");
				echo("     <td width=173 align=center height=46>允许同时在线人数</td>");
				echo("     <td width=439 align=left height=46>&nbsp;&nbsp;");
				echo("  	   <input type=text name=onlines size=3 value=1>");
				echo("     </td>");
				echo("  </tr>");
				echo("  <tr>");
				echo("     <td width=173 align=center height=46>用户名称</td>");
				echo("     <td width=439 align=left height=46>&nbsp;&nbsp;");
				echo("  	   <input type=text name=username value='".$row["username"]."' size=20 maxlength=50>");
				echo("     </td>");
				echo("  </tr>");
				echo("  <tr>");
				echo("     <td width=173 align=center height=46>联系方式</td>");
				echo("     <td width=439 align=left height=46>&nbsp;&nbsp;");
				echo("         <input type=text name=usertel value='".$row["usertel"]."' size=20 maxlength=50> </td>");
				echo("  </tr>");
				echo("  <tr>");
				echo("     <td width=173 align=center height=46>备注说明</td>");
				echo("     <td width=439 align=left height=46>&nbsp;&nbsp;");
				echo("         <input type=text name=comment value='".$row["comment"]."' size=20 maxlength=100>");
				echo("     </td>");
				echo("  </tr>");
				echo("  <tr>");
				echo("     <td width=173 align=center height=46>使用IP地址</td>");
				echo("     <td width=439 align=left height=46>&nbsp;&nbsp;");
				echo("         <input type=text name=ipaddr size=15><br>&nbsp;&nbsp; 设置该IP后，用户只能使用具有该IP的客户机登录上网。不填则用户可以使用任意IP地址的客户机登录。");
				echo("     </td>");
				echo("  </tr>");
				echo("  <tr>");
				echo("     <td width=173 align=center height=46>使用MAC地址</td>");
				echo("     <td width=439 align=left height=46>&nbsp;&nbsp;");
				echo("         <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地址。");
				echo("     </td>");
				echo("  </tr>");
				echo("  <tr>");
				echo("     <td width=173 align=center height=46>购买数量</td>");
				echo("     <td width=439 align=left height=46>&nbsp;&nbsp;");
				echo("  	<input type=text name=buylength size=8 value=".strval($row["length"])." onkeyup='setmoney1();'>");
				echo("     </td>");
				echo("  </tr>");
				echo("  <tr>");
				echo("     <td width=173 align=center height=46>合计费用</td>");
				echo("     <td width=439 align=left height=46>&nbsp;&nbsp;");
				echo("         <span id=money12>".strval($row["money"])."元</span>");
				echo("         <input type=hidden name=money value=".strval($row["money"]).">");
				echo("     </td>");
				echo("  </tr>");
				echo("  <tr>");
				echo("     <td colspan=2 width=566 align=center height=57>");
				echo("         <input type=button value=确认生效 name=B1 onclick='checkData();'>");
				echo("     </td>");
				echo("  </tr>");
				echo("  </table>");
				echo("</form>");
				echo("</center>");
				echo("</div>");
		}
		else {
			echo("<p align=center>错误，该自助注册用户ID不存在！</p>");
		}
		mysql_free_result($rs);
		mysql_close($db);
	}
	else {
		echo("<p align=center>必须输入用户ID</p>");
	}
?>

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

</body>

</html>
