• Модуль: advertising
  • Путь к файлу: ~/bitrix/modules/advertising/classes/general/advertising.php
  • Класс: CAdvBanner_all
  • Вызов: CAdvBanner_all::CheckFile
static function CheckFile($arFile, $iMaxSize=0, $iMaxWidth=0, $iMaxHeight=0, $access_typies=array(), $bForceMD5=false, $bSkipExt=false)
{
	if ($arFile["name"] == "")
	{
		return "";
	}

	if (preg_match("#^php://filter#i", $arFile["tmp_name"]))
	{
		return GetMessage("FILE_BAD_FILE_TYPE").".
"; } $extension = GetFileExtension(mb_strtolower($arFile["name"])); switch ($extension) { case "jpg": case "jpeg": case "gif": case "bmp": case "png": $file_type = "IMAGE"; break; case "swf": $file_type = "FLASH"; break; case "mp4": case "webm": case "ogg": $file_type = "VIDEO"; break; default: $file_type = "UNKNOWN"; } // IMAGE by default $flashEnabled = false; if(!in_array($file_type, $access_typies)) { $file_type = "IMAGE"; } if ($file_type == "FLASH") { $flashEnabled = true; static $flashMime = array("application/x-shockwave-flash", "application/vnd.adobe.flash.movie"); $res = CFile::CheckFile($arFile, $iMaxSize, $flashMime, CFile::GetFlashExtensions(), $bForceMD5, $bSkipExt); } else if ($file_type == "VIDEO") { $res = CFile::CheckFile($arFile, $iMaxSize, "video/", "mp4,webm,ogg", $bForceMD5, $bSkipExt); } else { $res = CFile::CheckFile($arFile, $iMaxSize, "image/", CFile::GetImageExtensions(), $bForceMD5, $bSkipExt); } if($res <> '') { return $res; } if ($file_type == 'IMAGE' || $file_type == "FLASH") { $imgArray = CFile::GetImageSize($arFile["tmp_name"], true, $flashEnabled); if(is_array($imgArray)) { $intWIDTH = $imgArray[0]; $intHEIGHT = $imgArray[1]; } else { return GetMessage("FILE_BAD_FILE_TYPE").".
"; } //check for dimensions 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").").
"; } } return null; }