<?php
!defined('M_P') && exit('Forbidden');
require_once(R_P.'require/element.class.php');// Load Element Class
$element = new Element();
InitGP(array('cateid'),'GP',2);
$cateid>0 && ObHeader("cate.php?cateid=$cateid");
// forum info
$forumdb = $showsub = $pwTPost = array();
$query  = $db->query("SELECT f.fid,f.childid,f.fup,f.logo,f.descrip,f.forumadmin,f.across,f.allowhtm,f.password,f.allowvisit,f.showsub,fd.tpost,fd.topic,fd.article,fd.subtopic,fd.top1,fd.lastpost FROM pw_forums f LEFT JOIN pw_forumdata fd USING(fid) WHERE f.ifsub='0' AND f.cms!=1 ORDER BY f.vieworder");
while ($forums = $db->fetch_array($query)) {
	$forums['name'] = $forum[$forums['fid']]['name'];
	$forums['type'] = $forum[$forums['fid']]['type'];
	if ($forums['type'] === 'category') {
		$forums['admin'] = '';
	} elseif ($forums['type'] === 'forum') {
		if ($forums['showsub'] && $forums['childid']) {
			$showsub[$forums['fid']] = '';
		}
		$forums['topics'] = $forums['topic']+$forums['subtopic'];
		if ($db_topped) {
			$forums['topics'] += $forums['top1'];
			$forums['article'] += $forums['top1'];
		}
		$article += $forums['article'];
		$topics += $forums['topics'];
		$tposts += $forums['tpost'];
		$forums['au'] = $forums['admin'] = '';
		$pwTPost[$forums['fup']] += $forums['tpost'];
		$forumdb[$forums['fup']][] = array('fid' => $forums['fid'],'name' => $forums['name'],'topics' => $forums['topics'],'article' => $forums['article'],'tpost' => $forums['tpost'],'admin' => $forums['admin'],'pic' => $forums['pic'],'logo' => $forums['logo'],'descrip' => $forums['descrip'],'au' => $forums['au'],'ft' => $forums['ft'],'t' => $forums['t'],'newtitle' => $forums['newtitle']);
	}
}
$db->free_result($query);
?>