<?php
	$acl=$_SESSION["acl"];
	if (strlen($acl)<1 || !strpos($acl,"<0021>")) {	//没有权限
		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">

<SCRIPT LANGUAGE="javascript">
function checkvalid()
{
	if ( isNaN( parseInt(document.form1.onlines.value) ) ) {
		document.form1.onlines.value="1";
	}
	if ( parseInt(document.form1.onlines.value)<1 ) {
		document.form1.onlines.value="1";
	}
	return true;
}
</SCRIPT>

<title>更改用户属性</title>
</head>

<body background="bkg.bmp">

<p align="center"><font size="5"><b>更改用户属性</b></font></p>
<hr color="#999966">


<p align="center">
<b>
<?php
	$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 userid,type,onlines from users where loginname='".$loginname."' and checked='n'",$db);	//取该用户开号数据
		if ($row = mysql_fetch_array($rs)) {
			$userid=$row["userid"];
			$usertype=$row["type"];
			$onlines=$row["onlines"];
			mysql_free_result($rs);
			if (is_null($onlines)) {
				$onlines=1;
			}
			$rs = mysql_query("select ipaddr from login where userid='".$userid."'",$db);
			if (($row = mysql_fetch_array($rs))==FALSE) {			//该用户ID没有在线，才能更改属性
				mysql_free_result($rs);
				echo("<form name=form1 method=POST action=changetype_result2.php onsubmit=".chr(34)."return checkvalid();".chr(34).">");
				echo("  <input type=hidden name=userid value=".$userid.">");
				echo("  <input type=hidden name=oldtype value=".$usertype.">");
				echo("  <input type=hidden name=oldlines value=".strval($onlines).">");
				echo("  <div align=center>");
				echo("    <center>");
				echo("    <table border=1 cellpadding=0 cellspacing=0 bordercolor=#008080 width=423 height=138>");
				echo("      <tr>");
				echo("        <td width=200 height=30>");
				echo("          <p align=center>用户ID</td>");
				echo("        <td width=217 height=30>");
				echo("          <p align=center>".$loginname."</td>");
				echo("      </tr>");
				echo("      <tr>");
				echo("        <td width=200 height=33>");
				echo("          <p align=center>计费类型</td>");
				echo("        <td width=217 height=33>");
				echo("          <p align=center>");
				echo("          <select size=1 name=newtype>");
				$rs = mysql_query("select name,orderid from types order by orderid",$db);		//读取结帐类型列表
   				while ($row = mysql_fetch_array($rs)) {
   	    	    	if ($row["name"]==$usertype) {
					   echo("<option selected value=".chr(34).$row["name"].chr(34).">".$row["name"]."</option>");
    	    		} else {
			       		echo("<option value=".chr(34).$row["name"].chr(34).">".$row["name"]."</option>");
				    }
    		    }
				mysql_free_result($rs);
				echo("          </select>");
				echo("          </td>");
				echo("      </tr>");
				echo("      <tr>");
				echo("        <td width=200 height=30>");
				echo("          <p align=center>同时在线使用人数</td>");
				echo("        <td width=217 height=30>");
				echo("          <p align=center><input type=text name=onlines size=2 value=".strval($onlines)."></td>");
				echo("      </tr>");
				echo("      <tr>");
				echo("        <td colspan=2 align=center width=419 height=37><input type=submit value=提交 name=B1></td>");
				echo("      </tr>");
				echo("    </table>");
				echo("    </center>");
				echo("  </div>");
				echo("</form>");
			} else {
				mysql_free_result($rs);
				echo("该用户ID正在上网，不能更改其属性!必须先停止上网，才能更改！");
			}
		} else {
			mysql_free_result($rs);
			echo("找不到该用户ID!");
		}
		mysql_close($db);
	} else {
		echo("必须输入需要更改用户属性的用户ID！");
	}
?>
</b></p>


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

</body>

</html>
