Current Path : /www/users/H10079900/sysadm/news/
Url:
Current File : /www/users/H10079900/sysadm/news/saveinitNews.php

<?
	include "../inc/config.php";
include "../../inc/inc.php";
	//----------------------------------------------文件上传----------------------------------------------------------
	//得到上传文件的扩展名函数
	function extend($file_name) 
	{
		$extend =explode("." , $file_name);
		$va=count($extend)-1;
		return $extend[$va];
	}
	function uploadfiles($F_name,$dir,$id,$s="s_s")
	{
		//取得当前日期信息,并连接成为一个字符串 
		$time = date('YmdHis'); 
		//获得扩展名
		$ExtensionSmall=extend($_FILES[$F_name]["name"]);
		//文件全名称
		$pic=$time."_s.".$ExtensionSmall;
		//检查是不是有文件名相同
		if(file_exists($dir.$pic))
		{
		   $pic=$time.$s.".".$ExtensionSmall;
		}
		//文件上传后全路径名称
		$uploadfileSmall=$dir.$pic;
		$loadSamll=move_uploaded_file($_FILES[$F_name]["tmp_name"],$uploadfileSmall);
		if(!$loadSamll)
		{
			$pic=$_POST['tmp'.$F_name];
		}else{
			$sqlPic=mysql_query("select ".$F_name." from news where id=$id");
			if(mysql_num_rows($sqlPic)>0){  
				$row=mysql_fetch_array($sqlPic);
				 if(file_exists($dir.$row[0])) unlink($dir.$row[0]);
			}
		}
		return $pic;
	}
	$id=$_POST['id'];
	//上传文件的存储目录
	$uploaddir="./../uploadfiles/";

	$pic=uploadfiles("pic",$uploaddir,$id);
	
	$pic2=uploadfiles("pic2",$uploaddir,$id,"_t");
	
	//------------------------------------------------文件上传END-------------------------------------------------
		//------------------------------------------------检查xml字段-------------------------------------------------
	if(file_exists('field.xml'))
	{
  	$doc  = new DOMDocument();
	$doc->load('field.xml');
	$root   =   $doc-> getElementsByTagName("news");
	$num=$root -> item(0)->childNodes->length;
	if($num>0)
	{
		$field  =   $root -> item(0)-> getElementsByTagName("field");
		foreach($field as $list)
		{
			$name=$list->getElementsByTagName("name")->item(0)->nodeValue;
			$type=$list->getElementsByTagName("type")->item(0)->nodeValue;
			if($type=="varchar(64)")
			{
				$v=uploadfiles($name,$uploaddir,$id);
				$f_values.=",".$name."='".$v."'";
			}
			else
			{
				$f_values.=",".$name."='".$_POST[$field]."'";
			}
		}
	}
	}
	//------------------------------------------------检查xml字段end-------------------------------------------------
	$ifsearch=$_POST['ifsearch'];
	if(empty($ifsearch)){$ifsearch="0";}
	$isnewly=$_POST['isnewly'];
	if(empty($isnewly)){$isnewly="0";}
	$comefrom=$_POST['comefrom'];
	if(empty($comefrom)){$comefrom="&nbsp;";}
	$keyword=$_POST['keyword'];
	if(empty($keyword)){$keyword="&nbsp;";}
	$title_color=$_POST['title_color'];
	if(empty($title_color)){$title_color="&nbsp;";}
	$title_fonttype=$_POST['title_fonttype'];
	if(empty($title_fonttype)){$title_fonttype="0";}
	$title_fontsize=$_POST['title_fontsize'];
	if(empty($title_fontsize)){$title_fontsize="0";}
	$ishot=$_POST['ishot'];
	if(empty($ishot)){$ishot="0";}
	$iscommend=$_POST['iscommend'];
	if(empty($iscommend)){$iscommend="0";}
	$name1=$_POST['name1'];
	if(empty($name1)){$name1="&nbsp;";}
	$name2=$_POST['name2'];
	if(empty($name2)){$name2="&nbsp;";}
	$name3=$_POST['name3'];
	if(empty($name3)){$name3="&nbsp;";}
	$name4=$_POST['name4'];
	if(empty($name4)){$name4="&nbsp;";}
	$name5=$_POST['name5'];
	if(empty($name5)){$name5="&nbsp;";}
	$name6=$_POST['name6'];
	if(empty($name6)){$name6="&nbsp;";}
	$name7=$_POST['name7'];
	if(empty($name7)){$name7="&nbsp;";}
	$name8=$_POST['name8'];
	if(empty($name8)){$name8="&nbsp;";}
	if(empty($pic)){$pic="&nbsp;";}
	if(empty($pic2)){$pic2="&nbsp;";}
	
	//插入记录
	$sql="UPDATE news SET 
	title='".$_POST['title']."',
	typeid='".$_POST['typeid']."',
	ifsearch='".$ifsearch."',
	date='".$_POST['date']."',
	keyword='".$keyword."',
	isnewly='".$isnewly."',
	comefrom='".$comefrom."',
	content='".$_POST['content']."',
	title_color='".$_POST['title_color']."', 
	title_color='".$title_color."', 
	title_fonttype='".$title_fonttype."',
	title_fontsize='".$title_fontsize."',
	ishot='".$ishot."',
	iscommend='".$iscommend."',
	name1='".$name1."',
	name2='".$name2."',
	name3='".$name3."',
	name4='".$name4."',
	name5='".$name5."',
	name6='".$name6."',
	name7='".$name7."',
	name8='".$name8."',
	uploadname1='$pic',
	uploadname2='$pic2',
	popedom='".$_POST['popedomid']."'".$f_values."
	WHERE id='$id'";
	$result=mysql_query($sql);
	if($result){
				//页面跳转
				$url="ManageNews.php?typeid=".$_POST['typeid']."&ctid=".$_POST['ctid']; 
				echo "<SCRIPT LANGUAGE='Javascript'>"; 
				echo "location.href='$url'"; 
				echo "</SCRIPT>"; 
	}
	else{
		echo $eor;
	}
?>