<?php
# Subroutine: adm_board_submit.php called by Admin.php
# Xinfeng Chen, 2002.11.22
# Input: $f_bid,$f_name,$f_secret,$f_owner,$f_owner1,$f_owner2,
#  $f_o_mail,$f_o_url,$f_htmlt,$f_htmlb,$f_desc;

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_board.php');
require_once('core/class_user.php');

#--- Check input data ---
if(($f_name == "")||($f_o_mail == "")||($f_owner == "")){
 msgBox("显示标题　名字　信箱　必要填写，请重新输入！",mCRITICAL);
 exit;
}
if(strlen($f_name) > 30){
 msgBox("标题不能大于30个字符！",mCRITICAL);
 exit;
}
if(strlen($f_desc) > 400){
 msgBox("简介不能大于200个汉字！",mCRITICAL);
 exit;
}
if(!preg_match("/.*\@.*\..*/",$f_o_mail)){
 msgBox("Email输入错误！",mCRITICAL);
 exit;
}
if($f_o_url == "http://"){$f_o_url="";}

#--- Validate owners ---
$oUsr=new CUser;

if(!$oUsr->load($f_owner)){
 msgBox("请先注册版主的用户名，再来申请论坛",mCRITICAL);
 exit;
}else{
 $f_owner=$oUsr->name;
}
if($f_owner1 && !$oUsr->load($f_owner1)){
 msgBox("请先注册版主的用户名，再来申请论坛",mCRITICAL);
 exit;
}else{
 if($f_owner1){$f_owner1=$oUsr->name;}
}
if($f_owner2 && !$oUsr->load($f_owner2)){
 msgBox("请先注册版主的用户名，再来申请论坛",mCRITICAL);
 exit;
}else{
 if($f_owner2){$f_owner2=$oUsr->name;}
}

#--- Prepare board info ---
$oBrd=new CBoard;
if(!$oBrd->load($f_bid)){
 msgBox("论坛ID错误！",mCRITICAL);
 exit;
}

$oBrd->name=$f_name;
$oBrd->secret=$f_secret;
$oBrd->owner=$f_owner;
$oBrd->o_mail=$f_o_mail;
$oBrd->o_url=$f_o_url;
$oBrd->owner1=$f_owner1;
$oBrd->owner2=$f_owner2;
$oBrd->desc=cleanHtml($f_desc);
$oBrd->htmlt=cleanText($f_htmlt);
$oBrd->htmlb=cleanText($f_htmlb);

#--- Store board info ---
$oBrd->store($f_bid);

#--- Destroy permission file ---
if(!$f_secret){
 $oMemo=new CBaseMemoFile;
 $fpath=CForumBase::getFilePath('PERMISSION',$f_bid);
 $oMemo->destroyFile($fpath);
}

#--- Display result ---
msgBox("论坛(ID=$f_bid)<BR> 信息更新成功！",mINFORMATION,
 '操作成功','?cmd=board','返回论坛列表');

?>