/* 1st page & separate topic form add-on */
//config options
if(!isset($firstPageTopicForm)) $firstPageTopicForm=1; // 1 - to enable 1st page topic form, 0 - to disable
$separateTopic=1; // 1 - to enable separate topic form on the topics page, 0 - to disable
//eof config options

if(!isset($_POST['prevForm']) and $firstPageTopicForm==1 and $action=='' and $page==PAGE1_OFFSET+1){
if(file_exists($pathToFiles.'addon_smilies.php')) {
if(!defined('NEW_TOPIC_FORM')) define('NEW_TOPIC_FORM', 1);
include ($pathToFiles.'addon_smilies.php');
}
}

if(isset($loginError) and $loginError==1){}
else{
if($action=='' and $page>PAGE1_OFFSET+1) $firstPageTopicForm=0;
if(($action==''&&$firstPageTopicForm==1)||(($action=='vtopic'||$action=='ptopic')&&((isset($_POST['showSep'])&&$_POST['showSep']==1)||(isset($_GET['showSep'])&&$_GET['showSep']==1)))){

$forumEx=array();

$_GET['showSep']=1; $mTop=1; $st=0; $frm=$forum;
include($pathToFiles.'bb_func_forums.php');

function checkMod($userId,$forumId){
if(!isset($GLOBALS['mods'][$forumId])) return false;
else{
if(!in_array($userId, $GLOBALS['mods'][$forumId])) return false;
else return true;
}
}

if($user_id!=1){
if(isset($roForums) and sizeof($roForums)>0) foreach($roForums as $r) { if($user_id==0 or !checkMod($user_id, $r)) { if(!in_array($r, $forumEx)) $forumEx[]=$r; } }
if(isset($poForums) and sizeof($poForums)>0) foreach($poForums as $r) { if($user_id==0 or !checkMod($user_id, $r)) { if(!in_array($r, $forumEx)) $forumEx[]=$r; } }
$closedForums=getAccess($clForums, $clForumsUsers, $user_id);
if($closedForums!='n') foreach($closedForums as $r) if(!in_array($r, $forumEx)) $forumEx[]=$r;
}

if(isset($forumEx) and sizeof($forumEx)>0){
$loc=array();
foreach($forumEx as $f) $loc[]='#<option (.*)value="'.$f.'">(.*)</option>#iU';
$listForums2=preg_replace("#<optgroup(.+?)>#is", '', $listForums);
$listForums2=str_replace('</optgroup>', '', $listForums2);

$listForums2=preg_replace($loc, '', $listForums2);
}
else $listForums2=$listForums;

if($forum==0){
preg_match('#<option(([ ]+)selected="selected")?([ ]+)value="([0-9]+)">(.*?)</option>#is',$listForums,$matches);
if(!isset($matches[3])||$matches[3]<1) preg_match('#<option([ ]+)?(selected="selected")?([ ]+)value="([0-9]+)">(.*?)</option>#is',$listForums,$matches);
$forum=(isset($matches[4])&&$matches[4]>0)?$matches[4]:0;
}

unset($listForums);
if($action=='vtopic') {
if(isset($_POST['postText'])) $postText=operate_string($_POST['postText']);
if(isset($_POST['topicTitle'])) $topicpTitle=operate_string($_POST['topicTitle']);
}

}
//separate topic form
if($separateTopic==1&&$action=='vtopic'&&(!isset($_GET['showSep'])&&!isset($_POST['showSep']))) $_GET['showSep']=2;
}
/*-- 1st page & separate topic form add-on */