<?php
include "../CheckUser.php";
include("../comm/db_sql.php");
include("../comm/config.php");
include("../comm/connect.php");
include("../comm/up_file.php");
include("../comm/Function.php");

$id= $_GET['id'];
$cation= $_GET['action'];
$Title=trim($_POST['Title']);
$Description=$_POST['Description'];
$cate_record=explode("|", $_POST['Cate_id']);
$Cate_id=trim($cate_record['0']); 
$channel=trim($cate_record['1']);
$big_cate_id=trim($cate_record['2']);
$Text=htmlentities($_POST['Text'],ENT_QUOTES,"UTF-8"); 
$Review=$_POST['Review']; 
$author=$_POST['author']; 
$source=$_POST['source']; 
$down_server1=$_POST['down_server1']; 
$down_server2=$_POST['down_server2']; 
$down_server3=$_POST['down_server3']; 
$down_server4=$_POST['down_server4']; 
$Recommend=$_POST['Recommend']; 
$Hot=$_POST['Hot']; 
$TOP=$_POST['TOP'];
$Flash_file=$_FILES['Flash_file']['tmp_name'];
$Up_File=$_FILES['Up_File']['tmp_name'];
$Picture=$_FILES['Picture']['tmp_name'];
$hit="0";
$Add_date=date("Y-m-d");                   //增加时间



$news_query=new mysql_db();
if($cation =="add" and trim($Title)!=="" and trim($Text)!=="" and trim($Cate_id)!=="" and trim($channel)!==""){
//判断类型
	if ($Cate_id=="zt"){
		$typefile=1;
		$Cate_id="";
		$big_cate_id="";
	}else if($Cate_id=="dl"){
		$typefile=2;
		$Cate_id="";
	}else{
		$typefile=0;
	}

//上传文件
if ($Picture<>""){
$up_file=new up_file();   
$up_file->up_filename="Picture"; //要上传的文件名
$up_file->type="0";       //0:img 1:flash 2:vod 3:other
$up_file->upload();
$up_file->img_max_w="400";                 //大图片宽度,产品高度为250,商城为250
$up_file->img_max_h="400";                 //大图片高度
$up_file->img_min_w="100";                 //小图宽度
$up_file->img_min_h="100";                 //小图高度
$up_file->img_type="0";                    //0:新闻图片 //1:强制产品/商城图片
$up_file->resize_picture();                //重设图片
$picture_url=$up_file->file_url;
$up_file=NULL;
}

if ($Flash_file<>""){
$up_flash=new up_file();
$up_flash->type="1";       //0:img 1:flash 2:vod 3:other
$up_flash->up_filename="Flash_file";
$up_flash->upload();
$flash_url=$up_flash->file_url;
$up_flash=NULL;
}

if ($Up_File<>""){
$Up_File_other=new up_file();
$Up_File_other->type="3";       //0:img 1:flash 2:vod 3:other
$Up_File_other->up_filename="Up_File";
$Up_File_other->upload();
$other_url=$Up_File_other->file_url;
$Up_File_other=NULL;
}
$list_var_name="Title,Description,Cate_id,Text,Review,author,source,Recommend,Hot,TOP,Flash_file,Up_File,Picture,hit,Add_date,channel,big_cate_id,typefile,down_server1,down_server2,down_server3,down_server4";
$list_var_value="'$Title','$Description','$Cate_id','$Text','$Review','$author','$source','$Recommend','$Hot','$TOP','$flash_url','$other_url','$picture_url','$hit','$Add_date','$channel','$big_cate_id','$typefile','$down_server1','$down_server2','$down_server3','$down_server4'";
$news_query->table=$db."download_info";  //表名
$news_query->table_mod="1"; 
$news_query->list_var_name=$list_var_name; //变量名
$news_query->list_var_value=$list_var_value;//值
$news_query->query();
@url_jump("add_info.php","manager_info.php","增加信息","返回信息管理中心");
}else
if ($cation=="del" and $id!==""){
$news_query->table=$db."download_info";  //表名
$news_query->table_mod="3"; //插入:1;修改:2;删除:3;建表,4;查询:5
$news_query->table_where="Id=$id";
$news_query->query();
@url_jump("add_info.php","manager_info.php","增加信息","返回信息管理中心");
}else
if($cation=="edit" and $id!=="" and trim($Title)!=="" and trim($Text)!=="" and trim($Cate_id)!=="" and trim($channel)!==""){
//判断类型
	if ($Cate_id=="zt"){
		$typefile=1;
		$Cate_id="";
		$big_cate_id="";
	}else if($Cate_id=="dl"){
		$typefile=2;
		$Cate_id="";
	}else{
		$typefile=0;
	}
$news_query->update_value="Title='$Title',Description='$Description',Cate_id='$Cate_id',Text='$Text',Review='$Review',author='$author',source='$source',Recommend='$Recommend',Hot='$Hot',TOP='$TOP',channel='$channel',big_cate_id='$big_cate_id',typefile='$typefile',down_server1='$down_server1',down_server2='$down_server2',down_server3='$down_server3',down_server4='$down_server4'";
$news_query->table=$db."download_info";  //表名
$news_query->table_mod="2"; 
$news_query->table_where="Id=$id";
$news_query->query();


//修改图片
if ($Picture<>""){
$up_file=new up_file();   
$up_file->up_filename="Picture"; //要上传的文件名
$up_file->type="0";       //0:img 1:flash 2:vod 3:other
$up_file->upload();
$up_file->img_max_w="400";                 //大图片宽度,产品高度为250,商城为250
$up_file->img_max_h="400";                 //大图片高度
$up_file->img_min_w="100";                 //小图宽度
$up_file->img_min_h="100";                 //小图高度
$up_file->img_type="0";                    //0:新闻图片 //1:强制产品/商城图片
$up_file->resize_picture();                //重设图片
$picture_url=$up_file->file_url;
$up_file=NULL;

$news_query->update_value="Picture='$picture_url'";
$news_query->table=$db."download_info";  //表名
$news_query->table_mod="2"; 
$news_query->table_where="Id=$id";
$news_query->query();
}

//修改FLash
if ($Flash_file<>""){
$up_flash=new up_file();
$up_flash->type="1";       //0:img 1:flash 2:vod 3:other
$up_flash->up_filename="Flash_file";
$up_flash->upload();
$flash_url=$up_flash->file_url;
$up_flash=NULL;

$news_query->update_value="Flash_file='$flash_url'";
$news_query->table=$db."download_info";  //表名
$news_query->table_mod="2"; 
$news_query->table_where="Id=$id";
$news_query->query();
}

//上传附件
if ($Up_File<>""){
$Up_File_other=new up_file();
$Up_File_other->type="3";       //0:img 1:flash 2:vod 3:other
$Up_File_other->up_filename="Up_File";
$Up_File_other->upload();
$other_url=$Up_File_other->file_url;
$Up_File_other=NULL;

$news_query->update_value="Up_File='$other_url'";
$news_query->table=$db."download_info";  //表名
$news_query->table_mod="2"; 
$news_query->table_where="Id=$id";
$news_query->query();
}
@url_jump("add_info.php","manager_info.php","增加信息","返回信息管理中心");
}else{
@url_error("add_info.php","manager_info.php","增加信息","返回信息管理中心","错误的操作!");
}
?>