当前位置: 首页>>代码示例>>PHP>>正文


PHP RemoveScriptExtension函数代码示例

本文整理汇总了PHP中RemoveScriptExtension函数的典型用法代码示例。如果您正苦于以下问题:PHP RemoveScriptExtension函数的具体用法?PHP RemoveScriptExtension怎么用?PHP RemoveScriptExtension使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了RemoveScriptExtension函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: transformName

 protected function transformName($name, $bForceMD5 = false, $bSkipExt = false)
 {
     //safe filename without path
     $fileName = GetFileName($name);
     $originalName = $bForceMD5 != true && COption::GetOptionString("main", "save_original_file_name", "N") == "Y";
     if ($originalName) {
         //transforming original name:
         //transliteration
         if (COption::GetOptionString("main", "translit_original_file_name", "N") == "Y") {
             $fileName = CUtil::translit($fileName, LANGUAGE_ID, array("max_len" => 1024, "safe_chars" => ".", "replace_space" => '-'));
         }
         //replace invalid characters
         if (COption::GetOptionString("main", "convert_original_file_name", "Y") == "Y") {
             $io = CBXVirtualIo::GetInstance();
             $fileName = $io->RandomizeInvalidFilename($fileName);
         }
     }
     //double extension vulnerability
     $fileName = RemoveScriptExtension($fileName);
     //safe extention without "."
     $fileExt = GetFileExtension($fileName);
     if (!$originalName) {
         //name is md5-generated:
         $fileName = md5(uniqid("", true)) . ($bSkipExt == true ? '' : "." . $fileExt);
     }
     //.jpe is not image type on many systems
     if ($bSkipExt == false && strtolower($fileExt) == "jpe") {
         $fileName = substr($fileName, 0, -4) . ".jpg";
     }
     return $fileName;
 }
开发者ID:spas-viktor,项目名称:books,代码行数:31,代码来源:file.php

示例2: validateFile

 protected function validateFile(&$strFileName, $arFile, $bForceMD5 = false)
 {
     $strFileName = GetFileName($arFile["name"]);
     //File is going to be deleted
     if (isset($arFile["del"]) && $arFile["del"] != "") {
         //There is no new file as replacement
         if ($strFileName == "") {
             return "";
         }
     }
     if ($arFile["name"] == "") {
         return "";
     }
     if (COption::GetOptionInt("main", "disk_space") > 0) {
         $quota = new CDiskQuota();
         if (!$quota->checkDiskQuota($arFile)) {
             return GetMessage("FILE_BAD_QUOTA");
         }
     }
     $io = CBXVirtualIo::GetInstance();
     if ($bForceMD5 != true && COption::GetOptionString("main", "save_original_file_name", "N") == "Y") {
         if (COption::GetOptionString("main", "translit_original_file_name", "N") == "Y") {
             $strFileName = CUtil::translit($strFileName, LANGUAGE_ID, array("max_len" => 1024, "safe_chars" => ".", "replace_space" => '-'));
         }
         if (COption::GetOptionString("main", "convert_original_file_name", "Y") == "Y") {
             $strFileName = $io->RandomizeInvalidFilename($strFileName);
         }
     }
     if (!$io->ValidateFilenameString($strFileName)) {
         return GetMessage("MAIN_BAD_FILENAME1");
     }
     //check for double extension vulnerability
     $strFileName = RemoveScriptExtension($strFileName);
     if ($strFileName == '') {
         return GetMessage("FILE_BAD_FILENAME");
     }
     if (strlen($strFileName) > 255) {
         return GetMessage("MAIN_BAD_FILENAME_LEN");
     }
     //check .htaccess etc.
     if (IsFileUnsafe($strFileName)) {
         return GetMessage("FILE_BAD_TYPE");
     }
     //nginx returns octet-stream for .jpg
     if (GetFileNameWithoutExtension($strFileName) == '') {
         return GetMessage("FILE_BAD_FILENAME");
     }
     return "";
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:49,代码来源:file.php

示例3: __construct

 public function __construct($pzipname)
 {
     $this->io = CBXVirtualIo::GetInstance();
     //protecting against creating malicious php file with gzdeflate
     $pzipname = GetDirPath($this->_convertWinPath($pzipname, false)) . $this->io->RandomizeInvalidFilename(GetFileName($pzipname));
     if (HasScriptExtension($pzipname)) {
         $pzipname = RemoveScriptExtension($pzipname) . ".zip";
     }
     $this->zipname = $pzipname;
     $this->step_time = 30;
     $this->arPackedFiles = array();
     $this->_errorReset();
     $this->fileSystemEncoding = $this->_getfileSystemEncoding();
     self::$bMbstring = extension_loaded("mbstring");
     return;
 }
开发者ID:spas-viktor,项目名称:books,代码行数:16,代码来源:zip.php

示例4: htmlspecialcharsbx

    $arLang[$res["LID"]] = $res;
    $arLangTitle["reference_id"][] = $res["LID"];
    $arLangTitle["reference"][] = htmlspecialcharsbx($res["NAME"]);
}
$bInitVars = false;
/********************************************************************
				/Input params
********************************************************************/
$APPLICATION->SetTitle($ID > 0 ? GetMessage("FORUM_EDIT_RECORD", array("#ID#" => $ID)) : GetMessage("FORUM_NEW_RECORD"));
/********************************************************************
				Action
********************************************************************/
$fileName = '';
if ($REQUEST_METHOD == "POST" && $forumPermissions >= "W" && (strlen($save) > 0 || strlen($apply) > 0)) {
    if (isset($_FILES["IMAGE"]["name"])) {
        $fileName = RemoveScriptExtension($_FILES["IMAGE"]["name"]);
    }
    if (!check_bitrix_sessid()) {
        $arError[] = array("id" => "bad_sessid", "text" => GetMessage("ERROR_BAD_SESSID"));
    } elseif ($ID > 0 && !CForumNew::CanUserUpdateForum($ID, $USER->GetUserGroupArray(), $USER->GetID())) {
        $arError[] = array("id" => "not_right_for_edit", "text" => GetMessage("FE_NO_PERMS2UPDATE"));
    } elseif ($ID <= 0 && !CForumNew::CanUserAddForum($USER->GetUserGroupArray(), $USER->GetID())) {
        $arError[] = array("id" => "not_right_for_add", "text" => GetMessage("FE_NO_PERMS2ADD"));
    } elseif (!empty($_FILES["IMAGE"]["tmp_name"])) {
        $sUploadDir = $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/images/forum/" . ($_REQUEST["TYPE"] == "I" ? "icon" : "smile") . "/";
        CheckDirPath($sUploadDir);
        $arSmile = $ID > 0 ? CForumSmile::GetByID($ID) : $arSmile;
        $res = CFile::CheckImageFile($_FILES["IMAGE"], COption::GetOptionString("forum", "file_max_size", 50000), 0, 0);
        if (strLen($res) > 0) {
            $arError[] = array("id" => "IMAGE", "text" => $res);
        } elseif (file_exists($sUploadDir . $fileName) && !(isset($arSmile["IMAGE"]) && $arSmile["IMAGE"] != $fileName)) {
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:smile_edit.php

示例5: OnFileSave

 public static function OnFileSave(&$arFile, $strFileName, $strSavePath, $bForceMD5 = false, $bSkipExt = false)
 {
     if (!$arFile["tmp_name"] && !array_key_exists("content", $arFile)) {
         return false;
     }
     if (array_key_exists("bucket", $arFile)) {
         $bucket = $arFile["bucket"];
     } else {
         $bucket = CCloudStorage::FindBucketForFile($arFile, $strFileName);
     }
     if (!is_object($bucket)) {
         return false;
     }
     if (!$bucket->Init()) {
         return false;
     }
     $copySize = false;
     $subDir = "";
     $filePath = "";
     if (array_key_exists("content", $arFile)) {
         $arFile["tmp_name"] = CTempFile::GetFileName($arFile["name"]);
         CheckDirPath($arFile["tmp_name"]);
         $fp = fopen($arFile["tmp_name"], "ab");
         if ($fp) {
             fwrite($fp, $arFile["content"]);
             fclose($fp);
         }
     }
     if (array_key_exists("bucket", $arFile)) {
         $newName = bx_basename($arFile["tmp_name"]);
         $prefix = $bucket->GetFileSRC("/");
         $subDir = substr($arFile["tmp_name"], strlen($prefix));
         $subDir = substr($subDir, 0, -strlen($newName) - 1);
     } else {
         if ($bForceMD5 != true && COption::GetOptionString("main", "save_original_file_name", "N") == "Y") {
             if (COption::GetOptionString("main", "convert_original_file_name", "Y") == "Y") {
                 $newName = CCloudStorage::translit($strFileName);
             } else {
                 $newName = $strFileName;
             }
         } else {
             $strFileExt = $bSkipExt == true ? '' : strrchr($strFileName, ".");
             $newName = md5(uniqid(mt_rand(), true)) . $strFileExt;
         }
         //check for double extension vulnerability
         $newName = RemoveScriptExtension($newName);
         while (true) {
             $strRand = md5(mt_rand());
             $strRand = substr($strRand, 0, 3) . "/" . $strRand;
             if (substr($strSavePath, -1) == "/") {
                 $subDir = $strSavePath . $strRand;
             } else {
                 $subDir = $strSavePath . "/" . $strRand;
             }
             $subDir = ltrim($subDir, "/");
             $filePath = "/" . $subDir . "/" . $newName;
             if (!$bucket->FileExists($filePath)) {
                 break;
             }
         }
         $targetPath = $bucket->GetFileSRC("/");
         if (strpos($arFile["tmp_name"], $targetPath) === 0) {
             $arDbFile = array("SUBDIR" => "", "FILE_NAME" => substr($arFile["tmp_name"], strlen($targetPath)), "CONTENT_TYPE" => $arFile["type"]);
             $copyPath = $bucket->FileCopy($arDbFile, $filePath);
             if (!$copyPath) {
                 return false;
             }
             $copySize = $bucket->GetFileSize("/" . urldecode(substr($copyPath, strlen($targetPath))));
         } else {
             $imgArray = CFile::GetImageSize($arFile["tmp_name"], true, false);
             if (is_array($imgArray) && $imgArray[2] == IMAGETYPE_JPEG) {
                 $exifData = CFile::ExtractImageExif($arFile["tmp_name"]);
                 if ($exifData && isset($exifData['Orientation'])) {
                     $properlyOriented = CFile::ImageHandleOrientation($exifData['Orientation'], $arFile["tmp_name"]);
                     if ($properlyOriented) {
                         $jpgQuality = intval(COption::GetOptionString('main', 'image_resize_quality', '95'));
                         if ($jpgQuality <= 0 || $jpgQuality > 100) {
                             $jpgQuality = 95;
                         }
                         imagejpeg($properlyOriented, $arFile["tmp_name"], $jpgQuality);
                     }
                 }
             }
             if (!$bucket->SaveFile($filePath, $arFile)) {
                 return false;
             }
         }
     }
     $arFile["HANDLER_ID"] = $bucket->ID;
     $arFile["SUBDIR"] = $subDir;
     $arFile["FILE_NAME"] = $newName;
     $arFile["WIDTH"] = 0;
     $arFile["HEIGHT"] = 0;
     if (array_key_exists("bucket", $arFile)) {
         $arFile["WIDTH"] = $arFile["width"];
         $arFile["HEIGHT"] = $arFile["height"];
         $arFile["size"] = $arFile["file_size"];
     } elseif ($copySize !== false) {
         $arFile["size"] = $copySize;
         $bucket->IncFileCounter($copySize);
//.........这里部分代码省略.........
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:storage.php

示例6: Request

    public static function Request($action, $site)
    {
        global $USER;
        if (!$USER->CanDoOperation('fileman_view_file_structure')) {
            return;
        }
        $io = CBXVirtualIo::GetInstance();
        CUtil::JSPostUnescape();
        switch ($action) {
            case "count":
            case "search":
            case "replace":
                $oSearch = new CFilemanSearch();
                $oSearch->Init(array('lastPath' => isset($_POST['last_path']) ? $_POST['last_path'] : false, 'bCount' => $action == "count", 'bReplace' => $action == "replace", "fileName" => trim($_POST['file']), "phrase" => trim($_POST['phrase']), "replacePhrase" => trim($_POST['replace_phrase']), "dir" => CFilemanUtils::NormalizePath($_POST['dir']), "bSubdir" => $_POST['subdir'], "dateFrom" => $_POST['date_from'], "dateTo" => $_POST['date_to'], "sizeFrom" => intVal($_POST['size_from']), "sizeTo" => intVal($_POST['size_to']), "entire" => $_POST['entire'], "bCaseSens" => $_POST['case_sens'], "bDirsToo" => $_POST['dirs_too'], "ssess" => $_POST['ssess'], "bInResult" => $_POST['in_result'], "site" => CFileMan::__CheckSite($_GET['fu_site'])));
                CFileMan::SaveLastPath(CFilemanUtils::NormalizePath($_POST['dir']));
                break;
            case "clean_old":
                CFilemanSearch::CleanOldSearchResult();
                break;
            case "search_save_config":
                CFilemanSearch::SaveConfig(array("advMode" => (bool) $_POST['adv_mode'], "bSubdir" => (bool) $_POST['subdir'], "entire" => (bool) $_POST['entire'], "bCaseSens" => (bool) $_POST['case_sens'], "bDirsToo" => (bool) $_POST['dirs_too']));
                break;
            case "copy_save_config":
                CFilemanCopy::SaveConfig(array("advMode" => (bool) $_POST['adv_mode'], "caseOption" => $_POST['case_option']));
                break;
            case "copy":
            case "move":
                $oCopy = new CFilemanCopy();
                $oCopy->Init(array("bCopy" => $action == "copy", "caseOption" => $_POST['case_option'], "arFiles" => $_POST['files'], "copyTo" => $_POST['copy_to'], "createCopyTo" => $_POST['create_copy_to'] == "Y", "userCaseAnswer" => isset($_POST['uc_answer']) ? $_POST['uc_answer'] : false, "userCaseToAll" => isset($_POST['uc_to_all']) ? $_POST['uc_to_all'] : false, "userCaseLastPath" => isset($_POST['uc_last_path']) ? $_POST['uc_last_path'] : false, "bSearch" => $_POST['search'] == "Y", "ssess" => $_POST['ssess'], "siteTo" => CFileMan::__CheckSite($_GET['fu_site'])));
                CFileMan::SaveLastPath($_POST['copy_to']);
                break;
            case "get_last_pathes":
                ?>
				<script>window.bx_last_pathes = <?php 
                echo CUtil::PhpToJSObject(CFilemanUtils::GetLastPathes());
                ?>
;</script>
				<?php 
                break;
            case "pack":
                if (isset($_POST["startFile"])) {
                    $startFile = trim($_POST["startFile"]);
                }
                if (isset($_POST["quickPath"])) {
                    $quickPath = trim($_POST["quickPath"]);
                }
                if (isset($_POST["packTo"])) {
                    if (substr($_POST["packTo"], 0, 1) == "/") {
                        $pack_to = $_POST["packTo"];
                    } else {
                        $pack_to = "/" . $_POST["packTo"];
                    }
                }
                $siteTo = CFileMan::__CheckSite($_POST['siteTo']);
                $docRootTo = CSite::GetSiteDocRoot($siteTo) ? CSite::GetSiteDocRoot($siteTo) : '';
                $siteFrom = CFileMan::__CheckSite($site);
                $docRootFrom = CSite::GetSiteDocRoot($siteFrom);
                if (!$USER->IsAdmin()) {
                    $pack_to = RemoveScriptExtension($pack_to);
                }
                //check writing permissions
                if (!$USER->CanDoFileOperation('fm_create_new_file', array($siteTo, $pack_to))) {
                    ?>
					<script>
						window.BXFM_archivePermsError = true;
					</script>
					<?php 
                    return;
                }
                if (IsFileUnsafe($docRootTo . $pack_to) || CFileMan::CheckFileName(GetFileName($pack_to)) !== true) {
                    ?>
					<script>
						window.BXFM_archiveFNameError = true;
					</script>
					<?php 
                    return;
                }
                //ask if the file already exists
                if (file_exists($io->GetPhysicalName($docRootTo . $pack_to))) {
                    if (empty($startFile)) {
                        if ($_POST["bPackReplace"] != "replace") {
                            ?>
							<script>
								window.BXFM_archiveExists = {
									fileOld:
									{
										name: "<?php 
                            echo CUtil::JSEscape(basename($pack_to));
                            ?>
",
										path: "<?php 
                            echo CUtil::JSEscape($pack_to);
                            ?>
",
										site: "<?php 
                            echo CUtil::JSEscape($siteTo);
                            ?>
",
										size: "<?php 
                            echo CFile::FormatSize(filesize($io->GetPhysicalName($docRootTo . $pack_to)));
//.........这里部分代码省略.........
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:101,代码来源:fileman_utils.php

示例7: OnFileSave

	function OnFileSave(&$arFile, $strFileName, $strSavePath, $bForceMD5 = false, $bSkipExt = false)
	{
		if(!$arFile["tmp_name"] && !$arFile["content"])
			return false;

		if(array_key_exists("bucket", $arFile))
			$bucket = $arFile["bucket"];
		else
			$bucket = CCloudStorage::FindBucketForFile($arFile, $strFileName);

		if(!is_object($bucket))
			return false;

		if(!$bucket->Init())
			return false;

		if(array_key_exists("bucket", $arFile))
		{
			$newName = bx_basename($arFile["tmp_name"]);

			$prefix = $bucket->GetFileSRC("/");
			$subDir = substr($arFile["tmp_name"], strlen($prefix));
			$subDir = substr($subDir, 0, -strlen($newName)-1);
		}
		else
		{
			if(
				$bForceMD5 != true
				&& COption::GetOptionString("main", "save_original_file_name", "N")=="Y"
			)
			{
				if(COption::GetOptionString("main", "convert_original_file_name", "Y")=="Y")
					$newName = CCloudStorage::translit($strFileName);
				else
					$newName = $strFileName;
			}
			else
			{
				$strFileExt = ($bSkipExt == true? '' : strrchr($strFileName, "."));
				$newName = md5(uniqid(mt_rand(), true)).$strFileExt;
			}

			//check for double extension vulnerability
			$newName = RemoveScriptExtension($newName);

			while(true)
			{
				$strRand = md5(mt_rand());
				$strRand = substr($strRand, 0, 3)."/".$strRand;

				if(substr($strSavePath, -1) == "/")
					$subDir = $strSavePath.$strRand;
				else
					$subDir = $strSavePath."/".$strRand;
				$subDir = ltrim($subDir, "/");

				$filePath = "/".$subDir."/".$newName;

				if(!$bucket->FileExists($filePath))
					break;
			}

			if(!$bucket->SaveFile($filePath, $arFile))
				return false;
		}

		$arFile["HANDLER_ID"] = $bucket->ID;
		$arFile["SUBDIR"] = $subDir;
		$arFile["FILE_NAME"] = $newName;

		$arFile["WIDTH"] = 0;
		$arFile["HEIGHT"] = 0;
		if(array_key_exists("bucket", $arFile))
		{
			$arFile["WIDTH"] = $arFile["width"];
			$arFile["HEIGHT"] = $arFile["height"];
			$arFile["size"] = $arFile["file_size"];
		}
		elseif(array_key_exists("content", $arFile))
		{
			$tmp_name = tempnam();
			$fp = fopen($tmp_name, "ab");
			if($fp)
			{
				if(fwrite($fp, $arFile["content"]))
				{
					$bucket->IncFileCounter(filesize($tmp_name));
					$imgArray = CFile::GetImageSize($tmp_name);
					if(is_array($imgArray))
					{
						$arFile["WIDTH"] = $imgArray[0];
						$arFile["HEIGHT"] = $imgArray[1];
					}
				}
				fclose($fp);
				unlink($tmp_name);
			}
		}
		else
		{
//.........这里部分代码省略.........
开发者ID:nProfessor,项目名称:Mytb,代码行数:101,代码来源:storage.php

示例8: CheckImageFile

	function CheckImageFile($arFile, $iMaxSize=0, $iMaxWidth=0, $iMaxHeight=0, $access_typies=array())
	{
		if(strlen($arFile["name"])<=0)
			return "";

		if(GetFileNameWithoutExtension(RemoveScriptExtension($arFile["name"])) == '')
			return GetMessage("FILE_BAD_FILENAME");

		$file_type = GetFileType($arFile["name"]);
		// если тип файла не входит в массив допустимых типов то
		// присваиваем ему тип IMAGE по умолчанию
		if(!in_array($file_type, $access_typies))
			$file_type = "IMAGE";

		switch ($file_type)
		{
			case "FLASH":
				$res = CFile::CheckFile($arFile, $iMaxSize, "application/x-shockwave-flash", CFile::GetFlashExtensions());
				break;
			default:
				$res = CFile::CheckFile($arFile, $iMaxSize, "image/", CFile::GetImageExtensions());
		}

		if(strlen($res)>0)
			return $res;

		$imgArray = CFile::GetImageSize($arFile["tmp_name"]);

		if(is_array($imgArray))
		{
			$intWIDTH = $imgArray[0];
			$intHEIGHT = $imgArray[1];
		}
		else
			return GetMessage("FILE_BAD_FILE_TYPE").".<br>";

		//проверка на максимальный размер картинки (ширина/высота)
		if($iMaxWidth > 0 && ($intWIDTH > $iMaxWidth || $intWIDTH == 0) || $iMaxHeight > 0 && ($intHEIGHT > $iMaxHeight || $intHEIGHT == 0))
			return GetMessage("FILE_BAD_MAX_RESOLUTION")." (".$iMaxWidth." * ".$iMaxHeight." ".GetMessage("main_include_dots").").<br>";

		return null;
	}
开发者ID:nProfessor,项目名称:Mytb,代码行数:42,代码来源:file.php


注:本文中的RemoveScriptExtension函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。