<?php
// Author: Sting_Band
// URL: http://www.bluish.jp/

require( '../../mainfile.php' );
require( 'header.php' );
require_once( BLUESBB_ROOT.'/include/btickets.php' );
$topic = isset($_GET['top']) ? intval($_GET['top']) : 0;
$style = isset($_GET['sty']) ? intval($_GET['sty']) : 0;
if (empty($topic) || empty($style)) {
	redirect_header(BLUESBB_URL.'/', 2, _MD_ERRORTOPIC);
	exit();
}
$sql = "SELECT topic_access, topic_group, allow_sig FROM ".$xoopsDB->prefix('bluesbb_topic')." WHERE topic_id = ".$topic;
if ( !$result = $xoopsDB->query($sql) ) {
	redirect_header(BLUESBB_URL.'/',3,"Error!! ".basename(__FILE__)." Line ".__LINE__);
	exit();
}
if ( !$topicdata = $xoopsDB->fetchArray($result) ) {
	redirect_header(BLUESBB_URL.'/', 2, _MD_ERROREXIST);
	exit();
}
$accesserror = 1;
if ( $topicdata['topic_access'] == "1" ) {
	$accesserror = 0;
}elseif ( $topicdata['topic_access'] == "2" || $topicdata['topic_access'] == "3" ) {
	if (is_object($xoopsUser)) {
		$accesserror = 0;
	}
}elseif ( $topicdata['topic_access'] == "4" || $topicdata['topic_access'] == "5" ) {
	if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid()) ) {
		$accesserror = 0;
	}
}elseif ( $topicdata['topic_access'] == "6" ) {
	if (is_object($xoopsUser)) {
		$groups =& $member_handler->getGroupsByUser($xoopsUser->getVar('uid'),true);
		foreach ($groups as $group){
			if (preg_match ("/\b".$topicdata['topic_group']."\b/", $group->getVar('groupid'))) {
				$accesserror = 0;
			}
		}
		if ( $xoopsUser->isAdmin($xoopsModule->mid()) ) {
			$accesserror = 0;
		}
	}
}
if ( $accesserror == 1 ) {
	redirect_header(BLUESBB_URL.'/',2,_MD_TOPICACCESSERROR2);
	exit();
}
$myts =& MyTextSanitizer::getInstance();
include XOOPS_ROOT_PATH.'/header.php';
$mode='0';
if(isset($_COOKIE['xoops_bluesbb'])){
	$coo = explode ( ",", $_COOKIE['xoops_bluesbb'] );
	$name = $myts->htmlSpecialChars($coo[0]);
	$mail = $myts->htmlSpecialChars($coo[1]);
	$url = $myts->htmlSpecialChars($coo[2]);
	$pass = $myts->htmlSpecialChars($coo[3]);
}else{
	$name = "";
	$mail = "";
	$url = "http://";
	$pass = "";
}
$title = "";
$message = "";
$hidden = "";
$post_id = "";
$thread = "";
$res_id = "";
$allow_sig = $topicdata['allow_sig'];
include( BLUESBB_ROOT.'/include/bbbform.inc.php' );
include( XOOPS_ROOT_PATH.'/footer.php' );
?>