<?php
if(!defined('IN_TM')) {exit('Access Denied');}
$id=intval(getgpc('id'));  
$fid=intval(getgpc('fid'));   
if($id){
	$new = $db->fetch_all("SELECT *FROM `{$tablepre}news`WHERE `id` = '{$id}'");
	$SiteName = $new[0][title].'-'.$SiteName;
	$title = $new[0][title];
	$body = $new[0][body];
	$time = date("YÄê-mÔÂ-dÈÕ hÊ±:i·Ö", $new[0][time]);
	$zz = $new[0][zz];
	$ly= $new[0][ly];
	$hist= $new[0][hist];
	$db->query("UPDATE {$tablepre}news SET hist = hist+1 WHERE id ={$id};");
	$db->close();
	$tplid=1;
	include template('news.htm');
}elseif($fid){
	$page = getgpc('page');
	if(isset($page)){ $page = intval($page); }else{ $page = 1; }
	$page_size = 10; 
	$sql = "SELECT * FROM `{$tablepre}news` WHERE `ssfl` =$fid";
	$row = $db->num_rows($db->query($sql));
	$mpurl =$PHP_SELF.'?action=news&fid='.$fid.'&';
	$dispage =  page($row,$page_size,$page,$mpurl);
	$page_get_start = page_get_start($page,$page_size,$row);
	$sql = "SELECT * FROM {$tablepre}news WHERE `ssfl` =$fid LIMIT $page_get_start, $page_size";
	$newslist = $db->fetch_all($sql);
	$a = 'Y-m-d H:i';
	$tplid=2;
	include template('news.htm');
}else{
	$page = getgpc('page');
	if(isset($page)){ $page = intval($page); }else{ $page = 1; }
	$page_size = 10; 
	$sql = "SELECT * FROM `{$tablepre}news`";
	$row = $db->num_rows($db->query($sql));
	$mpurl =$PHP_SELF.'?action=news&';
	$dispage =  page($row,$page_size,$page,$mpurl);
	$page_get_start = page_get_start($page,$page_size,$row);
	$sql = "SELECT * FROM {$tablepre}news LIMIT $page_get_start, $page_size";
	$newslist = $db->fetch_all($sql);
	$a = 'Y-m-d H:i';
	$tplid = 3;
	include template('news.htm');
	$db->close();
	exit;
}

?>