Only check HTML files with first method
This commit is contained in:
parent
635a5068c5
commit
b34c66d08d
20
favicon.php
20
favicon.php
@ -32,8 +32,13 @@ function getFavicon($urls) {
|
||||
// Convert array to the good format for curl downloader
|
||||
$curl_urls = array();
|
||||
foreach($urls as $url) {
|
||||
if (endswith($url, '.html')) { // Only check html files using first method
|
||||
$curl_urls[] = array('url'=>$url);
|
||||
}
|
||||
else {
|
||||
$errors[] = $url;
|
||||
}
|
||||
}
|
||||
|
||||
$contents = curl_downloader($curl_urls);
|
||||
foreach($contents['status_codes'] as $url=>$status) {
|
||||
@ -97,7 +102,7 @@ function getFavicon($urls) {
|
||||
$parsed_url = parse_url(trim($url));
|
||||
$second_try_url = "";
|
||||
if(isset($parsed_url['scheme'])) {
|
||||
$second_try_url .= $parsed_url['scheme'];
|
||||
$second_try_url .= $parsed_url['scheme'].'://';
|
||||
}
|
||||
if(isset($parsed_url['host'])) {
|
||||
$second_try_url .= $parsed_url['host'];
|
||||
@ -206,3 +211,16 @@ function curl_downloader($urls, $fetch_content=true) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check that $haystack ends with $needle.
|
||||
*/
|
||||
function endswith($haystack, $needle) {
|
||||
$length = strlen($needle);
|
||||
if ($length == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (substr($haystack, -$length) === $needle);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user