Skip to content

Commit

Permalink
Update to version 4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
denysdesign committed May 22, 2022
1 parent 2c20a4b commit d193995
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 54 deletions.
6 changes: 3 additions & 3 deletions JUImage.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/**
* @package JUImage
* @since 4.0
* @subpackage Class
*
* @author Denys D. Nosov ([email protected])
* @copyright (C) 2011-2021 by Denys D. Nosov (https://joomla-ua.org)
* @copyright (C) 2011-2022 by Denys D. Nosov (https://joomla-ua.org)
* @license GNU General Public License version 2 or later
*
* @since 4.0
* @package JUImage
*/

include_once __DIR__ . '/vendor/autoload.php';
Expand Down
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
basedir=".">

<property name="VERSION"
value="4.5" />
value="4.6" />
<property name="build"
value="build" />
<property name="temp"
Expand Down
10 changes: 7 additions & 3 deletions packages/lib_juimage/juimage.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="library" version="@minjversion@" method="upgrade">
<extension type="library"
version="@minjversion@"
method="upgrade">
<name>JUImage</name>
<libraryname>juimage</libraryname>
<creationDate>@date@</creationDate>
<author>Denys Nosov</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://joomla-ua.org</authorUrl>
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
<copyright>(C) 2006-2021 Joomla! Ukraine. All rights reserved.</copyright>
<copyright>(C) 2006-2022 Joomla! Ukraine. All rights reserved.</copyright>
<version>@version@</version>
<packager>Joomla! Ukraine</packager>
<packagerurl>https://joomla-ua.org</packagerurl>
Expand All @@ -20,6 +22,8 @@
<file>blank.png</file>
</files>
<updateservers>
<server type="extension" priority="1" name="juimage">https://joomla-ua.org/update/lib/juimage.xml</server>
<server type="extension"
priority="1"
name="juimage">https://joomla-ua.org/update/lib/juimage.xml</server>
</updateservers>
</extension>
30 changes: 16 additions & 14 deletions packages/lib_juimage/script.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?php
/**
* @package JUImage
* @since 5.0
* @subpackage Class
*
* @author Denys D. Nosov ([email protected])
* @copyright (C) 2016-2021 by Denys D. Nosov (https://joomla-ua.org)
* @copyright (C) 2016-2022 by Denys D. Nosov (https://joomla-ua.org)
* @license GNU General Public License version 2 or later
*
* @since 5.0
* @package JUImage
*/

/**
* Installation class to perform additional changes during install/uninstall/update
*
* @since 5.0
* @package JUImage
*
* @since 5.0
*/
class JUImageInstallerScript
{
Expand Down Expand Up @@ -73,17 +73,17 @@ public function postflight()
$path . 'vendor/rosell-dk/webp-convert/src/Converters/Binaries'
];

foreach( $files AS $file )
foreach($files as $file)
{
if( file_exists($file) )
if(file_exists($file))
{
unlink($file);
}
}

foreach( $folders AS $folder )
foreach($folders as $folder)
{
if( is_dir($folder) )
if(is_dir($folder))
{
$this->unlinkRecursive($folder, 1);
}
Expand All @@ -100,29 +100,31 @@ public function postflight()
*/
public function unlinkRecursive($dir, $deleteRootToo)
{
if( !$dh = opendir($dir) )
if(!$dh = opendir($dir))
{
return;
return true;
}

while( false !== ($obj = readdir($dh)) )
while(false !== ($obj = readdir($dh)))
{
if( $obj === '.' || $obj === '..' )
if($obj === '.' || $obj === '..')
{
continue;
}

if( !unlink($dir . '/' . $obj) )
if(!unlink($dir . '/' . $obj))
{
$this->unlinkRecursive($dir . '/' . $obj, true);
}
}

closedir($dh);

if( $deleteRootToo )
if($deleteRootToo)
{
rmdir($dir);
}

return true;
}
}
8 changes: 4 additions & 4 deletions packages/plg_system_juimage/juimage.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/**
* @package JUImage
* @since 5.0
* @subpackage Class
*
* @author Denys D. Nosov ([email protected])
* @copyright (C) 2011-2021 by Denys D. Nosov (https://joomla-ua.org)
* @copyright (C) 2011-2022 by Denys D. Nosov (https://joomla-ua.org)
* @license GNU General Public License version 2 or later
*
* @since 5.0
* @package JUImage
*/

use Joomla\CMS\Plugin\CMSPlugin;
Expand All @@ -17,9 +17,9 @@
/**
* JUImage plugin class.
*
* @since 5.0
* @package JUImage plugin
*
* @since 5.0
*/
class plgSystemJUImage extends CMSPlugin
{
Expand Down
7 changes: 5 additions & 2 deletions packages/plg_system_juimage/juimage.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="@minjversion@" group="system" method="upgrade">
<extension type="plugin"
version="@minjversion@"
group="system"
method="upgrade">
<name>System - JUImage</name>
<author>Denys Nosov</author>
<creationDate>@date@</creationDate>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://joomla-ua.org</authorUrl>
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
<copyright>(C) 2019-2021 Joomla! Ukraine. All rights reserved.</copyright>
<copyright>(C) 2019-2022 Joomla! Ukraine. All rights reserved.</copyright>
<version>@version@</version>
<description>Register JUImage library.</description>
<files>
Expand Down
19 changes: 13 additions & 6 deletions pkg_juimage.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<extension type="package" version="@minjversion@" method="upgrade">
<extension type="package"
version="@minjversion@"
method="upgrade">
<name>JUImage</name>
<packagename>juimage</packagename>
<creationDate>@date@</creationDate>
<packager>Joomla! Ukraine</packager>
<copyright>(C) 2016-2021 Denys Nosov, Joomla! Ukraine</copyright>
<copyright>(C) 2016-2022 Denys Nosov, Joomla! Ukraine</copyright>
<packageremail>[email protected]</packageremail>
<packagerurl>https://joomla-ua.org</packagerurl>
<author>Denys Nosov, Joomla! Ukraine</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://joomla-ua.org</authorUrl>
<version>@version@</version>
<description/>
<description />
<scriptfile>script.php</scriptfile>
<update>https://joomla-ua.org/update/lib/juimage.xml</update>
<updateservers>
<server type="extension" priority="1" name="juimage">https://joomla-ua.org/update/lib/juimage.xml</server>
<server type="extension"
priority="1"
name="juimage">https://joomla-ua.org/update/lib/juimage.xml</server>
</updateservers>
<files folder="packages">
<file type="plugin" id="juimage" group="system">plg_system_juimage.zip</file>
<file type="library" id="juimage">lib_juimage.zip</file>
<file type="plugin"
id="juimage"
group="system">plg_system_juimage.zip</file>
<file type="library"
id="juimage">lib_juimage.zip</file>
</files>
</extension>
14 changes: 7 additions & 7 deletions script.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/**
* @package JUImage
* @since 4.0
* @subpackage Class
*
* @author Denys D. Nosov ([email protected])
* @copyright (C) 2011-2021 by Denys D. Nosov (https://joomla-ua.org)
* @copyright (C) 2011-2022 by Denys D. Nosov (https://joomla-ua.org)
* @license GNU General Public License version 2 or later
*
* @since 4.0
* @package JUImage
*/

defined('_JEXEC') or die;
Expand Down Expand Up @@ -71,17 +71,17 @@ public function postflight()
$path . 'vendor/rosell-dk/webp-convert/src/Converters/Binaries'
];

foreach( $files AS $file )
foreach($files as $file)
{
if( file_exists($file) )
if(file_exists($file))
{
unlink($file);
}
}

foreach( $folders AS $folder )
foreach($folders as $folder)
{
if( is_dir($folder) )
if(is_dir($folder))
{
$this->unlinkRecursive($folder, 1);
}
Expand Down
15 changes: 7 additions & 8 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @subpackage Class
*
* @author Denys D. Nosov ([email protected])
* @copyright (C) 2016-2021 by Denys D. Nosov (https://joomla-ua.org)
* @copyright (C) 2016-2022 by Denys D. Nosov (https://joomla-ua.org)
* @license GNU General Public License version 2 or later
*
* @package JUImage
Expand Down Expand Up @@ -115,7 +115,7 @@ private function thumb($url, array $attr = [])
$url = $this->createVideoThumb($url);
}

$headers = get_headers($url);
$headers = get_headers($url, true);
if(strpos($headers[ 0 ], '200') === false)
{
$_error = true;
Expand All @@ -132,7 +132,7 @@ private function thumb($url, array $attr = [])

$img_name = pathinfo($url)[ 'filename' ];
$img_url = strtolower($img_name);
$img_url = preg_replace('#[[:punct:]]#', '', $img_url);
$img_url = preg_replace('#[:punct:]#', '', $img_url);
$img_url = preg_replace('#[а-яёєїіЁЄЇІ]#iu', '', $img_url);
$img_url = str_replace([ ' +', ' ' ], [ '_', '' ], $img_url);
}
Expand Down Expand Up @@ -176,7 +176,7 @@ private function thumb($url, array $attr = [])
if($_error === true)
{
$error_image = implode($error_image);
$url = $error_image === '' ? $this->path . '/' . $this->img_blank : $error_image;
$url = ($error_image === '' ? $this->path . '/' . $this->img_blank : $error_image);
}

// Image Size
Expand All @@ -190,8 +190,7 @@ private function thumb($url, array $attr = [])

// Path to Folder
$subfolder = $img_cache . '/' . $img_size . '/' . $img_name;

$uri_attr = [];
$uri_attr = [];
if(!empty($attr) && is_array($attr))
{
foreach($attr as $k => $v)
Expand Down Expand Up @@ -334,7 +333,6 @@ private function createThumb($url, $img_cache, $target, array $attr = [])
private function createVideoThumb($url, $video_detect = false)
{
$urls = parse_url($url);

if($video_detect === true)
{
return $urls[ 'host' ] === 'youtu.be' || $urls[ 'host' ] === 'youtube.com' || $urls[ 'host' ] === 'www.youtube.com' || $urls[ 'host' ] === 'vimeo.com';
Expand Down Expand Up @@ -414,6 +412,7 @@ private function youtube($id)
private function vimeo($id)
{
$vimeo = json_decode(file_get_contents('https://vimeo.com/api/v2/video/' . $id . '.json'));

if(!empty($vimeo))
{
return $vimeo[ 0 ]->thumbnail_large;
Expand Down Expand Up @@ -452,7 +451,7 @@ private function makeDir($dir)
*/
private function http($url)
{
$header = get_headers($url);
$header = get_headers($url, true);

return substr($header[ 0 ], 9, 3);
}
Expand Down
17 changes: 11 additions & 6 deletions src/classes/phpthumb/phpthumb.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class phpthumb {
public $issafemode = null;
public $php_memory_limit = null;

public $phpthumb_version = '1.7.18-202201121135';
public $phpthumb_version = '1.7.18-202204131313';

//////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -1405,10 +1405,12 @@ public function file_exists_ignoreopenbasedir($filename, $cached=true) {
static $open_basedirs = null;
static $file_exists_cache = array();
if (!$cached || !isset($file_exists_cache[$filename])) {
if (null === $open_basedirs) {
if (is_null($open_basedirs)) {
$open_basedirs = preg_split('#[;:]#', ini_get('open_basedir'));
}
if (empty($open_basedirs) || in_array(dirname($filename), $open_basedirs)) {
if (is_null($filename)) { // shouldn't happen, but https://github.com/JamesHeinrich/phpThumb/issues/188
$file_exists_cache[$filename] = false;
} elseif (empty($open_basedirs) || in_array(dirname($filename), $open_basedirs)) {
$file_exists_cache[$filename] = file_exists($filename);
} elseif ($this->iswindows) {
$ls_filename = trim(phpthumb_functions::SafeExec('dir /b '.phpthumb_functions::escapeshellarg_replacement($filename)));
Expand Down Expand Up @@ -1474,7 +1476,10 @@ public function ImageMagickCommandlineBase() {

$this->DebugMessage('using ImageMagick path from $this->config_imagemagick_path ('.$this->config_imagemagick_path.')', __FILE__, __LINE__);
if ($this->iswindows) {
$commandline = substr($this->config_imagemagick_path, 0, 2).' && cd '.phpthumb_functions::escapeshellarg_replacement(str_replace('/', DIRECTORY_SEPARATOR, substr(dirname($this->config_imagemagick_path), 2))).' && '.phpthumb_functions::escapeshellarg_replacement(basename($this->config_imagemagick_path));
$commandline = '';
$commandline .= substr($this->config_imagemagick_path, 0, 2);
$commandline .= ' && cd '.phpthumb_functions::escapeshellarg_replacement(str_replace('/', DIRECTORY_SEPARATOR, substr(dirname($this->config_imagemagick_path), 2)));
$commandline .= ' && '.phpthumb_functions::escapeshellarg_replacement(basename($this->config_imagemagick_path));
} else {
$commandline = phpthumb_functions::escapeshellarg_replacement($this->config_imagemagick_path);
}
Expand Down Expand Up @@ -1588,7 +1593,7 @@ public function ImageMagickFormatsList() {
if (null === $IMformatsList) {
$IMformatsList = '';
$commandline = $this->ImageMagickCommandlineBase();
if (null !== $commandline) {
if (!is_null($commandline)) {
$commandline = dirname($commandline).DIRECTORY_SEPARATOR.str_replace('convert', 'identify', basename($commandline));
$commandline .= ' -list format';
$IMformatsList = phpthumb_functions::SafeExec($commandline);
Expand Down Expand Up @@ -3513,7 +3518,7 @@ public function ExtractEXIFgetImageSize() {

}

$this->DebugMessage('EXIF thumbnail extraction: (size='.strlen($this->exif_thumbnail_data).'; type="'.$this->exif_thumbnail_type.'"; '. (int) $this->exif_thumbnail_width .'x'. (int) $this->exif_thumbnail_height .')', __FILE__, __LINE__);
$this->DebugMessage('EXIF thumbnail extraction: (size='.(!empty($this->exif_thumbnail_data) ? strlen($this->exif_thumbnail_data) : 0).'; type="'.$this->exif_thumbnail_type.'"; '. (int) $this->exif_thumbnail_width .'x'. (int) $this->exif_thumbnail_height .')', __FILE__, __LINE__);

// see if EXIF thumbnail can be used directly with no processing
if ($this->config_use_exif_thumbnail_for_speed && $this->exif_thumbnail_data) {
Expand Down

0 comments on commit d193995

Please sign in to comment.