Improve future framework
[infodrom.org/service.infodrom.org] / src / ajax.php
index 008b5a4..927ce94 100644 (file)
@@ -1,4 +1,27 @@
 <?php
 require_once('config.php');
 require_once('future.php');
+
+function json_return($data)
+{
+  header('Content-type: application/json; charset="UTF-8"');
+  echo json_encode($data);
+  exit();
+}
+
+$backend = new AJAXBackend();
+
+$data = array();
+
+if (strlen($_POST['func'])) {
+  if (method_exists($backend, $_POST['func'])) {
+    $func = $_POST['func'];
+    $data = $backend->$func();
+  } else {
+    $data = array('error' => 'Unbekannte Funktion '.$_POST['func'].'.');
+  }
+}
+
+json_return($data);
+
 ?>