mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-24 03:49:10 -04:00
ALPHA 3.0.2a
This commit is contained in:
@@ -84,14 +84,15 @@ class Image extends Base
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_FILE, $fp);
|
||||
$success = curl_exec($ch) && curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200;
|
||||
|
||||
if ($success) {
|
||||
fclose($fp);
|
||||
} else {
|
||||
unlink($filepath);
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
curl_close($ch);
|
||||
|
||||
if (!$success) {
|
||||
unlink($filepath);
|
||||
|
||||
// could not contact the distant URL or HTTP error - fail silently.
|
||||
return false;
|
||||
}
|
||||
} elseif (ini_get('allow_url_fopen')) {
|
||||
// use remote fopen() via copy()
|
||||
$success = copy($url, $filepath);
|
||||
@@ -99,11 +100,6 @@ class Image extends Base
|
||||
return new \RuntimeException('The image formatter downloads an image from a remote HTTP server. Therefore, it requires that PHP can request remote hosts, either via cURL or fopen()');
|
||||
}
|
||||
|
||||
if (!$success) {
|
||||
// could not contact the distant URL or HTTP error - fail silently.
|
||||
return false;
|
||||
}
|
||||
|
||||
return $fullPath ? $filepath : $filename;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user