summaryrefslogtreecommitdiff
path: root/backend.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2011-04-20 15:21:00 +0400
committerAndrew Dolgov <[email protected]>2011-04-20 15:21:00 +0400
commitae5f7bb11a7698a84c9352436c144286f7c81630 (patch)
treefbf541a0009cd8462d5137b04ffcea0113df37bc /backend.php
parentcfc0647184933b042b9929ede09f52e7d3f3318f (diff)
implement fetching and exporting of shared feeds
Diffstat (limited to 'backend.php')
-rw-r--r--backend.php33
1 files changed, 32 insertions, 1 deletions
diff --git a/backend.php b/backend.php
index e63d5abd7..c4edd92ea 100644
--- a/backend.php
+++ b/backend.php
@@ -60,7 +60,7 @@
if (!($_SESSION["uid"] && validate_session($link)) && $op != "globalUpdateFeeds" &&
$op != "rss" && $op != "getUnread" && $op != "getProfiles" &&
- $op != "logout" && $op != "pubsub") {
+ $op != "fbexport" && $op != "logout" && $op != "pubsub") {
header("Content-Type: text/plain");
print json_encode(array("error" => array("code" => 6)));
@@ -583,6 +583,37 @@
header("Location: tt-rss.php");
break; // logout
+ case "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(),
+ last_status_in = 1 WHERE id = '$instance_id'");
+
+ print json_encode(array("feeds" => $feeds));
+ } else {
+ print json_encode(array("error" => array("code" => 6)));
+ }
+ break; // fbexport
+
default:
header("Content-Type: text/plain");
print json_encode(array("error" => array("code" => 7)));