<?php

/* 在线列表 */
/* 162100源码 - 162100.com - download.162100.com */

$title = '在线';

@ require ('inc/set/set.php');
@ require ('inc/set/set_sql.php');
@ require ('inc/set/set_userface.php');
@ require ('inc/function/confirm_power.php');
@ require ('inc/function/get_page.php');
@ require ('inc/function/get_date.php');

//身份验证
define('POWER', confirm_power());
$userface = user_class(POWER, $session[3]);

if (@ $_GET['act'] == 'member') {
  //会员数
  $where_eval = ' WHERE memberye>0';
  $list_title = '"<a href=\"list_online.php\">在线记录</a><a class=\"list_title_in\">".$search_r."在线成员<span>（".$n."）</span></a><a href=\"?act=guest\">在线访客</a>"';
} elseif (@ $_GET['act'] == 'guest') {
  //访客数
  $where_eval = ' WHERE memberye="0"';
  $list_title = '"<a href=\"list_online.php\">在线记录</a><a href=\"?act=member\">在线成员</a><a class=\"list_title_in\">".$search_r."在线访客<span>（".$n."）</span></a>"';

} else {
  $where_eval = '';
  $list_title = '"<a class=\"list_title_in\">".$search_r."在线记录<span>（".$n."）</span></a><a href=\"?act=member\">在线成员</a><a href=\"?act=guest\">在线访客</a>"';
}

@ $_GET['username'] = trim($_GET['username']);

if ($_GET['username']) {
  $_GET['username'] = trim($_GET['username']);
  $_GET['username'] = str_replace('.', '&#46;', $_GET['username']);
  if (preg_match('/^([^\x00-\x7f]|\w|&#46;|\.){3,45}$/', $_GET['username'])) {
    $eval = ($where_eval != '' ? $where_eval.' AND' : ' WHERE').' username LIKE "%'.str_replace('_', '/_', $_GET['username']).'%" escape "/"';
    $search_r = '搜索结果 - ';
  } else {
    $eval = $where_eval;
    $search_r = '<span class="redword">用户名不合法</span> | ';
  }
} else {
  $eval = $where_eval;
}


$n = $mess = 0;
$text = $user_pic = '';

if (!isset($sql['db_err'])) {
  db_conn();
}
if ($sql['db_err'] != '') {
  die($sql['db_err']);
}

$sql['sql_version'] = @mysql_get_server_info();


@ require ('inc/function/add_online.php'); //在线
//总数
$result = mysql_query('SELECT COUNT(id) AS total FROM '.$sql['pref'].''.$sql['data']['承载在线统计的表名'].''.$eval.'',$db);
$row = @mysql_fetch_assoc($result);
$n = abs($row['total']);
@mysql_free_result($result);
unset($row);

if ($n > 0) { //总记录数
  $p = get_page($n); //页数
  $seek = $web['pagesize'] * ($p-1);
  $result = mysql_query('SELECT * FROM '.$sql['pref'].''.$sql['data']['承载在线统计的表名'].''.$eval.' ORDER BY memberye DESC,utime DESC LIMIT '.$seek.','.$web['pagesize'].'', $db);
  $text .= '
<div class="list_title_">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <th>用户名</th>
        <th width="450">位置</th>
        <th width="168">最后活动时间</th>
      </tr>
    </table>
  </div>
    '.(isset($sql['sql_version']) && $sql['sql_version'] < '5.0' ? '<div class="red_err">服务器数据库版本（'.$sql['sql_version'].'）太低！数据可能显示不正常。本程序建设基于MySQL版本5.0以上</div>' : '');

  while ($row = @mysql_fetch_assoc($result)) {
    if ($row['memberye'] >= 1) {
      $user_pic = '<td class="list_mode_logo"><span class="iface_s"><a href="user.php?get=card&username='.urlencode($row['username']).'" target="_blank"><img src="obj.php?title=face-'.urlencode($row['username']).'.'.$web['img_up_format'].'" width="'.$web['img_w_s'].'" height="'.$web['img_h_s'].'" /></span></td>';
      //if ($row['username'] == $web['manager']) { //如果是基础管理员
        //continue;
        //$username = 'admin';
      //} else {
        $username = '<a class="li_a" href="user.php?get=card&username='.urlencode($row['username']).'" target="_blank" title="点击查看发布人名片">'.$row['username'].'</a> '.$row['userface'].'';
      //}
    } else {
      $username = $row['username'];
    }

    $hurl = trim($row['position'], '/');
    if($hurl == ''){
      $hurl = $web['sitehttp'];
      $row['title'] = '首页';
    }
    $text .= '
  <div class="li">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    '.$user_pic.'
    <td style="text-align:left;"><b>'.$username.'</b></div></td>
    <td width="450" style="text-align:left;"><a href="'.$hurl.'" target="_blank">'.$hurl.'</a><div class="li_" style="text-align:left">'.$row['title'].'</div></td>
    <td width="168" style="text-align:center;">'.get_date_c($row['utime']).'</td>
  </tr>
</table>
  </div>
';
    unset($row, $user_pic);
  }
  @mysql_free_result($result);

} else {
  $text = '<div class="text_err">暂无记录！</div>';
}

if (POWER >= 1) {
  $result = @mysql_query('SELECT mess_num FROM `'.$sql['pref'].''.$sql['data']['承载成员档案的表名'].'` WHERE username="'.$session[0].'" LIMIT 1', $db); //短信
  $row_member = @mysql_fetch_assoc($result);
  $mess = '<span class="area_statistics">'.preg_replace('/^\d+/', '<span>$0</span>', $row_member['mess_num']).'</span>';
  @mysql_free_result($result);
  unset($row_member);
}


@mysql_close();


?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $title; ?> - <?php echo $web['sitename2'], $web['code_author']; ?></title>
<link id="my_style" rel="stylesheet" type="text/css" href="inc/css/<?php echo $web['sitemode']; ?>/style.css">
<script language="javascript" src="inc/js/main.js" type="text/javascript"></script>
</head>
<body>
<div id="session" class="session">
<button type="button" onclick="window.open('write.php?mode=<?php echo $web['sitemode']; ?>','_blank');" title="发布文章"><b><div class="send_write"></div></b></button>
  <?php @ include ('inc/require/head.txt'); ?> &nbsp;
</div>
<?php
if ($web['siteclose'] > 1) {
  @include ('inc/require/siteclose_why.txt');
}
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" id="logo">
  <tr>
    <td width="200"><a href="<?php echo $web['path']; ?>"><img src="<?php echo $web['sitelogo']; ?>" /></a></td>
    <td align="right"><form id="searchform" action="?" method="get" title="当前在线状态搜索" onsubmit="return $('keyword').value!=''||false;"><input name="username" id="keyword"  class="large" type="text" /><input type="submit" name="submit" id="submit" class="search_member search_member_online" value="" />
      <input name="act" type="hidden" value="<?php echo $_GET['act']; ?>" />
      
    </form></td>
  </tr>
</table>
<div id="banner"> <a href="./">首页</a> <a href="list_company.php">商号</a> <a href="list_member.php">成员</a> <a class="column_is">在线</a> <a href="help.php">帮助</a>
  <?php @include ('inc/css/'.$web['sitemode'].'/banner.txt'); ?>
</div>
<div class="column">
  <h5><a href="./">首页</a> &gt; 在线</h5>
</div>
<div class="body">
  <div class="list_title"> <?php echo eval('return '.$list_title.';'); ?> </div>
  <div class="body_in"> <?php echo $text; ?>
<?php
echo @ get_page_foot($n, $web['pagesize'], $p, '?username='.$_GET['username'].'&act='.$_GET['act'].'&p=');
?> </div>
</div>
<div id="foot">
  <?php @include ('inc/css/'.$web['sitemode'].'/foot.txt'); ?>
</div>
<script language="JavaScript" type="text/javascript">
<!--
try{$('new_mess').innerHTML='<?php echo $mess; ?>';}catch(err){}
-->
</script>

</body>
</html>