<?PHP
/*
* Copyright (c) www.baojisky.com All rights reserved. 
*/
ob_start(); 
header("Content-type: text/html;charset=utf-8");//输出编码,避免中文乱码
$root_path='.';
include_once($root_path.'/php/connect_sub.php');
include_once($root_path.'/php/sub.php');


if($page==''){$page='1';}
if($qid==''){$qid='1287669734';}
if($bnum==''){$bnum='1';}
if($nid=='')
{
	$result_ban=$db->query("SELECT * from {$db_sux}papers_ban where qid='$qid' and bnum='$bnum' ");
	$gb_ban = mysql_fetch_array($result_ban);
	$page--;
	$result_news_temp=$db->query("SELECT * from {$db_sux}papers_news where qid='$qid' and bid='$gb_ban[bid]' ORDER BY addtime LIMIT $page,1   ");
	$gb_temp = mysql_fetch_array($result_news_temp);
	
	
	$nid=$gb_temp[nid];
}

//点击数
$result	=	$db->query("update {$db_sux}papers_news set click_num=click_num+1 where nid=$nid");

//新闻数据
$result_news=$db->query("SELECT * from {$db_sux}papers_news where nid='$nid' ");
$gb_news = mysql_fetch_array($result_news);

$result_pic=$db->query("SELECT * from {$db_sux}papers_upfile where nid='$nid' ");
$pic_num=$db->num_rows($result_pic);

//取版名称
$result_ban2=$db->query("SELECT * from {$db_sux}papers_ban where bid='$gb_news[bid]'");
$gb_ban2 = mysql_fetch_array($result_ban2);

$gb_ban2[ban_name]=iconv("gbk", "UTF-8", $gb_ban2[ban_name]);
$gb_news[ztitle]=iconv("gbk", "UTF-8", $gb_news[ztitle]);
$gb_news[ftiltle]=iconv("gbk", "UTF-8", $gb_news[ftiltle]);
$gb_news[ftiltle2]=iconv("gbk", "UTF-8", $gb_news[ftiltle2]);
$gb_news[note]=iconv("gbk", "UTF-8", $gb_news[note]);

$fgfg	=	'<?xml version="1.0" encoding="utf-8"?>
<xmlbase>';
		$fgfg.=	'<news_note>';
		$fgfg.=	'<npage>'.$i.'</npage>';
		$fgfg.=	'<nid>'.$gb_news[nid].'</nid>';
		$fgfg.=	'<pic_num>'.$pic_num.'</pic_num>';
		$fgfg.=	'<bid>'.$gb_news[bid].'</bid>';
		$fgfg.=	'<bname>'.$gb_ban2[ban_name].'</bname>';
		$fgfg.=	'<ztitle>'.$gb_news[ztitle].'</ztitle>';
		$fgfg.=	'<qtitle>'.$gb_news[ftiltle].'</qtitle>';
		$fgfg.=	'<htitle>'.$gb_news[ftiltle2].'</htitle>';
		$fgfg.=	'<n_note>'.$gb_news[note].'</n_note>';
		$fgfg.=	'</news_note>';
	//图片列表
	$i=1;
	if($pic_num>0)
	{
		while ($gb_pic = mysql_fetch_array($result_pic))
		{
			$gb_pic[name]=iconv("gbk", "UTF-8", $gb_pic[name]);
			$fgfg.=	'<pic_list>';
			$fgfg.=	'<ppage>'.$i.'</ppage>';
			$fgfg.=	'<pid>'.$gb_pic[id].'</pid>';
			$fgfg.=	'<upfile>upload/paper_data/'.$gb_pic[upfile].'</upfile>';
			$fgfg.=	'<supfile>upload/paper_data/'.$gb_pic[supfile].'</supfile>';
			$fgfg.=	'<pname>'.$gb_pic[name].'</pname>';
			$fgfg.=	'</pic_list>';
			$i++;
		}
	}
$fgfg.=	"
</xmlbase>";
echo $fgfg;
ob_end_flush();
?>