]> git.wh0rd.org - tt-rss.git/blobdiff - backend.php
update eclipse .settings
[tt-rss.git] / backend.php
index 077788dc7cf3822b6b90f042b27cbd9245d218d8..c9eed0e9affdc95e30a9b21eebd1bfc67350fee2 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+       set_include_path(get_include_path() . PATH_SEPARATOR . "include");
+
        /* remove ill effects of magic quotes */
 
        if (get_magic_quotes_gpc()) {
                $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
        }
 
+       function __autoload($class) {
+               $file = "classes/".strtolower(basename($class)).".php";
+               if (file_exists($file)) {
+                       require $file;
+               }
+       }
+
        $op = $_REQUEST["op"];
 
        require_once "functions.php";
        if ($op != "share") require_once "sessions.php";
-       require_once "modules/backend-rpc.php";
        require_once "sanity_check.php";
        require_once "config.php";
        require_once "db.php";
@@ -42,7 +50,7 @@
 
        init_connection($link);
 
-       $subop = $_REQUEST["subop"];
+       $method = strtolower($_REQUEST["method"]);
        $mode = $_REQUEST["mode"];
 
        if ((!$op || $op == "rss" || $op == "dlg") && !$_REQUEST["noxml"]) {
@@ -68,7 +76,7 @@
                return;
 
        } else if (!($_SESSION["uid"] && validate_session($link))) {
-               if ($op == 'pref-feeds' && $_REQUEST['subop'] == 'add') {
+               if ($op == 'pref-feeds' && $_REQUEST['method'] == 'add') {
                        header("Content-Type: text/html");
                        login_sequence($link);
                        render_login_form($link);
                5 => __("Power User"),
                10 => __("Administrator"));
 
-       
+
 
        $error = sanity_check($link);
 
                return;
        }
 
-       switch($op) { // Select action according to $op value.
-               case "rpc":
-                       // Handle remote procedure calls.
-                       handle_rpc_request($link);
-               break; // rpc
+       if (class_exists($op)) {
+               $handler = new $op($link, $_REQUEST);
 
+               if ($handler) {
+                       if ($handler->before()) {
+                               if (method_exists($handler, $method)) {
+                                       return $handler->$method();
+                               }
+                       }
+               }
+       }
+
+       switch($op) { // Select action according to $op value.
                case "feeds":
-                       $subop = $_REQUEST["subop"];
+                       $method = $_REQUEST["method"];
                        $root = (bool)$_REQUEST["root"];
 
-                       switch($subop) {
+                       switch($method) {
                                case "catchupAll":
                                        db_query($link, "UPDATE ttrss_user_entries SET
                                                last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);
                        $omode = db_escape_string($_REQUEST["omode"]);
 
                        $feed = db_escape_string($_REQUEST["feed"]);
-                       $subop = db_escape_string($_REQUEST["subop"]);
+                       $method = db_escape_string($_REQUEST["method"]);
                        $view_mode = db_escape_string($_REQUEST["view_mode"]);
                        $limit = (int) get_pref($link, "DEFAULT_ARTICLE_LIMIT");
                        @$cat_view = db_escape_string($_REQUEST["cat"]) == "true";
 
                        if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);
 
-                       $ret = format_headlines_list($link, $feed, $subop,
+                       $ret = format_headlines_list($link, $feed, $method,
                                $view_mode, $limit, $cat_view, $next_unread_feed, $offset,
                                $vgroup_last_feed, $override_order);
 
                                $reply['articles'] = $articles;
                        }
 
-//                     if ($subop) {
+//                     if ($method) {
 //                             $reply['counters'] = getAllCounters($link, $omode, $feed);
 //                     }
 
                        $reply['runtime-info'] = make_runtime_info($link);
 
                        print json_encode($reply);
-
                break; // viewfeed
 
                case "pref-feeds":