]> git.wh0rd.org - tt-rss.git/blobdiff - modules/backend-rpc.php
subop -> method
[tt-rss.git] / modules / backend-rpc.php
index 34adc8f914f13366ca09c0d0502d298237daa9b5..341353480a504d2deeda70fdbb17fa9ca214a514 100644 (file)
@@ -1,11 +1,11 @@
 <?php
        function handle_rpc_request($link) {
 
-               $subop = $_REQUEST["subop"];
+               $method = $_REQUEST["method"];
                $seq = (int) $_REQUEST["seq"];
 
                // Silent
-               if ($subop == "setprofile") {
+               if ($method == "setprofile") {
                        $id = db_escape_string($_REQUEST["id"]);
 
                        $_SESSION["profile"] = $id;
@@ -14,7 +14,7 @@
                }
 
                // Silent
-               if ($subop == "remprofiles") {
+               if ($method == "remprofiles") {
                        $ids = explode(",", db_escape_string(trim($_REQUEST["ids"])));
 
                        foreach ($ids as $id) {
@@ -27,7 +27,7 @@
                }
 
                // Silent
-               if ($subop == "addprofile") {
+               if ($method == "addprofile") {
                        $title = db_escape_string(trim($_REQUEST["title"]));
                        if ($title) {
                                db_query($link, "BEGIN");
@@ -58,7 +58,7 @@
                }
 
                // Silent
-               if ($subop == "saveprofile") {
+               if ($method == "saveprofile") {
                        $id = db_escape_string($_REQUEST["id"]);
                        $title = db_escape_string(trim($_REQUEST["value"]));
 
@@ -90,7 +90,7 @@
                }
 
                // Silent
-               if ($subop == "remarchive") {
+               if ($method == "remarchive") {
                        $ids = explode(",", db_escape_string($_REQUEST["ids"]));
 
                        foreach ($ids as $id) {
                        return;
                }
 
-               if ($subop == "addfeed") {
+               if ($method == "addfeed") {
                        $feed = db_escape_string($_REQUEST['feed']);
                        $cat = db_escape_string($_REQUEST['cat']);
                        $login = db_escape_string($_REQUEST['login']);
 
                }
 
-               if ($subop == "extractfeedurls") {
+               if ($method == "extractfeedurls") {
 
                        $urls = get_feeds_from_html($_REQUEST['url']);
 
                        return;
                }
 
-               if ($subop == "togglepref") {
+               if ($method == "togglepref") {
                        $key = db_escape_string($_REQUEST["key"]);
                        set_pref($link, $key, !get_pref($link, $key));
                        $value = get_pref($link, $key);
                        return;
                }
 
-               if ($subop == "setpref") {
+               if ($method == "setpref") {
                        $value = str_replace("\n", "<br/>", $_REQUEST['value']);
 
                        $key = db_escape_string($_REQUEST["key"]);
                        return;
                }
 
-               if ($subop == "mark") {
+               if ($method == "mark") {
                        $mark = $_REQUEST["mark"];
                        $id = db_escape_string($_REQUEST["id"]);
 
                        return;
                }
 
-               if ($subop == "delete") {
+               if ($method == "delete") {
                        $ids = db_escape_string($_REQUEST["ids"]);
 
                        $result = db_query($link, "DELETE FROM ttrss_user_entries
                        return;
                }
 
-               if ($subop == "unarchive") {
+               if ($method == "unarchive") {
                        $ids = db_escape_string($_REQUEST["ids"]);
 
                        $result = db_query($link, "UPDATE ttrss_user_entries
                        return;
                }
 
-               if ($subop == "archive") {
+               if ($method == "archive") {
                        $ids = explode(",", db_escape_string($_REQUEST["ids"]));
 
                        foreach ($ids as $id) {
                        return;
                }
 
-               if ($subop == "publ") {
+               if ($method == "publ") {
                        $pub = $_REQUEST["pub"];
                        $id = db_escape_string($_REQUEST["id"]);
                        $note = trim(strip_tags(db_escape_string($_REQUEST["note"])));
                }
 
                // Silent
-               /* if ($subop == "update") {
+               /* if ($method == "update") {
                        $feed_id = db_escape_string($_REQUEST["feed"]);
                        update_rss_feed($link, $feed_id);
                        return;
                } */
 
-               if ($subop == "updateAllFeeds" || $subop == "getAllCounters") {
+               if ($method == "updateAllFeeds" || $method == "getAllCounters") {
                        $last_article_id = (int) $_REQUEST["last_article_id"];
 
                        $reply = array();
                }
 
                /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
-               if ($subop == "catchupSelected") {
+               if ($method == "catchupSelected") {
                        $ids = explode(",", db_escape_string($_REQUEST["ids"]));
                        $cmode = sprintf("%d", $_REQUEST["cmode"]);
 
                        return;
                }
 
-               if ($subop == "markSelected") {
+               if ($method == "markSelected") {
                        $ids = explode(",", db_escape_string($_REQUEST["ids"]));
                        $cmode = sprintf("%d", $_REQUEST["cmode"]);
 
                        return;
                }
 
-               if ($subop == "publishSelected") {
+               if ($method == "publishSelected") {
                        $ids = explode(",", db_escape_string($_REQUEST["ids"]));
                        $cmode = sprintf("%d", $_REQUEST["cmode"]);
 
                        return;
                }
 
-               if ($subop == "sanityCheck") {
+               if ($method == "sanityCheck") {
                        $_SESSION["hasAudio"] = $_REQUEST["hasAudio"] === "true";
 
                        $reply = array();
                        return;
                }
 
-               if ($subop == "setArticleTags") {
+               if ($method == "setArticleTags") {
                        global $memcache;
 
                        $id = db_escape_string($_REQUEST["id"]);
                        return;
                }
 
-               if ($subop == "regenOPMLKey") {
+               if ($method == "regenOPMLKey") {
                        update_feed_access_key($link, 'OPML:Publish',
                                false, $_SESSION["uid"]);
 
                        return;
                }
 
-               if ($subop == "completeTags") {
+               if ($method == "completeTags") {
                        $search = db_escape_string($_REQUEST["search"]);
 
                        $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags
                        return;
                }
 
-               if ($subop == "purge") {
+               if ($method == "purge") {
                        $ids = explode(",", db_escape_string($_REQUEST["ids"]));
                        $days = sprintf("%d", $_REQUEST["days"]);
 
                        return;
                }
 
-/*             if ($subop == "setScore") {
+/*             if ($method == "setScore") {
                        $id = db_escape_string($_REQUEST["id"]);
                        $score = sprintf("%d", $_REQUEST["score"]);
 
 
                } */
 
-               if ($subop == "getArticles") {
+               if ($method == "getArticles") {
                        $ids = explode(",", db_escape_string($_REQUEST["ids"]));
                        $articles = array();
 
                        return;
                }
 
-               if ($subop == "checkDate") {
+               if ($method == "checkDate") {
                        $date = db_escape_string($_REQUEST["date"]);
                        $date_parsed = strtotime($date);
 
                        return;
                }
 
-               if ($subop == "assignToLabel" || $subop == "removeFromLabel") {
+               if ($method == "assignToLabel" || $method == "removeFromLabel") {
                        $reply = array();
 
                        $ids = explode(",", db_escape_string($_REQUEST["ids"]));
 
                                foreach ($ids as $id) {
 
-                                       if ($subop == "assignToLabel")
+                                       if ($method == "assignToLabel")
                                                label_add_article($link, $id, $label, $_SESSION["uid"]);
                                        else
                                                label_remove_article($link, $id, $label, $_SESSION["uid"]);
                        return;
                }
 
-               if ($subop == "updateFeedBrowser") {
+               if ($method == "updateFeedBrowser") {
                        $search = db_escape_string($_REQUEST["search"]);
                        $limit = db_escape_string($_REQUEST["limit"]);
                        $mode = (int) db_escape_string($_REQUEST["mode"]);
                }
 
                // Silent
-               if ($subop == "massSubscribe") {
+               if ($method == "massSubscribe") {
 
                        $payload = json_decode($_REQUEST["payload"], false);
                        $mode = $_REQUEST["mode"];
                        return;
                }
 
-               if ($subop == "digest-get-contents") {
+               if ($method == "digest-get-contents") {
                        $article_id = db_escape_string($_REQUEST['article_id']);
 
                        $result = db_query($link, "SELECT content,title,link,marked,published
                        return;
                }
 
-               if ($subop == "digest-update") {
+               if ($method == "digest-update") {
                        $feed_id = db_escape_string($_REQUEST['feed_id']);
                        $offset = db_escape_string($_REQUEST['offset']);
                        $seq = db_escape_string($_REQUEST['seq']);
                        return;
                }
 
-               if ($subop == "digest-init") {
+               if ($method == "digest-init") {
                        $tmp_feeds = api_get_feeds($link, -4, true, false, 0);
 
                        $feeds = array();
                        return;
                }
 
-               if ($subop == "catchupFeed") {
+               if ($method == "catchupFeed") {
                        $feed_id = db_escape_string($_REQUEST['feed_id']);
                        $is_cat = db_escape_string($_REQUEST['is_cat']) == "true";
 
                        return;
                }
 
-               if ($subop == "sendEmail") {
+               if ($method == "sendEmail") {
                        $secretkey = $_REQUEST['secretkey'];
 
                        require_once 'lib/phpmailer/class.phpmailer.php';
                        return;
                }
 
-               if ($subop == "completeEmails") {
+               if ($method == "completeEmails") {
                        $search = db_escape_string($_REQUEST["search"]);
 
                        print "<ul>";
                        return;
                }
 
-               if ($subop == "quickAddCat") {
+               if ($method == "quickAddCat") {
                        $cat = db_escape_string($_REQUEST["cat"]);
 
                        add_feed_category($link, $cat);
                        return;
                }
 
-               if ($subop == "regenFeedKey") {
+               if ($method == "regenFeedKey") {
                        $feed_id = db_escape_string($_REQUEST['id']);
                        $is_cat = db_escape_string($_REQUEST['is_cat']) == "true";
 
                }
 
                // Silent
-               if ($subop == "clearKeys") {
+               if ($method == "clearKeys") {
                        db_query($link, "DELETE FROM ttrss_access_keys WHERE
                                owner_uid = " . $_SESSION["uid"]);
 
                }
 
                // Silent
-               if ($subop == "clearArticleKeys") {
+               if ($method == "clearArticleKeys") {
                        db_query($link, "UPDATE ttrss_user_entries SET uuid = '' WHERE
                                owner_uid = " . $_SESSION["uid"]);
 
                }
 
 
-               if ($subop == "verifyRegexp") {
+               if ($method == "verifyRegexp") {
                        $reg_exp = $_REQUEST["reg_exp"];
 
                        $status = @preg_match("/$reg_exp/i", "TEST") !== false;
                }
 
                // TODO: unify with digest-get-contents?
-               if ($subop == "cdmGetArticle") {
+               if ($method == "cdmGetArticle") {
                        $ids = array(db_escape_string($_REQUEST["id"]));
                        $cids = explode(",", $_REQUEST["cids"]);
 
                        return;
                }
 
-               if ($subop == "scheduleFeedUpdate") {
+               if ($method == "scheduleFeedUpdate") {
                        $feed_id = db_escape_string($_REQUEST["id"]);
                        $is_cat =  db_escape_string($_REQUEST['is_cat']) == 'true';
 
                        return;
                }
 
-               if ($subop == "getTweetInfo") {
+               if ($method == "getTweetInfo") {
                        $id = db_escape_string($_REQUEST['id']);
 
                        $result = db_query($link, "SELECT title, link
                        return;
                }
 
-               if ($subop == "setNote") {
+               if ($method == "setNote") {
                        $id = db_escape_string($_REQUEST["id"]);
                        $note = trim(strip_tags(db_escape_string($_REQUEST["note"])));
 
                        return;
                }
 
-               if ($subop == "genHash") {
+               if ($method == "genHash") {
                        $hash = sha1(uniqid(rand(), true));
 
                        print json_encode(array("hash" => $hash));
                }
 
                print json_encode(array("error" => array("code" => 7,
-                       "message" => "Unknown method: $subop")));
+                       "message" => "Unknown method: $method")));
        }
 ?>