diff --git a/ajax/getfoldercontents.php b/ajax/getfoldercontents.php index ac5fcd3..060e744 100644 --- a/ajax/getfoldercontents.php +++ b/ajax/getfoldercontents.php @@ -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 {