<?php
require("../class/connect.php");
include("../class/config.php");
include("../class/q_functions.php");
include("../class/db_sql.php");
include("../class/class.php");
$link=db_connect();
$empire=new mysqlquery();
//参数设置
$pagecode="gbk";

//-----------返回简介字段名
function ReturnTheIntroField($r){
	global $public_r,$dotbname;
	$f=0;
	if(strstr($public_r['savetxtf'],",".$dotbname.".newstext,"))
	{
		$r['newstext']='';
		$f=1;
	}
	if($r['newstext'])//新闻内容
	{
		$field="newstext";
	}
	elseif($r['smalltext'])//简介
	{
		$field="smalltext";
	}
	elseif($r['softsay'])//软件简介
	{
		$field="softsay";
	}
	elseif($r['flashsay'])//flash简介
	{
		$field="flashsay";
	}
	else
	{
		if($f!=1)
		{
			$field="newstext";
		}
	}
	return $field;
}
//替换
function RepSpeRssStr($str){
	$str=str_replace("[!--empirenews.page--]","",$str);
	$str=str_replace("[/!--empirenews.page--]","",$str);
	$str=str_replace("[","",$str);
	$str=str_replace("]","",$str);
	$str=str_replace('\"','&quot;',$str);
	$str=str_replace('\'','&apos;',$str);
	$str=str_replace('&','&amp;',$str);
	$str=str_replace('<','&lt;',$str);
	$str=str_replace('>','&gt;',$str);
	return $str;
}
//---------显示文件
$type=$_GET['type'];
if($type=="xml")//xml
{
	$webfilename="xml.php";
}
elseif($type=="atom")//atom
{
	$webfilename="atom.php";
}
elseif($type=="rss1")//rss1
{
	$webfilename="rss10.php";
}
else//rss2
{
	$webfilename="rss20.php";
}
//---------排序
$order=(int)$_GET['order'];
if($order==1)//按ID
{
	$myorder="id";
}
elseif($order==2)//评论数
{
	$myorder="plnum";
}
elseif($order==3)//点击数
{
	$myorder="onclick";
}
elseif($order==4)//下载数
{
	$myorder="totaldown";
}
else//发布时间
{
	$myorder="newstime";
}
//---------显示顺序
$orderby=(int)$_GET['orderby'];
if($orderby)
{
	$myorderby="ASC";
}
else
{
	$myorderby="DESC";
}
//---------类别ID
$classid=(int)$_GET['classid'];
$ztid=(int)$_GET['ztid'];
if($classid)//类别最新
{
	if(empty($class_r[$classid]['tbname']))
	{
		exit();
	}
	$dotbname=$class_r[$classid]['tbname'];
	if($class_r[$classid][islast])
	{
		$where="classid=$classid";
	}
	else
	{
		$where=ReturnClass($class_r[$classid][sonclass]);
		if(empty($where))
		{$where="classid=0";}
	}
	$query="select * from {$dbtbpre}ecms_".$class_r[$classid]['tbname']." where ".$where." and checked=1 order by ".$myorder." ".$myorderby." limit ".$public_r['rssnum'];
	//标题信息
	$pagetitle=$class_r[$classid]['classname'];
	$this_r['classid']=$classid;
	$pageurl=sys_ReturnBqClassname($this_r,9);
}
elseif($ztid)//专题最新
{
	if(empty($class_zr[$ztid]['tbname']))
	{
		exit();
	}
	$dotbname=$class_zr[$ztid]['tbname'];
	$query="select * from {$dbtbpre}ecms_".$class_zr[$ztid]['tbname']." where ztid like '%|".$ztid."|%' and checked=1 order by ".$myorder." ".$myorderby." limit ".$public_r['rssnum'];
	//标题信息
	$pagetitle=$class_zr[$ztid]['ztname'];
	$this_r['ztid']=$ztid;
	$pageurl=sys_ReturnBqZtname($this_r);
}
else//所有最新
{
	$dotbname=$public_r['tbname'];
	$query="select * from {$dbtbpre}ecms_".$public_r['tbname']." where checked=1 order by ".$myorder." ".$myorderby." limit ".$public_r['rssnum'];
	//标题信息
	$pagetitle=$public_r['sitename'];
	$pageurl=$public_r['newsurl'];
}
$sublen=$public_r['rsssub'];
$sql=$empire->query($query);
@include($webfilename);
db_close();
$empire=null;
?>