rpc/checkDate: use JSON; mark some XML methods

This commit is contained in:
Andrew Dolgov 2010-11-29 16:09:28 +03:00
parent e9175d13d7
commit da661d71db
2 changed files with 18 additions and 33 deletions

View File

@ -607,18 +607,14 @@ function filterDlgCheckDate() {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
if (transport.responseXML) { var reply = JSON.parse(transport.responseText);
var result = transport.responseXML.getElementsByTagName("result")[0];
if (result && result.firstChild) { if (reply['result'] == true) {
if (result.firstChild.nodeValue == "1") {
alert(__("Date syntax appears to be correct.")); alert(__("Date syntax appears to be correct."));
return; return;
} } else {
}
}
alert(__("Date syntax is incorrect.")); alert(__("Date syntax is incorrect."));
}
} }); } });

View File

@ -137,17 +137,14 @@
} }
if ($subop == "setpref") { if ($subop == "setpref") {
print "<rpc-reply>"; header("Content-Type: text/plain");
$key = db_escape_string($_REQUEST["key"]); $key = db_escape_string($_REQUEST["key"]);
$value = db_escape_string($_REQUEST["value"]); $value = db_escape_string($_REQUEST["value"]);
set_pref($link, $key, $value); set_pref($link, $key, $value);
print "<param-set key=\"$key\" value=\"$value\"/>"; print json_encode(array("param" =>$key, "value" => $value));
print "</rpc-reply>";
return; return;
} }
@ -210,7 +207,7 @@
return; return;
} }
// XML method
if ($subop == "publ") { if ($subop == "publ") {
$pub = $_REQUEST["pub"]; $pub = $_REQUEST["pub"];
$id = db_escape_string($_REQUEST["id"]); $id = db_escape_string($_REQUEST["id"]);
@ -325,6 +322,7 @@
return; return;
} }
// XML method
if ($subop == "sanityCheck") { if ($subop == "sanityCheck") {
print "<rpc-reply>"; print "<rpc-reply>";
if (sanity_check($link)) { if (sanity_check($link)) {
@ -335,24 +333,20 @@
print "]]></init-params>"; print "]]></init-params>";
print_runtime_info($link); print_runtime_info($link);
# assign client-passed params to session
$_SESSION["client.userAgent"] = $_REQUEST["ua"];
} }
print "</rpc-reply>"; print "</rpc-reply>";
return; return;
} }
if ($subop == "globalPurge") { /* if ($subop == "globalPurge") {
print "<rpc-reply>"; print "<rpc-reply>";
global_purge_old_posts($link, true); global_purge_old_posts($link, true);
print "</rpc-reply>"; print "</rpc-reply>";
return; return;
} } */
if ($subop == "setArticleTags") { if ($subop == "setArticleTags") {
header("Content-Type: text/plain"); header("Content-Type: text/plain");
@ -423,6 +417,7 @@
return; return;
} }
// XML method
if ($subop == "regenOPMLKey") { if ($subop == "regenOPMLKey") {
print "<rpc-reply>"; print "<rpc-reply>";
@ -436,6 +431,7 @@
return; return;
} }
// XML method
if ($subop == "logout") { if ($subop == "logout") {
logout_user(); logout_user();
print_error_xml(6); print_error_xml(6);
@ -491,6 +487,7 @@
} */ } */
// XML method
if ($subop == "getArticles") { if ($subop == "getArticles") {
$ids = split(",", db_escape_string($_REQUEST["ids"])); $ids = split(",", db_escape_string($_REQUEST["ids"]));
@ -507,20 +504,12 @@
} }
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);
print "<rpc-reply>"; print json_encode(array("result" => (bool)$date_parsed));
if ($date_parsed) {
print "<result>1</result>";
} else {
print "<result>0</result>";
}
print "</rpc-reply>";
return; return;
} }