<?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/";  //上传附件路径


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

//主报纸数据
$db->query("update {$db_sux}papers set n_qi='$n_qi', z_qi='$z_qi', addtime='$intime', bei_zhu='$bei_zhu' where qid='$inid'");

$result	=	$db->query("SELECT * FROM {$db_sux}papers WHERE  qid='$inid'");		
$gb 	=	$db->fetch_array($result);

//pdf文件
$max_up_M=ini_get('upload_max_filesize');
$max_up_kb=$max_up_M*1024*1024;
$inpic=$_FILES["ban_pdf"];
if($inpic[name] != "none" and $inpic[name] != "")
{
		$sux=get_sux($inpic[name]);
		$filename=rand(0,9999).gmdate(date(U)).".".$sux;
		
		//判断文件类型，大小，个数，是否合适
		if($sux != "pdf")
		{
			web_echo("报纸pdf文件格式不正确。上传失败。","Newspaper.php",'2',"$root_path",'info1');exit(0);
		}
		if($inpic[size]> $max_up_kb)
		{
			web_echo("报纸pdf文件不能大于$max_up_M。上传失败。","Newspaper.php",'2',"$root_path",'info1');exit(0);
		}
		//删除文件
		if($gb[ban_pdf]!=null and $gb[ban_pdf]!='')
		{
			$filename_del	=	$file_path_pdf.$gb[ban_pdf];
			$tt	=	unlink($filename_del);
		}
		//上传
		$newfiles='vod_'.$gb[qid].".".$sux;
		upload_file($inpic[tmp_name],$file_path_pdf.$newfiles);
    mysql_db_query("$datamybase","update {$db_sux}papers set ban_pdf='$newfiles' where qid='$inid'");
}


web_echo("操作成功!","Newspaper.php?page=$page",'0',"$root_path",'info1');exit(0);

echo $fgoutputstr;
?>