]> git.wh0rd.org - tt-rss.git/blobdiff - backend.php
add tiny-OOP style backend RPC
[tt-rss.git] / backend.php
index 0e485de7099582941f1609f416a71e4418173dc7..c9eed0e9affdc95e30a9b21eebd1bfc67350fee2 100644 (file)
                $_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";
@@ -43,7 +50,7 @@
 
        init_connection($link);
 
-       $method = $_REQUEST["method"];
+       $method = strtolower($_REQUEST["method"]);
        $mode = $_REQUEST["mode"];
 
        if ((!$op || $op == "rss" || $op == "dlg") && !$_REQUEST["noxml"]) {
                return;
        }
 
-       switch($op) { // Select action according to $op value.
-               case "rpc":
-                       require_once "modules/backend-rpc.php";
-                       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":
                        $method = $_REQUEST["method"];
                        $root = (bool)$_REQUEST["root"];