Skip to content

Commit

Permalink
v1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris-B committed Dec 28, 2020
1 parent aa3b5c8 commit ac567b8
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 45 deletions.
13 changes: 12 additions & 1 deletion dist/nano_photos_provider2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@ maxSize = 1900
jpegQuality = 85

[thumbnails]
jpegQuality = 90
jpegQuality = 85
blurredImageQuality = 3
allowedSizeValues = ""
;allowedSizeValues = "50|100|225|150|200|300|auto"
;serverSizeDefinition = false;
;width_xs = 75;
;height_xs = 50;
;width_sm = 150;
;height_sm = 100;
;width_me = 300;
;height_me = 200;
;width_la = 450;
;height_la = 300;
;width_xl = 600;
;height_xl = 400;

[security]
allowOrigins = "*"
Expand Down
10 changes: 5 additions & 5 deletions dist/nano_photos_provider2.encoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* @author "Sebastián Grignoli" <grignoli@gmail.com>
* @package Encoding
* @version 2.0
* @version 2.0 / fixed for PHP 8
* @link https://github.com/neitanod/forceutf8
* @example https://github.com/neitanod/forceutf8
* @license Revised BSD
Expand Down Expand Up @@ -193,11 +193,11 @@ static function toUTF8($text){

$buf = "";
for($i = 0; $i < $max; $i++){
$c1 = $text{$i};
$c1 = $text[$i];
if($c1>="\xc0"){ //Should be converted to UTF8, if it's not UTF8 already
$c2 = $i+1 >= $max? "\x00" : $text{$i+1};
$c3 = $i+2 >= $max? "\x00" : $text{$i+2};
$c4 = $i+3 >= $max? "\x00" : $text{$i+3};
$c2 = $i+1 >= $max? "\x00" : $text[$i+1];
$c3 = $i+2 >= $max? "\x00" : $text[$i+2];
$c4 = $i+3 >= $max? "\x00" : $text[$i+3];
if($c1 >= "\xc0" & $c1 <= "\xdf"){ //looks like 2 bytes UTF8
if($c2 >= "\x80" && $c2 <= "\xbf"){ //yeah, almost sure it's UTF8 already
$buf .= $c1 . $c2;
Expand Down
106 changes: 87 additions & 19 deletions dist/nano_photos_provider2.json.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@
/**
* nanoPhotosProvider2 add-on for nanogallery2
*
* This is an add-on for nanogallery2 (image gallery - http://nanogallery2.nanostudio.org).
* This is an add-on for nanogallery2 (image gallery - https://nanogallery2.nanostudio.org).
* This PHP application will publish your images and albums from a PHP webserver to nanogallery2.
* The content is provided on demand, one album at one time.
* Responsive thumbnails are generated automatically.
* Thumbnails and blurred preview images are generated automatically.
* Dominant colors are extracted as a base64 GIF.
*
* 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.
* License: nanoPhotosProvider2 is open source and licensed under GPLv3 license.
*
* PHP 5.2+
* @version 1.2.0
* PHP 5.3+
* @version 1.2.1
* @author Christophe BRISBOIS - http://www.brisbois.fr/
* @copyright Copyright 2015+
* @license GPL v3 and commercial
* @license GPL v3
* @link https://github.com/nanostudio-org/nanoPhotosProvider2
* @Support https://github.com/nanostudio-org/nanoPhotosProvider2/issues
*
*
* Thanks to:
* - Ruplahlava https://github.com/Ruplahlava
* - EelcoA - https://github.com/EelcoA
* - eae710 - https://github.com/eae710
* - Kevin Robert Keegan - https://github.com/krkeegan
* - Jesper Cockx - https://github.com/jespercockx
* - bhartvigsen - https://github.com/bhartvigsen
Expand All @@ -40,6 +42,7 @@ class item
public $src = ''; // image URL
public $title = ''; // item title
public $description = ''; // item description
public $tags = ''; // item tags
public $ID = ''; // item ID
public $albumID = '0'; // parent album ID
public $kind = ''; // 'album', 'image'
Expand Down Expand Up @@ -87,17 +90,63 @@ public function __construct()

$this->setConfig(self::CONFIG_FILE);


// thumbnail responsive sizes
$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'] ));

// default and server side defined sizes
// $this->tn_size['wxs'] = $this->config['thumbnails']['width_xs'];
// $this->tn_size['hxs'] = $this->config['thumbnails']['height_xs'];
// $this->tn_size['wsm'] = $this->config['thumbnails']['width_sm'];
// $this->tn_size['hsm'] = $this->config['thumbnails']['height_sm'];
// $this->tn_size['wme'] = $this->config['thumbnails']['width_me'];
// $this->tn_size['hme'] = $this->config['thumbnails']['height_me'];
// $this->tn_size['wla'] = $this->config['thumbnails']['width_la'];
// $this->tn_size['hla'] = $this->config['thumbnails']['height_la'];
// $this->tn_size['wxl'] = $this->config['thumbnails']['width_xl'];
// $this->tn_size['hxl'] = $this->config['thumbnails']['height_xl'];

// if( $this->config['thumbnails']['serverSizeDefinition'] == false ) {
// server side size definition is only used for default values
if (array_key_exists('wxs', $_GET)) {
$this->tn_size['wxs'] = strtolower($this->CheckThumbnailSize( $_GET['wxs'] ));
}
if (array_key_exists('hxs', $_GET)) {
$this->tn_size['hxs'] = strtolower($this->CheckThumbnailSize( $_GET['hxs'] ));
}

if (array_key_exists('wsm', $_GET)) {
$this->tn_size['wsm'] = strtolower($this->CheckThumbnailSize( $_GET['wsm'] ));
}
if (array_key_exists('hsm', $_GET)) {
$this->tn_size['hsm'] = strtolower($this->CheckThumbnailSize( $_GET['hsm'] ));
}

if (array_key_exists('wme', $_GET)) {
$this->tn_size['wme'] = strtolower($this->CheckThumbnailSize( $_GET['wme'] ));
}
if (array_key_exists('hme', $_GET)) {
$this->tn_size['hme'] = strtolower($this->CheckThumbnailSize( $_GET['hme'] ));
}

if (array_key_exists('wla', $_GET)) {
$this->tn_size['wla'] = strtolower($this->CheckThumbnailSize( $_GET['wla'] ));
}
if (array_key_exists('hla', $_GET)) {
$this->tn_size['hla'] = strtolower($this->CheckThumbnailSize( $_GET['hla'] ));
}

if (array_key_exists('wxl', $_GET)) {
$this->tn_size['wxl'] = strtolower($this->CheckThumbnailSize( $_GET['wxl'] ));
}
if (array_key_exists('hxl', $_GET)) {
$this->tn_size['hxl'] = strtolower($this->CheckThumbnailSize( $_GET['hxl'] ));
}
// }






$this->data = new galleryData();
$this->data->fullDir = ($this->config['contentFolder']) . ($this->album);
Expand Down Expand Up @@ -279,7 +328,7 @@ protected function SendData( $response )
header('Content-Type: application/json; charset=utf-8');

// add app version
$response[nanophotosprovider] = self::APP_VERSION;
$response['nanophotosprovider'] = self::APP_VERSION;
// return the data
$output = json_encode($response); // UTF-8 encoding is mandatory
if (isset($_GET['jsonp'])) {
Expand Down Expand Up @@ -336,6 +385,24 @@ protected function setConfig($filePath)
$this->config['thumbnails']['jpegQuality'] = $tq;
}

// if( isset( $config['thumbnails']['serverSizeDefinition'] ) ) {
// $this->config['thumbnails']['serverSizeDefinition'] = $config['thumbnails']['serverSizeDefinition'];
// }
// else {
// $this->config['thumbnails']['serverSizeDefinition'] = false;
// }
// $this->config['thumbnails']['width_xs'] = $config['thumbnails']['width_xs'];
// $this->config['thumbnails']['height_xs'] = $config['thumbnails']['height_xs'];
// $this->config['thumbnails']['width_sm'] = $config['thumbnails']['width_sm'];
// $this->config['thumbnails']['height_sm'] = $config['thumbnails']['height_sm'];
// $this->config['thumbnails']['width_me'] = $config['thumbnails']['width_me'];
// $this->config['thumbnails']['height_me'] = $config['thumbnails']['height_me'];
// $this->config['thumbnails']['width_la'] = $config['thumbnails']['width_la'];
// $this->config['thumbnails']['height_la'] = $config['thumbnails']['height_la'];
// $this->config['thumbnails']['width_xl'] = $config['thumbnails']['width_xl'];
// $this->config['thumbnails']['height_xl'] = $config['thumbnails']['height_xl'];


$tbq = $config['thumbnails']['blurredImageQuality'];
$this->config['thumbnails']['blurredImageQuality'] = 3; // default blurred image quality
if( ctype_digit(strval($tbq)) ){
Expand Down Expand Up @@ -793,11 +860,12 @@ protected function GenerateThumbnail2($baseFolder, $imagefilename, $thumbnailFil
$height = $size[1];

$originalAspect = $width / $height;
$thumbAspect = $thumbWidth / $thumbHeight;
// $thumbAspect = $thumbWidth / $thumbHeight;

if ( $thumbWidth != 'auto' && $thumbHeight != 'auto' ) {
// IMAGE CROP
// some inspiration found in donkeyGallery (from Gix075) https://github.com/Gix075/donkeyGallery
$thumbAspect = $thumbWidth / $thumbHeight;
if ($originalAspect >= $thumbAspect) {
// If image is wider than thumbnail (in aspect ratio sense)
$newHeight = $thumbHeight;
Expand Down
45 changes: 27 additions & 18 deletions dist/nano_photos_provider2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,50 @@
/**
* nanoPhotosProvider2 add-on for nanogallery2
*
* This is an add-on for nanogallery2 (image gallery - http://nanogallery2.nanostudio.org).
* This is an add-on for nanogallery2 (image gallery - https://nanogallery2.nanostudio.org).
* This PHP application will publish your images and albums from a PHP webserver to nanogallery2.
* The content is provided on demand, one album at one time.
* Thumbnails and blurred preview images are generated automatically.
* Dominant colors are extracted as a base64 GIF.
*
* License: GPLv3 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.
* License: nanoPhotosProvider2 is open source and licensed under GPLv3 license.
*
*
* PHP 5.2+
* @version 1.2.0
* PHP 5.3+
* @version 1.2.1
* @author Christophe BRISBOIS - http://www.brisbois.fr/
* @Contributor Ruplahlava - https://github.com/Ruplahlava
* @Contributor EelcoA - https://github.com/EelcoA
* @Contributor eae710 - https://github.com/eae710
* @copyright Copyright 2015+
* @license GPL v3 and commercial
* @license GPL v3
* @link https://github.com/nanostudio-org/nanoPhotosProvider2
* @Support https://github.com/nanostudio-org/nanoPhotosProvider2/issues
*
*
* Thanks to:
* - Ruplahlava https://github.com/Ruplahlava
* - EelcoA - https://github.com/EelcoA
* - eae710 - https://github.com/eae710
* - Kevin Robert Keegan - https://github.com/krkeegan
* - Jesper Cockx - https://github.com/jespercockx
* - bhartvigsen - https://github.com/bhartvigsen
*/
require './nano_photos_provider2.json.class.php';

require './nano_photos_provider2.json.class.php';

// Available values development, production
// Codeigniter env switch https://github.com/bcit-ci/CodeIgniter/

define('ENVIRONMENT', 'production');




switch (ENVIRONMENT) {
case 'development':
error_reporting(-1);
ini_set('display_errors', 1);
$t = new galleryJSON();
break;


case 'production':
ini_set('display_errors', 0);

Expand All @@ -46,14 +55,14 @@
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
}

set_error_handler('myErrorHandler');
// 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;
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)
Expand Down
12 changes: 10 additions & 2 deletions dist/nano_photos_provider2_check.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
echo 'Current PHP version: ' . phpversion() .'<br>';

if (extension_loaded('gd') && function_exists('gd_info')) {
echo 'PHP GD library is installed on your web server';
echo 'GD library is enabled on your web server';
}
else {
echo 'PHP GD library is NOT installed on your web server';
echo 'GD library is NOT enabled on your web server';
}
echo '<br>';

if (extension_loaded('exif') ) {
echo 'EXIF library is enabled on your web server';
}
else {
echo 'EXIF library is NOT enabled on your web server';
}
echo '<br>';

Expand Down

0 comments on commit ac567b8

Please sign in to comment.