<?php
 /*********************************************************      
 程序说明：         
    功能说明：操作员列表
              
    调用关系：调用: header.inc,connectdb_billing.inc     
              被调用:       
 
    变量说明：
    作者：崔体存    2005-11-14      
      
修改注释：      
NO.1      
姓名：            
时间：      
修改说明：      
*********************************************************/
require("../../inc/header.inc");
$confUser=$_REQUEST['confUser'];
?>
<body leftmargin="15" rightmargin="10" onload="javascript:adjust_frame('up');" onresize="javascript:adjust_frame('up');" style="background-color:#FFFAF4;overflow:hidden;overflow-x:hidden;overflow-y:hidden;">
<?php
adjust_head();
adjust_title_head();
$DEBUG	= 0; 
echo "<table  id=\"table_up\" border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"100%\" align=\"center\">";
echo "<font size=4 color=blue><b>$strOnlineSysUser</b></font>";
echo "</td>";
echo "</tr>";
echo "</table>";
adjust_title_tail();
adjust_content_head();
$userInfo = $_SESSION['userInfo'];
if($DEBUG)
	{
	  echo "userInfo[privilege] = $userInfo[privilege]<br>";
	  echo "userInfo[ID] = $userInfo[ID]<br>";
    }
 $table_name = 'sysOnlineUser'; 
 $table_name_alluser = 'sysUser';
 $sort_field = 'userName,login_time'; 
 $sort_direction = 'ASC'; 
 $number_records_to_display = 210; 




//超时自动登出
if(!isset($userInfo)) $userInfo = $_SESSION['userInfo'];
$sessionName=$userInfo['ID'];
$outime_table='sysUser';
$timeSql="
        SELECT timeOut
        FROM $outime_table
        WHERE userName='$sessionName'
          ";

if($DEBUG) echo "timesql=$timeSql,userName=$sessionName";
$timeResult = mysqli_query($pubConn,$timeSql);
$timeRow= mysqli_fetch_array($timeResult);
echo mysqli_error($pubConn);
$outTime =$timeRow['timeOut'];
//echo $outTime;
if(!$outTime) {
    $outTime=600;
    ?> <script type="text/JavaScript">
        var outtimeNull=<?php  echo $outTimeInfo?> //由于没有设置空闲超时时间,默认为10分钟
            alert(outtimeNull);
    </script>
    <?php
}
if(isset($_SESSION['expiretime'])) {
    if($_SESSION['expiretime'] < time()) {
        unset($_SESSION['expiretime']);
	echo "<script> var Timeout='$Timeout';alert(Timeout);
		
	window.top.location = \"../../security/login/login.php\";
	</script>";

        // echo retJson(401,'登录过期，请重新登录','');
    } else {
        $_SESSION['expiretime'] = time() + $outTime; // 刷新时间戳
    }
}else{
    $_SESSION['expiretime'] = time() + $outTime; // 5小时后过期
}
//end








 if (!$initial_record)
	 { 
       $initial_record = 0; 
       $str_sql_all ="SELECT  count(*) as number_of_records	FROM $table_name ";
       $result = @mysqli_query($pubConn,$str_sql_all); 
       $record = @mysqli_fetch_object($result); 
       $number_of_records = $record->number_of_records; 
     } 
 
  if ($number_of_records >= 1) 
	  {  
       //下面是控制分页显示，传递变量  
       $next_index = $initial_record + $number_records_to_display;  //本页的结束数目  
       if ($next_index > $number_of_records)
		   {  
               $next_index = $number_of_records;  
           }  
       $t1 = $initial_record + 1;  
       $prev_index = $initial_record - $number_records_to_display;  
       if ($prev_index < 0) 
		   {  
               $prev_index = 0;  
           }   
      }  
  $due_time=date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")-20,date("m"),date("d"),date("Y")));
  $str_sql="SELECT * 
            FROM $table_name WHERE refresh_time > '$due_time'
	        ORDER BY $sort_field $sort_direction 
            LIMIT $initial_record, $number_records_to_display"; 
	
 // echo "<br>str_sql=$str_sql";
  $result = mysqli_query($pubConn,$str_sql); 
  $myrows = @mysqli_fetch_array($result); 
  if(!$myrows)
	  {
	    echo "$strNotFindRecord";
	    exit();
      }    
?>

  <form method="POST" name=confForm>
   <table border="0" width="100%"  cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF">
   <tr>
   <td colspan="2" align="center">
   <!--统计在线操作员的数量-->
   <?php       
   echo "$strDisplayRecords:<FONT color=#0000ff>&nbsp;$initial_record - $next_index</FONT>, ($strTotalRecords:<font color=#0000ff> $number_of_records</font> ) &nbsp;&nbsp;";
   ?>
    </td>
  </tr>
  </table> 

  <!-- <table border="1" width="100%"  cellpadding="2" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF"  height="189"  bgcolor="#faf0e6">  
    -->
    <table class="formCenter">
      <tr bgcolor="#E6E6E6"> 
      <td align="center"><?php echo $strAccountName; ?></td> 
      <td align="center"><?php echo "IP"; ?></td> 
      <td align="center"><?php echo $strLoginTime; ?></td>
     </tr>  
<?php 
//echo "confUser=$confUser<br>";

do{	
	echo "<tr>";
	echo "<td align=\"center\">$myrows[username]</td>";
	echo "<td align=\"center\">$myrows[ip]</td>";
	echo "<td align=\"center\">$myrows[login_time]</td>";	
	$str_sql_alluser="SELECT privilege FROM $table_name_alluser WHERE userName='$myrows[username]'";
	$result_pri = mysqli_query($pubConn,$str_sql_alluser);
	$myrows_pri = @mysqli_fetch_array($result_pri);
	//echo "$str_sql_alluser<br>";
	//echo "user prive = $myrows_pri[privilege]";
/*	if ( ($myrows_pri['privilege']<$userInfo['privilege']) && ($myrows['userName'] != $userInfo['ID']) )
	{
		echo "<td align=\"center\"><a href=\"./onlineUserlist.php?confMode=del&userName=$myrows[username]\">$strForceOff</td>";
	}
	else
	{
		echo "<td>&nbsp;</td>";
	}*/
	echo "</tr>";	
  }while($myrows=@mysqli_fetch_array($result)); 
 
?>   
</table>   
<?php
adjust_content_tail();
?>    
</body> 
</html>  
