From 1dd3a3bc70c2e9ea0d89553c942be4e6212907fb Mon Sep 17 00:00:00 2001 From: Junior Date: Tue, 10 Mar 2026 20:58:48 -0400 Subject: [PATCH] Fix the conditional check for thumbnail existence before generation --- ajax/getfoldercontents.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ajax/getfoldercontents.php b/ajax/getfoldercontents.php index 5cac934..7c9ff51 100644 --- a/ajax/getfoldercontents.php +++ b/ajax/getfoldercontents.php @@ -31,6 +31,11 @@ function compareNames($a, $b) { return strnatcmp($a["name"], $b["name"]); } +$data["compath"] = $compath; +$pathparts = pathinfo($compath); +$data["parentpath"] = $pathparts['dirname']; +$data["foldername"] = $pathparts['basename']; + $adultcomics = getAdultComics(); $compath = $_SESSION['compath']; @@ -52,6 +57,7 @@ while ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) { $folders = array(); $issues = array(); $entries = scandir($fullcompath); +$data["makethumb"] = array(); foreach ( $entries as $entry ) { if ( ($entry == ".") || ($entry == "..") ) continue; if ( (ADULTMODE || !$_SESSION['adult']) && in_array($entry, $adultcomics) ) continue; @@ -79,7 +85,7 @@ foreach ( $entries as $entry ) { $info["comname"] = substr(((strpos($entry, " - ") !== false) ? str_replace(" - ", "
", $entry) : $entry), 0, -4); $info["relcomic"] = base64_encode($compath . (($compath == "/") ? "" : "/") . $entry); $info["mtime"] = filemtime($fullcompath . $entry); - $info["thumburl"] = htmlentities(THUMBSDIR . $compath . (($compath == "/") ? "" : "/") . substr($entry, 0, -4), ENT_QUOTES) . ".jpg"; + $info["thumburl"] = THUMBSDIR . $compath . (($compath == "/") ? "" : "/") . substr($entry, 0, -4) . ".jpg"; if ( in_array($entry, $issues_read) ) { $info["read"] = true; $readclass = " readborder"; @@ -91,9 +97,11 @@ foreach ( $entries as $entry ) { $info["div"] .= ""; $info["div"] .= "
{$info["comname"]}"; $issues[] = $info; + $thumbfile = "../" . THUMBSDIR . $data['compath'] . "/" . $info['comname'] . ".jpg"; } } if ( isset($info["thumburl"]) && !file_exists("../" . $info["thumburl"]) ) { + $data["makethumb"][] = $info["thumburl"]; $havethumb = makeThumb($fullcompath . $entry); } } @@ -107,10 +115,6 @@ if ( $_SESSION["sortorder"] == SORTBYNAME ) { // Always sort issues by name usort($issues, "compareNames"); -$data["compath"] = $compath; -$pathparts = pathinfo($compath); -$data["parentpath"] = $pathparts['dirname']; -$data["foldername"] = $pathparts['basename']; $data["contents"] = array_merge($folders, $issues); header('Content-Type: application/json');