⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upload.php

📁 asp商城模板。前后台都有。能更换模板。asp+a
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php header("content-Type: text/html; charset=utf-8");
/*
*######################################
* eWebEditor v3.80 - Advanced online web based WYSIWYG HTML editor.
* Copyright (c) 2003-2006 eWebSoft.com
*
* For further information go to http://www.ewebsoft.com/
* This copyright notice MUST stay intact for use.
*######################################
*/
?>


<?php

require("config.php");

require_once('../../admin/IsLogined.php');

InitUpload();

if (isset($_GET["action"])){
	$sAction = strtoupper($_GET["action"]);
}else{
	$sAction = "";
}


switch ($sAction){
case "REMOTE":
	DoCreateNewDir();
	DoRemote();
	break;
case "SAVE":
	ShowForm();
	DoCreateNewDir();
	DoSave();
	break;
default:
	ShowForm();
	break;
}


function  ShowForm() {
?>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>eWebEditor</TITLE>
<script language="javascript" src="../dialog/dialog.js"></script>
<link href='../language/<?=$GLOBALS["sLanguage"]?>.css' type='text/css' rel='stylesheet'>
<link href='../dialog/dialog.css' type='text/css' rel='stylesheet'>
</head>
<body class=upload>

<form action="?action=save&type=<?=$GLOBALS["sType"]?>&style=<?=$GLOBALS["sStyleName"]?>&language=<?=$GLOBALS["sLanguage"]?>" method=post name=myform enctype="multipart/form-data">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="<?=($GLOBALS["nAllowSize"]*1024);?>"> 
<input type=file name="uploadfile" size=1 style="width:100%">
</form>

<script language=javascript>

var sAllowExt = "<?=$GLOBALS["sAllowExt"]?>";

function  CheckUploadForm() {
	if (!IsExt(document.myform.uploadfile.value,sAllowExt)){
		parent.UploadError('lang["ErrUploadInvalidExt"]+":'+sAllowExt+'"');
		return false;
	}
	return true
}

var oForm = document.myform ;
oForm.attachEvent("onsubmit", CheckUploadForm) ;
if (! oForm.submitUpload) oForm.submitUpload = new Array() ;
oForm.submitUpload[oForm.submitUpload.length] = CheckUploadForm ;
if (! oForm.originalSubmit) {
	oForm.originalSubmit = oForm.submit ;
	oForm.submit = function () {
		if (this.submitUpload) {
			for (var i = 0 ; i < this.submitUpload.length ; i++) {
				this.submitUpload[i]() ;
			}
		}
		this.originalSubmit() ;
	}
}

try {
	parent.UploadLoaded();
}
catch(e){
}

</script>

</body>
</html>

<?php
}  


function DoSave(){

	if($_FILES['uploadfile']['error'] > 0){
		switch((int)$_FILES['uploadfile']['error']){
		case UPLOAD_ERR_NO_FILE:
			OutScript("parent.UploadError('lang[\"ErrUploadInvalidFile\"]')");
			break;
		case UPLOAD_ERR_FORM_SIZE: 
			OutScript("parent.UploadError('lang[\"ErrUploadSizeLimit\"]+\":".$GLOBALS["nAllowSize"]."KB\"')");
			break;
		}
		exit;
	}
	preg_match("/\.([a-zA-Z0-9]{2,4})$/",$_FILES['uploadfile']['name'],$exts);
	CheckValidExt($exts[1]);
	$GLOBALS["sSaveFileName"] = GetRndFileName(strtolower($exts[1]));
	$GLOBALS["sOriginalFileName"] = $_FILES['uploadfile']['name'];
	$sFileName = str_replace('\\','\\\\',realpath($GLOBALS["sUploadDir"]))."/";
	$sFileName .= $GLOBALS["sSaveFileName"];
	if(!move_uploaded_file($_FILES['uploadfile']['tmp_name'],$sFileName)){
		OutScript("parent.UploadError('Error')");
		exit;
	}


	$s_SmallImageFile = getSmallImageFile($GLOBALS["sSaveFileName"]);
	$s_SmallImagePathFile = "";
	$s_SmallImageScript = "";
	if (makeImageSLT($GLOBALS["sUploadDir"], $GLOBALS["sSaveFileName"], $s_SmallImageFile)){
		makeImageSY($GLOBALS["sUploadDir"], $s_SmallImageFile);
		makeImageSY($GLOBALS["sUploadDir"], $GLOBALS["sSaveFileName"]);
		$s_SmallImagePathFile = $GLOBALS["sContentPath"].$s_SmallImageFile;
		$s_SmallImageScript = "try{obj.addUploadFile('".$GLOBALS["sOriginalFileName"]."', '".$s_SmallImageFile."', '".$s_SmallImagePathFile."');} catch(e){} ";
	}else{
		$s_SmallImageFile = "";
		makeImageSY($GLOBALS["sUploadDir"], $GLOBALS["sSaveFileName"]);
	}

	$GLOBALS["sPathFileName"] = $GLOBALS["sContentPath"].$GLOBALS["sSaveFileName"];
	OutScript("parent.UploadSaved('".$GLOBALS["sPathFileName"]."','".$s_SmallImagePathFile."');var obj=parent.dialogArguments.dialogArguments;if (!obj) obj=parent.dialogArguments;try{obj.addUploadFile('".$GLOBALS["sOriginalFileName"]."', '".$GLOBALS["sSaveFileName"]."', '".$GLOBALS["sPathFileName"]."');} catch(e){} ".$s_SmallImageScript);

}


function makeImageSY($s_Path, $s_File){
	if($GLOBALS["nSYFlag"] == 0){return false;}
	if(!isValidSLTSYExt($s_File)){return false;}

	switch($GLOBALS["nSLTSYObject"]){
	case 0:
		$groundImage = $s_Path.$s_File;
		if(!file_exists($groundImage)){return false;}
        $ground_info = getimagesize($groundImage); 
        $ground_w = $ground_info[0];
        $ground_h = $ground_info[1];
		if($GLOBALS["nSYMinSize"] > $ground_w){return false;}
        switch($ground_info[2]){
            case 1:
				$ground_im = imagecreatefromgif($groundImage);
				break; 
            case 2:
				$ground_im = imagecreatefromjpeg($groundImage);
				break;
            case 3:
				$ground_im = imagecreatefrompng($groundImage);
				break;
            default:
				return false; 
        }
		imagealphablending($ground_im, true);


		switch($GLOBALS["nSYFlag"]){
		case 1:
			if($GLOBALS["sSYFontName"]){
				$s_SYText = gb2utf8($GLOBALS["sSYText"]);

				$fontSize = imagettfbbox($GLOBALS["nSYFontSize"], 0, $GLOBALS["sSYFontName"], $s_SYText);
				$n_SYWidth = $fontSize[2] - $fontSize[0];
				$n_SYHeight = $fontSize[1] - $fontSize[7];
			}

			if($GLOBALS["sSYShadowColor"]==""){
				$GLOBALS["sSYShadowColor"] = "ffffff";
			}
			$R = hexdec(substr($GLOBALS["sSYShadowColor"],0,2));
			$G = hexdec(substr($GLOBALS["sSYShadowColor"],2,2));
			$B = hexdec(substr($GLOBALS["sSYShadowColor"],4));
			$textcolor = imagecolorallocate($ground_im, $R, $G, $B);
			if($GLOBALS["sSYFontName"]){
				imagettftext($ground_im, $GLOBALS["nSYFontSize"], 0, 5+$GLOBALS["nSYShadowOffset"], 5+$n_SYHeight+$GLOBALS["nSYShadowOffset"], $textcolor, $GLOBALS["sSYFontName"],  $s_SYText);
			}else{
				imagestring($ground_im, $GLOBALS["nSYFontSize"], 5+$GLOBALS["nSYShadowOffset"], 5+$GLOBALS["nSYShadowOffset"], $GLOBALS["sSYText"], $textcolor);
			}

			if($GLOBALS["sSYFontColor"]==""){
				$GLOBALS["sSYFontColor"] = "000000";
			}
			$R = hexdec(substr($GLOBALS["sSYFontColor"],0,2));
			$G = hexdec(substr($GLOBALS["sSYFontColor"],2,2));
			$B = hexdec(substr($GLOBALS["sSYFontColor"],4));
			$textcolor = imagecolorallocate($ground_im, $R, $G, $B);
			if($GLOBALS["sSYFontName"]){
				imagettftext($ground_im, $GLOBALS["nSYFontSize"], 0, 5, 5+$n_SYHeight, $textcolor, $GLOBALS["sSYFontName"],  $s_SYText);
			}else{
				imagestring($ground_im, $GLOBALS["nSYFontSize"], 5, 5, $GLOBALS["sSYText"], $textcolor);
			}
			break;

		case 2:
			$waterImage = $GLOBALS["sSYPicPath"];
			if(!file_exists($waterImage)){return false;}
			$water_info = getimagesize($waterImage); 
			$water_w = $water_info[0];
			$water_h = $water_info[1];

			switch($water_info[2]){
				case 1:
					$water_im = imagecreatefromgif($waterImage);
					break;
				case 2:
					$water_im = imagecreatefromjpeg($waterImage);
					break;
				case 3:
					$water_im = imagecreatefrompng($waterImage);
					break;
				default:
					return false;
			}
			if(($ground_w<$water_w)||($ground_h<$water_h)){return false;}
			imagecopy($ground_im, $water_im, 0, 0, 0, 0, $water_w, $water_h);
			break;
		}

		//@unlink($groundImage);
		switch($ground_info[2]){
			case 1:
				imagegif($ground_im,$groundImage);
				break;
			case 2:
				imagejpeg($ground_im,$groundImage);
				break;
			case 3:
				imagepng($ground_im,$groundImage);
				break;
		}

		if(isset($water_info)) unset($water_info);
		if(isset($water_im)) imagedestroy($water_im);
		unset($ground_info);
		imagedestroy($ground_im);
		break;

	default:
		break;
	}
	return true;
}

function makeImageSLT($s_Path, $s_File, $s_SmallFile){
	if($GLOBALS["nSLTFlag"] == 0){echo("aaa");return false;}
	if(!isValidSLTSYExt($s_File)){echo("bbb");return false;}

	switch($GLOBALS["nSLTSYObject"]){
	case 0:
		$s_Ext = substr(strrchr($s_File, "."), 1);
		switch($s_Ext){
		case "png":
			$im = imagecreatefrompng($s_Path.$s_File);
			break;
		case "gif":
			$im = imagecreatefromgif($s_Path.$s_File);
			break;
		default:
			$im = imagecreatefromjpeg($s_Path.$s_File);
			break;
		}
		if(!$im){return false;}

		$n_OriginalWidth = imagesx($im);
		$n_OriginalHeight = imagesy($im);
		if(($n_OriginalWidth < $GLOBALS["nSLTMinSize"]) && ($n_OriginalHeight < $GLOBALS["nSLTMinSize"])) {return false;}
		if($n_OriginalWidth > $n_OriginalHeight){
			$n_Width = $GLOBALS["nSLTOkSize"];
			$n_Height = ($GLOBALS["nSLTOkSize"] / $n_OriginalWidth) * $n_OriginalHeight;
		}else{
			$n_Height = $GLOBALS["nSLTOkSize"];
			$n_Width = ($GLOBALS["nSLTOkSize"] / $n_OriginalHeight) * $n_OriginalWidth;
		}
		if(function_exists("imagecopyresampled")){
			$newim = imagecreatetruecolor($n_Width, $n_Height);
			imagecopyresampled($newim, $im, 0, 0, 0, 0, $n_Width, $n_Height, $n_OriginalWidth, $n_OriginalHeight);
		}else{
			$newim = imagecreate($n_Width, $n_Height);
			imagecopyresized($newim, $im, 0, 0, 0, 0, $n_Width, $n_Height, $n_OriginalWidth, $n_OriginalHeight);
		}
		
		switch($s_Ext){
		case "png":
			imagepng($newim,$s_Path.$s_SmallFile);
			break;
		case "gif":
			imagegif($newim,$s_Path.$s_SmallFile);
			break;
		default:
			imagejpeg($newim,$s_Path.$s_SmallFile);
			break;
		}

		imagedestroy($newim);
		imagedestroy($im);
		break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -