<?php

/*
	[SupeSite/X-Space] (C)2001-2006 Comsenz Inc.
	½×¾Âª©¶ô¦Cªí­¶­±

	$RCSfile: forumdisplay.php,v $
	$Revision: 1.16 $
	$Date: 2006/10/31 04:58:44 $
*/

if(!defined('IN_SUPESITE')) {
	exit('Access Denied');
}

$fid = intval($_SGET['fid']);
if($fid) {
	dbconnect();
	$query = $_SGLOBAL['db']->query("SELECT f.*, ff.* FROM ".tname('forums', 1)." f LEFT JOIN ".tname('forumfields', 1)." ff ON ff.fid=f.fid WHERE f.fid='$fid'");
	$forum = $_SGLOBAL['db']->fetch_array($query);
}
if(empty($forum)) messagebox('error', 'not_found', S_URL);

$forumurl = B_URL.'/forumdisplay.php?fid='.$fid;
$jumptobbs = false;
if($forum['status'] != 1) {
	$jumptobbs = true;
} elseif(!empty($forum['password'])) {
	$jumptobbs = true;
} elseif(!empty($forum['viewperm'])) {
	$viewpermarr = explode("\t", $forum['viewperm']);
	if(!in_array('7', $viewpermarr)) {
		$jumptobbs = true;
	}
} elseif(!empty($forum['redirect'])) {
	$forumurl = $forum['redirect'];
	$jumptobbs = true;
}
if(B_VER == '5') {
	if(empty($forum['allowshare'])) $jumptobbs = true;
} elseif (B_VER == '4') {
	if(empty($forum['allowblog'])) $jumptobbs = true;
}
if($jumptobbs) {
	header('location: '.$forumurl);
	exit;
}

if(!empty($_SCONFIG['htmlcategory'])) {
	$_SHTML['action'] = 'forumdisplay';
	$_SHTML['fid'] = $forum['fid'];
	if(!empty($_SGET['page'])) $_SHTML['page'] = intval($_SGET['page']);
	$_SGLOBAL['htmlfile'] = gethtmlfile($_SHTML);
	ehtml('get', $_SCONFIG['htmlcategorytime']);
	$_SCONFIG['debug'] = 0;
}

include_once(S_ROOT.'./include/common.inc.php');

@include_once(S_ROOT.'./data/system/bbsforums.cache.php');
if(!empty($_SGLOBAL['bbsforumarr']) && !empty($_SGLOBAL['bbsforumarr'][$forum['fid']]['name'])) {
	$forum['name'] = $_SGLOBAL['bbsforumarr'][$forum['fid']]['name'];
}

$title = $forum['name'].'_'.$lang['bbs'].'_'.$_SCONFIG['sitename'];
$keywords = $forum['name'].','.$lang['bbs'];
$description = $forum['name'].','.$lang['bbs'];

$guidearr = array();
$guidearr[] = array('url' => geturl('action/bbs'),'name' => $lang['bbs']);
$guidearr[] = array('url' => geturl('action/forumdisplay/fid/'.$forum['fid']),'name' => $forum['name']);

$tplname = 'bbs_forumdisplay';

include template($tplname);

if(!empty($_SCONFIG['htmlcategory'])) {
	ehtml('make');
} else {
	maketplblocknames($tplname);
	maketplblockvalue('cache');
}

?>