Change logic/order for detecting appropriate image types when extracting comics for showing

This commit is contained in:
Junior 2026-09-04 14:02:41 -04:00
parent af6d0d8338
commit 6afdaeda78

View File

@ -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 {