<?php
class Index
{
 
	function Index()
	{
		$getmenu 	 = $GLOBALS['Helpe'] -> get_menu();

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

		$forumInfo 	 = $this -> foruminfo();

		$getuserlink = $GLOBALS['WebSe']->getuserlink();

		$GLOBALS['Templ']->assign('getuserlink',$getuserlink);
		
		$GLOBALS['Templ'] -> assign('getmenu',$getmenu);
		$GLOBALS['Templ'] -> assign('getads',$getads);

		
		$GLOBALS['Templ'] -> assign('forumInfo',$forumInfo);
		
		$GLOBALS['Templ'] -> assign('threadInfo',$threadInfo);

		$GLOBALS['Templ'] -> display('index_tpl.html');
	}
	function infolist()
	{
		//var_dump($_REQUEST);
		
		
	}

	function foruminfo()
	{
	
	
		$webtitle = '论坛中心';
		//处理你现在的位置
		$nowaddress = '<a href="'.BASE_WEBURL.'/">首页</a> > <a href="'.BASE_WEBURL.'/bbs/">论坛中心</a>';
	
		$GLOBALS['Templ'] -> assign('webtitle',$webtitle);
		
		$GLOBALS['Templ'] -> assign('nowaddress',$nowaddress);
	
		$sqlinfo = " SELECT for_id, for_name, for_desc, for_image 	for_list  FROM  ".SQL_PREFIX."forum   WHERE for_enabled = 1  LIMIT 150  ";
		
		$info = $GLOBALS['MySql'] -> selectInfo($sqlinfo);
		//$comInfo = array();	
		if($info )
		{ 
			foreach($info as $key => $val )
			{
				$info[$key]["threadinfo"] = $this -> threadinfo( $val["for_id"] );
			}
			return $info;
		}
	}
	
	
	function threadinfo( $forumid = '')
	{

		if($forumid !='')
		{
			$sql = " 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 = $forumid GROUP BY t.thr_id ORDER BY  t.thr_addtime DESC,  t.thr_list , t.thr_id desc  LIMIT 10 ";
			$info = $GLOBALS['MySql'] -> selectInfo($sql);
			if ($info[0])
			{ 
				return $info;
			}
			//var_dump($info);
		}
	}

	

}

$Index = new Index();

?>