mirror of
https://github.com/LinkStackOrg/LinkStack.git
synced 2025-05-05 12:28:59 +02:00
Update favicon.blade.php
This commit is contained in:
parent
3609d1477a
commit
e201b4cbb1
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
use App\Models\Link;
|
||||
|
||||
if (!function_exists('getFaviconURL')) {
|
||||
function getFaviconURL($url)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
@ -61,7 +62,9 @@ function getFaviconURL($url)
|
||||
}
|
||||
return $faviconURL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('getRedirectUrlFromHeaders')) {
|
||||
function getRedirectUrlFromHeaders($headers)
|
||||
{
|
||||
if (preg_match('/^Location:\s+(.*)$/mi', $headers, $matches)) {
|
||||
@ -69,7 +72,9 @@ function getRedirectUrlFromHeaders($headers)
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('extractFaviconUrlFromDOM')) {
|
||||
function extractFaviconUrlFromDOM($dom)
|
||||
{
|
||||
$xpath = new DOMXPath($dom);
|
||||
@ -90,13 +95,17 @@ function extractFaviconUrlFromDOM($dom)
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('checkURLExists')) {
|
||||
function checkURLExists($url)
|
||||
{
|
||||
$headers = @get_headers($url);
|
||||
return ($headers && strpos($headers[0], '200') !== false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('extractFaviconUrlWithRegex')) {
|
||||
function extractFaviconUrlWithRegex($html)
|
||||
{
|
||||
// Check for the historical rel="shortcut icon"
|
||||
@ -113,7 +122,9 @@ function extractFaviconUrlWithRegex($html)
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('getAbsoluteUrl')) {
|
||||
function getAbsoluteUrl($baseUrl, $relativeUrl)
|
||||
{
|
||||
$parsedUrl = parse_url($baseUrl);
|
||||
@ -130,7 +141,9 @@ function getAbsoluteUrl($baseUrl, $relativeUrl)
|
||||
return "$basePath/$relativeUrl"; // Path-relative URL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('getFavIcon')) {
|
||||
function getFavIcon($id)
|
||||
{
|
||||
try {
|
||||
@ -170,4 +183,4 @@ function getFavIcon($id)
|
||||
return url('assets/favicon/icons/' . $filename);
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user