<?php
class Forum
{
	var $nowaddress = '';
	function Forum()
	{
		$getmenu = $GLOBALS['Helpe']->get_menu();
		$GLOBALS['Templ']->assign('getmenu',$getmenu);
		
		$getbbsconfig = $GLOBALS['Helpe']->get_bbsconfig();
		$GLOBALS['Templ']->assign('getbbsconfig',$getbbsconfig);
		
		$getlink = $GLOBALS['Helpe']->get_link();
		$GLOBALS['Templ']->assign('getlink',$getlink);

		$getads = $GLOBALS['Helpe'] -> get_ads( $instr = '1,2,3,4,5,6,7,8,9,10,11' );
		$GLOBALS['Templ'] -> assign('getads',$getads);
		
		$getuserlink = $GLOBALS['WebSe']->getuserlink();
		//var_dump($getuserlink);
		$GLOBALS['Templ']->assign('getuserlink',$getuserlink);

		$this -> nowaddress = '<a href="'.BASE_WEBURL.'/">首页</a> > <a href="'.BASE_WEBURL.'/bbs/">'.$getbbsconfig["bbsname"].'</a>';
		
		
	}

	
	function infolist()
	{
		$idval 		= $GLOBALS['Reque'] -> reqval["id"];
		$pageNumval = $GLOBALS['Reque'] -> reqval["pageNum"];

		$pageSize = 20 ;
		
		//var_dump($strArray );
		
		if( $pageNumval > 1 )
		{
			$pageNum  = $pageNumval;
			$LIMITnum = ceil( ( $pageNumval -1 ) * $pageSize );
		}else{
			$pageNum  = 1;
			$LIMITnum = 0 ;
		}
		
		$sqlQuery = " SELECT t.thr_id, t.thr_title,t.thr_addtime, t.thr_list, t.thr_replycount, t.thr_count ,d.usd_nick 	FROM ".SQL_PREFIX."thread AS t , ".SQL_PREFIX."userdetail as d    WHERE d.use_id = t.use_id and  t.thr_enabled = 1  and for_id = ".$idval." GROUP BY t.thr_id ORDER BY t.thr_uptime DESC,  t.thr_addtime DESC,  t.thr_list , t.thr_id desc  LIMIT  $LIMITnum , $pageSize ";
		
		$info 		= $GLOBALS['MySql']  ->  selectInfo($sqlQuery);
		
		
		$sqlQuery 	= " SELECT count(1) as CNUM  FROM  ".SQL_PREFIX."thread  WHERE thr_enabled = 1 and for_id = ".$idval." and use_id <> '' ORDER BY `for_id`  ";
		
		$infocount 	= $GLOBALS['MySql']  ->  selectOne($sqlQuery);
		
		$PageStr = $GLOBALS['Page'] -> buildPageStr(  $url = BASE_WEBURL.'/bbs/?load=forum&act=infolist&id='.$idval, $pageNum  , $pageSize  , $resultCount = $infocount["CNUM"] ,$endArray  );
		
		$GLOBALS['Templ'] -> assign('PageStr',$PageStr);
		
		$GLOBALS['Templ'] -> assign('info',$info);
		if($idval > 0){
			$sqlinfo = " SELECT for_id, for_name, for_desc, for_image 	for_list  FROM  ".SQL_PREFIX."forum  WHERE for_enabled = 1  and  for_id = $idval LIMIT 150  ";
		}else{
			$sqlinfo = " SELECT for_id, for_name, for_desc, for_image 	for_list  FROM  ".SQL_PREFIX."forum  WHERE for_enabled = 1  LIMIT 150  ";
		}
		$forumInfo = $GLOBALS['MySql'] -> selectOne($sqlinfo);
		//$comInfo = array();	
		
		
		$upthread = "UPDATE   ".SQL_PREFIX."forum  SET for_count = for_count + 1 WHERE  for_enabled = 1 and for_id = ".$idval." ";
		
		$GLOBALS['MySql'] -> querySql( $upthread );
		
		
		
		$GLOBALS['Templ']->assign('forumInfo',$forumInfo);
		
		$this -> nowaddress .= ' > <a href="'.BASE_WEBURL.'/bbs/?load=forum&act=infolist&id='.$forumInfo["for_id"].'&pageNum=1" >'.$forumInfo["for_name"].'</a>';
		
		$GLOBALS['Templ']->assign('nowaddress',$this -> nowaddress );
		
		$GLOBALS['Templ']-> display('forum_tpl.html');
	
	
		
	}
	
	

}


$Forum = new Forum();
?>