Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris-B committed Aug 1, 2017
1 parent 43580f2 commit 44974a6
Show file tree
Hide file tree
Showing 19 changed files with 148 additions and 27 deletions.
17 changes: 15 additions & 2 deletions 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)
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 2 additions & 0 deletions dist/nano_photos_content/berlin1.txt
@@ -0,0 +1,2 @@
title: Berlin 1
description: Berlin photo 1
File renamed without changes
File renamed without changes
25 changes: 25 additions & 0 deletions 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

File renamed without changes.
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand All @@ -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' &&
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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));
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
26 changes: 24 additions & 2 deletions nano_photos_provider2.php → dist/nano_photos_provider2.php
Expand Up @@ -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
Expand All @@ -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 . '<br> ('.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:
Expand All @@ -51,6 +74,5 @@
exit(1); // EXIT_ERROR
}

$t = new galleryJSON();

?>
47 changes: 47 additions & 0 deletions dist/nano_photos_provider2_check.php
@@ -0,0 +1,47 @@
<?php
echo '<b>nanoPhotosProvide2 - installation check</b><br><br><br>';

echo 'Current PHP version: ' . phpversion() .'<br>';

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 '<br>';

echo 'Free disk space: ' . disk_free_space('.');
echo '<br><br>';

echo '<b>Content folder:</b><br>' ;
$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 '&nbsp;&nbsp;&nbsp;' . $filename . ' ['.$k.']<br>';
}
}
closedir($dh);
}

echo '<br><br><br><br><br>';
phpinfo();

?>
2 changes: 0 additions & 2 deletions nano_photos_content/berlin1.txt

This file was deleted.

0 comments on commit 44974a6

Please sign in to comment.