rpc: no longer use XML

This commit is contained in:
Andrew Dolgov 2011-03-18 19:12:38 +03:00 committed by Andrew Dolgov
parent b6bf3e74fb
commit 565ca5653c
2 changed files with 5 additions and 95 deletions

View File

@ -48,18 +48,11 @@
$print_exec_time = false; $print_exec_time = false;
if ((!$op || $op == "rpc" || $op == "rss" || if ((!$op || $op == "rss" || $op == "dlg") && !$_REQUEST["noxml"]) {
$op == "digestSend" || $op == "dlg" ||
$op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) {
header("Content-Type: application/xml; charset=utf-8"); header("Content-Type: application/xml; charset=utf-8");
} else {
if (!$_REQUEST["noxml"]) {
header("Content-Type: text/html; charset=utf-8");
} else { } else {
header("Content-Type: text/plain; charset=utf-8"); header("Content-Type: text/plain; charset=utf-8");
} }
}
if (ENABLE_GZIP_OUTPUT) { if (ENABLE_GZIP_OUTPUT) {
ob_start("ob_gzhandler"); ob_start("ob_gzhandler");
@ -428,16 +421,8 @@
break; // pref-pub-items break; // pref-pub-items
case "globalUpdateFeeds": case "globalUpdateFeeds":
// update feeds of all users, may be used anonymously
print "<!--";
// Update all feeds needing a update. // Update all feeds needing a update.
update_daemon_common($link, 0, true, true); update_daemon_common($link, 0, true, true);
print " -->";
print "<rpc-reply>
<message msg=\"All feeds updated\"/>
</rpc-reply>";
break; // globalUpdateFeeds break; // globalUpdateFeeds
case "pref-feed-browser": case "pref-feed-browser":
@ -483,8 +468,6 @@
$login = db_escape_string($_REQUEST["login"]); $login = db_escape_string($_REQUEST["login"]);
$fresh = $_REQUEST["fresh"] == "1"; $fresh = $_REQUEST["fresh"] == "1";
header("Content-Type: text/plain; charset=utf-8");
$result = db_query($link, "SELECT id FROM ttrss_users WHERE login = '$login'"); $result = db_query($link, "SELECT id FROM ttrss_users WHERE login = '$login'");
if (db_num_rows($result) == 1) { if (db_num_rows($result) == 1) {
@ -505,13 +488,11 @@
break; // getUnread break; // getUnread
case "digestTest": case "digestTest":
header("Content-Type: text/plain");
print_r(prepare_headlines_digest($link, $_SESSION["uid"])); print_r(prepare_headlines_digest($link, $_SESSION["uid"]));
$print_exec_time = false; $print_exec_time = false;
break; // digestTest break; // digestTest
case "digestSend": case "digestSend":
header("Content-Type: text/plain");
send_headlines_digests($link); send_headlines_digests($link);
$print_exec_time = false; $print_exec_time = false;
break; // digestSend break; // digestSend

View File

@ -105,8 +105,6 @@
} }
if ($subop == "addfeed") { if ($subop == "addfeed") {
header("Content-Type: text/plain");
$feed = db_escape_string($_REQUEST['feed']); $feed = db_escape_string($_REQUEST['feed']);
$cat = db_escape_string($_REQUEST['cat']); $cat = db_escape_string($_REQUEST['cat']);
$login = db_escape_string($_REQUEST['login']); $login = db_escape_string($_REQUEST['login']);
@ -121,7 +119,6 @@
} }
if ($subop == "extractfeedurls") { if ($subop == "extractfeedurls") {
header("Content-Type: text/plain");
$urls = get_feeds_from_html($_REQUEST['url']); $urls = get_feeds_from_html($_REQUEST['url']);
@ -130,8 +127,6 @@
} }
if ($subop == "togglepref") { if ($subop == "togglepref") {
header("Content-Type: text/plain");
$key = db_escape_string($_REQUEST["key"]); $key = db_escape_string($_REQUEST["key"]);
set_pref($link, $key, !get_pref($link, $key)); set_pref($link, $key, !get_pref($link, $key));
$value = get_pref($link, $key); $value = get_pref($link, $key);
@ -141,8 +136,6 @@
} }
if ($subop == "setpref") { if ($subop == "setpref") {
header("Content-Type: text/plain");
$value = str_replace("\n", "<br/>", $_REQUEST['value']); $value = str_replace("\n", "<br/>", $_REQUEST['value']);
$key = db_escape_string($_REQUEST["key"]); $key = db_escape_string($_REQUEST["key"]);
@ -155,8 +148,6 @@
} }
if ($subop == "mark") { if ($subop == "mark") {
header("Content-Type: text/plain");
$mark = $_REQUEST["mark"]; $mark = $_REQUEST["mark"];
$id = db_escape_string($_REQUEST["id"]); $id = db_escape_string($_REQUEST["id"]);
@ -174,8 +165,6 @@
} }
if ($subop == "delete") { if ($subop == "delete") {
header("Content-Type: text/plain");
$ids = db_escape_string($_REQUEST["ids"]); $ids = db_escape_string($_REQUEST["ids"]);
$result = db_query($link, "DELETE FROM ttrss_user_entries $result = db_query($link, "DELETE FROM ttrss_user_entries
@ -186,8 +175,6 @@
} }
if ($subop == "unarchive") { if ($subop == "unarchive") {
header("Content-Type: text/plain");
$ids = db_escape_string($_REQUEST["ids"]); $ids = db_escape_string($_REQUEST["ids"]);
$result = db_query($link, "UPDATE ttrss_user_entries $result = db_query($link, "UPDATE ttrss_user_entries
@ -199,8 +186,6 @@
} }
if ($subop == "archive") { if ($subop == "archive") {
header("Content-Type: text/plain");
$ids = split(",", db_escape_string($_REQUEST["ids"])); $ids = split(",", db_escape_string($_REQUEST["ids"]));
foreach ($ids as $id) { foreach ($ids as $id) {
@ -212,8 +197,6 @@
} }
if ($subop == "publ") { if ($subop == "publ") {
header("Content-Type: text/plain");
$pub = $_REQUEST["pub"]; $pub = $_REQUEST["pub"];
$id = db_escape_string($_REQUEST["id"]); $id = db_escape_string($_REQUEST["id"]);
$note = trim(strip_tags(db_escape_string($_REQUEST["note"]))); $note = trim(strip_tags(db_escape_string($_REQUEST["note"])));
@ -245,9 +228,6 @@
} */ } */
if ($subop == "updateAllFeeds" || $subop == "getAllCounters") { if ($subop == "updateAllFeeds" || $subop == "getAllCounters") {
header("Content-Type: text/plain");
$last_article_id = (int) $_REQUEST["last_article_id"]; $last_article_id = (int) $_REQUEST["last_article_id"];
$reply = array(); $reply = array();
@ -272,8 +252,6 @@
/* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */ /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
if ($subop == "catchupSelected") { if ($subop == "catchupSelected") {
header("Content-Type: text/plain");
$ids = split(",", db_escape_string($_REQUEST["ids"])); $ids = split(",", db_escape_string($_REQUEST["ids"]));
$cmode = sprintf("%d", $_REQUEST["cmode"]); $cmode = sprintf("%d", $_REQUEST["cmode"]);
@ -284,8 +262,6 @@
} }
if ($subop == "markSelected") { if ($subop == "markSelected") {
header("Content-Type: text/plain");
$ids = split(",", db_escape_string($_REQUEST["ids"])); $ids = split(",", db_escape_string($_REQUEST["ids"]));
$cmode = sprintf("%d", $_REQUEST["cmode"]); $cmode = sprintf("%d", $_REQUEST["cmode"]);
@ -296,8 +272,6 @@
} }
if ($subop == "publishSelected") { if ($subop == "publishSelected") {
header("Content-Type: text/plain");
$ids = split(",", db_escape_string($_REQUEST["ids"])); $ids = split(",", db_escape_string($_REQUEST["ids"]));
$cmode = sprintf("%d", $_REQUEST["cmode"]); $cmode = sprintf("%d", $_REQUEST["cmode"]);
@ -308,8 +282,6 @@
} }
if ($subop == "sanityCheck") { if ($subop == "sanityCheck") {
header("Content-Type: text/plain");
$_SESSION["hasAudio"] = $_REQUEST["hasAudio"] === "true"; $_SESSION["hasAudio"] = $_REQUEST["hasAudio"] === "true";
$reply = array(); $reply = array();
@ -335,8 +307,6 @@
} */ } */
if ($subop == "setArticleTags") { if ($subop == "setArticleTags") {
header("Content-Type: text/plain");
global $memcache; global $memcache;
$id = db_escape_string($_REQUEST["id"]); $id = db_escape_string($_REQUEST["id"]);
@ -404,8 +374,6 @@
} }
if ($subop == "regenOPMLKey") { if ($subop == "regenOPMLKey") {
header("Content-Type: text/plain");
update_feed_access_key($link, 'OPML:Publish', update_feed_access_key($link, 'OPML:Publish',
false, $_SESSION["uid"]); false, $_SESSION["uid"]);
@ -415,16 +383,7 @@
return; return;
} }
// XML method
if ($subop == "logout") {
logout_user();
print_error_xml(6);
return;
}
if ($subop == "completeTags") { if ($subop == "completeTags") {
header("Content-Type: text/plain");
$search = db_escape_string($_REQUEST["search"]); $search = db_escape_string($_REQUEST["search"]);
$result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags
@ -472,8 +431,6 @@
} */ } */
if ($subop == "getArticles") { if ($subop == "getArticles") {
header("Content-Type: text/plain");
$ids = split(",", db_escape_string($_REQUEST["ids"])); $ids = split(",", db_escape_string($_REQUEST["ids"]));
$articles = array(); $articles = array();
@ -488,8 +445,6 @@
} }
if ($subop == "checkDate") { if ($subop == "checkDate") {
header("Content-Type: text/plain");
$date = db_escape_string($_REQUEST["date"]); $date = db_escape_string($_REQUEST["date"]);
$date_parsed = strtotime($date); $date_parsed = strtotime($date);
@ -498,8 +453,6 @@
} }
if ($subop == "assignToLabel" || $subop == "removeFromLabel") { if ($subop == "assignToLabel" || $subop == "removeFromLabel") {
header("Content-Type: text/plain");
$reply = array(); $reply = array();
$ids = split(",", db_escape_string($_REQUEST["ids"])); $ids = split(",", db_escape_string($_REQUEST["ids"]));
@ -535,8 +488,6 @@
} }
if ($subop == "updateFeedBrowser") { if ($subop == "updateFeedBrowser") {
header("Content-Type: text/plain");
$search = db_escape_string($_REQUEST["search"]); $search = db_escape_string($_REQUEST["search"]);
$limit = db_escape_string($_REQUEST["limit"]); $limit = db_escape_string($_REQUEST["limit"]);
$mode = (int) db_escape_string($_REQUEST["mode"]); $mode = (int) db_escape_string($_REQUEST["mode"]);
@ -593,8 +544,6 @@
} }
if ($subop == "digest-get-contents") { if ($subop == "digest-get-contents") {
header("Content-Type: text/plain");
$article_id = db_escape_string($_REQUEST['article_id']); $article_id = db_escape_string($_REQUEST['article_id']);
$result = db_query($link, "SELECT content $result = db_query($link, "SELECT content
@ -609,8 +558,6 @@
} }
if ($subop == "digest-update") { if ($subop == "digest-update") {
header("Content-Type: text/plain");
$feed_id = db_escape_string($_REQUEST['feed_id']); $feed_id = db_escape_string($_REQUEST['feed_id']);
$offset = db_escape_string($_REQUEST['offset']); $offset = db_escape_string($_REQUEST['offset']);
$seq = db_escape_string($_REQUEST['seq']); $seq = db_escape_string($_REQUEST['seq']);
@ -637,8 +584,6 @@
} }
if ($subop == "digest-init") { if ($subop == "digest-init") {
header("Content-Type: text/plain");
$tmp_feeds = api_get_feeds($link, -3, true, false, 0); $tmp_feeds = api_get_feeds($link, -3, true, false, 0);
$feeds = array(); $feeds = array();
@ -662,8 +607,6 @@
} }
if ($subop == "sendEmail") { if ($subop == "sendEmail") {
header("Content-Type: text/plain");
$secretkey = $_REQUEST['secretkey']; $secretkey = $_REQUEST['secretkey'];
$reply = array(); $reply = array();
@ -721,8 +664,6 @@
} }
if ($subop == "completeEmails") { if ($subop == "completeEmails") {
header("Content-Type: text/plain");
$search = db_escape_string($_REQUEST["search"]); $search = db_escape_string($_REQUEST["search"]);
print "<ul>"; print "<ul>";
@ -739,8 +680,6 @@
} }
if ($subop == "quickAddCat") { if ($subop == "quickAddCat") {
header("Content-Type: text/plain");
$cat = db_escape_string($_REQUEST["cat"]); $cat = db_escape_string($_REQUEST["cat"]);
add_feed_category($link, $cat); add_feed_category($link, $cat);
@ -760,8 +699,6 @@
} }
if ($subop == "regenFeedKey") { if ($subop == "regenFeedKey") {
header("Content-Type: text/plain");
$feed_id = db_escape_string($_REQUEST['id']); $feed_id = db_escape_string($_REQUEST['id']);
$is_cat = (bool) db_escape_string($_REQUEST['is_cat']); $is_cat = (bool) db_escape_string($_REQUEST['is_cat']);
@ -780,8 +717,6 @@
} }
if ($subop == "verifyRegexp") { if ($subop == "verifyRegexp") {
header("Content-Type: text/plain");
$reg_exp = $_REQUEST["reg_exp"]; $reg_exp = $_REQUEST["reg_exp"];
$status = @preg_match("/$reg_exp/i", "TEST") !== false; $status = @preg_match("/$reg_exp/i", "TEST") !== false;
@ -792,8 +727,6 @@
// TODO: unify with digest-get-contents? // TODO: unify with digest-get-contents?
if ($subop == "cdmGetArticle") { if ($subop == "cdmGetArticle") {
header("Content-Type: text/plain");
$id = db_escape_string($_REQUEST["id"]); $id = db_escape_string($_REQUEST["id"]);
$result = db_query($link, "SELECT content, $result = db_query($link, "SELECT content,
@ -820,8 +753,6 @@
} }
if ($subop == "scheduleFeedUpdate") { if ($subop == "scheduleFeedUpdate") {
header("Content-Type: text/plain");
$feed_id = db_escape_string($_REQUEST["id"]); $feed_id = db_escape_string($_REQUEST["id"]);
$is_cat = db_escape_string($_REQUEST['is_cat']) == 'true'; $is_cat = db_escape_string($_REQUEST['is_cat']) == 'true';
@ -858,7 +789,6 @@
} }
if ($subop == "getTweetInfo") { if ($subop == "getTweetInfo") {
header("Content-Type: text/plain");
$id = db_escape_string($_REQUEST['id']); $id = db_escape_string($_REQUEST['id']);
$result = db_query($link, "SELECT title, link $result = db_query($link, "SELECT title, link
@ -878,8 +808,6 @@
} }
if ($subop == "setNote") { if ($subop == "setNote") {
header("Content-Type: text/plain");
$id = db_escape_string($_REQUEST["id"]); $id = db_escape_string($_REQUEST["id"]);
$note = strip_tags(db_escape_string($_REQUEST["note"])); $note = strip_tags(db_escape_string($_REQUEST["note"]));
@ -892,6 +820,7 @@
return; return;
} }
print "<rpc-reply><error>Unknown method: $subop</error></rpc-reply>"; print json_encode(array("error" => array("code" => 7,
"message" => "Unknown method: $subop")));
} }
?> ?>