]> git.wh0rd.org Git - tt-rss.git/commitdiff
add rpc method to export feedbrowser data; update schema
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 20 Apr 2011 08:06:30 +0000 (12:06 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 20 Apr 2011 08:07:07 +0000 (12:07 +0400)
modules/backend-rpc.php
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql
schema/versions/mysql/84.sql
schema/versions/pgsql/84.sql

index f21ca5814033b86aab80a6054b4ea2760c0e9e5a..8b4fb04c7fd8673994fbd2ad2cfca73df41fd1ec 100644 (file)
                        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")));
        }
index 2a6e89c8d65e8846aee2049cd48a8efadb1e174b..91475e6029a583c5fc04d8ed12afc5b7e0290bbf 100644 (file)
@@ -429,6 +429,7 @@ create table ttrss_access_keys (id integer not null primary key auto_increment,
        foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) TYPE=InnoDB DEFAULT CHARSET=UTF8;
 
 create table ttrss_linked_instances (id integer not null primary key auto_increment,
+       last_connected datetime not null,
        access_key varchar(250) not null,
        access_url text not null) TYPE=InnoDB DEFAULT CHARSET=UTF8;
 
index d6cc924f067a583db3cb3c92d00ad9c0d5e94c73..a7cee5363f264f1f12e1abdf2e5b4113adafa725 100644 (file)
@@ -389,6 +389,7 @@ create table ttrss_access_keys (id serial not null primary key,
        owner_uid integer not null references ttrss_users(id) on delete cascade);
 
 create table ttrss_linked_instances (id serial not null primary key,
+       last_connected timestamp not null,
        access_key varchar(250) not null,
        access_url text not null);
 
index 631daa03b4bb56068632b0494277c4fec4bdf83e..7a0ccbfb9fa22b089a9aa155a519672a3354d2b3 100644 (file)
@@ -1,6 +1,7 @@
 begin;
 
 create table ttrss_linked_instances (id integer not null primary key auto_increment,
+       last_connected timestamp not null,
        access_key varchar(250) not null,
        access_url text not null) TYPE=InnoDB DEFAULT CHARSET=UTF8;
 
index 1ff253f730dc07d1331eff066f394d7349d4e54e..77212317b6e27397473f5ad3d9f0df1895aba398 100644 (file)
@@ -1,6 +1,7 @@
 begin;
 
 create table ttrss_linked_instances (id serial not null primary key,
+       last_connected datetime not null,
        access_key varchar(250) not null,
        access_url text not null);