Change read status logic to be more efficient

This commit is contained in:
Junior 2026-11-09 19:00:44 -05:00
parent d0b610f572
commit b9b92ab1e4

View File

@ -31,7 +31,6 @@ function compareNames($a, $b) {
return strnatcmp($a["name"], $b["name"]); return strnatcmp($a["name"], $b["name"]);
} }
$adultcomics = getAdultComics();
$compath = $_SESSION['compath']; $compath = $_SESSION['compath'];
$fullcompath = COMICSDIR . $compath . (($compath == "/") ? "" : "/") . "/"; $fullcompath = COMICSDIR . $compath . (($compath == "/") ? "" : "/") . "/";
@ -52,9 +51,10 @@ $sth->execute();
$comics_read = array(); $comics_read = array();
$issues_read = array(); $issues_read = array();
while ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) { while ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) {
if ( !in_array($row['comic'], $comics_read) ) $comics_read[] = $row['comic']; $comics_read[$row['comic']] = true;
if ( !in_array($row['issue'], $issues_read) ) $issues_read[] = $row['issue']; $issues_read[$row['issue']] = true;
} }
$adultcomics = array_flip(getAdultComics());
$folders = array(); $folders = array();
$issues = array(); $issues = array();
@ -62,7 +62,7 @@ $entries = scandir($fullcompath);
$data["makethumb"] = array(); $data["makethumb"] = array();
foreach ( $entries as $entry ) { foreach ( $entries as $entry ) {
if ( ($entry == ".") || ($entry == "..") ) continue; if ( ($entry == ".") || ($entry == "..") ) continue;
if ( (ADULTMODE || !$_SESSION['adult']) && in_array($entry, $adultcomics) ) continue; if ( (ADULTMODE || !$_SESSION['adult']) && isset($adultcomics[$entry]) ) continue;
$info = array(); $info = array();
$info["name"] = $entry; $info["name"] = $entry;
$info["namesafe"] = htmlspecialchars($entry, ENT_QUOTES); $info["namesafe"] = htmlspecialchars($entry, ENT_QUOTES);
@ -72,7 +72,7 @@ foreach ( $entries as $entry ) {
$info["mtime"] = filemtime($fullcompath . $entry); $info["mtime"] = filemtime($fullcompath . $entry);
//$info["thumburl"] = htmlentities(THUMBSDIR . $compath . (($compath == "/") ? "" : "/") . $entry, ENT_QUOTES) . ".jpg"; //$info["thumburl"] = htmlentities(THUMBSDIR . $compath . (($compath == "/") ? "" : "/") . $entry, ENT_QUOTES) . ".jpg";
$info["thumburl"] = THUMBSDIR . $compath . (($compath == "/") ? "" : "/") . $entry . ".jpg"; $info["thumburl"] = THUMBSDIR . $compath . (($compath == "/") ? "" : "/") . $entry . ".jpg";
if ( in_array($entry, $comics_read) ) { if ( isset($comics_read[$entry]) ) {
$info["read"] = true; $info["read"] = true;
$readclass = " readborder"; $readclass = " readborder";
} else { } else {
@ -98,7 +98,7 @@ foreach ( $entries as $entry ) {
$info["relcomic"] = base64_encode($compath . (($compath == "/") ? "" : "/") . $entry); $info["relcomic"] = base64_encode($compath . (($compath == "/") ? "" : "/") . $entry);
$info["mtime"] = filemtime($fullcompath . $entry); $info["mtime"] = filemtime($fullcompath . $entry);
$info["thumburl"] = THUMBSDIR . $compath . (($compath == "/") ? "" : "/") . $withoutext . ".jpg"; $info["thumburl"] = THUMBSDIR . $compath . (($compath == "/") ? "" : "/") . $withoutext . ".jpg";
if ( in_array($entry, $issues_read) ) { if ( isset($issues_read[$entry]) ) {
$info["read"] = true; $info["read"] = true;
$readclass = " readborder"; $readclass = " readborder";
} else { } else {