X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=backend.php;h=e718f8103ebd639428488fab24f7aaf513197c7a;hb=23419d117bf6db266ce2fc4b7e8d14e96b788f9b;hp=1337db5c2e86cc8eca2d57ba3246cacd4ad0152e;hpb=66b042fcfeac7273b0e3ed249a93f7cb3603c891;p=tt-rss.git diff --git a/backend.php b/backend.php index 1337db5c..e718f810 100644 --- a/backend.php +++ b/backend.php @@ -1,6 +1,6 @@ array("code" => 6))); - } - return; + if ($_SESSION["uid"]) { + load_user_plugins($link, $_SESSION["uid"]); } $purge_intervals = array( @@ -108,50 +97,47 @@ 1440 => __("Daily"), 10080 => __("Weekly")); - $update_methods = array( - 0 => __("Default"), - 1 => __("Magpie"), - 2 => __("SimplePie"), - 3 => __("Twitter OAuth")); - - if (DEFAULT_UPDATE_METHOD == "1") { - $update_methods[0] .= ' (SimplePie)'; - } else { - $update_methods[0] .= ' (Magpie)'; - } - $access_level_names = array( 0 => __("User"), 5 => __("Power User"), 10 => __("Administrator")); - $error = sanity_check($link); + #$error = sanity_check($link); - if ($error['code'] != 0 && $op != "logout") { - print json_encode(array("error" => $error)); - return; - } - - function __autoload($class) { - $file = "classes/".strtolower(basename($class)).".php"; - if (file_exists($file)) { - require $file; - } - } + #if ($error['code'] != 0 && $op != "logout") { + # print json_encode(array("error" => $error)); + # return; + #} $op = str_replace("-", "_", $op); - if (class_exists($op)) { - $handler = new $op($link, $_REQUEST); + global $pluginhost; + $override = $pluginhost->lookup_handler($op, $method); + + if (class_exists($op) || $override) { - if ($handler) { + if ($override) { + $handler = $override; + } else { + $handler = new $op($link, $_REQUEST); + } + + if ($handler && implements_interface($handler, 'IHandler')) { if (validate_csrf($csrf_token) || $handler->csrf_ignore($method)) { if ($handler->before($method)) { if ($method && method_exists($handler, $method)) { $handler->$method(); + } else { + if (method_exists($handler, "catchall")) { + $handler->catchall($method); + } } $handler->after(); return; + } else { + header("Content-Type: text/plain"); + print json_encode(array("error" => array("code" => 6))); + return; } } else { header("Content-Type: text/plain");