From 6afdaeda78d29d12c37a6d7037ac7db9d052f5d9 Mon Sep 17 00:00:00 2001 From: Junior Date: Fri, 4 Sep 2026 14:02:41 -0400 Subject: [PATCH] Change logic/order for detecting appropriate image types when extracting comics for showing --- ajax/showcomic.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/ajax/showcomic.php b/ajax/showcomic.php index fcb4822..47a000f 100644 --- a/ajax/showcomic.php +++ b/ajax/showcomic.php @@ -66,27 +66,24 @@ if ( $extracted ) { $opened = $zip->open($comicfull); for ( $i=0; $i<$zip->numFiles; $i++ ) { $imgname = basename($zip->getNameIndex($i)); - //$myext = substr($imgname, -3); if ( ! isset(pathinfo($imgname)['extension']) ) continue; $myext = strtolower(pathinfo($imgname)['extension']); - if ( in_array($myext, VALIDIMAGETYPES) ) { - $imgname = str_replace("#", "", $imgname); - $imgcontents = $zip->getFromIndex($i); - $written = file_put_contents($comicoutputfull . $imgname, $imgcontents); - if ( $written ) $files[] = $imgname; - } + if ( ! in_array($myext, VALIDIMAGETYPES) ) continue; + $imgname = str_replace("#", "", $imgname); + $imgcontents = $zip->getFromIndex($i); + $written = file_put_contents($comicoutputfull . $imgname, $imgcontents); + if ( $written ) $files[] = $imgname; } } elseif ( $ext == "cbr" ) { $rar = RarArchive::open($comicfull); $entries = $rar->getEntries(); foreach ( $entries as $entry ) { $outfile = str_replace("#", "", basename($entry->getName())); - $entry->extract(false, $comicoutputfull . $outfile); if ( ! isset(pathinfo($outfile)['extension']) ) continue; $myext = strtolower(pathinfo($outfile)['extension']); - if ( in_array($myext, VALIDIMAGETYPES) ) { - $files[] = basename($outfile); - } + if ( ! in_array($myext, VALIDIMAGETYPES) ) continue; + $entry->extract(false, $comicoutputfull . $outfile); + $files[] = basename($outfile); } unset($entry); } else {