Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace yii\validators; use Yii; use yii\helpers\FileHelper; use yii\helpers\Html..

Decoded Output download

<?php
 namespace yii\validators; use Yii; use yii\helpers\FileHelper; use yii\helpers\Html; use yii\helpers\Json; use yii\helpers\StringHelper; use yii\web\JsExpression; use yii\web\UploadedFile; class FileValidator extends Validator { public $extensions; public $checkExtensionByMimeType = true; public $mimeTypes; public $minSize; public $maxSize; public $maxFiles = 1; public $minFiles = 0; public $message; public $uploadRequired; public $tooBig; public $tooSmall; public $tooMany; public $tooFew; public $wrongExtension; public $wrongMimeType; public function init() { parent::init(); if ($this->message === null) { $this->message = Yii::t("yii", "File upload failed."); } if ($this->uploadRequired === null) { $this->uploadRequired = Yii::t("yii", "Please upload a file."); } if ($this->tooMany === null) { $this->tooMany = Yii::t("yii", "You can upload at most {limit, number} {limit, plural, one{file} other{files}}."); } if ($this->tooFew === null) { $this->tooFew = Yii::t("yii", "You should upload at least {limit, number} {limit, plural, one{file} other{files}}."); } if ($this->wrongExtension === null) { $this->wrongExtension = Yii::t("yii", "Only files with these extensions are allowed: {extensions}."); } if ($this->tooBig === null) { $this->tooBig = Yii::t("yii", "The file "{file}" is too big. Its size cannot exceed {formattedLimit}."); } if ($this->tooSmall === null) { $this->tooSmall = Yii::t("yii", "The file "{file}" is too small. Its size cannot be smaller than {formattedLimit}."); } if (!is_array($this->extensions)) { $this->extensions = preg_split("/[\s,]+/", strtolower((string) $this->extensions), -1, PREG_SPLIT_NO_EMPTY); } else { $this->extensions = array_map("strtolower", $this->extensions); } if ($this->wrongMimeType === null) { $this->wrongMimeType = Yii::t("yii", "Only files with these MIME types are allowed: {mimeTypes}."); } if (!is_array($this->mimeTypes)) { $this->mimeTypes = preg_split("/[\s,]+/", strtolower((string) $this->mimeTypes), -1, PREG_SPLIT_NO_EMPTY); } else { $this->mimeTypes = array_map("strtolower", $this->mimeTypes); } } public function validateAttribute($model, $attribute) { if ($this->maxFiles != 1 || $this->minFiles > 1) { $rawFiles = $model->{$attribute}; if (!is_array($rawFiles)) { $this->addError($model, $attribute, $this->uploadRequired); return; } $files = $this->filterFiles($rawFiles); $model->{$attribute} = $files; if (empty($files)) { $this->addError($model, $attribute, $this->uploadRequired); return; } $filesCount = count($files); if ($this->maxFiles && $filesCount > $this->maxFiles) { $this->addError($model, $attribute, $this->tooMany, array("limit" => $this->maxFiles)); } if ($this->minFiles && $this->minFiles > $filesCount) { $this->addError($model, $attribute, $this->tooFew, array("limit" => $this->minFiles)); } foreach ($files as $file) { $result = $this->validateValue($file); if (!empty($result)) { $this->addError($model, $attribute, $result[0], $result[1]); } } } else { $result = $this->validateValue($model->{$attribute}); if (!empty($result)) { $this->addError($model, $attribute, $result[0], $result[1]); } } } private function filterFiles(array $files) { $result = array(); foreach ($files as $fileName => $file) { if ($file instanceof UploadedFile && $file->error !== UPLOAD_ERR_NO_FILE) { $result[$fileName] = $file; } } return $result; } protected function validateValue($value) { if (!$value instanceof UploadedFile || $value->error == UPLOAD_ERR_NO_FILE) { return array($this->uploadRequired, array()); } switch ($value->error) { case UPLOAD_ERR_OK: if ($this->maxSize !== null && $value->size > $this->getSizeLimit()) { return array($this->tooBig, array("file" => $value->name, "limit" => $this->getSizeLimit(), "formattedLimit" => Yii::$app->formatter->asShortSize($this->getSizeLimit()))); } elseif ($this->minSize !== null && $value->size < $this->minSize) { return array($this->tooSmall, array("file" => $value->name, "limit" => $this->minSize, "formattedLimit" => Yii::$app->formatter->asShortSize($this->minSize))); } elseif (!empty($this->extensions) && !$this->validateExtension($value)) { return array($this->wrongExtension, array("file" => $value->name, "extensions" => implode(", ", $this->extensions))); } elseif (!empty($this->mimeTypes) && !$this->validateMimeType($value)) { return array($this->wrongMimeType, array("file" => $value->name, "mimeTypes" => implode(", ", $this->mimeTypes))); } return null; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: return array($this->tooBig, array("file" => $value->name, "limit" => $this->getSizeLimit(), "formattedLimit" => Yii::$app->formatter->asShortSize($this->getSizeLimit()))); case UPLOAD_ERR_PARTIAL: Yii::warning("File was only partially uploaded: " . $value->name, __METHOD__); break; case UPLOAD_ERR_NO_TMP_DIR: Yii::warning("Missing the temporary folder to store the uploaded file: " . $value->name, __METHOD__); break; case UPLOAD_ERR_CANT_WRITE: Yii::warning("Failed to write the uploaded file to disk: " . $value->name, __METHOD__); break; case UPLOAD_ERR_EXTENSION: Yii::warning("File upload was stopped by some PHP extension: " . $value->name, __METHOD__); break; default: break; } return array($this->message, array()); } public function getSizeLimit() { $limit = $this->sizeToBytes(ini_get("upload_max_filesize")); $postLimit = $this->sizeToBytes(ini_get("post_max_size")); if ($postLimit > 0 && $postLimit < $limit) { Yii::warning("PHP.ini's 'post_max_size' is less than 'upload_max_filesize'.", __METHOD__); $limit = $postLimit; } if ($this->maxSize !== null && $limit > 0 && $this->maxSize < $limit) { $limit = $this->maxSize; } if (isset($_POST["MAX_FILE_SIZE"]) && $_POST["MAX_FILE_SIZE"] > 0 && $_POST["MAX_FILE_SIZE"] < $limit) { $limit = (int) $_POST["MAX_FILE_SIZE"]; } return $limit; } public function isEmpty($value, $trim = false) { $value = is_array($value) ? reset($value) : $value; return !$value instanceof UploadedFile || $value->error == UPLOAD_ERR_NO_FILE; } private function sizeToBytes($sizeStr) { switch (substr($sizeStr, -1)) { case "M": case "m": return (int) $sizeStr * 1048576; case "K": case "k": return (int) $sizeStr * 1024; case "G": case "g": return (int) $sizeStr * 1073741824; default: return (int) $sizeStr; } } protected function validateExtension($file) { $extension = mb_strtolower($file->extension, "UTF-8"); if ($this->checkExtensionByMimeType) { $mimeType = FileHelper::getMimeType($file->tempName, null, false); if ($mimeType === null) { return false; } $extensionsByMimeType = FileHelper::getExtensionsByMimeType($mimeType); if (!in_array($extension, $extensionsByMimeType, true)) { return false; } } if (!empty($this->extensions)) { foreach ((array) $this->extensions as $ext) { if ($extension === $ext || StringHelper::endsWith($file->name, ".{$ext}", false)) { return true; } } return false; } return true; } public function clientValidateAttribute($model, $attribute, $view) { ValidationAsset::register($view); $options = $this->getClientOptions($model, $attribute); return "yii.validation.file(attribute, messages, " . Json::htmlEncode($options) . ");"; } public function getClientOptions($model, $attribute) { $label = $model->getAttributeLabel($attribute); $options = array(); if ($this->message !== null) { $options["message"] = $this->formatMessage($this->message, array("attribute" => $label)); } $options["skipOnEmpty"] = $this->skipOnEmpty; if (!$this->skipOnEmpty) { $options["uploadRequired"] = $this->formatMessage($this->uploadRequired, array("attribute" => $label)); } if ($this->mimeTypes !== null) { $mimeTypes = array(); foreach ($this->mimeTypes as $mimeType) { $mimeTypes[] = new JsExpression(Html::escapeJsRegularExpression($this->buildMimeTypeRegexp($mimeType))); } $options["mimeTypes"] = $mimeTypes; $options["wrongMimeType"] = $this->formatMessage($this->wrongMimeType, array("attribute" => $label, "mimeTypes" => implode(", ", $this->mimeTypes))); } if ($this->extensions !== null) { $options["extensions"] = $this->extensions; $options["wrongExtension"] = $this->formatMessage($this->wrongExtension, array("attribute" => $label, "extensions" => implode(", ", $this->extensions))); } if ($this->minSize !== null) { $options["minSize"] = $this->minSize; $options["tooSmall"] = $this->formatMessage($this->tooSmall, array("attribute" => $label, "limit" => $this->minSize, "formattedLimit" => Yii::$app->formatter->asShortSize($this->minSize))); } if ($this->maxSize !== null) { $options["maxSize"] = $this->maxSize; $options["tooBig"] = $this->formatMessage($this->tooBig, array("attribute" => $label, "limit" => $this->getSizeLimit(), "formattedLimit" => Yii::$app->formatter->asShortSize($this->getSizeLimit()))); } if ($this->maxFiles !== null) { $options["maxFiles"] = $this->maxFiles; $options["tooMany"] = $this->formatMessage($this->tooMany, array("attribute" => $label, "limit" => $this->maxFiles)); } return $options; } private function buildMimeTypeRegexp($mask) { return "/^" . str_replace("\*", ".*", preg_quote($mask, "/")) . "$/i"; } protected function validateMimeType($file) { $fileMimeType = $this->getMimeTypeByFile($file->tempName); if ($fileMimeType === null) { return false; } foreach ($this->mimeTypes as $mimeType) { if (strcasecmp($mimeType, $fileMimeType) === 0) { return true; } if (strpos($mimeType, "*") !== false && preg_match($this->buildMimeTypeRegexp($mimeType), $fileMimeType)) { return true; } } return false; } protected function getMimeTypeByFile($filePath) { return FileHelper::getMimeType($filePath); } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace yii\validators; use Yii; use yii\helpers\FileHelper; use yii\helpers\Html; use yii\helpers\Json; use yii\helpers\StringHelper; use yii\web\JsExpression; use yii\web\UploadedFile; class FileValidator extends Validator { public $extensions; public $checkExtensionByMimeType = true; public $mimeTypes; public $minSize; public $maxSize; public $maxFiles = 1; public $minFiles = 0; public $message; public $uploadRequired; public $tooBig; public $tooSmall; public $tooMany; public $tooFew; public $wrongExtension; public $wrongMimeType; public function init() { parent::init(); if ($this->message === null) { $this->message = Yii::t("\x79\x69\x69", "\106\151\x6c\x65\x20\x75\x70\x6c\157\x61\x64\x20\x66\141\x69\x6c\145\144\x2e"); } if ($this->uploadRequired === null) { $this->uploadRequired = Yii::t("\x79\x69\151", "\120\x6c\145\141\x73\145\40\165\x70\154\157\141\144\40\x61\40\146\x69\154\145\56"); } if ($this->tooMany === null) { $this->tooMany = Yii::t("\x79\151\x69", "\131\157\165\x20\143\141\x6e\x20\165\x70\154\157\141\144\40\141\x74\40\x6d\157\163\164\40\173\154\x69\x6d\x69\164\54\40\156\x75\x6d\x62\145\162\x7d\40\x7b\154\151\155\151\x74\54\x20\x70\x6c\x75\162\141\x6c\54\x20\x6f\156\x65\173\x66\x69\x6c\145\175\40\x6f\164\x68\145\x72\173\x66\151\154\x65\163\x7d\x7d\56"); } if ($this->tooFew === null) { $this->tooFew = Yii::t("\171\151\151", "\x59\157\x75\40\163\150\157\x75\154\144\40\x75\160\x6c\x6f\x61\x64\40\141\x74\x20\x6c\145\x61\x73\x74\40\173\154\151\155\151\164\x2c\x20\156\x75\155\x62\x65\162\175\x20\x7b\154\x69\155\x69\x74\54\40\160\x6c\165\x72\141\154\54\x20\x6f\156\145\x7b\146\x69\154\x65\x7d\x20\157\164\x68\x65\x72\173\x66\x69\154\145\x73\x7d\175\x2e"); } if ($this->wrongExtension === null) { $this->wrongExtension = Yii::t("\171\x69\x69", "\117\156\154\x79\x20\146\151\x6c\145\163\40\x77\151\164\150\40\164\x68\145\163\x65\x20\x65\x78\164\145\x6e\x73\151\x6f\x6e\163\x20\141\162\x65\x20\141\154\x6c\157\x77\x65\x64\72\40\173\x65\170\x74\x65\x6e\163\x69\157\156\163\x7d\x2e"); } if ($this->tooBig === null) { $this->tooBig = Yii::t("\171\x69\x69", "\x54\x68\145\x20\x66\151\x6c\x65\x20\x22\173\x66\x69\154\145\x7d\x22\40\151\163\x20\164\157\157\40\x62\151\147\x2e\40\x49\x74\x73\40\163\x69\x7a\145\40\x63\x61\156\156\x6f\x74\40\x65\x78\x63\145\145\144\40\173\x66\x6f\162\x6d\141\164\x74\145\x64\x4c\151\x6d\151\x74\175\x2e"); } if ($this->tooSmall === null) { $this->tooSmall = Yii::t("\171\151\151", "\x54\x68\145\x20\x66\151\154\x65\x20\x22\173\x66\x69\x6c\145\x7d\42\40\151\163\x20\164\157\x6f\x20\163\155\141\154\x6c\x2e\40\x49\164\x73\x20\x73\151\172\145\40\143\141\x6e\x6e\x6f\x74\40\x62\x65\40\x73\x6d\141\154\154\145\162\40\x74\150\x61\156\40\x7b\x66\157\x72\155\x61\164\x74\x65\144\x4c\151\x6d\x69\x74\175\x2e"); } if (!is_array($this->extensions)) { $this->extensions = preg_split("\57\x5b\x5c\163\54\x5d\53\57", strtolower((string) $this->extensions), -1, PREG_SPLIT_NO_EMPTY); } else { $this->extensions = array_map("\163\164\x72\164\157\x6c\x6f\167\145\x72", $this->extensions); } if ($this->wrongMimeType === null) { $this->wrongMimeType = Yii::t("\171\x69\x69", "\117\156\154\x79\40\x66\x69\154\145\163\x20\x77\151\164\150\40\x74\150\x65\163\145\40\x4d\111\x4d\x45\x20\164\171\160\x65\163\40\x61\162\145\x20\141\x6c\x6c\x6f\167\145\x64\72\x20\x7b\155\151\x6d\x65\124\x79\x70\x65\163\175\x2e"); } if (!is_array($this->mimeTypes)) { $this->mimeTypes = preg_split("\57\133\134\163\x2c\x5d\53\57", strtolower((string) $this->mimeTypes), -1, PREG_SPLIT_NO_EMPTY); } else { $this->mimeTypes = array_map("\x73\x74\x72\x74\x6f\x6c\157\167\145\162", $this->mimeTypes); } } public function validateAttribute($model, $attribute) { if ($this->maxFiles != 1 || $this->minFiles > 1) { $rawFiles = $model->{$attribute}; if (!is_array($rawFiles)) { $this->addError($model, $attribute, $this->uploadRequired); return; } $files = $this->filterFiles($rawFiles); $model->{$attribute} = $files; if (empty($files)) { $this->addError($model, $attribute, $this->uploadRequired); return; } $filesCount = count($files); if ($this->maxFiles && $filesCount > $this->maxFiles) { $this->addError($model, $attribute, $this->tooMany, array("\x6c\151\155\151\x74" => $this->maxFiles)); } if ($this->minFiles && $this->minFiles > $filesCount) { $this->addError($model, $attribute, $this->tooFew, array("\x6c\151\155\151\164" => $this->minFiles)); } foreach ($files as $file) { $result = $this->validateValue($file); if (!empty($result)) { $this->addError($model, $attribute, $result[0], $result[1]); } } } else { $result = $this->validateValue($model->{$attribute}); if (!empty($result)) { $this->addError($model, $attribute, $result[0], $result[1]); } } } private function filterFiles(array $files) { $result = array(); foreach ($files as $fileName => $file) { if ($file instanceof UploadedFile && $file->error !== UPLOAD_ERR_NO_FILE) { $result[$fileName] = $file; } } return $result; } protected function validateValue($value) { if (!$value instanceof UploadedFile || $value->error == UPLOAD_ERR_NO_FILE) { return array($this->uploadRequired, array()); } switch ($value->error) { case UPLOAD_ERR_OK: if ($this->maxSize !== null && $value->size > $this->getSizeLimit()) { return array($this->tooBig, array("\x66\151\154\145" => $value->name, "\x6c\151\x6d\151\x74" => $this->getSizeLimit(), "\146\157\x72\155\141\164\164\145\144\x4c\x69\155\151\x74" => Yii::$app->formatter->asShortSize($this->getSizeLimit()))); } elseif ($this->minSize !== null && $value->size < $this->minSize) { return array($this->tooSmall, array("\x66\x69\x6c\x65" => $value->name, "\154\151\x6d\x69\x74" => $this->minSize, "\146\157\162\155\141\x74\x74\x65\x64\x4c\x69\x6d\151\x74" => Yii::$app->formatter->asShortSize($this->minSize))); } elseif (!empty($this->extensions) && !$this->validateExtension($value)) { return array($this->wrongExtension, array("\146\151\x6c\145" => $value->name, "\x65\x78\x74\145\x6e\x73\x69\x6f\156\x73" => implode("\54\40", $this->extensions))); } elseif (!empty($this->mimeTypes) && !$this->validateMimeType($value)) { return array($this->wrongMimeType, array("\x66\151\x6c\145" => $value->name, "\155\x69\155\145\x54\171\160\145\163" => implode("\54\40", $this->mimeTypes))); } return null; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: return array($this->tooBig, array("\146\x69\x6c\145" => $value->name, "\154\151\x6d\151\x74" => $this->getSizeLimit(), "\146\x6f\162\155\x61\164\164\145\144\x4c\x69\155\151\x74" => Yii::$app->formatter->asShortSize($this->getSizeLimit()))); case UPLOAD_ERR_PARTIAL: Yii::warning("\106\151\x6c\145\40\x77\141\x73\x20\157\156\x6c\x79\x20\x70\141\x72\x74\151\x61\x6c\154\171\40\165\160\154\157\141\x64\x65\x64\x3a\40" . $value->name, __METHOD__); break; case UPLOAD_ERR_NO_TMP_DIR: Yii::warning("\x4d\x69\163\x73\151\156\147\40\164\150\145\40\x74\145\155\x70\157\x72\x61\x72\171\x20\x66\157\x6c\x64\145\x72\x20\164\x6f\40\163\x74\157\x72\145\40\x74\150\x65\40\165\160\154\x6f\141\144\145\x64\x20\146\151\154\145\72\x20" . $value->name, __METHOD__); break; case UPLOAD_ERR_CANT_WRITE: Yii::warning("\106\x61\x69\154\145\144\x20\x74\157\40\x77\x72\x69\164\145\x20\164\x68\x65\x20\x75\x70\x6c\157\x61\x64\x65\x64\40\146\151\154\x65\40\164\157\x20\144\151\163\153\72\40" . $value->name, __METHOD__); break; case UPLOAD_ERR_EXTENSION: Yii::warning("\106\x69\154\x65\40\165\160\x6c\x6f\x61\144\40\167\141\x73\x20\x73\164\157\160\160\x65\144\x20\142\171\40\x73\157\155\x65\x20\120\x48\120\x20\145\170\164\x65\156\x73\151\x6f\156\x3a\x20" . $value->name, __METHOD__); break; default: break; } return array($this->message, array()); } public function getSizeLimit() { $limit = $this->sizeToBytes(ini_get("\165\x70\x6c\157\141\x64\x5f\155\x61\170\137\146\151\154\x65\x73\x69\172\x65")); $postLimit = $this->sizeToBytes(ini_get("\160\x6f\163\164\137\155\x61\170\x5f\163\151\172\x65")); if ($postLimit > 0 && $postLimit < $limit) { Yii::warning("\120\x48\x50\56\151\156\x69\47\163\40\47\160\x6f\163\x74\x5f\155\x61\170\137\x73\151\172\x65\47\x20\x69\x73\x20\154\x65\x73\163\40\164\x68\141\156\40\47\x75\x70\x6c\157\x61\x64\137\x6d\141\x78\137\x66\x69\x6c\x65\x73\151\x7a\145\x27\56", __METHOD__); $limit = $postLimit; } if ($this->maxSize !== null && $limit > 0 && $this->maxSize < $limit) { $limit = $this->maxSize; } if (isset($_POST["\115\x41\x58\x5f\x46\111\114\x45\137\x53\111\x5a\105"]) && $_POST["\x4d\x41\x58\x5f\106\x49\114\x45\x5f\x53\111\132\x45"] > 0 && $_POST["\x4d\x41\130\137\x46\111\x4c\105\137\123\111\x5a\105"] < $limit) { $limit = (int) $_POST["\115\x41\130\x5f\x46\x49\x4c\105\137\123\x49\132\x45"]; } return $limit; } public function isEmpty($value, $trim = false) { $value = is_array($value) ? reset($value) : $value; return !$value instanceof UploadedFile || $value->error == UPLOAD_ERR_NO_FILE; } private function sizeToBytes($sizeStr) { switch (substr($sizeStr, -1)) { case "\x4d": case "\155": return (int) $sizeStr * 1048576; case "\x4b": case "\153": return (int) $sizeStr * 1024; case "\107": case "\147": return (int) $sizeStr * 1073741824; default: return (int) $sizeStr; } } protected function validateExtension($file) { $extension = mb_strtolower($file->extension, "\125\124\x46\x2d\x38"); if ($this->checkExtensionByMimeType) { $mimeType = FileHelper::getMimeType($file->tempName, null, false); if ($mimeType === null) { return false; } $extensionsByMimeType = FileHelper::getExtensionsByMimeType($mimeType); if (!in_array($extension, $extensionsByMimeType, true)) { return false; } } if (!empty($this->extensions)) { foreach ((array) $this->extensions as $ext) { if ($extension === $ext || StringHelper::endsWith($file->name, "\56{$ext}", false)) { return true; } } return false; } return true; } public function clientValidateAttribute($model, $attribute, $view) { ValidationAsset::register($view); $options = $this->getClientOptions($model, $attribute); return "\x79\x69\151\x2e\x76\x61\x6c\x69\x64\141\x74\151\157\x6e\x2e\146\151\x6c\x65\x28\x61\x74\x74\x72\151\x62\165\x74\145\x2c\40\x6d\x65\x73\x73\141\147\145\163\54\x20" . Json::htmlEncode($options) . "\x29\x3b"; } public function getClientOptions($model, $attribute) { $label = $model->getAttributeLabel($attribute); $options = array(); if ($this->message !== null) { $options["\155\145\x73\163\x61\x67\x65"] = $this->formatMessage($this->message, array("\x61\164\164\x72\x69\x62\165\x74\x65" => $label)); } $options["\x73\x6b\151\160\117\x6e\105\x6d\160\164\x79"] = $this->skipOnEmpty; if (!$this->skipOnEmpty) { $options["\165\160\154\x6f\x61\x64\122\x65\x71\165\x69\x72\145\144"] = $this->formatMessage($this->uploadRequired, array("\141\164\x74\162\x69\x62\165\164\145" => $label)); } if ($this->mimeTypes !== null) { $mimeTypes = array(); foreach ($this->mimeTypes as $mimeType) { $mimeTypes[] = new JsExpression(Html::escapeJsRegularExpression($this->buildMimeTypeRegexp($mimeType))); } $options["\x6d\151\x6d\145\x54\171\x70\145\163"] = $mimeTypes; $options["\167\x72\x6f\156\147\115\x69\x6d\145\124\171\160\x65"] = $this->formatMessage($this->wrongMimeType, array("\141\x74\164\162\151\x62\x75\x74\145" => $label, "\x6d\151\x6d\145\x54\x79\x70\x65\x73" => implode("\54\40", $this->mimeTypes))); } if ($this->extensions !== null) { $options["\145\x78\x74\145\156\x73\x69\157\156\163"] = $this->extensions; $options["\167\x72\157\156\147\105\x78\x74\145\156\x73\x69\x6f\156"] = $this->formatMessage($this->wrongExtension, array("\x61\x74\x74\162\151\142\165\x74\x65" => $label, "\x65\170\x74\145\x6e\x73\x69\x6f\156\x73" => implode("\54\40", $this->extensions))); } if ($this->minSize !== null) { $options["\155\x69\x6e\x53\151\x7a\x65"] = $this->minSize; $options["\164\157\x6f\123\x6d\141\x6c\x6c"] = $this->formatMessage($this->tooSmall, array("\141\x74\x74\x72\151\142\165\x74\145" => $label, "\x6c\151\x6d\151\x74" => $this->minSize, "\x66\x6f\162\155\141\164\x74\145\x64\x4c\151\155\x69\x74" => Yii::$app->formatter->asShortSize($this->minSize))); } if ($this->maxSize !== null) { $options["\155\141\170\123\x69\172\x65"] = $this->maxSize; $options["\x74\157\157\x42\151\x67"] = $this->formatMessage($this->tooBig, array("\x61\164\x74\x72\151\142\x75\164\x65" => $label, "\154\151\x6d\151\164" => $this->getSizeLimit(), "\146\x6f\x72\x6d\141\164\164\x65\144\x4c\151\x6d\151\164" => Yii::$app->formatter->asShortSize($this->getSizeLimit()))); } if ($this->maxFiles !== null) { $options["\155\x61\170\106\x69\x6c\x65\163"] = $this->maxFiles; $options["\164\157\157\115\141\156\171"] = $this->formatMessage($this->tooMany, array("\141\164\164\162\151\x62\165\x74\x65" => $label, "\x6c\151\155\151\x74" => $this->maxFiles)); } return $options; } private function buildMimeTypeRegexp($mask) { return "\57\136" . str_replace("\x5c\x2a", "\56\52", preg_quote($mask, "\57")) . "\x24\x2f\x69"; } protected function validateMimeType($file) { $fileMimeType = $this->getMimeTypeByFile($file->tempName); if ($fileMimeType === null) { return false; } foreach ($this->mimeTypes as $mimeType) { if (strcasecmp($mimeType, $fileMimeType) === 0) { return true; } if (strpos($mimeType, "\52") !== false && preg_match($this->buildMimeTypeRegexp($mimeType), $fileMimeType)) { return true; } } return false; } protected function getMimeTypeByFile($filePath) { return FileHelper::getMimeType($filePath); } }

Function Calls

None

Variables

None

Stats

MD5 631c8c95741f7ec5e31c99ec4dd047c9
Eval Count 0
Decode Time 112 ms