]> git.wh0rd.org Git - tt-rss.git/commitdiff
icons in feedlist
authorAndrew Dolgov <fox@madoka.spb.ru>
Thu, 25 Aug 2005 06:46:24 +0000 (07:46 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Thu, 25 Aug 2005 06:46:24 +0000 (07:46 +0100)
README
backend.php
config.php-dist
functions.php

diff --git a/README b/README
index e2620e061d1ed91cecc6eb49d1b4645f3cb1bccd..2bea749b5cb2c109494a27278d9dd7edf014898a 100644 (file)
--- a/README
+++ b/README
@@ -17,4 +17,6 @@ Requirements:
 
 Don't forget to copy config.php-dist to config.php and edit it.
 
+icons/ directory should be writable for your httpd user.
+
 Send your questions, comments, patches to Andrew Dolgov <cthulhoo@gmail.com>
index 6bc6ab9df86148b68e1dca0e13af649ea52fbb4a..fc973edb8fa0af6f19c00002b07c4c9b82b52f41 100644 (file)
 
                        print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">";
 
+                       $icon_file = ICONS_DIR . "/$feed_id.ico";
+       
+                       if (file_exists($icon_file) && filesize($icon_file) > 0) {
+                               $feed_icon = "<img width=\"16\" height=\"16\"
+                                       src=\"" . ICONS_URL . "/$feed_id.ico\">";
+                       } else {
+                               $feed_icon = "&nbsp;";
+                       }
+                       
                        $feed = "<a href=\"javascript:viewfeed($feed_id, 0);\">$feed</a>";
+                       if (ENABLE_FEED_ICONS) {
+                               print "<td>$feed_icon</td>";
+                       }
                        print "<td id=\"FEEDN-$feed_id\">$feed</td>";
                        print "<td>";
                        print "<span id=\"FEEDU-$feed_id\">$unread</span>&nbsp;/&nbsp;";
index c7b3a55bd9ac161a5024ace06e073bace9579bd2..c237d41a9719f6576454b9f7527fed24fefe5180 100644 (file)
@@ -5,5 +5,9 @@
        define(HEADLINES_PER_PAGE, 15);
        define(MIN_UPDATE_TIME, 1800);
        define(WEB_DEMO_MODE, false);
+       define(ENABLE_FEED_ICONS, true);
+       define(ICONS_DIR, "icons");
+       define(ICONS_URL, "icons");
+
 ?>
 
index 578020f239c811cb6c021f13d59b7ba82326c356..4dafe4578958f1a7832decde3bc9da9019af26e0 100644 (file)
 
        }
 
+       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;
        
                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");
        }
 
 
-
-
 ?>