<?php
	$acl=$_SESSION["acl"];
	if (strlen($acl)<1 || !strpos($acl,"<0005>")) {	//没有权限
		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
		$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 loginname from users where checked='n' order by length(loginname),loginname",$db);
		if ($row = mysql_fetch_array($rs)) {			//有记录
			echo("<table border='1' bordercolor='#808080' cellspacing='0' cellpadding='0'>");
			echo("<tr><td align=center>当前所有开通客人概况表</td></tr>");
			$str="";
			$lastname="";
			$tmpname="";
			$ordertype=1;
			while ($row) {
				if ($lastname=="") {			//第一行
					$lastname=trim($row["loginname"]);
					$str=$lastname;
				} else {
					$tmpname=trim($row["loginname"]);
					if (strlen($tmpname)!=strlen($lastname)) {		//不同的楼层，需要换行
						echo("<tr>");
						echo("<td>".$str."</td>");
						echo("</tr>");
						$lastname=$tmpname;
						$str=$lastname;
					} else {
						if (strlen($lastname)<=2) {				//不同的楼层，需要换行
							echo("<tr>");
							echo("<td>".$str."</td>");
							echo("</tr>");
							$lastname=$tmpname;
							$str=$lastname;
						} elseif (strlen($lastname)==3) {			//第一位视作楼层
							if (substr($lastname,0,1)==substr($tmpname,0,1)) {
								$str=$str.",".$tmpname;
								$lastname=$tmpname;
							} else {
								echo("<tr>");
								echo("<td>".$str."</td>");
								echo("</tr>");
								$lastname=$tmpname;
								$str=$lastname;
							}
						} elseif (strlen($lastname)==4) {			//前2位视作楼层
							if (substr($lastname,0,2)==substr($tmpname,0,2)) {
								$str=$str.",".$tmpname;
								$lastname=$tmpname;
							} else {
								echo("<tr>");
								echo("<td>".$str."</td>");
								echo("</tr>");
								$lastname=$tmpname;
								$str=$lastname;
							}
						} else {									//前3位视作楼层
							if (substr($lastname,0,3)==substr($tmpname,0,3)) {
								$str=$str.",".$tmpname;
								$lastname=$tmpname;
							} else {
								echo("<tr>");
								echo("<td>".$str."</td>");
								echo("</tr>");
								$lastname=$tmpname;
								$str=$lastname;
							}
						}
					}
				}
				$row = mysql_fetch_array($rs);
			}
			if ($str!="") {
				echo("<tr>");
				echo("<td>".$str."</td>");
				echo("</tr>");
			}
			echo("</table><br>");
		} else {
			echo("暂时还没有开通上网客人！");
		}
		mysql_free_result($rs);
		mysql_close($db);
?>
</p>

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

</body>

</html>
