From: Andrew Dolgov Date: Sun, 26 Aug 2007 04:00:30 +0000 (+0100) Subject: enable caching of images X-Git-Tag: 1.2.15~40 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=bc0f07856012aa94eaea7c409e720d73f2fba0c3;p=tt-rss.git enable caching of images --- diff --git a/config.php-dist b/config.php-dist index 3664254e..ecacf202 100644 --- a/config.php-dist +++ b/config.php-dist @@ -167,13 +167,11 @@ // Cache directory for RSS feeds when using SimplePie define('SIMPLEPIE_CACHE_IMAGES', false); - // Ignore this option for now on, it doesn't work yet. - - // Cache feed images when using SimplePie. This will allow you to - // see images in feeds when originating server uses some sort of - // hotlink prevention at the expense of local bandwidth and - // disk space. - + // Allow caching feed images when using SimplePie, to bypass hotlink + // prevention and such at expense of local disk space and bandwidth. + // Note that you (or your users) also have to enable image caching + // in feed editor. + define('COUNTERS_MAX_AGE', 365); // Hard limit for unread counters calculation. Try tweaking this // parameter to speed up tt-rss when having a huge number of articles diff --git a/functions.php b/functions.php index d2f04216..c321f9b4 100644 --- a/functions.php +++ b/functions.php @@ -430,13 +430,14 @@ _debug("update_rss_feed: start"); } - $result = db_query($link, "SELECT update_interval,auth_login,auth_pass + $result = db_query($link, "SELECT update_interval,auth_login,auth_pass,cache_images FROM ttrss_feeds WHERE id = '$feed'"); $auth_login = db_fetch_result($result, 0, "auth_login"); $auth_pass = db_fetch_result($result, 0, "auth_pass"); $update_interval = db_fetch_result($result, 0, "update_interval"); + $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images")); if ($update_interval < 0) { return; } @@ -475,9 +476,13 @@ $rss->set_feed_url($fetch_url); $rss->set_output_encoding('UTF-8'); -/* if (SIMPLEPIE_CACHE_IMAGES) { + if (SIMPLEPIE_CACHE_IMAGES && $cache_images) { + if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) { + _debug("enabling image cache"); + } + $rss->set_image_handler('./image.php', 'i'); - } */ + } if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) { _debug("feed update interval (sec): " . diff --git a/image.php b/image.php index 49c3ec89..6bed38b7 100644 --- a/image.php +++ b/image.php @@ -1,6 +1,6 @@ diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index af7f772c..f0081a09 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -318,6 +318,27 @@ name=\"include_in_digest\" $checked>"; + $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images")); + + if ($cache_images) { + $checked = "checked"; + } else { + $checked = ""; + } + + if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) { + $disabled = ""; + $label_class = ""; + } else { + $disabled = "disabled"; + $label_class = "class='insensitive'"; + } + + print "
"; + print ""; print ""; @@ -351,6 +372,8 @@ $hidden = checkbox_to_sql_bool(db_escape_string($_POST["hidden"])); $include_in_digest = checkbox_to_sql_bool( db_escape_string($_POST["include_in_digest"])); + $cache_images = checkbox_to_sql_bool( + db_escape_string($_POST["cache_images"])); if (get_pref($link, 'ENABLE_FEED_CATS')) { if ($cat_id && $cat_id != 0) { @@ -371,6 +394,12 @@ $parent_qpart = 'parent_feed = NULL'; } + if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) { + $cache_images_qpart = "cache_images = $cache_images,"; + } else { + $cache_images_qpart = ""; + } + $result = db_query($link, "UPDATE ttrss_feeds SET $category_qpart $parent_qpart, title = '$feed_title', feed_url = '$feed_link', @@ -381,6 +410,7 @@ private = $private, rtl_content = $rtl_content, hidden = $hidden, + $cache_images_qpart include_in_digest = $include_in_digest WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); diff --git a/tt-rss.css b/tt-rss.css index 5d710708..a6b2d3b6 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -668,7 +668,7 @@ span.feed_error { color : red; } -span.insensitive, div.insensitive, li.insensitive { +span.insensitive, div.insensitive, li.insensitive, label.insensitive { color : gray; }