hanze/iwa-panda2

index.php in datatowebsite
Repositories | Summary | Log | Files | README.md

index.php (1720B) download


 1<?php
 2use Lollipop\Template;
 3
 4require_once "utils/autoloader.php";
 5require_once "Controller/api/api.php";
 6
 7$templater = new Template();
 8$router = new Lollipop\Router($templater);
 9
10//login
11$router->addRoute(["GET"], "/", "views/login.html");
12$router->addRoute(["POST"], "/login", function($vars){
13  include "Controller/login/login_post.php";
14  login_handler();
15});
16
17$router->addRoute(['GET', 'POST'], "/windchill/:since", $get_windchill);
18$router->addRoute(['GET', 'POST'], "/graph/:since", $get_graph);
19//logout
20$router->addRoute(["POST", "GET"], "/logout", function($vars){
21  include "Controller/logout/logout.php";
22  logout();
23  return "views/login.html";
24});
25session_start();
26if(isset($_SESSION['user_permissions']) && in_array(1,$_SESSION['user_permissions'])){
27  //user
28  //add
29  $router->addRoute(["GET"], "/user/add", "views/add_user.html");
30  $router->addRoute(["POST"], "/user/add", function(&$vars){
31  include "Controller/user/add_post.php";
32  $res = add_user("password");
33
34  foreach($res as $key => $data){
35    $vars[$key] = $data;
36  }
37
38  return "views/add_user.html";
39  });
40
41  //dashboard
42  $router->addRoute(["GET"], "/dashboard", function(&$vars){
43    foreach($_SESSION as $key => $data){
44      $vars[$key] = $data;
45    }
46    return "views/dashboard.html";
47  });
48
49  $router->addRoute(["GET"], "/map", "views/map.html");
50  $router->addRoute(["GET"], "/hdata", function(&$vars){
51      include"Controller/hdata/hdata.php";
52      $vars["table"] = make_table();
53      return "views/hdata.html";
54  });
55  $router->addRoute(["GET"], "/api/:data", function($vars) {
56    $key = new Key;
57    $key->retrieveData($vars);
58  });
59  $router->addRoute(['GET'], '/css/dashboard.css', "css/dashboard.css");
60}
61$router->route();