<?php
# Subroutine: adm_log.php called by Admin.php
# Xinfeng Chen, 2002.11.26

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/class_log.php');

#--- Print log file list ---
page_header();

print <<<EOT
<h1>系统日志</h1>
<p>系统日志文件列表，查阅指定日志文件。</p>
<table class="forumline" align="center" width="100%">
<tr> 
 <th class="thHead">日志 ID</th>
 <th class="thHead">文件状态</th>
 <th class="thHead">最后修改时间</th>
 <th class="thHead">文件大小</th>
 <th class="thHead">&nbsp;</th>
</tr>
EOT;

#--- Generate info for each log file ---
$logs=CLOG::getLogFileGroup();
foreach($logs as $logid){
 if($logid){_printLogInfo($logid);}
}

print '</table>';

page_footer();
exit;

function _printLogInfo($logid){

 $fpath=CLOG::getLogFilePath($logid);
 if(file_exists($fpath)){
  $fstat='<font color=green>正常</font>';
  $fsize=filesize($fpath);
  $ftime=strftime("%Y-%m-%d.%H:%M:%S",filemtime($fpath));
 }else{
  $fstat='<font color=red>丢失</font>';
  $fsize='N/A';
  $ftime='N/A';
 }

 print <<<EOT
<tr>
 <td class="row1">$logid</td>
 <td class="row1">$fstat</td>
 <td class="row1">$ftime</td>
 <td class="row1">$fsize</td>
 <td class="row1"><a href="?cmd=log_view&logid=$logid">查阅</a></td>
</tr>
EOT;

}
?>