From 75682cb2bab634df22f219f12b564b7f6e53b20b Mon Sep 17 00:00:00 2001 From: Stefan Brand Date: Tue, 11 Jan 2022 16:25:49 +0100 Subject: [PATCH] Add directory Support --- conf/config.php | 2 +- img/folder.png | Bin 0 -> 2229 bytes index.php | 9 +++++++-- tpl/gallery.html | 7 +++++++ 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 img/folder.png diff --git a/conf/config.php b/conf/config.php index eb6ab64..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'] = 'r34'; +$conf['defdir'] = ''; ?> \ No newline at end of file diff --git a/img/folder.png b/img/folder.png new file mode 100644 index 0000000000000000000000000000000000000000..29757b85a9fa32acb213187dfcfa92bc7c29affd GIT binary patch literal 2229 zcmb_cX;2eb5`KUP;tE6|xMVm4Rv1w*LnH`BPy*ppGag7lIRpg>1{4ATAyF1NVnBk( zN;nisl;OTizyabA2##_Y0tN<92ShG096~}!CQj9E?f#jXs@bl3)nD~{-TifSeJ}0A zG0ZkKT{Qr}Hdhz)_W&r!p#o6dEO)+FpInr?EfFr>*8ouGd_4*|=ISs2R4=)rkDQ7f zo*zAjFNoG-3&)oZP30FhMl~c8YjiflG*fOfZ`^U%v?WW&lEb2@4tZQC&I%bY*WNF@ zX?8yCxt-&F{LU4{O-wWNj&HDc|9RGX6BE8Q%5rqD5%qX#QW$7?g#~+ByYxlmTNzfz zllrwL6h0npgUIRp8SAs76W0t|KX*|lT^84k-jA8M4x%~A5G(>^`ow8sVUn~slq&Jc zGKG8gE$-bv(jV_Mb254Ng83Z{(S+ z;@Msn_Cb{0?YuZi8-G?GfLNbF|(@<;g-DDEg3v+yE&!EQm1ZizGPLx z#~EKNZ|n*eYak2A)!AbptUHIH-#U_XWOx;7m==_Ax+#x{K}t#pG3IrWV2UhOL2j-gOHjywqyq<4*OvRICdxUYYWxRndih zfRAhcVBZcg3ktoPKCN4F#7D)jcgg7*KQGI^UCzNwTWqm^dqXt%FxyRkEHUV|x*>|I z4>Ac^0<2}^(`7u+rIljk;4<))!hGUv00jU=pb89s2kbJIY~50P(Let3ODnxzF$u&Z z%p##5F(E-UcuiYJpZsYvpy;r*QS5swzR|?*n}}!HhQA8KuCwznDs$k z|31*be$f-0`Ht&g= z>jGMJCRbQ^n<{U(mQLmuZj;g@v!FC>j`vBzM5KQybj0-1djer0vrQ7VXNJaGSC9Fc z#sa^@id-t51-t%jn~efvFcD%)2>7HvMkO&S|J^mW z$c;zs!YSnH7WOoYIC+PU#x!5-xC8R5s9bTSiS75M6{Alz*i9Qw=4lxS#0f15PYUV> z+=`8(e;QsPD?G?G4pw#es`pJmlT!bW-lZp})ty?t+d+#vu;{$OTCIY+M^z*(v_#MK zx}Hg`c%zftdc*8q@4hNKY)wQ%jN%Cf<8b7X zY3NWEb96!3;~~!snNT2{N?d!E`Y+T-bwU2T zjxQ^g-}O9A=&triy47N$y2v+dOJDhz0hz=bEJ_g8iY54KA%Yy)n5+l3-fRn~ zRV)-qX3*C5osk;^;&uJQY*Fi6hGjyxl|tNnp{#q~@k7$ysl*0RmtVJKtGEie`#gEq z!VEy8moxY36^=5)I{KOG&zAlgyQ*uTi_+jWc4h2GM2`uk&3zXOc#Br{l!PS(*?UDSSHH<=2 zvRqytr6XtCA#g3o1_XOMbwKwa6=7TqO=;sZ?O&*!B$X7xpx}=!ge+4YDkpySq?ZML Oed+3S3|)29|K@Lz56pJ} literal 0 HcmV?d00001 diff --git a/index.php b/index.php index ba9e8c1..4f584f7 100644 --- a/index.php +++ b/index.php @@ -36,7 +36,11 @@ if (isset($_SESSION['files']) { $files = $_SESSION['files']; } else { - $files = array_diff(scandir($imagedir.$dir, SCANDIR_SORT_DESCENDING), array('..', '.')); + $dirs = glob($imagedir.$dir.'/*' , GLOB_ONLYDIR); + $rmdirs = $dirs; + $rmdirs[] = '.'; + $rmdirs[] = '..'; + $files = array_diff(scandir($imagedir.$dir, SCANDIR_SORT_DESCENDING), $rmdirs); $_SESSION['files'] = $files; $_SESSION['dir'] = $dir; $_SESSION['cachetime'] = time(); @@ -60,7 +64,7 @@ $files = array_reverse($files); // Get Files for current Page $curfiles = array_slice($files, ($page-1)*$slice ,$slice, true); -if (count($curfiles) > 0) { +if (count($curfiles) > 0 | count($dirs) > 0) { // Prepare Generic Data for Template $data['galleryname'] = $galleryname; $data['startpage'] = $_SERVER['PHP_SELF']; @@ -83,6 +87,7 @@ if (count($curfiles) > 0) { $tmp['i'] = $index+1; $tmp['t'] = $thumburl.$t->get_thumb($image); $data['images'][] = $tmp; + $data['dirs'] = $dirs; } Template::view('tpl/gallery.html', $data); } else { diff --git a/tpl/gallery.html b/tpl/gallery.html index 071109a..2b8b785 100644 --- a/tpl/gallery.html +++ b/tpl/gallery.html @@ -16,6 +16,13 @@
+ {% foreach($dirs as $d): %} +
+ + {{ $d }} + +
+ {% endforeach %} {% foreach($images as $image): %}