From 5ef0996bbd20f5ceb0025c9bf54d85728556d828 Mon Sep 17 00:00:00 2001 From: Oliver Lang Date: Mon, 3 Jun 2019 23:03:25 +0200 Subject: [PATCH] Provider::small generates files into Settings::$small_dir --- src/classes/AdminStats.php | 2 +- src/classes/Provider.php | 6 +----- src/classes/Settings.php | 10 ++++++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/classes/AdminStats.php b/src/classes/AdminStats.php index 2b4f98f..9709370 100644 --- a/src/classes/AdminStats.php +++ b/src/classes/AdminStats.php @@ -72,7 +72,7 @@ public function Calculate() { $this->stats['Items'] = sizeof(Menu::list_files(Settings::$photos_dir,true)); - $this->stats['Generated items'] = sizeof(Menu::list_files(Settings::$thumbs_dir,true)); + $this->stats['Generated items'] = sizeof(Menu::list_files(Settings::$thumbs_dir,true)) + sizeof(Menu::list_files(Settings::$small_dir,true)); $this->stats['Albums'] = sizeof(Menu::list_dirs(Settings::$photos_dir,true)); diff --git a/src/classes/Provider.php b/src/classes/Provider.php index 2cb8e85..383525a 100755 --- a/src/classes/Provider.php +++ b/src/classes/Provider.php @@ -256,16 +256,12 @@ public static function small($file) { require_once dirname(__FILE__).'/../phpthumb/phpthumb.class.php'; - $basefile = new File($file); - $basepath = File::a2r($file); - $webimg = dirname($basepath) . "/" . $basefile->name . "_small." . $basefile->extension; - list($x,$y) = getimagesize($file); if($x <= 1200 && $y <= 1200){ return $file; } - $path = File::r2a($webimg, Settings::$thumbs_dir); + $path = File::r2a(File::a2r($file),Settings::$small_dir); /// Create smaller image if (!file_exists($path) || filectime($file) > filectime($path)) { diff --git a/src/classes/Settings.php b/src/classes/Settings.php index 80036b7..be2cd0a 100644 --- a/src/classes/Settings.php +++ b/src/classes/Settings.php @@ -51,6 +51,9 @@ class Settings extends Page /// Directory where the thumbs are stored static public $thumbs_dir; + /// Directory where the small images are stored + static public $small_dir; + /// Directory where the configuration files are stored static public $conf_dir; @@ -212,6 +215,7 @@ static public function init($forced = false, $config_file = NULL){ /// Setup variables Settings::$photos_dir = $config->photos_dir; Settings::$thumbs_dir = $config->ps_generated."/Thumbs/"; + Settings::$small_dir = $config->ps_generated."/Small/"; Settings::$conf_dir = $config->ps_generated."/Conf/"; Settings::$admin_settings_file = $config->ps_generated."/Conf/admin_settings.ini"; @@ -255,6 +259,12 @@ static public function init($forced = false, $config_file = NULL){ } } + if(!file_exists(Settings::$small_dir)){ + if(! @mkdir(Settings::$small_dir,0750,true)){ + throw new Exception("PS_GENERATED dir '".Settings::$small_dir."' doesn't exist or doesn't have the good rights."); + } + } + if(!file_exists(Settings::$conf_dir)){ if(! @mkdir(Settings::$conf_dir,0750,true)){ throw new Exception("PS_GENERATED dir '".Settings::$conf_dir."' doesn't exist or doesn't have the good rights.");