From da661d71db322c0a67109f7ef6bfddb629456f84 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 29 Nov 2010 16:09:28 +0300 Subject: [PATCH] rpc/checkDate: use JSON; mark some XML methods --- functions.js | 16 ++++++---------- modules/backend-rpc.php | 35 ++++++++++++----------------------- 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/functions.js b/functions.js index f0364deb..5dcfe6f3 100644 --- a/functions.js +++ b/functions.js @@ -607,19 +607,15 @@ function filterDlgCheckDate() { parameters: query, onComplete: function(transport) { - if (transport.responseXML) { - var result = transport.responseXML.getElementsByTagName("result")[0]; + var reply = JSON.parse(transport.responseText); - if (result && result.firstChild) { - if (result.firstChild.nodeValue == "1") { - alert(__("Date syntax appears to be correct.")); - return; - } - } + if (reply['result'] == true) { + alert(__("Date syntax appears to be correct.")); + return; + } else { + alert(__("Date syntax is incorrect.")); } - alert(__("Date syntax is incorrect.")); - } }); diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 54c66df3..3120fb7b 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -137,17 +137,14 @@ } if ($subop == "setpref") { - print ""; + header("Content-Type: text/plain"); $key = db_escape_string($_REQUEST["key"]); $value = db_escape_string($_REQUEST["value"]); set_pref($link, $key, $value); - print ""; - - print ""; - + print json_encode(array("param" =>$key, "value" => $value)); return; } @@ -210,7 +207,7 @@ return; } - + // XML method if ($subop == "publ") { $pub = $_REQUEST["pub"]; $id = db_escape_string($_REQUEST["id"]); @@ -325,6 +322,7 @@ return; } + // XML method if ($subop == "sanityCheck") { print ""; if (sanity_check($link)) { @@ -335,24 +333,20 @@ print "]]>"; print_runtime_info($link); - - # assign client-passed params to session - $_SESSION["client.userAgent"] = $_REQUEST["ua"]; - } print ""; return; } - if ($subop == "globalPurge") { +/* if ($subop == "globalPurge") { print ""; global_purge_old_posts($link, true); print ""; return; - } + } */ if ($subop == "setArticleTags") { header("Content-Type: text/plain"); @@ -423,6 +417,7 @@ return; } + // XML method if ($subop == "regenOPMLKey") { print ""; @@ -436,6 +431,7 @@ return; } + // XML method if ($subop == "logout") { logout_user(); print_error_xml(6); @@ -491,6 +487,7 @@ } */ + // XML method if ($subop == "getArticles") { $ids = split(",", db_escape_string($_REQUEST["ids"])); @@ -503,24 +500,16 @@ } print ""; - return; + return; } if ($subop == "checkDate") { + header("Content-Type: text/plain"); $date = db_escape_string($_REQUEST["date"]); $date_parsed = strtotime($date); - print ""; - - if ($date_parsed) { - print "1"; - } else { - print "0"; - } - - print ""; - + print json_encode(array("result" => (bool)$date_parsed)); return; } -- 2.39.5