Improve future framework
authorJoey Schulze <joey@infodrom.org>
Fri, 4 Apr 2014 15:31:34 +0000 (15:31 +0000)
committerJoey Schulze <joey@infodrom.org>
Fri, 4 Apr 2014 15:31:34 +0000 (15:31 +0000)
class/ajaxbackend.class.php [new file with mode: 0644]
src/ajax.php

diff --git a/class/ajaxbackend.class.php b/class/ajaxbackend.class.php
new file mode 100644 (file)
index 0000000..505251c
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+
+class AJAXBackend() {
+  private $db;
+
+  public function __construct__()
+  {
+    global $db;
+    $this->db = $db;
+  }
+}
+
+?>
\ No newline at end of file
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);
+
 ?>