mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit b72f3fe820a0c2689254a667a5dc27ed85a8cd9e
parent e91ed3c50b9fe38da3fbfe76da088e3a47ea1a23
Author: markseu <mark2011@mayberg.se>
Date:   Mon, 26 Jun 2017 15:19:49 +0200

Plugins update (GIF support)

Diffstat:
Msystem/plugins/command.php | 4++--
Msystem/plugins/core.php | 20+++++++++++++++++---
Msystem/plugins/image.php | 35++++++++++++++++++-----------------
3 files changed, 37 insertions(+), 22 deletions(-)

diff --git a/system/plugins/command.php b/system/plugins/command.php @@ -5,7 +5,7 @@ class YellowCommand { - const VERSION = "0.7.1"; + const VERSION = "0.7.2"; var $yellow; //access to API var $files; //number of files var $errors; //number of errors @@ -410,7 +410,7 @@ class YellowCommand function getSystemLocations() { $locations = array(); - $regex = "/\.(css|ico|js|jpg|png|svg|txt|woff|woff2)$/"; + $regex = "/\.(css|gif|ico|js|jpg|png|svg|txt|woff|woff2)$/"; $pluginDirLength = strlenu($this->yellow->config->get("pluginDir")); $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->config->get("pluginDir"), $regex, false, false); foreach($fileNames as $fileName) diff --git a/system/plugins/core.php b/system/plugins/core.php @@ -2397,7 +2397,7 @@ class YellowLookup // Return file path from system location function findFileFromSystem($location) { - if(preg_match("/\.(css|ico|js|jpg|png|svg|txt|woff|woff2)$/", $location)) + if(preg_match("/\.(css|gif|ico|js|jpg|png|svg|txt|woff|woff2)$/", $location)) { $pluginLocationLength = strlenu($this->yellow->config->get("pluginLocation")); $themeLocationLength = strlenu($this->yellow->config->get("themeLocation")); @@ -2880,6 +2880,7 @@ class YellowToolbox { $mimeTypes = array( "css" => "text/css", + "gif" => "image/gif", "html" => "text/html; charset=utf-8", "ico" => "image/x-icon", "js" => "application/javascript", @@ -3181,6 +3182,10 @@ class YellowToolbox { $dataBuffer = $salt = ""; $dataBufferSize = $bcryptFormat ? intval(ceil($length/4) * 3) : intval(ceil($length/2)); + if(empty($dataBuffer) && function_exists("random_bytes")) + { + $dataBuffer = @random_bytes($dataBufferSize); + } if(empty($dataBuffer) && function_exists("mcrypt_create_iv")) { $dataBuffer = @mcrypt_create_iv($dataBufferSize, MCRYPT_DEV_URANDOM); @@ -3304,7 +3309,7 @@ class YellowToolbox return $language; } - // Detect image dimensions and type for jpg/png/svg + // Detect image dimensions and type for gif/jpg/png/svg function detectImageInfo($fileName) { $width = $height = 0; @@ -3312,8 +3317,17 @@ class YellowToolbox $fileHandle = @fopen($fileName, "rb"); if($fileHandle) { - if(substru(strtoloweru($fileName), -3)=="jpg") + if(substru(strtoloweru($fileName), -3)=="gif") { + $dataSignature = fread($fileHandle, 6); + $dataHeader = fread($fileHandle, 7); + if(!feof($fileHandle) && ($dataSignature=="GIF87a" || $dataSignature=="GIF89a")) + { + $width = (ord($dataHeader[1])<<8) + ord($dataHeader[0]); + $height = (ord($dataHeader[3])<<8) + ord($dataHeader[2]); + $type = "gif"; + } + } else if(substru(strtoloweru($fileName), -3)=="jpg") { $dataBufferSizeMax = filesize($fileName); $dataBufferSize = min($dataBufferSizeMax, 4096); if($dataBufferSize) $dataBuffer = fread($fileHandle, $dataBufferSize); diff --git a/system/plugins/image.php b/system/plugins/image.php @@ -5,7 +5,7 @@ class YellowImage { - const VERSION = "0.6.8"; + const VERSION = "0.7.1"; var $yellow; //access to API var $graphicsLibrary; //graphics library support? (boolean) @@ -28,7 +28,7 @@ class YellowImage { if(!$this->graphicsLibrary) { - $this->yellow->page->error(500, "Plugin 'image' requires GD library with JPG and PNG support!"); + $this->yellow->page->error(500, "Plugin 'image' requires GD library with gif/jpg/png support!"); return $output; } list($name, $alt, $style, $width, $height) = $this->yellow->toolbox->getTextArgs($text); @@ -119,11 +119,25 @@ class YellowImage $image = false; switch($type) { + case "gif": $image = @imagecreatefromgif($fileName); break; case "jpg": $image = @imagecreatefromjpeg($fileName); break; case "png": $image = @imagecreatefrompng($fileName); break; } return $image; } + + // Save image to file + function saveImage($image, $fileName, $type) + { + $ok = false; + switch($type) + { + case "gif": $ok = @imagegif($image, $fileName); break; + case "jpg": $ok = @imagejpeg($image, $fileName, $this->yellow->config->get("imageJpegQuality")); break; + case "png": $ok = @imagepng($image, $fileName); break; + } + return $ok; + } // Create image from scratch function createImage($width, $height) @@ -150,18 +164,6 @@ class YellowImage } return $imageOutput; } - - // Save image to file - function saveImage($image, $fileName, $type) - { - $ok = false; - switch($type) - { - case "jpg": $ok = @imagejpeg($image, $fileName, $this->yellow->config->get("imageJpegQuality")); break; - case "png": $ok = @imagepng($image, $fileName); break; - } - return $ok; - } // Return value according to unit function convertValueAndUnit($text, $valueBase) @@ -186,9 +188,9 @@ class YellowImage function isGraphicsLibrary() { return extension_loaded("gd") && function_exists("gd_info") && - ((imagetypes()&(IMG_JPG|IMG_PNG))==(IMG_JPG|IMG_PNG)); + ((imagetypes()&(IMG_GIF|IMG_JPG|IMG_PNG))==(IMG_GIF|IMG_JPG|IMG_PNG)); } } $yellow->plugins->register("image", "YellowImage", YellowImage::VERSION); -?> -\ No newline at end of file +?>