From 9947f2b706da4adf8680e81a178b0aa971882c2d Mon Sep 17 00:00:00 2001 From: Stefan Brand Date: Tue, 11 Jan 2022 17:19:02 +0100 Subject: [PATCH] Also Cache Dir List --- conf/config.php | 2 +- index.php | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/conf/config.php b/conf/config.php index bdf514c..2d56c2d 100644 --- a/conf/config.php +++ b/conf/config.php @@ -22,6 +22,6 @@ $conf['defpage'] = 1; // Images per Page if not specified $conf['defslice'] = 34; // Default Subdirectory if none given -$conf['defdir'] = '/'; +$conf['defdir'] = ''; ?> \ No newline at end of file diff --git a/index.php b/index.php index 35c293f..83a0926 100644 --- a/index.php +++ b/index.php @@ -32,12 +32,16 @@ session_start(); $t = new Thumb(Helpers::end_dir($imagedir.$dir), $thumbdir, 200, 200); // Filelist Cache Handling -if (isset($_SESSION[$dir]) - && (time() - $_SESSION[$dir]['t']) < $conf['flcache'] +$cdir = $dir; +if (empty($cdir)) + $cdir = '/'; + +if (isset($_SESSION[$cdir]) + && (time() - $_SESSION[$cdir]['t']) < $conf['flcache'] && !isset($_GET['refcache'])) { - $files = $_SESSION[$dir]['f']; - $dirs = $_SESSION[$dir]['d']; + $files = $_SESSION[$cdir]['f']; + $dirs = $_SESSION[$cdir]['d']; } else { $r_imagedir = realpath($imagedir.$dir); if ($r_imagedir === false || strpos(Helpers::end_dir($r_imagedir), $r_basedir.DIRECTORY_SEPARATOR) !== 0) { @@ -53,9 +57,9 @@ if (isset($_SESSION[$dir]) $rmdirs[] = '.'; $rmdirs[] = '..'; $files = array_diff(scandir($imagedir.$dir, SCANDIR_SORT_DESCENDING), $rmdirs); - $_SESSION[$dir]['f'] = $files; - $_SESSION[$dir]['d'] = $dirs; - $_SESSION[$dir]['t'] = time(); + $_SESSION[$cdir]['f'] = $files; + $_SESSION[$cdir]['d'] = $dirs; + $_SESSION[$cdir]['t'] = time(); } // Apply Filters to Filelist