Add ADULTMODE feature to hide adult themed comics

This commit is contained in:
Junior 2023-11-14 08:25:05 -05:00
parent 65ce549848
commit 3ea9a2a5dd
3 changed files with 17 additions and 0 deletions

View File

@ -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);

View File

@ -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") ? "../" : "";

View File

@ -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
//