]> git.wh0rd.org - tt-rss.git/blobdiff - backend.php
backend/la: properly handle situation when article has multiple ref_ids on one accoun...
[tt-rss.git] / backend.php
index e63d5abd705bc5f791652751fd8b0c02b41c97be..6b93d1b3c5444c55079fa68e8bdc05b1ca3cc40c 100644 (file)
@@ -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)));
                        $id = db_escape_string($_REQUEST['id']);
 
                        $result = db_query($link, "SELECT link FROM ttrss_entries, ttrss_user_entries
-                               WHERE id = '$id' AND id = ref_id AND owner_uid = '".$_SESSION['uid']."'");
+                               WHERE id = '$id' AND id = ref_id AND owner_uid = '".$_SESSION['uid']."'
+                               LIMIT 1");
 
                        if (db_num_rows($result) == 1) {
                                $article_url = db_fetch_result($result, 0, 'link');
                        header("Location: tt-rss.php");
                break; // logout
 
+               case "fbexport":
+
+                       $access_key = db_escape_string($_POST["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, site_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_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)));