index.php (3703B)
1 <?php 2 3 require_once "utils/autoloader.php"; 4 require_once "routing/index.php"; 5 require_once "routing/user.php"; 6 require_once "routing/course.php"; 7 require_once "routing/exam.php"; 8 require_once "routing/grade.php"; 9 10 $templater = new Lollipop\Template(new Lollipop\TemplateMethods()); 11 $router = new Lollipop\Router($templater); 12 $db = new Lollipop\SQLDatabase("86.92.67.21", "friedel", "hailiwa", "lollipop"); 13 14 session_start(); 15 16 // static files 17 18 $router->addRoute(["GET"], "/views/css/add_user.css", "views/css/add_user.css"); 19 $router->addRoute(["GET"], "/views/css/course.css", "views/css/course.css"); 20 $router->addRoute(["GET"], "/views/css/exam.css", "views/css/exam.css"); 21 $router->addRoute(["GET"], "/views/css/form_template.css", "views/css/form_template.css"); 22 $router->addRoute(["GET"], "/views/css/login.css", "views/css/login.css"); 23 $router->addRoute(["GET"], "/views/css/theme.css", "views/css/theme.css"); 24 25 $router->addRoute(["GET"], "/", $index_get); 26 27 $router->addRoute(["POST"], "/", $index_post); 28 29 $router->addRoute(["GET"], "/logout", $logout); 30 31 // restricted section 32 if(isset($_SESSION['user_permissions'])) { 33 if(in_array(1, $_SESSION['user_permissions']) || in_array(2, $_SESSION['user_permissions']) || in_array(3, $_SESSION['user_permissions'])) { 34 $router->addRoute(["GET"], "/user/:primary_key", $user_page); 35 36 $router->addRoute(["GET"], "/dashboard", $dashboard); 37 38 $router->addRoute(["GET"], "/course/:primary_key/enroll", $course_enroll); 39 40 $router->addRoute(["GET"], "/course/:primary_key/disenroll", $course_disenroll); 41 } 42 43 if(in_array(2, $_SESSION['user_permissions']) || in_array(3, $_SESSION['user_permissions'])) { 44 $router->addRoute(["GET"], "/course", $course_get); 45 46 $router->addRoute(["GET"], "/course/:course", $course_data); 47 48 $router->addRoute(["POST"], "/course", $course_post); 49 50 $router->addRoute(["GET"], "/course/search/:search_query", $course_query); 51 52 $router->addRoute(["POST"], "/course/search", $course_search); 53 54 $router->addRoute(["GET"], "/course/:primary_key/edit", $course_edit); 55 56 $router->addRoute(["GET"], "/course/:primary_key/delete", $course_delete); 57 58 $router->addRoute(["GET"], "/exam", $exam_get); 59 60 $router->addRoute(["GET"], "/exam/:exam", $exam_data); 61 62 $router->addRoute(["POST"], "/exam", $exam_post); 63 64 $router->addRoute(["GET"], "/exam/search/:search_query", $exam_query); 65 66 $router->addRoute(["POST"], "/exam/search", $exam_search); 67 68 $router->addRoute(["GET"], "/exam/:primary_key/edit", $exam_edit); 69 70 $router->addRoute(["GET"], "/exam/:primary_key/delete", $exam_delete); 71 72 $router->addRoute(["GET"], "/grade", $grade_get); 73 74 $router->addRoute(["POST"], "/grade", $grade_post); 75 76 $router->addRoute(["GET"], "/grade/search/:search_query", $grade_query); 77 78 $router->addRoute(["POST"], "/grade/search", $grade_search); 79 80 $router->addRoute(["GET"], "/grade/:primary_key/edit", $grade_edit); 81 82 $router->addRoute(["GET"], "/grade/:primary_key/delete", $grade_delete); 83 } 84 85 if(in_array(3, $_SESSION['user_permissions'])) { 86 87 $router->addRoute(["GET"], "/user", $user_get); 88 89 $router->addRoute(["POST"], "/user", $user_post); 90 91 $router->addRoute(["GET"], "/user/search/:search_query", $user_query); 92 93 $router->addRoute(["POST"], "/user/search", $user_search); 94 95 $router->addRoute(["GET"], "/user/:primary_key/edit", $user_edit); 96 97 $router->addRoute(["GET"], "/user/:primary_key/delete", $user_delete); 98 99 $router->addRoute(["GET"], "/test", $test); 100 } 101 } 102 103 $router->route();