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