summaryrefslogtreecommitdiffstats
path: root/public_html/api
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-12-06 12:48:54 +0000
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-12-06 12:48:54 +0000
commita5bda37b1243a287a8c14118b6898c23eed259db (patch)
tree22a8ba18cc6504840772e96ea985b6e035702608 /public_html/api
parent98562ba546ef3a378363679055132c134ca4e4d2 (diff)
downloadwebadmin-a5bda37b1243a287a8c14118b6898c23eed259db.tar.gz
Check in initial version of Thomas' work
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");
+
?>