内核更新

This commit is contained in:
2016-07-22 14:33:13 +08:00
parent 265a9da552
commit c4ba53fd9e
10 changed files with 80 additions and 44 deletions

View File

@@ -561,7 +561,7 @@ class Validate
$result = $value instanceof \think\File;
break;
case 'image':
$result = $value instanceof \think\File && in_array(exif_imagetype($value->getRealPath()), [1, 2, 3, 6]);
$result = $value instanceof \think\File && in_array($this->getImageType($value->getRealPath()), [1, 2, 3, 6]);
break;
default:
if (isset(self::$type[$rule])) {
@@ -575,6 +575,17 @@ class Validate
return $result;
}
// 判断图像类型
protected function getImageType($image)
{
if (function_exists('exif_imagetype')) {
return exif_imagetype($image);
} else {
$info = getimagesize($image);
return $info[2];
}
}
/**
* 验证是否为合格的域名或者IP 支持AMXNSSOAPTRCNAMEAAAAA6 SRVNAPTRTXT 或者 ANY类型
* @access protected
@@ -699,7 +710,7 @@ class Validate
if ('jpeg' == $imageType) {
$imageType = 'jpg';
}
if (image_type_to_extension($type) != $imageType) {
if (image_type_to_extension($type, false) != $imageType) {
return false;
}
}