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

<?php
	if ($_REQUEST["delall"]=="yes") {
		$db=mysql_pconnect(get_cfg_var("SIPSERVER"),get_cfg_var("SIPUSER"),get_cfg_var("SIPPWD"));
		mysql_select_db(get_cfg_var("SIPDB"),$db);
		mysql_query( "delete from users",$db );
		mysql_query( "delete from history",$db );
		mysql_query( "delete from usertime",$db );
		mysql_query( "delete from addtimelist",$db );
		mysql_query( "delete from operation",$db );
		mysql_query( "delete from groups",$db );
		mysql_query( "delete from batchs",$db );
		mysql_query( "delete from batusers",$db );
		mysql_query( "delete from gpaddtimelist",$db );
		mysql_query( "delete from vips",$db );
		mysql_query( "delete from vipuser",$db );
		mysql_query( "delete from useracl1",$db );
		mysql_query( "delete from useracl2",$db );
		mysql_query( "delete from useracl3",$db );
		mysql_query( "delete from userband",$db );
		mysql_query( "delete from returnlist",$db );
		mysql_query( "delete from allowtimelist",$db );
		mysql_query( "delete from tmpusers",$db );
		mysql_close($db);
	}
	else {
	   	$strYear=trim($_REQUEST["year"]);
   		if ($strYear=="") {
			echo("必须输入年度！");
			exit;
	   	}
   		$timestr=$strYear."-";
		$db=mysql_pconnect(get_cfg_var("SIPSERVER"),get_cfg_var("SIPUSER"),get_cfg_var("SIPPWD"));
		mysql_select_db(get_cfg_var("SIPDB"),$db);
		mysql_query( "delete from users where createtime like '".$timestr."%'",$db );
		mysql_query( "delete from history where starttime like '".$timestr."%'",$db );
		mysql_query( "delete from usertime where starttime like '".$timestr."%'",$db );
		mysql_query( "delete from addtimelist where addtime like '".$timestr."%'",$db );
		mysql_query( "delete from operation where opertime like '".$timestr."%'",$db );
		mysql_query( "delete from groups where createtime like '".$timestr."%'",$db );
		mysql_query( "delete from batchs where createtime like '".$timestr."%'",$db );
		mysql_query( "delete from batusers where createtime like '".$timestr."%'",$db );
		mysql_query( "delete from gpaddtimelist where addtime like '".$timestr."%'",$db );
		mysql_query( "delete from returnlist where returntime like '".$timestr."%'",$db );
		mysql_close($db);
	}
?>

<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 echo $strYear; ?>年度历史数据已经成功清除！</b>
<p align="center">　</p>
<hr>

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

</body>

</html>
