$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 {
}
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;
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"]);
generate_syndicated_feed($link, $feed, $is_cat,
$search, $search_mode, $match_on);
}
+
+ session_destroy();
}
if ($op == "labelFromSearch") {
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'");
}
+ if ($subop == "regenPubKey") {
+
+ print "<rpc-reply>";
+
+ 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 "<link><![CDATA[$new_link]]></link>";
+
+ print "</rpc-reply>";
+
+ }
+
if ($subop == "logout") {
logout_user();
print_error_xml(6);
$url_path .= "?op=publish&key=" . get_pref($link, "_PREFS_PUBLISH_KEY");
- print "<p><a id=\"pubGenAddress\" target=\"_new\" href=\"$url_path\">$url_path</a></p>";
+ print "<p class=\"small\"><a id=\"pubGenAddress\" target=\"_new\" href=\"$url_path\">$url_path</a></p>";
print "<p><input type=\"submit\" onclick=\"return pubRegenKey()\"
value=\"".__('Generate another address')."\"></p>";
var sanity_check_done = false;
-/*
function replace_pubkey_callback() {
if (xmlhttp.readyState == 4) {
try {
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) {
updateFeedList()
}
-/*
function pubRegenKey() {
if (!xmlhttp_ready(xmlhttp)) {
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;
-} */
+}