summaryrefslogtreecommitdiff
path: root/functions.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2005-08-25 07:46:24 +0100
committerAndrew Dolgov <[email protected]>2005-08-25 07:46:24 +0100
commit78800912937468fc68219b0ae1190edc049282b7 (patch)
treeb48bf3e60375a8afc8df5980462a6ef0931be695 /functions.php
parent79a33f8922bf86c34bcc6a04bbfc917f4eba9653 (diff)
icons in feedlist
Diffstat (limited to 'functions.php')
-rw-r--r--functions.php38
1 files changed, 36 insertions, 2 deletions
diff --git a/functions.php b/functions.php
index 578020f23..4dafe4578 100644
--- a/functions.php
+++ b/functions.php
@@ -27,6 +27,38 @@
}
+ function check_feed_favicon($feed_url, $feed) {
+ $feed_url = str_replace("http://", "", $feed_url);
+ $feed_url = preg_replace("/\/.*$/", "", $feed_url);
+
+ $icon_url = "http://$feed_url/favicon.ico";
+ $icon_file = ICONS_DIR . "/$feed.ico";
+
+ if (!file_exists($icon_file)) {
+
+ error_reporting(0);
+ $r = fopen($icon_url, "r");
+ error_reporting (E_ERROR | E_WARNING | E_PARSE);
+
+ if ($r) {
+ $tmpfname = tempnam("/tmp", "ttrssicon");
+
+ $t = fopen($tmpfname, "w");
+
+ while (!feof($r)) {
+ $buf = fread($r, 16384);
+ fwrite($t, $buf);
+ }
+
+ fclose($r);
+ fclose($t);
+
+ rename($tmpfname, $icon_file);
+
+ }
+ }
+ }
+
function update_rss_feed($link, $feed_url, $feed) {
if (WEB_DEMO_MODE) return;
@@ -39,6 +71,10 @@
if ($rss) {
+ if (ENABLE_FEED_ICONS) {
+ check_feed_favicon($feed_url, $feed);
+ }
+
$result = pg_query("SELECT title FROM ttrss_feeds WHERE id = '$feed'");
$registered_title = pg_fetch_result($result, 0, "title");
@@ -186,6 +222,4 @@
}
-
-
?>