summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2011-04-20 12:06:30 +0400
committerAndrew Dolgov <[email protected]>2011-04-20 12:07:07 +0400
commitafb875ccd704dec355b73eecb2ded23f047414d8 (patch)
tree9a7a541206e27387f0cc8cc5117a098b3c923dba /modules
parent34846e514f916e0ae7d942cc99e84c9507e4728b (diff)
add rpc method to export feedbrowser data; update schema
Diffstat (limited to 'modules')
-rw-r--r--modules/backend-rpc.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php
index f21ca5814..8b4fb04c7 100644
--- a/modules/backend-rpc.php
+++ b/modules/backend-rpc.php
@@ -834,6 +834,38 @@
return;
}
+ if ($subop == "fbExport") {
+
+ // TODO: change to _POST
+ $access_key = db_escape_string($_REQUEST["key"]);
+
+ // TODO: rate limit checking using last_connected
+ $result = db_query($link, "SELECT id FROM ttrss_linked_instances
+ WHERE access_key = '$access_key'");
+
+ if (db_num_rows($result) == 1) {
+
+ $instance_id = db_fetch_result($result, 0, "id");
+
+ $result = db_query($link, "SELECT feed_url, title, subscribers
+ FROM ttrss_feedbrowser_cache ORDER BY subscribers DESC LIMIT 100");
+
+ $feeds = array();
+
+ while ($line = db_fetch_assoc($result)) {
+ array_push($feeds, $line);
+ }
+
+ db_query($link, "UPDATE ttrss_linked_instances SET last_connected = NOW()
+ WHERE id = '$instance_id'");
+
+ print json_encode(array("feeds" => $feeds));
+ } else {
+ print json_encode(array("error" => array("code" => 6)));
+ }
+ return;
+ }
+
print json_encode(array("error" => array("code" => 7,
"message" => "Unknown method: $subop")));
}