<?php
# Subroutine: adm_board.php called by Admin.php
# Xinfeng Chen, 2002.11.19

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_array_file.php');
require_once('core/class_board_list.php');
require_once('core/base_memo_file.php');
require_once('core/class_board.php');
require_once('core/base_record_file.php');
require_once('core/class_topic_list.php');
require_once('core/base_index_file.php');
require_once('core/class_topic_index.php');

page_header();

print <<<EOT
<h1>注册论坛管理</h1>
<p>检查与重建论坛注索引文件。论坛属性修改、论坛数据文件检查与修复。</p>
<table class="forumline" align="center" width="100%">
  <tr> 
    <th colspan="4" class="thHead">论坛主索引文件</th>
  </tr>
EOT;

#--- Generate info of board list data file ---
$blistpath=CForumBase::getFilePath('BLIST');
$blname=basename($blistpath);
$oBrdLst=new CBoardList;
if($oBrdLst->load()){
 $blsize=$oBrdLst->itemcount();
 $blstat='正常';
}else{
 $blsize='N/A';
 $blstat='丢失或损坏';
}

print <<<EOT
  <tr> 
    <td class="row2">文件名: $blname</td>
    <td class="row1">信息: 包含 $blsize 个论坛信息</td>
    <td class="row1">状态: $blstat</td>
    <td class="row1"><a href=?cmd=blist_resync>重建</a></td>
  </tr>
</table>
EOT;

print <<<EOT
<br>
<table class="forumline" align="center" width="100%">
  <tr> 
    <th colspan="6" class="thHead">论坛列表</th>
  </tr>
  <tr> 
    <th class="thHead">论坛ID</th>
    <th class="thHead">名称/描述</th>
    <th class="thHead">数据文件状态</th>
    <th class="thHead">&nbsp;</th>
    <th class="thHead">&nbsp;</th>
  </tr>
EOT;

#--- Generate info for each board ---
if($blsize=='N/A'){$blsize=0;}
for($ii=0; $ii<$blsize; $ii++){
 $oBrdLst->moveTo($ii);
 _printBoardInfo($oBrdLst->id);
}

print '</table>';

page_footer();
exit;

function _printBoardInfo($bid){

 $oBrd=new CBoard;
 if($oBrd->load($bid)){
  $bname=$oBrd->name;
  $bdesc=$oBrd->desc;
  $bstat='[<font color=green>信息</font>]';
 }else{
  $bname=$bdesc='N/A';
  $bstat='[<font color=red>信息</font>]';
 }

 $oTpcLst=new CTopicList;
 $bcstat=$oTpcLst->open($bid) ?
  '[<font color=green>列表</font>]' : '[<font color=red>列表</font>]';
 $oTpcLst->close();

 $oTpcIdx=new CTopicIndex;
 $bistat=$oTpcIdx->open($bid) ? 
  '[<font color=green>索引</font>]' : '[<font color=red>索引</font>]';
 $oTpcIdx->close();

 print <<<EOT
<tr>
 <td class="row1">$bid</td>
 <td class="row1"><b>$bname</b><br>$bdesc</td>
 <td class="row1" width=105>$bstat$bcstat$bistat</td>
 <td class="row1" width=30><a href="?cmd=board_form&bid=$bid">编辑</a></td>
 <td class="row1" width=45><a href="?cmd=board_reindex&bid=$bid">重索引</a></td>
</tr>
EOT;

}
?>