summaryrefslogtreecommitdiff
path: root/backend.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2011-12-12 23:32:29 +0400
committerAndrew Dolgov <[email protected]>2011-12-12 23:32:29 +0400
commitd51124689d199ef3796c09f4353ef595bd3827b0 (patch)
tree1f656e62a375be71f177490a34e4bc30a6c858a0 /backend.php
parentf30ef1fa1bd76b497b5c0a64a92e2e0ef7116515 (diff)
add tiny-OOP style backend RPC
Diffstat (limited to 'backend.php')
-rw-r--r--backend.php26
1 files changed, 20 insertions, 6 deletions
diff --git a/backend.php b/backend.php
index 0e485de70..c9eed0e9a 100644
--- a/backend.php
+++ b/backend.php
@@ -16,6 +16,13 @@
$_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"]) {
@@ -136,12 +143,19 @@
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"];