Mirv-Startpage/get_fav.php

17 lines
503 B
PHP
Raw Permalink Normal View History

2023-08-21 16:18:47 +03:00
<?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;
}