Explorar o código

修改底层不兼容fileinfo扩展问题

liaofei %!s(int64=2) %!d(string=hai) anos
pai
achega
d0965060bc

+ 21 - 21
crmeb/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php

@@ -11,7 +11,7 @@ abstract class AbstractDecoder
     /**
      * Initiates new image from path in filesystem
      *
-     * @param  string $path
+     * @param string $path
      * @return \Intervention\Image\Image
      */
     abstract public function initFromPath($path);
@@ -19,7 +19,7 @@ abstract class AbstractDecoder
     /**
      * Initiates new image from binary data
      *
-     * @param  string $data
+     * @param string $data
      * @return \Intervention\Image\Image
      */
     abstract public function initFromBinary($data);
@@ -27,7 +27,7 @@ abstract class AbstractDecoder
     /**
      * Initiates new image from GD resource
      *
-     * @param  Resource $resource
+     * @param Resource $resource
      * @return \Intervention\Image\Image
      */
     abstract public function initFromGdResource($resource);
@@ -60,30 +60,30 @@ abstract class AbstractDecoder
     /**
      * Init from given URL
      *
-     * @param  string $url
+     * @param string $url
      * @return \Intervention\Image\Image
      */
     public function initFromUrl($url)
     {
-        
+
         $options = [
             'http' => [
-                'method'=>"GET",
-                'protocol_version'=>1.1, // force use HTTP 1.1 for service mesh environment with envoy
-                'header'=>"Accept-language: en\r\n".
-                "User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36\r\n"
-          ]
+                'method' => "GET",
+                'protocol_version' => 1.1, // force use HTTP 1.1 for service mesh environment with envoy
+                'header' => "Accept-language: en\r\n" .
+                    "User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36\r\n"
+            ]
         ];
-        
-        $context  = stream_context_create($options);
-        
+
+        $context = stream_context_create($options);
+
 
         if ($data = @file_get_contents($url, false, $context)) {
             return $this->initFromBinary($data);
         }
 
         throw new NotReadableException(
-            "Unable to init from given url (".$url.")."
+            "Unable to init from given url (" . $url . ")."
         );
     }
 
@@ -213,7 +213,7 @@ abstract class AbstractDecoder
      */
     public function isUrl()
     {
-        return (bool) filter_var($this->data, FILTER_VALIDATE_URL);
+        return (bool)filter_var($this->data, FILTER_VALIDATE_URL);
     }
 
     /**
@@ -238,8 +238,8 @@ abstract class AbstractDecoder
     public function isBinary()
     {
         if (is_string($this->data)) {
-            $mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $this->data);
-            return (substr($mime, 0, 4) != 'text' && $mime != 'application/x-empty');
+            $mime = getimagesize($this->data)['mime'] ?? '';
+            return !in_array($mime, ['image/jpeg', 'image/png', 'image/gif']);
         }
 
         return false;
@@ -274,7 +274,7 @@ abstract class AbstractDecoder
     /**
      * Initiates new Image from Intervention\Image\Image
      *
-     * @param  Image $object
+     * @param Image $object
      * @return \Intervention\Image\Image
      */
     public function initFromInterventionImage($object)
@@ -285,7 +285,7 @@ abstract class AbstractDecoder
     /**
      * Parses and decodes binary image data from data-url
      *
-     * @param  string $data_url
+     * @param string $data_url
      * @return string
      */
     private function decodeDataUrl($data_url)
@@ -307,7 +307,7 @@ abstract class AbstractDecoder
     /**
      * Initiates new image from mixed data
      *
-     * @param  mixed $data
+     * @param mixed $data
      * @return \Intervention\Image\Image
      */
     public function init($data)
@@ -359,6 +359,6 @@ abstract class AbstractDecoder
      */
     public function __toString()
     {
-        return (string) $this->data;
+        return (string)$this->data;
     }
 }

+ 3 - 3
crmeb/vendor/intervention/image/src/Intervention/Image/File.php

@@ -53,7 +53,7 @@ class File
         $this->filename = array_key_exists('filename', $info) ? $info['filename'] : null;
 
         if (file_exists($path) && is_file($path)) {
-            $this->mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);
+            $this->mime = getimagesize($path)['mime'] ?? '';
         }
 
         return $this;
@@ -61,7 +61,7 @@ class File
 
      /**
       * Get file size
-      * 
+      *
       * @return mixed
       */
     public function filesize()
@@ -71,7 +71,7 @@ class File
         if (file_exists($path) && is_file($path)) {
             return filesize($path);
         }
-        
+
         return false;
     }
 

+ 1 - 1
crmeb/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php

@@ -23,7 +23,7 @@ class Decoder extends \Intervention\Image\AbstractDecoder
         }
 
         // get mime type of file
-        $mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);
+        $mime =  getimagesize($path)['mime'] ?? '';
 
         // define core
         switch (strtolower($mime)) {

+ 5 - 5
crmeb/vendor/intervention/image/src/Intervention/Image/ImageManager.php

@@ -133,10 +133,10 @@ class ImageManager
      */
     private function checkRequirements()
     {
-        if ( ! function_exists('finfo_buffer')) {
-            throw new MissingDependencyException(
-                "PHP Fileinfo extension must be installed/enabled to use Intervention Image."
-            );
-        }
+//        if ( ! function_exists('finfo_buffer')) {
+//            throw new MissingDependencyException(
+//                "PHP Fileinfo extension must be installed/enabled to use Intervention Image."
+//            );
+//        }
     }
 }