<?php
if(!defined('IN_MYMPS')) exit('FORBIDDEN');
runcron();

$top_news	= mymps_get_news_list(18,'',0);//取得最新的18条新闻
$hot_news	= mymps_get_news_list(20,'',0,false,1);//取得最新的推荐新闻
$image_news = mymps_get_news_list(7,'',1,false);//取得最新的6条图文新闻
/*取得各一级栏目下的最新新闻*/
$catquery = $db -> query("SELECT catid,catname,html_dir FROM `{$db_mymps}channel` WHERE parentid = '0' AND if_view = '2' ORDER BY catorder ASC");
while($queryrow = $db -> fetchRow($catquery)){
	$_array['catid'] 	= $queryrow['catid'];
	$_array['catname'] 	= $queryrow['catname'];
	$_array['uri'] 		= Rewrite('news',array('catid'=>$queryrow['catid'],'html_dir'=>$queryrow['html_dir']));
	$channel[]		= $_array;
}
for($i=0; $i<count($channel); $i++){
	$do_sql = $db -> query("SELECT iscommend,id,title,catid,html_path,begintime,isjump,redirect_url FROM `{$db_mymps}news` WHERE catid IN(".get_cat_children($channel[$i]['catid'],'channel').") ORDER BY begintime DESC LIMIT 0,8");
	while($row = $db -> fetchRow($do_sql)){
		$arr['id'] 			= $row['id'];
		$arr['iscommend'] 	= $row['iscommend'];
		$arr['title'] 		= $row['title'];
		$arr['begintime'] 	= $row['begintime'];
		$arr['uri']			= $row['isjump'] == 1 ? $row['redirect_url'] : Rewrite('news',array('id'=>$row['id'],'html_path'=>$row['html_path']));
		
		$channel[$i]['news'][] = $arr;
	}
}

$loc		= get_location('news',0,'网站新闻');

$page_title = $loc['page_title'];
$location	= $loc['location'];

$s		= array();
$s['keywords'] = $pluginsettings['news']['seokeywords'];
$s['description'] = $pluginsettings['news']['seodescription'];
$smarty -> assign('seo',$s);

$advertisement	= get_advertisement('other');//获得全局广告
$adveritems		= $advertisement['items'];
$advertisement	= $advertisement['all'];

tpl_assign();

$smarty->assign('channel',$channel);
$smarty->assign('top_news',$top_news);
$smarty->assign('hot_news',$hot_news);
$smarty->assign('focus',mymps_get_focus('news',5));
$smarty->assign('image_news',$image_news);
$smarty->assign('latest_info',mymps_get_info_list(10,'','','','','','','',false));
$smarty->assign('hot_member',mymps_get_member_list(12,3,'',1));
$smarty->assign('cat',NULL);
$page_title = $location = $channel = $cat_list = $area_list = $top_news = $focus = $focus2 = $image_news = $advertisement = $adveritems = $cat = $catid = $page1 =  NULL;
?>