rpc: mark silent methods, rework verifyRegexp to use JSON
This commit is contained in:
parent
a6fdab2e14
commit
91d16ff193
14
functions.js
14
functions.js
|
@ -962,15 +962,12 @@ function quickAddFilter() {
|
||||||
new Ajax.Request("backend.php", {
|
new Ajax.Request("backend.php", {
|
||||||
parameters: query,
|
parameters: query,
|
||||||
onComplete: function(transport) {
|
onComplete: function(transport) {
|
||||||
handle_rpc_reply(transport);
|
var reply = JSON.parse(transport.responseText);
|
||||||
var response = transport.responseXML;
|
|
||||||
|
|
||||||
if (response) {
|
|
||||||
var s = response.getElementsByTagName("status")[0].firstChild.nodeValue;
|
|
||||||
|
|
||||||
|
if (reply) {
|
||||||
notify('');
|
notify('');
|
||||||
|
|
||||||
if (s == "INVALID") {
|
if (!reply['status']) {
|
||||||
alert("Match regular expression seems to be invalid.");
|
alert("Match regular expression seems to be invalid.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1162,14 +1159,13 @@ function genUrlChangeKey(feed, is_cat) {
|
||||||
new Ajax.Request("backend.php", {
|
new Ajax.Request("backend.php", {
|
||||||
parameters: query,
|
parameters: query,
|
||||||
onComplete: function(transport) {
|
onComplete: function(transport) {
|
||||||
var new_link = transport.responseXML.getElementsByTagName("link")[0];
|
var reply = JSON.parse(transport.responseText);
|
||||||
|
var new_link = reply.link;
|
||||||
|
|
||||||
var e = $('gen_feed_url');
|
var e = $('gen_feed_url');
|
||||||
|
|
||||||
if (new_link) {
|
if (new_link) {
|
||||||
|
|
||||||
new_link = new_link.firstChild.nodeValue;
|
|
||||||
|
|
||||||
e.innerHTML = e.innerHTML.replace(/\&key=.*$/,
|
e.innerHTML = e.innerHTML.replace(/\&key=.*$/,
|
||||||
"&key=" + new_link);
|
"&key=" + new_link);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
$subop = $_REQUEST["subop"];
|
$subop = $_REQUEST["subop"];
|
||||||
$seq = (int) $_REQUEST["seq"];
|
$seq = (int) $_REQUEST["seq"];
|
||||||
|
|
||||||
|
// Silent
|
||||||
if ($subop == "setprofile") {
|
if ($subop == "setprofile") {
|
||||||
$id = db_escape_string($_REQUEST["id"]);
|
$id = db_escape_string($_REQUEST["id"]);
|
||||||
|
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Silent
|
||||||
if ($subop == "remprofiles") {
|
if ($subop == "remprofiles") {
|
||||||
$ids = split(",", db_escape_string(trim($_REQUEST["ids"])));
|
$ids = split(",", db_escape_string(trim($_REQUEST["ids"])));
|
||||||
|
|
||||||
|
@ -24,6 +26,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Silent
|
||||||
if ($subop == "addprofile") {
|
if ($subop == "addprofile") {
|
||||||
$title = db_escape_string(trim($_REQUEST["title"]));
|
$title = db_escape_string(trim($_REQUEST["title"]));
|
||||||
if ($title) {
|
if ($title) {
|
||||||
|
@ -54,6 +57,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Silent
|
||||||
if ($subop == "saveprofile") {
|
if ($subop == "saveprofile") {
|
||||||
$id = db_escape_string($_REQUEST["id"]);
|
$id = db_escape_string($_REQUEST["id"]);
|
||||||
$title = db_escape_string(trim($_REQUEST["value"]));
|
$title = db_escape_string(trim($_REQUEST["value"]));
|
||||||
|
@ -85,6 +89,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Silent
|
||||||
if ($subop == "remarchive") {
|
if ($subop == "remarchive") {
|
||||||
$ids = split(",", db_escape_string($_REQUEST["ids"]));
|
$ids = split(",", db_escape_string($_REQUEST["ids"]));
|
||||||
|
|
||||||
|
@ -96,7 +101,6 @@
|
||||||
|
|
||||||
$rc = db_affected_rows($link, $result);
|
$rc = db_affected_rows($link, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,8 +164,6 @@
|
||||||
$mark = "false";
|
$mark = "false";
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME this needs collision testing
|
|
||||||
|
|
||||||
$result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark
|
$result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark
|
||||||
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
|
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
|
||||||
|
|
||||||
|
@ -417,17 +419,15 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML method
|
|
||||||
if ($subop == "regenOPMLKey") {
|
if ($subop == "regenOPMLKey") {
|
||||||
|
header("Content-Type: text/plain");
|
||||||
print "<rpc-reply>";
|
|
||||||
|
|
||||||
update_feed_access_key($link, 'OPML:Publish',
|
update_feed_access_key($link, 'OPML:Publish',
|
||||||
false, $_SESSION["uid"]);
|
false, $_SESSION["uid"]);
|
||||||
|
|
||||||
$new_link = opml_publish_url($link);
|
$new_link = opml_publish_url($link);
|
||||||
print "<link><![CDATA[$new_link]]></link>";
|
|
||||||
print "</rpc-reply>";
|
print json_encode(array("link" => $new_link));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,6 +563,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Silent
|
||||||
if ($subop == "massSubscribe") {
|
if ($subop == "massSubscribe") {
|
||||||
|
|
||||||
$ids = split(",", db_escape_string($_REQUEST["ids"]));
|
$ids = split(",", db_escape_string($_REQUEST["ids"]));
|
||||||
|
@ -774,22 +775,19 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML method
|
|
||||||
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']);
|
||||||
|
|
||||||
print "<rpc-reply>";
|
|
||||||
|
|
||||||
$new_key = update_feed_access_key($link, $feed_id, $is_cat);
|
$new_key = update_feed_access_key($link, $feed_id, $is_cat);
|
||||||
|
|
||||||
print "<link><![CDATA[$new_key]]></link>";
|
print json_encode(array("link" => $new_key));
|
||||||
|
|
||||||
print "</rpc-reply>";
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Silent
|
||||||
if ($subop == "clearKeys") {
|
if ($subop == "clearKeys") {
|
||||||
db_query($link, "DELETE FROM ttrss_access_keys WHERE
|
db_query($link, "DELETE FROM ttrss_access_keys WHERE
|
||||||
owner_uid = " . $_SESSION["uid"]);
|
owner_uid = " . $_SESSION["uid"]);
|
||||||
|
@ -797,20 +795,14 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML method
|
|
||||||
if ($subop == "verifyRegexp") {
|
if ($subop == "verifyRegexp") {
|
||||||
|
header("Content-Type: text/plain");
|
||||||
|
|
||||||
$reg_exp = $_REQUEST["reg_exp"];
|
$reg_exp = $_REQUEST["reg_exp"];
|
||||||
|
|
||||||
print "<rpc-reply><status>";
|
$status = @preg_match("/$reg_exp/i", "TEST") !== false;
|
||||||
|
|
||||||
if (@preg_match("/$reg_exp/i", "TEST") === false) {
|
|
||||||
print "INVALID";
|
|
||||||
} else {
|
|
||||||
print "OK";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</status></rpc-reply>";
|
|
||||||
|
|
||||||
|
print json_encode(array("status" => $status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
prefs.js
17
prefs.js
|
@ -206,15 +206,12 @@ function editFilter(id) {
|
||||||
new Ajax.Request("backend.php", {
|
new Ajax.Request("backend.php", {
|
||||||
parameters: query,
|
parameters: query,
|
||||||
onComplete: function(transport) {
|
onComplete: function(transport) {
|
||||||
handle_rpc_reply(transport);
|
var reply = JSON.parse(transport.responseText);
|
||||||
var response = transport.responseXML;
|
|
||||||
|
|
||||||
if (response) {
|
|
||||||
var s = response.getElementsByTagName("status")[0].firstChild.nodeValue;
|
|
||||||
|
|
||||||
|
if (reply) {
|
||||||
notify('');
|
notify('');
|
||||||
|
|
||||||
if (s == "INVALID") {
|
if (!reply['status']) {
|
||||||
alert("Match regular expression seems to be invalid.");
|
alert("Match regular expression seems to be invalid.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1248,13 +1245,15 @@ function opmlRegenKey() {
|
||||||
new Ajax.Request("backend.php", {
|
new Ajax.Request("backend.php", {
|
||||||
parameters: query,
|
parameters: query,
|
||||||
onComplete: function(transport) {
|
onComplete: function(transport) {
|
||||||
var new_link = transport.responseXML.getElementsByTagName("link")[0];
|
var reply = JSON.parse(transport.responseText);
|
||||||
|
|
||||||
|
var new_link = reply.link;
|
||||||
|
|
||||||
var e = $('pub_opml_url');
|
var e = $('pub_opml_url');
|
||||||
|
|
||||||
if (new_link) {
|
if (new_link) {
|
||||||
e.href = new_link.firstChild.nodeValue;
|
e.href = new_link;
|
||||||
e.innerHTML = new_link.firstChild.nodeValue;
|
e.innerHTML = new_link;
|
||||||
|
|
||||||
new Effect.Highlight(e);
|
new Effect.Highlight(e);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue