<?php
include_once("inc/config.php");
include_once("inc/publicfun.php");
include_once("inc/ftbbsdbclass.php");
include_once("inc/pageclass.php");
include_once("conn.php");
include_once("ftbbs_nav.php");

$query = "SELECT * FROM {$tablepre}ftbbsmb";
$ftbbsmb=makecache('ftbbsmb.html',$query,$expire);
include_once("sound.php");
$pagesize=$ftbbsmb[5];
$defaulthome=$ftbbsmb[31];
include_once("homeurl.php");

$usertype=$_GET["usertype"];
if ($usertype==""||empty($usertype)){
   $usertype=1;
}

switch($usertype){
case 1:
    $strsql="select * from {$tablepre}ftbbs_online Order By ID desc";
	break;
case 2:
    $strsql="select * from {$tablepre}ftbbs_online where useradmin=2 Order By ID desc";
	break;
case 3:
    $strsql="select * from {$tablepre}ftbbs_online where useradmin=1 Order By ID desc";
	break;
}

$p = new ft_page;
$rs=mysql_query($strsql);
$myrow = mysql_fetch_array($rs);
$numrows = mysql_num_rows($rs);
//$numrows=$myrow[0];//记录总数
$p->pvar="page"; //设置页面传递的参数，默认为page
$p->setvar(array("usertype" => $usertype)); 
$p->set($pagesize,$numrows,$psize); 
$rs=mysql_query($strsql." limit ".$p->limit());
?>
<HTML><HEAD>
<title>在线用户列表</title>
<META http-equiv=Content-Type content=text/html;charset=utf-8>
<script language=javascript src="inc/cookies.js"></script>
<script>
var stylecook = getCookie("STYLESHOW");
var style;
var strstyle;
if(stylecook=="")
{
 stylecook=1;
}
else
{
 stylecook++;
}
style="main0"+stylecook+".css";
strstyle="<link href=\"css/"+style+"\"  rel=\"stylesheet\" type=\"text/css\"> ";
document.write(strstyle);
</script>
</HEAD>
</head>
<body>
<?
if (get_cookie('ftbbstype')==1){
include_once("pbhead.php");
}
?>
<table width="99%" border="0" cellspacing="0" cellpadding="0" align="center" class="maintbbg">
  <tr>
    <td> 
      <table width="100%" border=0 cellpadding=2 cellspacing=1 class="maintbbg">
        <tbody>
          <tr> 
            <td height="25" colspan="3" class="f12bg">&nbsp;<?=$userinfo?></td>
          </tr>
          <tr> 
            <td height="25" colspan="3" class="maintbtr3">&nbsp;<a href="<?=$homepage?>">论坛首页</a> 
              >> 在线人数</td>
          </tr>
          <tr> 
            <td height="26" class="maintbtr3"><div align="center"><a href="disonline.php?usertype=1">普通用户在线情况</a></div></td>
            <td class="maintbtr3"><div align="center"><a href="disonline.php?usertype=2">版主在线情况</a></div></td>
            <td class="maintbtr3"><div align="center"><a href="disonline.php?usertype=3">管理员在线情况</a></div></td>
          </tr>
        </tbody>
      </table>
      <table width="100%" border=0 cellpadding=2 cellspacing=1 class="maintbbg" align="center">
        <tbody>
          <tr align=middle class=f12> 
            <td width="16%" height="25" class="f12bg"><div align="center">用户名</div></td>
            <td width="26%" class="f12bg" ><div align="center">当前位置</div></td>
            <td width="17%" class="f12bg" ><div align="center">权限</div></td>
            <td width="20%" class="f12bg" ><div align="center">IP</div></td>
            <td width="21%" class="f12bg" ><div align="center">登陆时间</div></td>
          </tr>
<?
if ($numrows != 0){
   while ($myrow = mysql_fetch_array($rs)){
		$username=$myrow["useradmin"];
		$ip=$myrow["ip"];
	    $arr=explode(".",$ip);
		$ip=$arr[0].".".$arr[1].".".$arr[2].".*";
		if ($username==0){
            If ($username=="匿名"){
                $useradmin="游客";
				}
            else{
                $useradmin="注册用户";
            }
		}
		elseif ($username==1){
		   $useradmin="管理员";
		}
		elseif ($username==2){
		   $useradmin="版主";
		}
?>
          <tr align=middle> 
            <td width="16%" height="28" class="maintbtr1">
              <div align="center"><?=$myrow["username"]?></div></td>
            <td width="26%"  align=left valign="middle" class="maintbtr2"> <div align="center"><?=$myrow["stats"]?></div></td>
            <td width="17%" class="maintbtr1"><div align="center"><?=$useradmin?></div></td>
            <td width="20%" class="maintbtr3"> <div align="center"><?=$ip?></div></td>
            <td width="21%" class="maintbtr3"> <div align="center"><?=$myrow["logintime"]?></div></td>
          </tr>
<?
}
?>
          <tr valign="middle"> 
            <td height="20" colspan="6" class="maintbtr1">
               <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
                <tr> 
                  <td height="23" align="left" class="f12">
            <?
            $p->output(0);
			mysql_free_result($rs);
            $db->close(); 
            ?>
				  </td>
                </tr>
              </table>
			</td>
          </tr>
<?
}
else{
?>
          <tr class="maintbtr3"> 
            <td colspan=6 align=center height=28> 没有人在线</td>
          </tr>
<?}?>
        </tbody>
      </table>
    </td>
  </tr>
</table>
<?
include_once("inc/bbstail.php");
?>