<?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_ban set ban_name='$ban_name', bnum='$bnum' where bid='$bid'");

$result	=	$db->query("SELECT * FROM {$db_sux}papers_ban WHERE  bid='$bid'");		
$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_pic"];
if($inpic[name] != "none" and $inpic[name] != "")
{
		$sux=get_sux($inpic[name]);
		$filename=rand(0,9999).gmdate(date(U)).".".$sux;
		
		//判断文件类型
		if($sux != "jpg")
		{
			web_echo("图片必须是jpg文件。上传失败。","Newspaper_ban_list.php?page=$page&qid=$qid",'2',"$root_path",'info1');exit(0);
		}
		if($inpic[size]> $max_up_kb)
		{
			web_echo("图片文件不能大于$max_up_M。上传失败。","Newspaper_ban_list.php?page=$page&qid=$qid",'2',"$root_path",'info1');exit(0);
		}
		//删除文件
		if($gb[ban_pic]!=null and $gb[ban_pic]!='')
		{
			$filename_del	=	$file_path_pdf.$gb[ban_pic];
			$tt	=	unlink($filename_del);
			$filename_del	=	$file_path_pdf.'s'.$gb[ban_pic];
			$tt	=	unlink($filename_del);
		}
		//上传
		$newfiles=$gb[bid].".".$sux;
		$snewfiles='s'.$gb[bid].".".$sux;
		upload_file($inpic[tmp_name],$file_path_pdf.$newfiles);
		
		//检测图片是否过大
		$im = @imagecreatefromjpeg($file_path_pdf.$newfiles); 
		$temp_w= ImageSX($im); 
		if($temp_w>450){HrResize($file_path_pdf.$newfiles,$file_path_pdf.$newfiles,450,670,1,0,0,90);}
		//小图
		HrResize($file_path_pdf.$newfiles,$file_path_pdf.$snewfiles,165,247,1,0,0,90);
    mysql_db_query("$datamybase","update {$db_sux}papers_ban set ban_pic='$newfiles' where bid='$bid' ");
}


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

echo $fgoutputstr;
?>