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

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>
<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>
</tr>
EOT;

#--- Print log file info & content ---
if($logid){_printLogInfo($logid);}

print '</table>';

page_footer();
exit;

function _printLogInfo($logid){

 $fpath=CLOG::getLogFilePath($logid);
 if(file_exists($fpath)){
  $fstat='正常';
  $fsize=filesize($fpath);
  $ftime=strftime("%Y-%m-%d.%H:%M:%S",filemtime($fpath));
 }else{
  $fstat='丢失';
  $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>
</tr>
EOT;

 print "<tr><td class='row1' colspan=4><textarea readonly cols=90 rows=25>";
 readfile($fpath);
 print "</textarea></td></tr>";

}
?>