www.gusucode.com > 典当行电子商务网站php网站源码程序 > code/tools/dd_yuyue/post.php

    <?php
define("ROOTPATH", "../../");
include(ROOTPATH."includes/common.inc.php");
include("language/".$sLan.".php");
include("includes/dd.inc.php");

$act = $_POST['act'];

switch($act){

	case "ddyuyue":
		
		//当ajax上传图片时,jform是在iframe中实现的,需要给中文提示加上编码
		$Meta="<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>";

		$yuyuename=htmlspecialchars($_POST["yuyuename"]);
		$yuyuetel=htmlspecialchars($_POST["yuyuetel"]);
		$yuyuemobile=htmlspecialchars($_POST["yuyuemobile"]);
		$yuyueorder=$_POST["yuyueorder"];
		$yuyueorder=Url2Path($yuyueorder);
		$checkimgcode=htmlspecialchars($_POST["checkimgcode"]);

		$pic=$_FILES["yuyuejpg"];

		if($yuyuename==""){
			echo $Meta.$strDDNTC1;
			exit;
		}

		if(strlen($yuyuename)>200){
			echo $Meta.$strDDNTC2;
			exit;
		}
		
		if(strlen($yuyuetel)>200){
			echo $Meta.$strDDNTC2;
			exit;
		}

		if($yuyuemobile==""){
			echo $Meta.$strDDNTC4;
			exit;
		}
		
		if(strlen($yuyuemobile)>200){
			echo $Meta.$strDDNTC2;
			exit;
		}

		if($yuyueorder==""){
			echo $Meta.$strDDNTC5;
			exit;
		}
		
		if(strlen($yuyueorder)>65000){
			echo $Meta.$strDDNTC6;
			exit;
		}
		
		//图片校验
		if($pic["size"]==0){
			echo $Meta.$strDDNTC7;
			exit;
		}
		
		//图形验证码
		if($checkimgcode!="no"){
			$ImgCode=$_POST["ImgCode"];
			
			$Ic=$_COOKIE["CODEIMG"];
			$Ic=strrev($Ic)+5*2-9;
			$Ic=substr ($Ic,0,4);

			if($ImgCode=="" || $Ic!=$ImgCode){
				echo $Meta.$strIcErr;
				exit;
			}
		}

		//标签过滤
		$yuyueorder=str_replace("{#","{ #",$yuyueorder);
		$yuyueorder=str_replace("#}","# }",$yuyueorder);

		//图片上传
		if($pic["size"]>0){
			$nowdate=date("Ymd",time());
			$picpath=ROOTPATH."tools/pics/".$nowdate;
			@mkdir($picpath,0777);
			$updir="tools/pics/".$nowdate;
			$arr=DDUploadImage($pic["tmp_name"],$pic["type"],$pic["size"],$updir);
			if($arr[0]!="err"){
				$src=$arr[3];
			}else{
				echo $Meta.$arr[1];
				exit;
			}
		}

		$msql->query("insert into {P}_tools_code set
		name='$yuyuename',
		tel='$yuyuetel',
		phone='$yuyuemobile',
		code='$yuyueorder',
		groupname='dd_yuyue',
		position='$src'
		");

		$id=$msql->instid();

		echo "OK";
		exit;

	break;

}
?>