<?php
# Subroutine: adm_user.php called by Admin.php
# Xinfeng Chen, 2002.11.18
# Input: $page

require_once('bin/config.php');
require_once('admin/adm.inc');

#--- Validate dministrator ---
include('admin/adm_validate.php');
if(!$adm_validated){jumpTo('admin.php?cmd=logon'); exit;}

#--- Start Processing ---
require_once('core/class_forum_base.php');
CForumBase::setFileBase("$filepath");
require_once('core/base_memo_file.php');
require_once('core/class_note.php');

$userpath=CForumBase::getDirPath('USER');

page_header();

print <<<EOT
<H1>注册用户管理</H1>
<p>在此可以浏览用户列表、查询用户详细信息、删除用户账号。</p>
<TABLE width="90%" align="center" class="forumline">
<tr>
 <th>用户名</th>
 <th>最后更新时间</th>
 <th>编辑</th>
 <th>删除</th>
</tr>
EOT;

if($page<=0){$page=1;}
$nUser=0; $nStart=20*($page-1); $nEnd=$nStart+20;

$dir=opendir($userpath);
while (($file=readdir($dir)) != false && $nUser < $nEnd){
 if(substr($file,-4)=='.dat'){
  $nUser++; if($nUser <= $nStart){continue;}

  $uname=substr(basename($file),0,-4);
  $udate=strftime("%Y-%m-%d %H:%M:%S",filemtime("$userpath/$file"));
  print <<<EOT
<tr>
 <td class="row1">$uname</td>
 <td class="row2">$udate</td>
 <td class="row1" align=center><a href=?cmd=user_form&user=$uname>编辑</a></td>
 <td class="row2" align=center><a href=?cmd=user_delete>删除</a></td>
</tr>
EOT;
 }
}
closedir($dir);

print "</TABLE>";

#--- print page navigator ---
print "<TABLE width='90%' align='center'><TR><TD align='right'>";

for($i=1; $i<$page; $i++){
 print "[<a href='?cmd=user&page=$i'>$i</a>] ";
}
print "[$page] ";
$page++;
if($nUser>=$nEnd){print "[<a href='?cmd=user&page=$page'>后页</a>] ";}

print "</TD></TR></TABLE>";

page_footer();

#--- update user statistic ---
$oNote=new CNote;
$oNote->load();
if($nUser > $oNote->numuser){
 $oNote->numuser=$nUser;
 $oNote->store();
}

?>