<?phprequire_once ('../../global.php');
require_once ('json.class.php');
header("Content-type: application/json; charset=UTF-8 "); 
if($_SERVER['REQUEST_METHOD']=="GET") {

$httpZid = $_SERVER['HTTP_ZID'];
$getZid=$_GET['zid'];

$Zid =$httpZid!=NULL||$httpZid!=""?$httpZid:($getZid!=NULL||$getZid!=""?$getZid:0);

$sqlwhere="";
if ($Zid==0||$Zid==""||$Zid==NULL){//未传参数获取所有主版块信息
$sqlwhere=" and f.type='category'";


}elseif ($Zid>0) {//获取fid主版块下的子版块信息
$sqlwhere=" and f.fup='$Zid'";

}$query = $db->query("SELECT f.fid,f.name,f.type,f.childid,f.fup,f.logo,f.descrip,f.metadescrip,f.forumadmin,f.across,f.allowhtm,f.password,f.allowvisit,f.showsub,f.ifcms,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.ifcms!=2 $sqlwhere ORDER BY f.vieworder");


$zjson['list']=array();
while ($forums = $db->fetch_array($query)) {
$fid=$forums['fid'];//FID
$name= iconv( "gb2312","utf-8",$forums['name']);//版块名称
$tpost=$forums['tpost'];//新帖子数
$topic=$forums['topic'];//主题数
$article=$forums['article'];//帖子数
$postsCountnum=20;//主题分页
$replyCountnum=20;//帖子分页
$sumpage=$topic/$postsCountnum;
$sumpage=(int)($sumpage+1);

if ($Zid==0||$Zid==""||$Zid==NULL){
$platearray = array("zid" => "$fid","Name" => "$name");
}elseif ($Zid>0) {
$platearray = array("fid" => "$fid","Name" => "$name","threads" => "$topic","posts" => "$article","todayposts" => "$tpost","sumpage" => "$sumpage","postsCountnum" => "$postsCountnum","replyCountnum" => "$replyCountnum");
}
array_push($zjson['list'],$platearray);
                     
                              }

echo  $json_stringen = Json::encode($zjson);

//echo json_encode($zjson);
}else {

echo "{\"error\":1}";
}

?>