Improved favicon API

This commit is contained in:
Julian Prieber 2022-12-09 18:06:53 +01:00
parent 63d53752b9
commit 699ed0ae4a

View File

@ -2412,8 +2412,21 @@ if(!function_exists('get_headers'))
} }
$headers = get_headers($urlICO, 1); $headers = get_headers($urlICO, 1);
$headersImage = get_headers($urlICO);
if ($headers[0] == 'HTTP/1.1 200 OK' or $headers[0] == 'HTTP/1.1 301 Moved Permanently') { foreach ($headersImage as $header) {
if (stripos($header, 'Content-Type:') === 0) {
if (stripos($header, 'image/') !== false) {
$isIco = true;
} else {
$isIco = false;
}
break;
}
}
if (($headers[0] == 'HTTP/1.1 200 OK' or $headers[0] == 'HTTP/1.1 301 Moved Permanently') and $isIco === true) {
$favicon = $urlICO; $favicon = $urlICO;
} else { } else {
@ -2445,6 +2458,8 @@ if(!file_exists(base_path("studio/favicon/icons")."/".$id.".".$extension)){
} }
} catch (exception $e) {} } catch (exception $e) {}
$favicon = preg_replace('/([^:])(\/{2,})/', '$1/', $favicon);
return $favicon; return $favicon;
} }