summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGregor Tätzner <gregor@freenet.de>2012-07-23 21:02:49 +0200
committerGregor Tätzner <gregor@freenet.de>2012-07-23 21:02:49 +0200
commit4abcc53a178b8393ecbe812567093d89e1827eb3 (patch)
tree806f1cba59d2e44dffbd093887ca9483e11e714c /lib
parent4161bb9241d9e7c22242e1e3061e810b86357685 (diff)
Use base url for extracting favicon
Diffstat (limited to 'lib')
-rw-r--r--lib/utils.php17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/utils.php b/lib/utils.php
index 2afa229ca..3e7562609 100644
--- a/lib/utils.php
+++ b/lib/utils.php
@@ -43,23 +43,22 @@ class OC_News_Utils {
$feed = new OC_News_Feed($url, $title, $items);
$favicon = $spfeed->get_image_url();
- //check if this file exists and the size with getimagesize()
- if ($favicon == null) { //try really hard to find a favicon
- if( null !== ($webFavicon = OC_News_Utils::discoverFavicon($url)) )
- $feed->setFavicon($webFavicon);
- }
- else { //use favicon from feed
+ if ($favicon !== null) { // use favicon from feed
if(OC_News_Utils::checkFavicon($favicon))
$feed->setFavicon($favicon);
}
+ else { // try really hard to find a favicon
+ if( null !== ($webFavicon = OC_News_Utils::discoverFavicon($url)) )
+ $feed->setFavicon($webFavicon);
+ }
return $feed;
}
public static function checkFavicon($favicon) {
$file = new SimplePie_File($favicon);
- //TODO additional checks?
+ //TODO additional checks? getimagesize()?
if($file->success && strlen($file->body) > 0) {
$sniffer = new SimplePie_Content_Type_Sniffer($file);
if(substr($sniffer->get_type(), 0, 6) === 'image/') {
@@ -77,8 +76,10 @@ class OC_News_Utils {
return $favicon;
//try to extract favicon from web page
+ $absoluteUrl = SimplePie_Misc::absolutize_url('/', $url);
+
$handle = curl_init ( );
- curl_setopt ( $handle, CURLOPT_URL, $url );
+ curl_setopt ( $handle, CURLOPT_URL, $absoluteUrl );
curl_setopt ( $handle, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $handle, CURLOPT_FOLLOWLOCATION, TRUE );
curl_setopt ( $handle, CURLOPT_MAXREDIRS, 10 );