<?php
	$acl=$_SESSION["acl"];
	if (strlen($acl)<1 || !strpos($acl,"<0025>")) {	//没有权限
		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
	$loginname = trim($_REQUEST["loginname"]);
	$acttype = trim($_REQUEST["acttype"]);
	$prepay = trim($_REQUEST["prepay"]);
	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,suspendtime from users where loginname='".$loginname."' and checked='n'",$db);	//取该用户开号数据
		if ($row = mysql_fetch_array($rs)) {
			$userid=$row["userid"];
			$suspendtime=$row["suspendtime"];
			mysql_free_result($rs);
			if (is_null($suspendtime)) {
				$suspendtime="";
			}
			$timestr=strftime("%Y-%m-%d %H:%M:%S");
			if ($acttype=="suspend") {
				if ($suspendtime=="") {
					mysql_query("update users set suspendtime='".$timestr."' where userid='".$userid."'",$db);
					mysql_query( "insert into operation values('".$_SESSION["operator"]."','".$timestr."','暂停上网。用户ID：".$userid."')",$db );
					echo("成功暂停用户".$loginname."上网！");
				}
				else {
					echo("用户".$loginname."已经被暂停上网，不需要重复操作！");
				}
			}
			else {
				if ($suspendtime=="") {
					echo("用户".$loginname."没有被暂停上网，不需要恢复上网！");
				}
				else {
					mysql_query("update users set suspendtime='',prepay=prepay+".$prepay." where userid='".$userid."'",$db);
					mysql_query( "insert into operation values('".$_SESSION["operator"]."','".$timestr."','恢复上网。用户ID：".$userid."')",$db );
					$m=intval($prepay);
					if ($m>0) {
						mysql_query( "insert into cash values('".$userid."','".$timestr."',".$prepay.",'1','".$_SESSION["operator"]."')",$db );
					}
					echo("成功恢复用户".$loginname."上网！");
					if ($m>0) {
						echo("<br><br>需要收取押金".$prepay."元！");
					}
				}
			}
		} 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>
