Switch to testing image types against defined array of valid options
This commit is contained in:
parent
1dd3a3bc70
commit
5d3db365b4
|
|
@ -69,7 +69,7 @@ if ( $extracted ) {
|
|||
//$myext = substr($imgname, -3);
|
||||
if ( ! isset(pathinfo($imgname)['extension']) ) continue;
|
||||
$myext = strtolower(pathinfo($imgname)['extension']);
|
||||
if ( ($myext == "jpeg") || ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
|
||||
if ( in_array($myext, VALIDIMAGETYPES) ) {
|
||||
$imgname = str_replace("#", "", $imgname);
|
||||
$imgcontents = $zip->getFromIndex($i);
|
||||
$written = file_put_contents($comicoutputfull . $imgname, $imgcontents);
|
||||
|
|
@ -84,7 +84,7 @@ if ( $extracted ) {
|
|||
$entry->extract(false, $comicoutputfull . $outfile);
|
||||
if ( ! isset(pathinfo($outfile)['extension']) ) continue;
|
||||
$myext = strtolower(pathinfo($outfile)['extension']);
|
||||
if ( ($myext == "jpeg") || ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
|
||||
if ( in_array($myext, VALIDIMAGETYPES) ) {
|
||||
$files[] = basename($outfile);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,3 +43,4 @@ define('DBNAME', 'comics');
|
|||
define('SORTBYNAME', "Name");
|
||||
define('SORTBYDATE', "Date");
|
||||
define('SORTBYREAD', "Read");
|
||||
define('VALIDIMAGETYPES', array("jpg", "jpeg", "gif", "png", "webp"));
|
||||
|
|
|
|||
|
|
@ -14,6 +14,11 @@ function getAdultComics() {
|
|||
return $adultcomics;
|
||||
}
|
||||
|
||||
function safeFileName($file = "") {
|
||||
$to_remove = array("<", ">", "#", "\"", "/", "\\", "*", "?", "|");
|
||||
return str_replace($to_remove, '', $file);
|
||||
}
|
||||
|
||||
function makeThumb($item = "") {
|
||||
if ( $item == "" ) { return false; }
|
||||
$prefix = (substr(getcwd(), -4) == "ajax") ? "../" : "";
|
||||
|
|
@ -57,11 +62,7 @@ function makeThumb($item = "") {
|
|||
$parts = pathinfo($imgname);
|
||||
if ( isset($parts['extension']) ) {
|
||||
$imgext = strtolower($parts['extension']);
|
||||
if ( (strcmp($lowest, $imgname) > 0)
|
||||
&& ((strcasecmp($imgext, "jpg") == 0)
|
||||
|| (strcasecmp($imgext, "jpeg") == 0)
|
||||
|| (strcasecmp($imgext, "png") == 0)
|
||||
|| (strcasecmp($imgext, "webp") == 0)) ) {
|
||||
if ( (strcmp($lowest, $imgname) > 0) && in_array($imgext, VALIDIMAGETYPES) ) {
|
||||
$lowest = $imgname;
|
||||
$imgdata = $zip->getFromIndex($i);
|
||||
}
|
||||
|
|
@ -81,11 +82,7 @@ function makeThumb($item = "") {
|
|||
$parts = pathinfo($imgname);
|
||||
if ( isset($parts['extension']) ) {
|
||||
$imgext = strtolower($parts['extension']);
|
||||
if ( (strcmp($lowest, $imgname) > 0)
|
||||
&& ((strcasecmp($imgext, "jpg") == 0)
|
||||
|| (strcasecmp($imgext, "jpeg") == 0)
|
||||
|| (strcasecmp($imgext, "png") == 0)
|
||||
|| (strcasecmp($imgext, "webp") == 0)) ) {
|
||||
if ( (strcmp($lowest, $imgname) > 0) && in_array($imgext, VALIDIMAGETYPES) ) {
|
||||
$lowest = $imgname;
|
||||
$didwrite = $entry->extract(false, $outfile);
|
||||
if ( !$didwrite ) { return false; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user