<?php

$pg_d = 20;

$pg_c = A < 1 ? 1 : A;
$pg_s = $pg_d * ($pg_c - 1);
$s = $_GET['s'];
$e = $_GET['e'];
$skey = $_GET['skey'];
$teamid = $_GET['teamid'] <> '' ? intval($_GET['teamid']) : '';
$arr = array();
$where = array();
/**
 * 关键字查询
 */
if (!empty($skey))
{
    $where[] = 'name like \'%' . addslashes($skey) . '%\'';
}
if ($teamid !== '')
{
    $where[] = 'team=' . $teamid;
}
if (!empty($s) or !empty($e))
{
    if (empty($s))
    {
        $s = date('Y-m-d', TIME);
    }
    if (empty($e))
    {
        $e = date('Y-m-d', TIME);
    }
    $stime = strtotime($s);
    $etime = strtotime($e) + 24 * 3600;
    $where[] = 'reg_time>=\'' . $stime . '\' && reg_time<\'' . $etime . '\'';
}
$where[] = '1=1';
$wherestr = implode(' && ', $where);
$result = $db->query("select * from " . PF . "user where $wherestr order by reg_time desc LIMIT $pg_s,$pg_d");
while ($row = $db->fetch_array($result))
{
    $id = $row['id'];
    $arr[$id]['name'] = htmlspecialchars($row['name']);
    $arr[$id]['reg_time'] = showtime($row['reg_time']);
    $arr[$id]['sex'] = $row['sex'] ? '女' : '男';
    $arr[$id]['team'] = htmlmlang($conf['sys_teams'][$row['team']]['name'], 'system');
    $arr[$id]['email'] = htmlspecialchars($row['email']);
    $arr[$id]['posts'] = $row['posts'];
}
$rs = $db->query('select count(*) as pg_m from ' . PF . 'user where ' . $wherestr);
$row2 = $db->fetch_array($rs);
$page = page(RPGMA . '(*)/', $pg_c, $row2['pg_m'], $pg_d);
arg($arr, $page, htmlspecialchars($s), htmlspecialchars($e), htmlspecialchars($skey),
    $row2['pg_m'], $teamid);
apply('head', '
<script type="text/javascript" src="' . ROOTPATH .
    'includes/datepicker/date.js"></script> 
<script type="text/javascript" src="' . ROOTPATH .
    'includes/datepicker/jquery.datePicker.min-2.1.2.js"></script>     
<script type="text/javascript">
$(function()
{
	$(\'#datepicker1\').datePicker({startDate:\'2010-04-01\'});
	$(\'#datepicker2\').datePicker({startDate:\'2010-04-01\'});
});
</script>
');

?>