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

📄 upload.php

📁 asp商城模板。前后台都有。能更换模板。asp+a
💻 PHP
📖 第 1 页 / 共 2 页
字号:

	default:
		break;
	}

	return true;
}



function isValidSLTSYExt($s_File){
	$sExt = substr(strrchr($s_File, "."), 1);
	$aExt = explode('|',strtoupper($GLOBALS["sSLTSYExt"]));
	if(!in_array(strtoupper($sExt),$aExt)){
		return false;
	}
	return true;
}

function getSmallImageFile($s_File){
	$exts = explode(".",$s_File);
	return $exts[0]."_s.".$exts[1];
}

function DoRemote(){
	if (isset($_POST["eWebEditor_UploadText"])){
		$sContent = stripslashes($_POST["eWebEditor_UploadText"]);
	}else{
		$sContent = "";
	}
	If (($GLOBALS["sAllowExt"] != "")&&($sContent!="")) {
		$sContent = ReplaceRemoteUrl($sContent, $GLOBALS["sAllowExt"]);
	}

	echo "<HTML><HEAD><TITLE>eWebEditor</TITLE><meta http-equiv='Content-Type' content='text/html; charset=utf-8'></head><body>".
		"<input type=hidden id=UploadText value=\"".htmlspecialchars($sContent)."\">".
		"</body></html>";

	OutScriptNoBack("parent.setHTML(UploadText.value);try{parent.addUploadFile('".$GLOBALS["sOriginalFileName"]."', '".$GLOBALS["sSaveFileName"]."', '".$GLOBALS["sPathFileName"]."');} catch(e){} parent.remoteUploadOK();");

}


function DoCreateNewDir(){
	switch ($GLOBALS["nAutoDir"]){
	Case 1:
		$sCreateDir = date("Y");
		break;
	Case 2:
		$sCreateDir = date("Ym");
		break;
	Case 3:
		$sCreateDir = date("Ymd");
		break;
	default:
		return;
	}
	$GLOBALS["sUploadDir"] = $GLOBALS["sUploadDir"].$sCreateDir."/";
	$GLOBALS["sContentPath"] = $GLOBALS["sContentPath"].$sCreateDir."/";
	
	mkdir_p($GLOBALS["sUploadDir"]);

}

function mkdir_p($target){
	if (is_dir($target)||empty($target)) return 1;
	if (file_exists($target) && !is_dir($target)) return 0;
	if (mkdir_p(substr($target,0,strrpos($target,'/'))))
		return mkdir($target);
	return 0;
}

function GetRndFileName($sExt){
	return date("YmdHis").rand(1,999).".".$sExt;
}

function  OutScriptNoBack($str){
	echo "<script language=javascript>".$str."</script>";
}

function OutScript($str){
	echo "<script language=javascript>".$str.";history.back()</script>";
}

function CheckValidExt($sExt){
	$aExt = explode('|',$GLOBALS["sAllowExt"]);
	if(!in_array(strtoupper($sExt),$aExt)){
		OutScript("parent.UploadError('lang[\"ErrUploadInvalidExt\"]+\":".$GLOBALS["sAllowExt"]."\"')");
		exit;
	}
}

function  InitUpload(){
	global $sType, $sStyleName, $sLanguage;
	global $sAllowExt, $nAllowSize, $sUploadDir, $nUploadObject, $nAutoDir, $sBaseUrl, $sContentPath;
	global $sFileExt, $sOriginalFileName, $sSaveFileName, $sPathFileName, $nFileNum;
	global $nSLTFlag, $nSLTMinSize, $nSLTOkSize, $nSYFlag, $sSYText, $sSYFontColor, $nSYFontSize, $sSYFontName, $sSYPicPath, $nSLTSYObject, $sSLTSYExt, $nSYMinSize, $sSYShadowColor, $nSYShadowOffset;

	$sType = toTrim("type");
	$sStyleName = toTrim("style");
	$sLanguage = toTrim("language");

	$bValidStyle = false;
	$numElements = count($GLOBALS["aStyle"]);
	for($i=1; $i<=$numElements; $i++){
		$aStyleConfig = explode("|||", $GLOBALS["aStyle"][$i]);
		if (strtolower($sStyleName)==strtolower($aStyleConfig[0])){
			$bValidStyle = true;
			break;
		}
	}

	if ($bValidStyle == false) {
		OutScript("parent.UploadError('lang[\"ErrInvalidStyle\"]')");
	}

	$sBaseUrl = $aStyleConfig[19];
	$nUploadObject = (int)$aStyleConfig[20];
	$nAutoDir = (int)$aStyleConfig[21];

	$sUploadDir = $aStyleConfig[3];
	if (substr($sUploadDir, 0, 1) != "/"){
		$sUploadDir = "../".$sUploadDir;
	}

	switch ($sBaseUrl){
	case "0":
		$sContentPath = $aStyleConfig[23];
		break;
	case "1":
		$sContentPath = RelativePath2RootPath($sUploadDir);
		break;
	case "2":
		$sContentPath = RootPath2DomainPath(RelativePath2RootPath($sUploadDir));
		break;
	}

	switch (strtoupper($sType)){
	case "REMOTE":
		$sAllowExt = $aStyleConfig[10];
		$nAllowSize = (int)$aStyleConfig[15];
		break;
	case "FILE":
		$sAllowExt = $aStyleConfig[6];
		$nAllowSize = (int)$aStyleConfig[11];
		break;
	case "MEDIA":
		$sAllowExt = $aStyleConfig[9];
		$nAllowSize = (int)$aStyleConfig[14];
		break;
	case "FLASH":
		$sAllowExt = $aStyleConfig[7];
		$nAllowSize = (int)$aStyleConfig[12];
		break;
	default:
		$sAllowExt = $aStyleConfig[8];
		$nAllowSize = (int)$aStyleConfig[13];
		break;
	}

	$sAllowExt = strtoupper($sAllowExt);

	$nSLTFlag = (int)$aStyleConfig[29];
	$nSLTMinSize = (int)$aStyleConfig[30];
	$nSLTOkSize = (int)$aStyleConfig[31];
	$nSYFlag = (int)$aStyleConfig[32];
	$sSYText = $aStyleConfig[33];
	$sSYFontColor = $aStyleConfig[34];
	$nSYFontSize = (int)$aStyleConfig[35];
	$sSYFontName = $aStyleConfig[36];
	$sSYPicPath = $aStyleConfig[37];
	$nSLTSYObject = (int)$aStyleConfig[38];
	$sSLTSYExt = $aStyleConfig[39];
	$nSYMinSize = (int)$aStyleConfig[40];
	$sSYShadowColor = $aStyleConfig[41];
	$nSYShadowOffset = (int)$aStyleConfig[42];

}

function toTrim($p){
	if (isset($_GET[$p])){
		return trim($_GET[$p]);
	}else{
		return "";
	}
}

function RelativePath2RootPath($url){
	$sTempUrl = $url;
	if (substr($sTempUrl, 0, 1) == "/"){
		return $sTempUrl;
	}

	if (isset($_SERVER["REQUEST_URI"])){
		$sWebEditorPath = $_SERVER["REQUEST_URI"];
	}else{
		$sWebEditorPath = $_SERVER["SCRIPT_NAME"];
	}

	$sWebEditorPath = substr($sWebEditorPath, 0, strrpos($sWebEditorPath, "/"));
	while (substr($sTempUrl, 0, 3) == "../"){
		$sTempUrl = substr($sTempUrl, 3, strlen($sTempUrl));
		$sWebEditorPath = substr($sWebEditorPath, 0, strrpos($sWebEditorPath, "/"));
	}
	return $sWebEditorPath."/".$sTempUrl;
}

function RootPath2DomainPath($url){
	$sProtocol = explode("/", $_SERVER["SERVER_PROTOCOL"]);
	$sHost = strtolower($sProtocol[0])."://".$_SERVER["HTTP_HOST"];
	$sPort = $_SERVER["SERVER_PORT"];
	if ($sPort != "80") {
		$sHost = $sHost.":".$sPort;
	}
	return $sHost.$url;
}

function ReplaceRemoteUrl($sHTML, $sExt){

	$s_Content = $sHTML;
	$s_Match = "/(http|https|ftp|rtsp|mms):(\/\/|\\\\){1}(([A-Za-z0-9_-])+[.]){1,}(net|com|cn|org|cc|tv|[0-9]{1,3})(\S*\/)((\S)+[.]{1}(".$sExt."))/i";
	if (!preg_match_all($s_Match, $s_Content, $a_Matches)){
		return $s_Content;
	};

	for ($i=0; $i< count($a_Matches[0]); $i++) {
		$a_RepeatRemote[] = $a_Matches[0][$i];
	}
	$a_RemoteUrl = array_unique($a_RepeatRemote);


	$nFileNum = 0;
	for ($i=0; $i< count($a_RemoteUrl); $i++) {

		$SaveFileType = substr($a_RemoteUrl[$i], strrpos($a_RemoteUrl[$i], ".") + 1);
		$SaveFileName = GetRndFileName($SaveFileType);

		if (SaveRemoteFile($SaveFileName, $a_RemoteUrl[$i])) {
			$nFileNum = $nFileNum + 1;
			if ($nFileNum > 0) {
				$GLOBALS["sOriginalFileName"] .= "|";
				$GLOBALS["sSaveFileName"] .= "|";
				$GLOBALS["sPathFileName"] .= "|";
			}
			$GLOBALS["sOriginalFileName"] .= substr($a_RemoteUrl[i], strrpos($a_RemoteUrl[i], "/") + 1);
			$GLOBALS["sSaveFileName"] .= $SaveFileName;
			$GLOBALS["sPathFileName"] .= $GLOBALS["sContentPath"].$SaveFileName;
			$s_Content = str_replace($a_RemoteUrl[$i], $GLOBALS["sContentPath"].$SaveFileName, $s_Content);
		}
	}

	return $s_Content;
}

function SaveRemoteFile($s_LocalFileName, $s_RemoteFileUrl) { 
	$fp = @fopen($s_RemoteFileUrl, "rb");
	if (!$fp) {return false;}
	$cont = "";
	while(!feof($fp)) {
		$cont.= fread($fp, 2048);
	}
	fclose($fp);

	if (strlen($cont) > $GLOBALS["nAllowSize"]*1024) {
		return false;
	}
	$fp2 = @fopen($GLOBALS["sUploadDir"].$s_LocalFileName,"w");
	fwrite($fp2,$cont);
	fclose($fp2);
	return true;
} 

function gb2utf8($gb){
	if(!trim($gb)){return $gb;}
	$filename="gb2312.txt";
	$tmp=file($filename);
	$codetable=array();
	while(list($key,$value)=each($tmp))
	$codetable[hexdec(substr($value,0,6))]=substr($value,7,6);

	$utf8="";
	while($gb){
		if (ord(substr($gb,0,1))>127){
			$tthis=substr($gb,0,2);
			$gb=substr($gb,2,strlen($gb)-2);
			$utf8.=u2utf8(hexdec($codetable[hexdec(bin2hex($tthis))-0x8080]));
		}else{
			$tthis=substr($gb,0,1);
			$gb=substr($gb,1,strlen($gb)-1);
			$utf8.=u2utf8($tthis);
		}
	}

	return $utf8;
}

function u2utf8($c){
	$str="";
	if ($c < 0x80){
		$str.=$c;
	}else if ($c < 0x800){
		$str.=chr(0xC0 | $c>>6);
		$str.=chr(0x80 | $c & 0x3F);
	}else if ($c < 0x10000){
		$str.=chr(0xE0 | $c>>12);
		$str.=chr(0x80 | $c>>6 & 0x3F);
		$str.=chr(0x80 | $c & 0x3F);
	}else if ($c < 0x200000){
		$str.=chr(0xF0 | $c>>18);
		$str.=chr(0x80 | $c>>12 & 0x3F);
		$str.=chr(0x80 | $c>>6 & 0x3F);
		$str.=chr(0x80 | $c & 0x3F);
	}
	return $str;
}
?>

⌨️ 快捷键说明

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