properly remove and replace favicon color when favicon gets manually removed/uploaded

master
Andrew Dolgov 12 years ago
parent 86f7d2a9f2
commit bc7a144dd5

@ -464,6 +464,9 @@ class Pref_Feeds extends Handler_Protected {
if (db_num_rows($result) != 0) { if (db_num_rows($result) != 0) {
@unlink(ICONS_DIR . "/$feed_id.ico"); @unlink(ICONS_DIR . "/$feed_id.ico");
db_query($this->link, "UPDATE ttrss_feeds SET favicon_avg_color = NULL
where id = '$feed_id'");
} }
return; return;
@ -498,8 +501,19 @@ class Pref_Feeds extends Handler_Protected {
if (db_num_rows($result) != 0) { if (db_num_rows($result) != 0) {
@unlink(ICONS_DIR . "/$feed_id.ico"); @unlink(ICONS_DIR . "/$feed_id.ico");
rename($icon_file, ICONS_DIR . "/$feed_id.ico"); if (rename($icon_file, ICONS_DIR . "/$feed_id.ico")) {
$rc = 0;
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 { } else {
$rc = 2; $rc = 2;
} }

@ -336,6 +336,6 @@ function hsl2rgb($arr) {
} }
} }
} }
return false; return '';
} }
?> ?>

@ -412,17 +412,16 @@
$favicon_file = ICONS_DIR . "/$feed.ico"; $favicon_file = ICONS_DIR . "/$feed.ico";
if (file_exists($favicon_file)) { if (file_exists($favicon_file)) {
require_once "colors.php"; require_once "colors.php";
$favicon_color = db_escape_string($link, $favicon_color = db_escape_string($link,
calculate_avg_color($favicon_file)); 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'"); WHERE id = '$feed'");
} }

Loading…
Cancel
Save