Finish framework, include W3.css build web site via templates and jQuery
[infodrom/musiikki-web.git] / html / index.php
1 <?php
2 require_once(__DIR__.'/../class/autoloader.class.php');
3
4 if ($_SERVER['REQUEST_METHOD'] == 'GET') {
5     $template = new Template('index');
6     echo $template->render([]);
7 } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
8     $method = $_POST['action'] . 'Action';
9
10     header('Content-type: application/json; charset=UTF-8');
11     $data = AJAX::$method($_POST);
12     $return = json_encode($data);
13
14     if ($return === false) {
15         error_log('Return ' . var_export($data,true));
16         $return = json_encode(array('status' => false, 'error' => 'Rückgabedaten können nicht kodiert werden.'));
17     }
18
19     echo $return;
20
21 }