Add auto-getting favicons for links

This commit is contained in:
2023-08-21 16:18:47 +03:00
parent 0595a64f93
commit 12e0a58258
20 changed files with 62 additions and 2 deletions
+16
View File
@@ -0,0 +1,16 @@
<?php
function save_favicon($url, $path='./ico/') {
$url = parse_url($url, PHP_URL_HOST);
$file = $path.$url.'.png';
if ( !file_exists($file)) {
$fp = fopen ($file, 'w+');
$ch = curl_init('http://www.google.com/s2/favicons?domain='.$url);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_FILE, $fp); /* Save the returned Data to File */
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
return $file;
}