Only check HTML files with first method

This commit is contained in:
Phyks 2014-07-18 23:34:58 +02:00
parent 635a5068c5
commit b34c66d08d

View File

@ -32,7 +32,12 @@ function getFavicon($urls) {
// Convert array to the good format for curl downloader
$curl_urls = array();
foreach($urls as $url) {
$curl_urls[] = array('url'=>$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);
@ -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);
}