Fix the conditional check for thumbnail existence before generation

This commit is contained in:
Junior 2026-03-10 20:58:48 -04:00
parent bf8905f5f7
commit 1dd3a3bc70

View File

@ -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(" - ", "<br />", $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"] .= "<img class='issue' data-relcomic=\"{$info["relcomic"]}\" data-comname=\"{$info["comname"]}\" border=0 src=\"{$info["thumburl"]}\">";
$info["div"] .= "<br clear=all /><a href=\"downloadcomic.php?comic={$info["relcomic"]}\">{$info["comname"]}</a></div>";
$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');