]> git.wh0rd.org Git - tt-rss.git/commitdiff
properly remove and replace favicon color when favicon gets manually removed/uploaded
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 15 Apr 2013 14:22:48 +0000 (18:22 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 15 Apr 2013 14:22:48 +0000 (18:22 +0400)
classes/pref/feeds.php
include/colors.php
include/rssfuncs.php

index c57cccc44e9f17fd2e5ce2fc4ec6e78c364f4a8e..c5d6245fe8712e627ee920bdbd8e778ca7adc29d 100644 (file)
@@ -464,6 +464,9 @@ class Pref_Feeds extends Handler_Protected {
 
                if (db_num_rows($result) != 0) {
                        @unlink(ICONS_DIR . "/$feed_id.ico");
+
+                       db_query($this->link, "UPDATE ttrss_feeds SET favicon_avg_color = NULL
+                               where id = '$feed_id'");
                }
 
                return;
@@ -498,8 +501,19 @@ class Pref_Feeds extends Handler_Protected {
 
                                if (db_num_rows($result) != 0) {
                                        @unlink(ICONS_DIR . "/$feed_id.ico");
-                                       rename($icon_file, ICONS_DIR . "/$feed_id.ico");
-                                       $rc = 0;
+                                       if (rename($icon_file, ICONS_DIR . "/$feed_id.ico")) {
+
+                                               require_once "colors.php";
+
+                                               $favicon_color = db_escape_string($this->link,
+                                                       calculate_avg_color(ICONS_DIR . "/$feed_id.ico"));
+
+                                               db_query($this->link, "UPDATE ttrss_feeds SET
+                                                       favicon_avg_color = '$favicon_color'
+                                                       WHERE id = '$feed_id'");
+
+                                               $rc = 0;
+                                       }
                                } else {
                                        $rc = 2;
                                }
index 19c8915177473b3cdc007f02d29a6e5014d1f75d..1359b9e2d8f9978e937593320363df4de11f2788 100644 (file)
@@ -336,6 +336,6 @@ function hsl2rgb($arr) {
                                }
                        }
                }
-               return false;
+               return '';
        }
 ?>
index 250534bd745af8d18be21992399d75bba373e8a2..283e485324f3bb1b90d4f831a172a0cfaababb50 100644 (file)
                                $favicon_file = ICONS_DIR . "/$feed.ico";
 
                                if (file_exists($favicon_file)) {
-                                                require_once "colors.php";
+                                               require_once "colors.php";
 
-                                                $favicon_color = db_escape_string($link,
-                                                        calculate_avg_color($favicon_file));
+                                               $favicon_color = db_escape_string($link,
+                                                       calculate_avg_color($favicon_file));
 
-                                                if ($debug_enabled) _debug("color: $favicon_color");
-
-                                                $favicon_colorstring = ",favicon_avg_color = '".$favicon_color."'";
+                                               $favicon_colorstring = ",favicon_avg_color = '".$favicon_color."'";
                                }
 
-                               db_query($link, "UPDATE ttrss_feeds SET favicon_last_checked = NOW() $favicon_colorstring
+                               db_query($link, "UPDATE ttrss_feeds SET favicon_last_checked = NOW()
+                                       $favicon_colorstring
                                        WHERE id = '$feed'");
                        }