// 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
_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; }
$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): " .
<?php
-// This should be modifed as your own use warrants.
+ require_once "config.php";
+ require_once "simplepie/simplepie.inc";
-require_once('../simplepie.inc');
-SimplePie_Misc::display_cached_file($_GET['i'], './cache', 'spi');
+ SimplePie_Misc::display_cached_file($_GET['i'], SIMPLEPIE_CACHE_DIR, 'spi');
?>
name=\"include_in_digest\"
$checked><label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
+ $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 "<br><input type=\"checkbox\" id=\"cache_images\"
+ name=\"cache_images\" $disabled
+ $checked><label $label_class for=\"cache_images\">".
+ __('Cache images locally')."</label>";
+
print "</td></tr>";
print "</table>";
$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) {
$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',
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"]);
color : red;
}
-span.insensitive, div.insensitive, li.insensitive {
+span.insensitive, div.insensitive, li.insensitive, label.insensitive {
color : gray;
}