<?PHP
/*
* Copyright (c) www.baojisky.com All rights reserved. 
*/
$root_path='../..';
include($root_path.'/php/connect_sub.php');
include($root_path.'/php/sub.php');
include($root_path."/php/img_sub.php");
include($root_path.'/php/page_sub_old.php');
include($root_path.'/admin/check.php');
 

$file_path_pdf		=	$root_path."/upload/paper_file/";  //上传pdf附件路径
$file_path_pic  	=	$root_path."/upload/paper_data/";  //上传图片附件路径

$nid	=	gmdate(date(U));
if($intime==''){$intime		=	Date("Y-m-d H:i:s");}

//添加新闻数据
$db->query("insert into {$db_sux}papers_news(nid,qid,bid,ztitle,ftiltle,ftiltle2,note,addtime,active)
VALUES('$nid','$qid','$bid','$ztitle','$ftiltle','$ftiltle2','$note','$intime','1')");
echo mysql_error();

//更新临时数据为正式
$db->query("update {$db_sux}papers_upfile set  nid='$nid',active='1' where nid='$temp_inid'");


//清除过期的临时图片
$clear_day  = date('Y-m-d H:i:s',mktime(date("H")-12,date("i"),date("s"),date("m"),date("d"),date("y")));
$result_pic	=	$db->query("SELECT * from {$db_sux}papers_upfile where active='0' and addtime<'$clear_day'  ");
$pic_numberz	=	$db->num_rows($result_pic);
//echo $clear_day.$pic_numberz;
if($pic_numberz>0)
{
	while($gb_pic = $db->fetch_array($result_pic))
	{
		//删除图片数据
		if($gb_pic[upfile]!=null and $gb_pic[upfile]!='')
		{
			  $filename_del	=	$file_path_pic.$gb_pic[upfile];//大图
				$tt	=	unlink($filename_del);
				$filename_del	=	$file_path_pic.$gb_pic[supfile];//小图
				$tt	=	unlink($filename_del);
		}
		$db->query("delete from {$db_sux}papers_upfile WHERE id='$gb_pic[id]'");//删除图片数据
	}
}

//#$maodian
web_echo("操作成功!","Newspaper_ban_list.php?page=$page&qid=$qid",'0',"$root_path",'info1');exit(0);

echo $fgoutputstr;
?>