summaryrefslogtreecommitdiff
path: root/public_html/api
diff options
context:
space:
mode:
Diffstat (limited to 'public_html/api')
-rw-r--r--public_html/api/index.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/public_html/api/index.php b/public_html/api/index.php
index 5146e3d..dfde495 100644
--- a/public_html/api/index.php
+++ b/public_html/api/index.php
@@ -1,16 +1,18 @@
<?php
require_once( dirname(__FILE__) . "/../../lib/functions.php");
- if (!valid_login()) {
- need_login();
- }
+ // init frontend controller
+ $controller = new kolab_admin_controller;
- if (!empty($_GET['object']) && !empty($_GET['action'])) {
- if (function_exists($_GET['object'] . '_' . $_GET['action'])) {
- call_user_func_array($_GET['object'] . '_' . $_GET['action']);
- } elseif (file_exists(dirname(__FILE__) . "/../../lib/actions/" . $_GET['object'] . '_' . $_GET['action'] . ".php")) {
- require_once(dirname(__FILE__) . "/../../lib/actions/" . $_GET['object'] . '_' . $_GET['action'] . ".php");
- }
+ try {
+ $postdata = $_SERVER['REQUEST_METHOD'] == 'POST' ? @json_decode(file_get_contents('php://input'), true) : null;
+ $controller->dispatch($postdata);
+ } catch(Exception $e) {
+ error_log($e->getMessage());
+ $controller->output->error($e->getMessage(), $e->getCode());
}
+ // if we arrive here the controller didn't generate output
+ $controller->output->error("Invalid request");
+
?>