From 945c243e355d8f06779a395bda2f66bb0fd795c2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 9 Aug 2007 14:09:34 +0100 Subject: [PATCH] more published feeds work --- backend.php | 33 +++++++++++++++++++++++++++++++-- functions.php | 2 ++ modules/backend-rpc.php | 17 +++++++++++++++++ modules/pref-feeds.php | 2 +- prefs.js | 20 ++++++++++++++------ 5 files changed, 65 insertions(+), 9 deletions(-) diff --git a/backend.php b/backend.php index d5272ddae..9454702fb 100644 --- a/backend.php +++ b/backend.php @@ -56,7 +56,7 @@ $print_exec_time = false; if ((!$op || $op == "rpc" || $op == "rss" || $op == "view" || - $op == "digestSend" || $op == "viewfeed" || + $op == "digestSend" || $op == "viewfeed" || $op == "publish" || $op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) { header("Content-Type: application/xml; charset=utf-8"); } else { @@ -69,7 +69,7 @@ } if (!($_SESSION["uid"] && validate_session($link)) && $op != "globalUpdateFeeds" - && $op != "rss" && $op != "getUnread") { + && $op != "rss" && $op != "getUnread" && $op != "publish") { if ($op == "rpc" || $op == "viewfeed" || $op == "view") { print_error_xml(6); die; @@ -404,6 +404,33 @@ module_pref_feed_browser($link); } + if ($op == "publish") { + $key = db_escape_string($_GET["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"); + $login = db_fetch_result($result, 0, "login"); + + $_SESSION["uid"] = $owner; + + generate_syndicated_feed($link, -2, false); + + session_destroy(); + } else { + + $_SESSION["uid"] = 0; + generate_syndicated_feed($link, -2, false); + session_destroy(); + } + + } + if ($op == "rss") { $feed = db_escape_string($_GET["id"]); $user = db_escape_string($_GET["user"]); @@ -424,6 +451,8 @@ generate_syndicated_feed($link, $feed, $is_cat, $search, $search_mode, $match_on); } + + session_destroy(); } if ($op == "labelFromSearch") { diff --git a/functions.php b/functions.php index a77d2f85c..8157d12d2 100644 --- a/functions.php +++ b/functions.php @@ -2279,6 +2279,8 @@ function getFeedTitle($link, $id) { if ($id == -1) { return __("Starred articles"); + } else if ($id == -2) { + return __("Published articles"); } else if ($id < -10) { $label_id = -10 - $id; $result = db_query($link, "SELECT description FROM ttrss_labels WHERE id = '$label_id'"); diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 1e757ca72..ddf33a0df 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -295,6 +295,23 @@ } + if ($subop == "regenPubKey") { + + print ""; + + set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key()); + + $url_path = 'http://' . $_SERVER["HTTP_HOST"] . \ + parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); + + $new_link = $url_path . "?op=publish&key=" . get_pref($link, "_PREFS_PUBLISH_KEY"); + + print ""; + + print ""; + + } + if ($subop == "logout") { logout_user(); print_error_xml(6); diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index b5070c7e9..173244245 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -1057,7 +1057,7 @@ $url_path .= "?op=publish&key=" . get_pref($link, "_PREFS_PUBLISH_KEY"); - print "

$url_path

"; + print "

$url_path

"; print "

"; diff --git a/prefs.js b/prefs.js index a662aeef7..0fec36206 100644 --- a/prefs.js +++ b/prefs.js @@ -16,7 +16,6 @@ var caller_subop = false; var sanity_check_done = false; -/* function replace_pubkey_callback() { if (xmlhttp.readyState == 4) { try { @@ -24,15 +23,25 @@ function replace_pubkey_callback() { if (xmlhttp.responseXML) { + var new_link = xmlhttp.responseXML.getElementsByTagName("link")[0]; + + if (new_link) { + link.href = new_link.firstChild.nodeValue; + link.innerHTML = new_link.firstChild.nodeValue; + + notify_info("Address changed"); + } else { + notify_error("Could not change address"); + } } else { - notify_error("Error while changing adress"); + notify_error("Could not change address"); } } catch (e) { exception_error("replace_pubkey_callback", e); } } -} */ +} function expand_feed_callback() { if (xmlhttp.readyState == 4) { @@ -1748,7 +1757,6 @@ function feedlistToggleSLAT() { updateFeedList() } -/* function pubRegenKey() { if (!xmlhttp_ready(xmlhttp)) { @@ -1762,10 +1770,10 @@ function pubRegenKey() { notify_progress("Trying to change address..."); - xmlhttp.open("GET", "backend.php?op=backend-rpc&subop=regen-pub-key"); + xmlhttp.open("GET", "backend.php?op=rpc&subop=regenPubKey"); xmlhttp.onreadystatechange=replace_pubkey_callback; xmlhttp.send(null); } return false; -} */ +}