function DoSave() { echo "<html><head><title>eWebEditor</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'></head><body>"; if ($_FILES['uploadfile']['error'] > 0) { switch ((int) $_FILES['uploadfile']['error']) { case UPLOAD_ERR_NO_FILE: OutScript("parent.UploadError('file')"); break; case UPLOAD_ERR_FORM_SIZE: OutScript("parent.UploadError('size')"); break; } exit; } preg_match("/\\.([a-zA-Z0-9]{2,4})\$/", $_FILES['uploadfile']['name'], $exts); if (!IsValidExt($exts[1])) { OutScript("parent.UploadError('ext')"); exit; } $GLOBALS["sSaveFileName"] = GetRndFileName(strtolower($exts[1])); $GLOBALS["sOriginalFileName"] = $_FILES['uploadfile']['name']; //$sFileName = str_replace('\\','\\\\',realpath($GLOBALS["sUploadDir"]))."/"; $sFileName = $GLOBALS["sUploadDir"] . $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;if((!obj.eWebEditor)||(!obj.eWebEditor_Temp_HTML)||(!obj.eWebEditor_UploadForm)){obj=parent.dialogArguments.dialogArguments;} try{obj.addUploadFile('" . $GLOBALS["sOriginalFileName"] . "', '" . $GLOBALS["sSaveFileName"] . "', '" . $GLOBALS["sPathFileName"] . "');} catch(e){} " . $s_SmallImageScript); }
function ReplaceRemoteUrl($sHTML, $sExt) { $s_Content = $sHTML; $s_Match = "/(http|https|ftp|rtsp|mms):(\\/\\/|\\\\){1}(([A-Za-z0-9_-])+[.]){1,}([A-Za-z0-9]{1,5})\\/(\\S+\\.(" . $sExt . "))/i"; if (!preg_match_all($s_Match, $s_Content, $a_Matches)) { return $s_Content; } $s_SameSiteDomain = ""; if ($GLOBALS["sBaseUrl"] == "3") { $s_SameSiteDomain = GetDomainFromUrl($GLOBALS["sSetContentPath"]); } else { $s_SameSiteDomain = strtolower($_SERVER["SERVER_NAME"]); } for ($i = 0; $i < count($a_Matches[0]); $i++) { $s = $a_Matches[0][$i]; $b_SameSiteUrl = false; if (GetDomainFromUrl($s) == $s_SameSiteDomain) { $b_SameSiteUrl = true; } if (!$b_SameSiteUrl) { $a_RepeatRemote[] = $s; } } $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])) { makeImageSY($GLOBALS["sUploadDir"], $SaveFileName); $nFileNum = $nFileNum + 1; if ($nFileNum > 1) { $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; }