From 44974a6699d5480a461248d2dc70ea9142da6c96 Mon Sep 17 00:00:00 2001 From: Kris_B Date: Tue, 1 Aug 2017 19:42:36 +0200 Subject: [PATCH] v1.1.0 --- changelog.md | 17 +++++- .../Album A/berlin A1.jpg | Bin .../Album A/berlin A2-A.jpg | Bin .../Album A/berlin A2-B.jpg | Bin .../Album A/berlin A3.jpg | Bin .../nano_photos_content}/Album B/berlin2.jpg | Bin .../nano_photos_content}/Album B/berlin3.jpg | Bin .../nano_photos_content}/Album B/berlin3A.jpg | Bin .../nano_photos_content}/Album B/berlin3C.jpg | Bin .../nano_photos_content}/berlin1.jpg | Bin dist/nano_photos_content/berlin1.txt | 2 + .../nano_photos_content}/berlin2.jpg | Bin .../nano_photos_content}/berlin3.jpg | Bin dist/nano_photos_provider2.cfg | 25 ++++++++ .../nano_photos_provider2.encoding.php | 0 .../nano_photos_provider2.json.class.php | 56 +++++++++++------- .../nano_photos_provider2.php | 26 +++++++- dist/nano_photos_provider2_check.php | 47 +++++++++++++++ nano_photos_content/berlin1.txt | 2 - 19 files changed, 148 insertions(+), 27 deletions(-) rename {nano_photos_content => dist/nano_photos_content}/Album A/berlin A1.jpg (100%) rename {nano_photos_content => dist/nano_photos_content}/Album A/berlin A2-A.jpg (100%) rename {nano_photos_content => dist/nano_photos_content}/Album A/berlin A2-B.jpg (100%) rename {nano_photos_content => dist/nano_photos_content}/Album A/berlin A3.jpg (100%) rename {nano_photos_content => dist/nano_photos_content}/Album B/berlin2.jpg (100%) rename {nano_photos_content => dist/nano_photos_content}/Album B/berlin3.jpg (100%) rename {nano_photos_content => dist/nano_photos_content}/Album B/berlin3A.jpg (100%) rename {nano_photos_content => dist/nano_photos_content}/Album B/berlin3C.jpg (100%) rename {nano_photos_content => dist/nano_photos_content}/berlin1.jpg (100%) create mode 100644 dist/nano_photos_content/berlin1.txt rename {nano_photos_content => dist/nano_photos_content}/berlin2.jpg (100%) rename {nano_photos_content => dist/nano_photos_content}/berlin3.jpg (100%) create mode 100644 dist/nano_photos_provider2.cfg rename nano_photos_provider2.encoding.php => dist/nano_photos_provider2.encoding.php (100%) rename nano_photos_provider2.json.class.php => dist/nano_photos_provider2.json.class.php (92%) rename nano_photos_provider2.php => dist/nano_photos_provider2.php (64%) create mode 100644 dist/nano_photos_provider2_check.php delete mode 100644 nano_photos_content/berlin1.txt diff --git a/changelog.md b/changelog.md index 80501d7..240b0d0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,12 +1,25 @@ -nanoPhotosProvider2 - nanogallery2 plugin +nanoPhotosProvider2 - add-on for nanogallery2 =========== -**Visit nanoPhotosProvider2 homepage for usage details: [https://github.com/nanostudio-org/nanoPhotosProvider2](https://github.com/nanostudio-org/nanoPhotosProvider2)** +**Visit nanoPhotosProvider2 homepage for usage details: [https://github.com/nanostudio-org/nano_photos_provider2](https://github.com/nanostudio-org/nano_photos_provider2)** + ChangeLog ------ +v1.1.0 +------ +- enhanced error management +- new configuration option to resolve possible memory usage issue with large images +- support Solaris web server +- fixed: incorrect thumbnail size returned for grid layout +- fixed: misc minor bugs + +v1.0.1 +------ +- fixed incorrect file in release v1.0.0 + v1.0.0 ------ - possibility to define the maximum image size used for display (full resolution version will be available for download) diff --git a/nano_photos_content/Album A/berlin A1.jpg b/dist/nano_photos_content/Album A/berlin A1.jpg similarity index 100% rename from nano_photos_content/Album A/berlin A1.jpg rename to dist/nano_photos_content/Album A/berlin A1.jpg diff --git a/nano_photos_content/Album A/berlin A2-A.jpg b/dist/nano_photos_content/Album A/berlin A2-A.jpg similarity index 100% rename from nano_photos_content/Album A/berlin A2-A.jpg rename to dist/nano_photos_content/Album A/berlin A2-A.jpg diff --git a/nano_photos_content/Album A/berlin A2-B.jpg b/dist/nano_photos_content/Album A/berlin A2-B.jpg similarity index 100% rename from nano_photos_content/Album A/berlin A2-B.jpg rename to dist/nano_photos_content/Album A/berlin A2-B.jpg diff --git a/nano_photos_content/Album A/berlin A3.jpg b/dist/nano_photos_content/Album A/berlin A3.jpg similarity index 100% rename from nano_photos_content/Album A/berlin A3.jpg rename to dist/nano_photos_content/Album A/berlin A3.jpg diff --git a/nano_photos_content/Album B/berlin2.jpg b/dist/nano_photos_content/Album B/berlin2.jpg similarity index 100% rename from nano_photos_content/Album B/berlin2.jpg rename to dist/nano_photos_content/Album B/berlin2.jpg diff --git a/nano_photos_content/Album B/berlin3.jpg b/dist/nano_photos_content/Album B/berlin3.jpg similarity index 100% rename from nano_photos_content/Album B/berlin3.jpg rename to dist/nano_photos_content/Album B/berlin3.jpg diff --git a/nano_photos_content/Album B/berlin3A.jpg b/dist/nano_photos_content/Album B/berlin3A.jpg similarity index 100% rename from nano_photos_content/Album B/berlin3A.jpg rename to dist/nano_photos_content/Album B/berlin3A.jpg diff --git a/nano_photos_content/Album B/berlin3C.jpg b/dist/nano_photos_content/Album B/berlin3C.jpg similarity index 100% rename from nano_photos_content/Album B/berlin3C.jpg rename to dist/nano_photos_content/Album B/berlin3C.jpg diff --git a/nano_photos_content/berlin1.jpg b/dist/nano_photos_content/berlin1.jpg similarity index 100% rename from nano_photos_content/berlin1.jpg rename to dist/nano_photos_content/berlin1.jpg diff --git a/dist/nano_photos_content/berlin1.txt b/dist/nano_photos_content/berlin1.txt new file mode 100644 index 0000000..07b95c7 --- /dev/null +++ b/dist/nano_photos_content/berlin1.txt @@ -0,0 +1,2 @@ +title: Berlin 1 +description: Berlin photo 1 \ No newline at end of file diff --git a/nano_photos_content/berlin2.jpg b/dist/nano_photos_content/berlin2.jpg similarity index 100% rename from nano_photos_content/berlin2.jpg rename to dist/nano_photos_content/berlin2.jpg diff --git a/nano_photos_content/berlin3.jpg b/dist/nano_photos_content/berlin3.jpg similarity index 100% rename from nano_photos_content/berlin3.jpg rename to dist/nano_photos_content/berlin3.jpg diff --git a/dist/nano_photos_provider2.cfg b/dist/nano_photos_provider2.cfg new file mode 100644 index 0000000..56bb489 --- /dev/null +++ b/dist/nano_photos_provider2.cfg @@ -0,0 +1,25 @@ +[config] +fileExtensions="jpg|jpeg|png|gif" +contentFolder="nano_photos_content" +sortOrder="asc" +titleDescSeparator="$$" +albumCoverDetector="@@@@@" +ignoreDetector="_hidden" + +[images] +maxSize=1900 +jpegQuality=85 + +[thumbnails] +jpegQuality=90 +blurredImageQuality=3 +allowedSizeValues="" +;allowedSizeValues="50|100|225|150|200|300|auto" + +[security] +allowOrigins="*" +; allowOrigins="http://nanogallery2.nanostudio.org|https://nanogallery2.nanostudio.org" + +[memory] +unlimited=false + diff --git a/nano_photos_provider2.encoding.php b/dist/nano_photos_provider2.encoding.php similarity index 100% rename from nano_photos_provider2.encoding.php rename to dist/nano_photos_provider2.encoding.php diff --git a/nano_photos_provider2.json.class.php b/dist/nano_photos_provider2.json.class.php similarity index 92% rename from nano_photos_provider2.json.class.php rename to dist/nano_photos_provider2.json.class.php index 54da850..f9b5fd3 100644 --- a/nano_photos_provider2.json.class.php +++ b/dist/nano_photos_provider2.json.class.php @@ -11,6 +11,14 @@ * License: For personal, non-profit organizations, or open source projects (without any kind of fee), you may use nanogallery2 for free. * -------- ALL OTHER USES REQUIRE THE PURCHASE OF A COMMERCIAL LICENSE. * + * PHP 5.2+ + * @version 1.1.0 + * @author Christophe BRISBOIS - http://www.brisbois.fr/ + * @copyright Copyright 2015+ + * @license GPL v3 and commercial + * @link https://github.com/nanostudio-org/nanoPhotosProvider2 + * @Support https://github.com/nanostudio-org/nanoPhotosProvider2/issues + * */ require './nano_photos_provider2.encoding.php'; @@ -70,19 +78,16 @@ public function __construct() $this->setConfig(self::CONFIG_FILE); // thumbnail responsive sizes - $this->tn_size[wxs] = $this->CheckThumbnailSize( $_GET['wxs'] ); - $this->tn_size[hxs] = $this->CheckThumbnailSize( $_GET['hxs'] ); - $this->tn_size[wsm] = $this->CheckThumbnailSize( $_GET['wsm'] ); - $this->tn_size[hsm] = $this->CheckThumbnailSize( $_GET['hsm'] ); - $this->tn_size[wme] = $this->CheckThumbnailSize( $_GET['wme'] ); - $this->tn_size[hme] = $this->CheckThumbnailSize( $_GET['hme'] ); - $this->tn_size[wla] = $this->CheckThumbnailSize( $_GET['wla'] ); - $this->tn_size[hla] = $this->CheckThumbnailSize( $_GET['hla'] ); - $this->tn_size[wxl] = $this->CheckThumbnailSize( $_GET['wxl'] ); - $this->tn_size[hxl] = $this->CheckThumbnailSize( $_GET['hxl'] ); - - - + $this->tn_size['wxs'] = strtolower($this->CheckThumbnailSize( $_GET['wxs'] )); + $this->tn_size['hxs'] = strtolower($this->CheckThumbnailSize( $_GET['hxs'] )); + $this->tn_size['wsm'] = strtolower($this->CheckThumbnailSize( $_GET['wsm'] )); + $this->tn_size['hsm'] = strtolower($this->CheckThumbnailSize( $_GET['hsm'] )); + $this->tn_size['wme'] = strtolower($this->CheckThumbnailSize( $_GET['wme'] )); + $this->tn_size['hme'] = strtolower($this->CheckThumbnailSize( $_GET['hme'] )); + $this->tn_size['wla'] = strtolower($this->CheckThumbnailSize( $_GET['wla'] )); + $this->tn_size['hla'] = strtolower($this->CheckThumbnailSize( $_GET['hla'] )); + $this->tn_size['wxl'] = strtolower($this->CheckThumbnailSize( $_GET['wxl'] )); + $this->tn_size['hxl'] = strtolower($this->CheckThumbnailSize( $_GET['hxl'] )); $this->data = new galleryData(); $this->data->fullDir = ($this->config['contentFolder']) . ($this->album); @@ -108,7 +113,8 @@ public function __construct() } else { // it's a folder - $files = glob($this->data->fullDir . $filename."/*.{".str_replace("|",",",$this->config['fileExtensions'])."}", GLOB_BRACE); // to check if folder contains images + //$files = glob($this->data->fullDir . $filename."/*.{".str_replace("|",",",$this->config['fileExtensions'])."}", GLOB_BRACE); // to check if folder contains images - warning - glob is not supported by all platforms + $files = preg_grep('~\.('.$this->config['fileExtensions'].')$~', scandir($this->data->fullDir . $filename)); // to check if folder contains images if ($filename != '.' && $filename != '..' && $filename != '_thumbnails' && @@ -139,7 +145,8 @@ public function __construct() */ protected function CheckThumbnailSize( $size ) { - if( $this->config['thumbnails']['allowedSizeValues'] == "" ) { + if( !array_key_exists("allowedSizeValues",$this->config['thumbnails']) || $this->config['thumbnails']['allowedSizeValues'] == "" ) { + // no size restriction return $size; } @@ -210,6 +217,11 @@ protected function setConfig($filePath) $this->config['albumCoverDetector'] = $config['config']['albumCoverDetector']; $this->config['ignoreDetector'] = strtoupper($config['config']['ignoreDetector']); + // memory usage + if( $config['memory']['unlimited'] == true ) { + ini_set('memory_limit', '-1'); + } + // images $this->config['images']['maxSize'] = 0; $ms = $config['images']['maxSize']; @@ -352,8 +364,8 @@ protected function GetImageDisplayURL( $baseFolder, $filename ) if( filemtime($lowresFilename) > filemtime($baseFolder . $filename) ) { // original image file is older as the image use for display $size = getimagesize($lowresFilename); - $this->currentItem->imgWidth = $imgSize[0]; - $this->currentItem->imgHeight = $imgSize[1]; + $this->currentItem->imgWidth = $size[0]; + $this->currentItem->imgHeight = $size[1]; return rawurlencode($this->CustomEncode($lowresFilename)); } } @@ -600,8 +612,10 @@ protected function GenerateThumbnail2($baseFolder, $imagefilename, $thumbnailFil } // thumbnail image size - $this->currentItem->t_width[$s]=$newWidth; - $this->currentItem->t_height[$s]=$newHeight; + // $this->currentItem->t_width[$s]=$newWidth; + // $this->currentItem->t_height[$s]=$newHeight; + $this->currentItem->t_width[$s]=$thumbWidth; + $this->currentItem->t_height[$s]=$thumbHeight; if( $generateThumbnail == true ) { $thumb = imagecreatetruecolor($thumbWidth, $thumbHeight); @@ -665,7 +679,7 @@ protected function GenerateThumbnail2($baseFolder, $imagefilename, $thumbnailFil imagecopyresampled($pixel, $orgImage, 0, 0, 0, 0, 1, 1, $width, $height); $rgb = imagecolorat($pixel, 0, 0); $color = imagecolorsforindex($pixel, $rgb); - $hex=sprintf('#%02x%02x%02x', $color[red], $color[green], $color[blue]); + $hex=sprintf('#%02x%02x%02x', $color['red'], $color['green'], $color['blue']); $this->currentItem->dc= $hex; // save to cache @@ -893,13 +907,13 @@ protected function PrepareData($filename, $kind) if ( $kind == 'IMAGE' ) { // ONE IMAGE $this->currentItem->kind = 'image'; - $e = $this->GetMetaData($filename, true); $this->currentItem->title = $e->title; $this->currentItem->description = $e->description; // $this->currentItem->src = rawurlencode($this->CustomEncode($this->config['contentFolder'] . $this->album . '/' . $filename)); $this->currentItem->originalURL = rawurlencode($this->CustomEncode($this->config['contentFolder'] . $this->album . '/' . $filename)); $this->currentItem->src = $this->GetImageDisplayURL($this->data->fullDir, $filename); + if( $this->currentItem->src == '' ) { $this->currentItem->src = $this->currentItem->originalURL; $imgSize = getimagesize($this->data->fullDir . '/' . $filename); diff --git a/nano_photos_provider2.php b/dist/nano_photos_provider2.php similarity index 64% rename from nano_photos_provider2.php rename to dist/nano_photos_provider2.php index a52f7f1..f2cd251 100644 --- a/nano_photos_provider2.php +++ b/dist/nano_photos_provider2.php @@ -12,7 +12,7 @@ * * * PHP 5.2+ - * @version 1.0.0 + * @version 1.1.0 * @author Christophe BRISBOIS - http://www.brisbois.fr/ * @Contributor Ruplahlava - https://github.com/Ruplahlava * @Contributor EelcoA - https://github.com/EelcoA @@ -34,15 +34,38 @@ case 'development': error_reporting(-1); ini_set('display_errors', 1); + $t = new galleryJSON(); break; case 'production': ini_set('display_errors', 0); + if (version_compare(PHP_VERSION, '5.3', '>=')) { error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); } else { error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE); } + + set_error_handler('myErrorHandler'); + function myErrorHandler($code, $message, $file, $line) { + header("HTTP/1.1 200 OK"); // we catched the error, so we send OK to let nanogallery2 display the error message (and so avoid a browser error) + header('Content-Type: application/json; charset=utf-8'); + $response = array('nano_status' => 'error', 'nano_message' => $message . '
('.basename($file).'/'.$line.')'); + $output = json_encode($response); + echo $output; + exit; + } + + // called at the end of the script (including abnormal end) + register_shutdown_function( function(){ + $last_error = error_get_last(); + if ($last_error['type'] === E_ERROR) { + // fatal error + myErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); + } + }); + + $t = new galleryJSON(); break; default: @@ -51,6 +74,5 @@ exit(1); // EXIT_ERROR } -$t = new galleryJSON(); ?> diff --git a/dist/nano_photos_provider2_check.php b/dist/nano_photos_provider2_check.php new file mode 100644 index 0000000..7a09621 --- /dev/null +++ b/dist/nano_photos_provider2_check.php @@ -0,0 +1,47 @@ +nanoPhotosProvide2 - installation check


'; + + echo 'Current PHP version: ' . phpversion() .'
'; + + if (extension_loaded('gd') && function_exists('gd_info')) { + echo 'PHP GD library is installed on your web server'; + } + else { + echo 'PHP GD library is NOT installed on your web server'; + } + echo '
'; + + echo 'Free disk space: ' . disk_free_space('.'); + echo '

'; + + echo 'Content folder:
' ; + $config = parse_ini_file('./nano_photos_provider2.cfg', true); + $content_folder = $config['config']['contentFolder']; + $fileExtensions = $config['config']['fileExtensions']; + + + $dh = opendir($content_folder); + + // check the content folder + if ($dh != false) { + while (false !== ($filename = readdir($dh))) { + $k = 'album'; + if (is_file($content_folder . '/' . $filename) ) { + $k= 'image'; + } + else { + // $files = glob($content_folder . '/' . $filename."/*.{".str_replace("|",",",$fileExtensions)."}", GLOB_BRACE); // to check if folder contains images + $files = preg_grep('~\.('.$fileExtensions.')$~', scandir($content_folder . '/' . $filename)); + $k = $k . ' - ' . sizeof($files); + } + if ($filename != '.' && $filename != '..' && $filename != '_thumbnails' ) { + echo '   ' . $filename . ' ['.$k.']
'; + } + } + closedir($dh); + } + + echo '




'; + phpinfo(); + +?> \ No newline at end of file diff --git a/nano_photos_content/berlin1.txt b/nano_photos_content/berlin1.txt deleted file mode 100644 index e7b1571..0000000 --- a/nano_photos_content/berlin1.txt +++ /dev/null @@ -1,2 +0,0 @@ -title: Berlin 1 -description: Berlin photo 1 \ No newline at end of file