From c34b9bd0aac7e0e7ee13bb848a28b98a81e17c21 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Thu, 16 Jun 2022 15:11:33 +0200 Subject: [PATCH] Improve wish image and favicon generation --- src/api/wishes.php | 6 +++--- src/classes/cache/embed.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/wishes.php b/src/api/wishes.php index b1d77b14..d4b5c4d7 100644 --- a/src/api/wishes.php +++ b/src/api/wishes.php @@ -35,7 +35,7 @@ switch ($_SERVER['REQUEST_METHOD']) { if (isset($info->url) && $info->url) { $code = URL::getResponseCode($info->url); - if (200 !== $code) { + if ($code < 200 || $code >= 400) { $info->url = $url; } } @@ -87,7 +87,7 @@ switch ($_SERVER['REQUEST_METHOD']) { if (!empty($info->image)) { $codeImage = URL::getResponseCode($info->image); - if (200 === $codeImage) { + if ($codeImage >= 200 && $codeImage < 400) { $wish_image = '"' . $info->image . '"'; } } @@ -156,7 +156,7 @@ switch ($_SERVER['REQUEST_METHOD']) { if (!empty($info->image)) { $codeImage = URL::getResponseCode($info->image); - if (200 === $codeImage) { + if ($codeImage >= 200 && $codeImage < 400) { $wish_image = '"' . $info->image . '"'; } } diff --git a/src/classes/cache/embed.php b/src/classes/cache/embed.php index a3dc6b9b..37e875aa 100644 --- a/src/classes/cache/embed.php +++ b/src/classes/cache/embed.php @@ -101,13 +101,13 @@ class Embed extends Cache curl_close($ch); - $info->favicon = $favicon && 200 === $code ? 'data:image/x-icon;base64,' . base64_encode($favicon) : ''; + $info->favicon = $favicon && ($code >= 200 && $code < 400) ? 'data:image/x-icon;base64,' . base64_encode($favicon) : ''; } /** URL */ $codeURL = \wishthis\URL::getResponseCode($info->url); - if (200 !== $codeURL) { + if ($codeURL < 200 || $codeURL >= 400) { $generateCache = false; } }