<?php
!function_exists('readover') && exit('Forbidden');

require_once(R_P.'require/forum.php');
$forumname = strip_tags($forum[$fid]['name']);
$foruminfo = $db->get_one("SELECT f.*,fe.forumset,fd.topic FROM pw_forums f LEFT JOIN pw_forumsextra fe ON fe.fid=f.fid LEFT JOIN pw_forumdata fd ON fd.fid=f.fid WHERE f.fid=".pwEscape($fid));
!$foruminfo && Showmsg('data_error');
if ($foruminfo['type'] == 'category') {
	header("Location: index.php");exit;
}
wind_forumcheck($foruminfo);

$forumset  = unserialize($foruminfo['forumset']);

if ($groupid != 3 && !$foruminfo['allowvisit'] && !admincheck($foruminfo['forumadmin'],$foruminfo['fupadmin'],$windid)) {
	forum_creditcheck();
}

if ($groupid != 3 && $foruminfo['forumsell'] && !admincheck($foruminfo['forumadmin'],$foruminfo['fupadmin'],$windid)) {
	forum_sell($fid);
}
$db_perpage = 100;
$db_maxpage && $page > $db_maxpage && $page=$db_maxpage;
(!is_numeric($page) || $page < 1) && $page=1;
if ($page > 1) {
	$start_limit = ($page - 1) * $db_perpage;
} else{
	$start_limit = 0;
	$page = 1;
}
$startid = $start_limit+1;
$count = $foruminfo['topic'];
$numofpage = ceil($count/$db_perpage);
if ($numofpage && $page > $numofpage) {
	$page = $numofpage;
}
$pages = PageDiv($count,$page,$numofpage,"{$DIR}f$fid",$db_maxpage);

$threaddb = array();
$query = $db->query("SELECT * FROM pw_threads WHERE fid=".pwEscape($fid)." AND topped<=3 AND ifcheck='1' ORDER BY topped DESC, lastpost DESC".pwLimit($start_limit,$db_perpage));
while ($thread = $db->fetch_array($query)) {
	$threaddb[] = $thread;
}
$db->free_result($query);

require_once PrintEot('simple_header');
require_once PrintEot('simple_thread');
?>