From 86e26f1a742f75ec208eb41019667329c9347010 Mon Sep 17 00:00:00 2001 From: Matt Katz Date: Fri, 9 Apr 2010 21:31:51 -0400 Subject: [PATCH] added filtering for private feeds to opml, and key lookup --- opml.php | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/opml.php b/opml.php index 44e94ee3..0de5dd33 100644 --- a/opml.php +++ b/opml.php @@ -15,7 +15,7 @@ $owner_uid = $_SESSION["uid"]; - function opml_export($link, $owner_uid) { + function opml_export($link, $owner_uid, $hide_private_feeds=False) { header("Content-type: application/xml+opml"); print ""; @@ -27,21 +27,25 @@ print ""; $cat_mode = false; + + $select = "SELECT * "; + $where = "WHERE owner_uid = '$owner_uid'"; + $orderby = "ORDER BY title"; + if ($hide_private_feeds){ + $where = "WHERE owner_uid = '$owner_uid' AND private IS false"; + } if (get_pref($link, 'ENABLE_FEED_CATS')) { $cat_mode = true; - $result = db_query($link, "SELECT - title,feed_url,site_url, - (SELECT title FROM ttrss_feed_categories WHERE id = cat_id) as cat_title - FROM ttrss_feeds - WHERE - owner_uid = '$owner_uid' - ORDER BY cat_title,title"); - } else { - $result = db_query($link, "SELECT * FROM ttrss_feeds - WHERE owner_uid = '$owner_uid' ORDER BY title"); + $select = "SELECT + title, feed_url, site_url, + (SELECT title FROM ttrss_feed_categories WHERE id = cat_id) as cat_title"; + $orderby = "ORDER BY cat_title, title"; + } + $result = db_query($link, $select." FROM ttrss_feeds ".$where." ".$orderby); + $old_cat_title = ""; while ($line = db_fetch_assoc($result)) { @@ -90,6 +94,22 @@ if ($op == "Export") { return opml_export($link, $owner_uid); } + if ($op == "publish"){ + $key = db_escape_string($_REQUEST["key"]); + + $result = db_query($link, "SELECT login, owner_uid + FROM ttrss_user_prefs, ttrss_users WHERE + pref_name = '_PREFS_PUBLISH_KEY' AND + value = '$key' AND + ttrss_users.id = owner_uid"); + + if (db_num_rows($result) == 1) { + $owner = db_fetch_result($result, 0, "owner_uid"); + return opml_export($link, $owner, True); + } else { + print "User not found"; + } + } if ($op == "Import") { -- 2.39.5