|
|
@ -345,9 +345,6 @@ if (!empty($q)) { |
|
|
|
// Get remote image data |
|
|
|
// Get remote image data |
|
|
|
if (empty($hostImage->data)) { |
|
|
|
if (empty($hostImage->data)) { |
|
|
|
|
|
|
|
|
|
|
|
// Define image variables |
|
|
|
|
|
|
|
$hostImageTimeBanned = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Init image request |
|
|
|
// Init image request |
|
|
|
$hostImageCurl = new Curl($hostImageURL, PROXY_CURLOPT_USERAGENT); |
|
|
|
$hostImageCurl = new Curl($hostImageURL, PROXY_CURLOPT_USERAGENT); |
|
|
|
|
|
|
|
|
|
|
@ -358,7 +355,7 @@ if (!empty($q)) { |
|
|
|
|
|
|
|
|
|
|
|
if (200 != $hostImageHttpCode) { |
|
|
|
if (200 != $hostImageHttpCode) { |
|
|
|
|
|
|
|
|
|
|
|
$hostImageTimeBanned = time(); |
|
|
|
$db->updateHostImageTimeBanned($hostImage->hostImageId, time()); |
|
|
|
|
|
|
|
|
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
@ -366,23 +363,31 @@ if (!empty($q)) { |
|
|
|
// Skip image processing on MIME type not provided |
|
|
|
// Skip image processing on MIME type not provided |
|
|
|
if (!$hostImageContentType = $hostImageCurl->getContentType()) { |
|
|
|
if (!$hostImageContentType = $hostImageCurl->getContentType()) { |
|
|
|
|
|
|
|
|
|
|
|
$hostImageTimeBanned = time(); |
|
|
|
$db->updateHostImageTimeBanned($hostImage->hostImageId, time()); |
|
|
|
|
|
|
|
|
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Skip image processing on MIME type not allowed in settings |
|
|
|
// Skip image processing on MIME type not allowed in settings |
|
|
|
if (false === strpos(CRAWL_IMAGE_MIME, $hostImageContentType)) { |
|
|
|
$hostImageBanned = true; |
|
|
|
|
|
|
|
foreach ((array) explode(',', CRAWL_IMAGE_MIME) as $mime) { |
|
|
|
|
|
|
|
|
|
|
|
$hostImageTimeBanned = time(); |
|
|
|
if (false !== strpos($hostImageContentType, trim($mime))) { |
|
|
|
|
|
|
|
|
|
|
|
continue; |
|
|
|
$hostImageBanned = false; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($hostImageBanned) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$hostImagesBanned += $db->updateHostImageTimeBanned($hostImage->hostImageId, time()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Skip image processing without returned content |
|
|
|
// Skip image processing without returned content |
|
|
|
if (!$hostImageContent = $hostImageCurl->getContent()) { |
|
|
|
if (!$hostImageContent = $hostImageCurl->getContent()) { |
|
|
|
|
|
|
|
|
|
|
|
$hostImageTimeBanned = time(); |
|
|
|
$db->updateHostImageTimeBanned($hostImage->hostImageId, time()); |
|
|
|
|
|
|
|
|
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
@ -390,14 +395,14 @@ if (!empty($q)) { |
|
|
|
// Convert remote image data to base64 string to prevent direct URL call |
|
|
|
// Convert remote image data to base64 string to prevent direct URL call |
|
|
|
if (!$hostImageExtension = @pathinfo($hostImageURL, PATHINFO_EXTENSION)) { |
|
|
|
if (!$hostImageExtension = @pathinfo($hostImageURL, PATHINFO_EXTENSION)) { |
|
|
|
|
|
|
|
|
|
|
|
$hostImageTimeBanned = time(); |
|
|
|
$db->updateHostImageTimeBanned($hostImage->hostImageId, time()); |
|
|
|
|
|
|
|
|
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!$hostImageBase64 = @base64_encode($hostImageContent)) { |
|
|
|
if (!$hostImageBase64 = @base64_encode($hostImageContent)) { |
|
|
|
|
|
|
|
|
|
|
|
$hostImageTimeBanned = time(); |
|
|
|
$db->updateHostImageTimeBanned($hostImage->hostImageId, time()); |
|
|
|
|
|
|
|
|
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
@ -408,8 +413,7 @@ if (!empty($q)) { |
|
|
|
$db->updateHostImage($hostImage->hostImageId, |
|
|
|
$db->updateHostImage($hostImage->hostImageId, |
|
|
|
Filter::mime($hostImageContentType), |
|
|
|
Filter::mime($hostImageContentType), |
|
|
|
CRAWL_HOST_DEFAULT_META_ONLY ? null : $hostImageURLencoded, |
|
|
|
CRAWL_HOST_DEFAULT_META_ONLY ? null : $hostImageURLencoded, |
|
|
|
time(), |
|
|
|
time()); |
|
|
|
$hostImageTimeBanned); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Local image data exists |
|
|
|
// Local image data exists |
|
|
|
} else { |
|
|
|
} else { |
|
|
|