<?php
function httpcode($url){
$ch = curl_init();
$timeout = 3;
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch,CURLOPT_URL,$url);
curl_exec($ch);
return $httpcode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
}?>
<?php
function favicon_file($site_url){
$diy_fav = $site_url."favicon.ico";
$site_md5 = md5($diy_fav);
$fav_url = TEMPLATE_URL.'favicon/';
$fav_path = TEMPLATE_PATH.'favicon/';
$t = 2592000;
if(is_file($fav_path.$site_md5.'.png') == false || (time() - filemtime($fav_path.$site_md5.'.png')) > $t) {
if(httpcode($diy_fav) == 200){copy($site_url.'favicon.ico',$fav_path.$site_md5.'.png');}else{
copy($fav_path.'link.png',$fav_path.$site_md5.'.png');
}
}else{$endurl = $fav_url.$site_md5.'.png';}
return $endurl;
}?>
使用方法:<img width="16" height="16" src="<?php echo favicon_file($value['url']); ?>" alt="<?php echo $value['link']; ?>" style="padding-right:5px;" />
免责声明:
本页网址:点击复制分享给朋友吧!
本站分享的一切内容资源如若没有备注,均为蓝叶原创,如需转载请注明出处;如有侵权请与我们联系处理。敬请谅解!