<?php
	$acl=$_SESSION["acl"];
	if (strlen($acl)<1 || !strpos($acl,"<26>")) {	//没有权限
		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">
<?php
	$timestr=strftime("%Y-%m-%d %H:%M:%S");
	if ($_REQUEST["count"]!=""&&$_REQUEST["count"]!="0") {						//必须输入用户ID
		$db=mysql_pconnect(get_cfg_var("SIPSERVER"),get_cfg_var("SIPUSER"),get_cfg_var("SIPPWD"));
		mysql_select_db(get_cfg_var("SIPDB"),$db);
		$str="";
		$count=intval($_REQUEST["count"]);
		for ($n=1;$n<=$count;$n++) {
			$userid=$_REQUEST["deluser".strval($n)];
			if ($userid!="") {
				$rs = mysql_query( "select loginname from users where userid='".$userid."' and checked='y'",$db );
				if ($row = mysql_fetch_array($rs)) {
					$loginname=$row["loginname"];
					$str=$str.",".$loginname;
					mysql_free_result($rs);
					mysql_query( "delete from users where userid='".$userid."'",$db );
					mysql_query( "delete from history where userid='".$userid."'",$db );
					mysql_query( "delete from usertime where userid='".$userid."'",$db );
					mysql_query( "delete from addtimelist where userid='".$userid."'",$db );
					mysql_query( "delete from batusers where userid='".$userid."'",$db );
					mysql_query( "delete from vipuser where userid='".$userid."'",$db );
					mysql_query( "delete from useracl1 where userid='".$userid."'",$db );
					mysql_query( "delete from useracl2 where userid='".$userid."'",$db );
					mysql_query( "delete from useracl3 where userid='".$userid."'",$db );
					mysql_query( "delete from userband where loginname='".$loginname."'",$db );
					mysql_query( "delete from returnlist where userid='".$userid."'",$db );
					mysql_query( "delete from allowtimelist where userid='".$userid."'",$db );
				}
				else {
					mysql_free_result($rs);
				}
			}
		}
		mysql_query( "insert into operation values('".$_SESSION["operator"]."','".$timestr."','清除注销用户')",$db );
		if ($str!="") {
			$str=substr($str,1);
			echo("以下注销用户清除成功：".$str."！");
		}
		else {
			echo("清除成功！");
		}
		mysql_close($db);
	}
	else {
		echo("必须输入需要清除的注销用户ID");
	}
?>
</p>
<hr>
<p align="center">SIP企业上网管理系统</p>
<p align="center">作者：<b>深圳市飞沃软件有限公司</b></p>

</body>

</html>
