From 3ea9a2a5dd544c5ff26e74df644abe0aa6a10096 Mon Sep 17 00:00:00 2001 From: Junior Date: Tue, 14 Nov 2023 08:25:05 -0500 Subject: [PATCH] Add ADULTMODE feature to hide adult themed comics --- ajax/getfoldercontents.php | 3 +++ functions.php | 9 +++++++++ variables-dist.php | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/ajax/getfoldercontents.php b/ajax/getfoldercontents.php index aac0557..1dfd28b 100644 --- a/ajax/getfoldercontents.php +++ b/ajax/getfoldercontents.php @@ -18,6 +18,8 @@ function compareNames($a, $b) { return strnatcmp($a["name"], $b["name"]); } +$adultcomics = getAdultComics(); + $compath = $_SESSION['compath']; $fullcompath = COMICSDIR . (($compath == "/") ? "" : $compath) . "/"; @@ -40,6 +42,7 @@ $issues = array(); $entries = scandir($fullcompath); foreach ( $entries as $entry ) { if ( ($entry == ".") || ($entry == "..") ) continue; + if ( (ADULTMODE || !$_SESSION['adult']) && in_array($entry, $adultcomics) ) continue; $info = array(); $info["name"] = $entry; $info["namesafe"] = htmlspecialchars($entry, ENT_QUOTES); diff --git a/functions.php b/functions.php index b0eb92e..19334dc 100644 --- a/functions.php +++ b/functions.php @@ -5,6 +5,15 @@ function microtime_float() { return ((float)$usec + (float)$sec); } +function getAdultComics() { + $adultlist = COMICSDIR . "/adultcomics.json"; + $adultcomics = array(); + if ( file_exists($adultlist) ) { + $adultcomics = json_decode(file_get_contents($adultlist), true); + } + return $adultcomics; +} + function makeThumb($item = "") { if ( $item == "" ) { return false; } $prefix = (substr(getcwd(), -4) == "ajax") ? "../" : ""; diff --git a/variables-dist.php b/variables-dist.php index 911a9ba..8fcaa0c 100644 --- a/variables-dist.php +++ b/variables-dist.php @@ -24,6 +24,11 @@ define('THUMBSDIR', 'thumbs'); // define('EXTRACTSDIR', 'comics'); +// +// Whether the system will display "adult" comics (i.e. PG-13+) +// +define('ADULTMODE', false); + // // Database information for tracking last read page //