summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-04-15 15:08:00 +0400
committerAndrew Dolgov <[email protected]>2013-04-15 15:08:00 +0400
commit687a4f59c8d8be091b732ae6714fbdc140169d47 (patch)
treeb9a8993035e4cd05902de51d4b125eb9e8c05cb2 /include
parent14118af36f2ba65a4e5151ee33b6ad565492cbf0 (diff)
store favicon color as #rrggbb; process existing favicons
Diffstat (limited to 'include')
-rw-r--r--include/rssfuncs.php32
1 files changed, 19 insertions, 13 deletions
diff --git a/include/rssfuncs.php b/include/rssfuncs.php
index 498700906..bcc88dc2a 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'");
}