From 687a4f59c8d8be091b732ae6714fbdc140169d47 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Apr 2013 15:08:00 +0400 Subject: [PATCH] store favicon color as #rrggbb; process existing favicons --- include/rssfuncs.php | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/include/rssfuncs.php b/include/rssfuncs.php index 49870090..bcc88dc2 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -259,6 +259,8 @@ $cache_timestamp = file_exists($cache_filename) ? filemtime($cache_filename) : 0; $last_updated_timestamp = strtotime($last_updated); + $force_refetch = isset($_REQUEST["force_refetch"]); + if (file_exists($cache_filename) && is_readable($cache_filename) && !$auth_login && !$auth_pass && @@ -275,7 +277,7 @@ $rss_hash = sha1($rss_data); @$rss = unserialize($rss_data); } - } else { + } else if (!$force_refetch) { if ($debug_enabled) { _debug("update_rss_feed: local cache valid and older than last_updated, nothing to do."); } @@ -290,8 +292,6 @@ _debug("update_rss_feed: fetching [$fetch_url] (ts: $cache_timestamp/$last_updated_timestamp)"); } - $force_refetch = isset($_REQUEST["force_refetch"]); - $feed_data = fetch_file_contents($fetch_url, false, $auth_login, $auth_pass, false, $no_cache ? FEED_FETCH_NO_CACHE_TIMEOUT : FEED_FETCH_TIMEOUT, @@ -403,18 +403,24 @@ $site_url = db_escape_string($link, mb_substr(rewrite_relative_url($fetch_url, $rss->get_link()), 0, 245)); - if ($debug_enabled) { - _debug("update_rss_feed: checking favicon..."); - } + if ($favicon_needs_check || $force_refetch) { + if ($debug_enabled) { + _debug("update_rss_feed: checking favicon..."); + } + + check_feed_favicon($site_url, $feed, $link); + $favicon_file = ICONS_DIR . "/$feed.ico"; + + if (file_exists($favicon_file)) { + $favicon_color = calculate_avg_color($favicon_file); - if ($favicon_needs_check) { - $favicon_file = check_feed_favicon($site_url, $feed, $link); - if ($favicon_file) { - $favicon_color = calculate_avg_color($favicon_file); - if (is_array($favicon_color)) - $favicon_colorstring = ",favicon_avg_color = '" . implode("|", array_slice($favicon_color, 0, 3)) . "'"; + require_once "colors.php"; + + if (is_array($favicon_color)) + $favicon_colorstring = ",favicon_avg_color = '" . + _color_pack(array_slice($favicon_color, 0, 3)) . "'"; } - + db_query($link, "UPDATE ttrss_feeds SET favicon_last_checked = NOW() $favicon_colorstring WHERE id = '$feed'"); } -- 2.39.2