From 5d7328613da31b7ce1fce57dcc404eb71cab7280 Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Sat, 26 Apr 2014 21:02:50 +0200 Subject: [PATCH] Continue url-import even when an error occurs --- php/modules/Import.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/php/modules/Import.php b/php/modules/Import.php index b72168f..b4bbb25 100644 --- a/php/modules/Import.php +++ b/php/modules/Import.php @@ -30,25 +30,31 @@ class Import extends Module { static function url($urls, $albumID = 0) { + $error = false; + # Parse $urls = str_replace(' ', '%20', $urls); $urls = explode(',', $urls); foreach ($urls as &$url) { - if (@exif_imagetype($url)!==false) { - - $pathinfo = pathinfo($url); - $filename = $pathinfo['filename'] . '.' . $pathinfo['extension']; - $tmp_name = LYCHEE_DATA . $filename; - - if (!@copy($url, $tmp_name)) return false; - + if (@exif_imagetype($url)===false) { + $error = true; + continue; } + $pathinfo = pathinfo($url); + $filename = $pathinfo['filename'] . '.' . $pathinfo['extension']; + $tmp_name = LYCHEE_DATA . $filename; + + if (@copy($url, $tmp_name)===false) $error = true; + } - return Import::server($albumID, LYCHEE_DATA); + $import = Import::server($albumID, LYCHEE_DATA); + + if ($error===false&&$import===true) return true; + else return false; }