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

	if (empty($arFile["tmp_name"]))
	{
		return GetMessage("FILE_BAD_FILE_TYPE").".
"; } if (preg_match("#^(php://|phar://)#i", $arFile["tmp_name"])) { return GetMessage("FILE_BAD_FILE_TYPE").".
"; } $file_type = GetFileType($arFile["name"]); // 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 = static::CheckFile($arFile, $iMaxSize, $flashMime, static::GetFlashExtensions(), $bForceMD5, $bSkipExt); } else { $res = static::CheckFile($arFile, $iMaxSize, "image/", static::GetImageExtensions(), $bForceMD5, $bSkipExt); } if($res <> '') { return $res; } $imgInfo = (new FileImage($arFile["tmp_name"]))->getInfo($flashEnabled); if($imgInfo) { $intWIDTH = $imgInfo->getWidth(); $intHEIGHT = $imgInfo->getHeight(); } 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; }