From 49f9c92303a0a669808c4fa6847243a18cdaccd0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 25 Dec 2006 09:00:41 +0100 Subject: [PATCH] deprecate RSS_BACKEND_TYPE --- config.php-dist | 6 ---- functions.php | 73 +++++++++++------------------------------------- sanity_check.php | 47 ++++--------------------------- 3 files changed, 22 insertions(+), 104 deletions(-) diff --git a/config.php-dist b/config.php-dist index 3f12ba439..21725abc9 100644 --- a/config.php-dist +++ b/config.php-dist @@ -9,9 +9,6 @@ define('DB_PASS', "XXXXXX"); //define('DB_PORT', '5432'); // when neeeded, PG-only - define('RSS_BACKEND_TYPE', "magpie"); - // magpie (stable) or simplepie (EXPERIMENTAL!) - define('MAGPIE_FETCH_TIME_OUT', 60); // Magpie's default timeout is 5 seconds. Some RSS feeds, // such as from large Trac installs, can take significantly @@ -21,9 +18,6 @@ define('MAGPIE_CACHE_DIR', '/var/tmp/magpie-ttrss-cache'); // Local cache directory for RSS feeds - define('SIMPLEPIE_CACHE_DIR', '/var/tmp/simplepie-ttrss-cache'); - // Local cache directory for RSS feeds (simplepie) - define('WEB_DEMO_MODE', false); // Demo mode with reduced functionality. // Warning: this option is obsolete. Don't rely on it being diff --git a/functions.php b/functions.php index e4400cad4..201e290bb 100644 --- a/functions.php +++ b/functions.php @@ -12,16 +12,12 @@ require_once 'errors.php'; require_once 'version.php'; - if (RSS_BACKEND_TYPE == "magpie") { - define('MAGPIE_USER_AGENT_EXT', ' (Tiny Tiny RSS/' . VERSION . ')'); - require_once "magpierss/rss_fetch.inc"; - require_once 'magpierss/rss_utils.inc'; - } else if (RSS_BACKEND_TYPE == "simplepie") { - require_once 'simplepie/simplepie.inc'; - } - + define('MAGPIE_USER_AGENT_EXT', ' (Tiny Tiny RSS/' . VERSION . ')'); define('MAGPIE_OUTPUT_ENCODING', 'UTF-8'); + require_once "magpierss/rss_fetch.inc"; + require_once 'magpierss/rss_utils.inc'; + function purge_feed($link, $feed_id, $purge_interval, $debug = false) { $rows = -1; @@ -336,8 +332,6 @@ function update_rss_feed($link, $feed_url, $feed, $ignore_daemon = false) { - if (WEB_DEMO_MODE) return; - if (DAEMON_REFRESH_ONLY && !$_GET["daemon"] && !$ignore_daemon) { return; } @@ -366,31 +360,13 @@ } - if (RSS_BACKEND_TYPE == "magpie") { - error_reporting(0); - $rss = fetch_rss($fetch_url); - error_reporting (DEFAULT_ERROR_LEVEL); - } else if (RSS_BACKEND_TYPE == "simplepie") { - - if (!file_exists(SIMPLEPIE_CACHE_DIR)) { - mkdir(SIMPLEPIE_CACHE_DIR); - } - - $rss = new SimplePie(); - $rss->feed_url($fetch_url); - $rss->cache_location(SIMPLEPIE_CACHE_DIR); - $rss->init(); - } + error_reporting(0); + $rss = fetch_rss($fetch_url); + error_reporting (DEFAULT_ERROR_LEVEL); $feed = db_escape_string($feed); - $rss_check = $rss; - - if (RSS_BACKEND_TYPE == "simplepie") { - $rss_check = $rss->data; - } - - if ($rss_check) { + if ($rss) { // db_query($link, "BEGIN"); @@ -409,23 +385,15 @@ if (!$registered_title || $registered_title == "[Unknown]") { - if (RSS_BACKEND_TYPE == "magpie") { - $feed_title = db_escape_string($rss->channel["title"]); - } else { - $feed_title = $rss->get_feed_title(); - } + $feed_title = db_escape_string($rss->channel["title"]); db_query($link, "UPDATE ttrss_feeds SET title = '$feed_title' WHERE id = '$feed'"); } - if (RSS_BACKEND_TYPE == "magpie") { - $site_url = $rss->channel["link"]; - // weird, weird Magpie - if (!$site_url) $site_url = db_escape_string($rss->channel["link_"]); - } else { - $site_url = $rss->get_feed_link(); - } + $site_url = $rss->channel["link"]; + // weird, weird Magpie + if (!$site_url) $site_url = db_escape_string($rss->channel["link_"]); if ($site_url && $orig_site_url != db_escape_string($site_url)) { db_query($link, "UPDATE ttrss_feeds SET @@ -434,11 +402,7 @@ // print "I: " . $rss->channel["image"]["url"]; - if (RSS_BACKEND_TYPE == "magpie") { - $icon_url = $rss->image["url"]; - } else { - $icon_url = $rss->get_image_url(); # FIXME - } + $icon_url = $rss->image["url"]; if ($icon_url && !$orig_icon_url != db_escape_string($icon_url)) { $icon_url = db_escape_string($icon_url); @@ -469,15 +433,10 @@ array_push($filters[$line["name"]], $filter); } - if (RSS_BACKEND_TYPE == "magpie") { - $iterator = $rss->items; + $iterator = $rss->items; - if (!$iterator || !is_array($iterator)) $iterator = $rss->entries; - if (!$iterator || !is_array($iterator)) $iterator = $rss; - - } else { - $iterator = $rss->get_items(); - } + if (!$iterator || !is_array($iterator)) $iterator = $rss->entries; + if (!$iterator || !is_array($iterator)) $iterator = $rss; if (!is_array($iterator)) { /* db_query($link, "UPDATE ttrss_feeds diff --git a/sanity_check.php b/sanity_check.php index fa277f043..fe0d6cad0 100644 --- a/sanity_check.php +++ b/sanity_check.php @@ -9,45 +9,16 @@ require_once "config.php"; - if (CONFIG_VERSION != EXPECTED_CONFIG_VERSION) { - print _("Fatal Error: Your configuration file has - wrong version. Please copy new options from config.php-dist and - update CONFIG_VERSION directive.\n"); - exit; - } - - if (!defined('RSS_BACKEND_TYPE')) { - print _("Fatal error: RSS backend type is not defined - (config variable RSS_BACKEND_TYPE) - please check your - configuration file.\n"); - exit; - } - - if (RSS_BACKEND_TYPE == "magpie" && !file_exists("magpierss/rss_fetch.inc")) { - print _("Fatal Error: You forgot to place - MagpieRSS - distribution in magpierss/ - subdirectory of TT-RSS tree.\n"); - exit; - } - - if (RSS_BACKEND_TYPE == "simplepie" && !file_exists("simplepie/simplepie.inc")) { - print _("Fatal Error: You forgot to place - SimplePie - distribution in simplepie/ - subdirectory of TT-RSS tree.\n"); - exit; - } - - if (RSS_BACKEND_TYPE != "simplepie" && RSS_BACKEND_TYPE != "magpie") { - print _("Fatal Error: Invalid RSS_BACKEND_TYPE\n"); - exit; - } - if (CONFIG_VERSION != EXPECTED_CONFIG_VERSION) { return _("config: your config file version is incorrect. See config.php-dist.\n"); } + if (defined('RSS_BACKEND_TYPE')) { + print _("Fatal error: RSS_BACKEND_TYPE is deprecated. Please remove this + option from config.php\n"); + exit; + } + if (file_exists("xml-export.php") || file_exists("xml-import.php")) { print _("Fatal Error: XML Import/Export tools (xml-export.php and xml-import.php) could be used maliciously. Please remove them @@ -55,12 +26,6 @@ exit; } - if (RSS_BACKEND_TYPE != "magpie") { - print _("Fatal Error: RSS backends other than magpie are not - supported now.\n"); - exit; - } - if (SINGLE_USER_MODE && DAEMON_UPDATE_LOGIN_LIMIT > 0) { print _("Fatal Error: Please set DAEMON_UPDATE_LOGIN_LIMIT to 0 in single user mode.\n");