<?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">
<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
	$timestr=strftime("%Y-%m-%d %H:%M:%S");
	$userid = trim($_REQUEST["userid"]);
	$newtype = trim($_REQUEST["newtype"]);
	$newlines=trim($_REQUEST["onlines"]);
	if (userid!="" && newtype!="") {
		$n=intval($newlines);
		$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 userid='".$userid."' and checked='n'",$db);	//取该用户开号数据
		if ($row = mysql_fetch_array($rs)) {
			$oldtype=$row["type"];
			$oldlines=$row["onlines"];
			if (is_null($oldlines)) {
				$oldlines=1;
			}
			mysql_free_result($rs);
			if ($newtype!=$oldtype || $oldlines!=$n) {
				if ($newtype!=$oldtype && $oldlines!=$n) {
					mysql_query( "update users set type='".$newtype."',onlines=".$newlines." where userid='".$userid."'",$db );
					mysql_query( "update history set type='".$newtype."' where userid='".$userid."'",$db );		//更换旧的userid，以便和新的登录ID保持一致
					mysql_query( "insert into operation values('".$_SESSION["operator"]."','".$timestr."','更换计费类型。用户ID：".$userid."，原计费类型：".$oldtype."，新计费类型：".$newtype."')",$db );
					$timestr=strftime("%Y-%m-%d %H:%M:%S",time()+1);		//增加1秒，避免重复
					mysql_query( "insert into operation values('".$_SESSION["operator"]."','".$timestr."','更改同时在线人数。用户ID：".$userid."，原在线人数：".strval($oldlines)."，新在线人数：".$newlines."')",$db );
				} else {
					if ($newtype!=$oldtype) {
						mysql_query( "update users set type='".$newtype."' where userid='".$userid."'",$db );
						mysql_query( "update history set type='".$newtype."' where userid='".$userid."'",$db );		//更换旧的userid，以便和新的登录ID保持一致
						mysql_query( "insert into operation values('".$_SESSION["operator"]."','".$timestr."','更换计费类型。用户ID：".$userid."，原计费类型：".$oldtype."，新计费类型：".$newtype."')",$db );
					} else {
						mysql_query( "update users set onlines=".$newlines." where userid='".$userid."'",$db );
						mysql_query( "insert into operation values('".$_SESSION["operator"]."','".$timestr."','更改同时在线人数。用户ID：".$userid."，原在线人数：".strval($oldlines)."，新在线人数：".$newlines."')",$db );
					}
				}
				echo("该用户用户属性已经成功更改！");
			} else {
				echo("没有修改用户属性操作发生!");
			}
		} 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>
