-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·78 lines (64 loc) · 1.87 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
session_cache_limiter(false);
if(!isset($_SESSION)){
session_start();
}
require 'vendor/autoload.php';
include 'manager.php';
date_default_timezone_set('Atlantic/Bermuda');
$app = new \Slim\Slim();
$app->config(array(
'debug' => true,
'templates.path' => './templates'
));
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
// $_SESSION['working'] = 'no';
// $_SESSION['user_access'] = 0;//changingthis breiaks the ap kinda weird
$app->get('/test', function(){
echo 'pew pew pew';
});
$app->get('/', function()use ($app) {
$app->render('login.php');
});
$app->get('/home', function() use ($app) {
$app->render('home.php');
});
$app->get('/getAll',function(){
echo getAll();//in manager.php
});
$app->get('/validate',function(){
$returnObj['status'] = 0;
if(isset($_SESSION['user_access']))
$returnObj['status'] = $_SESSION['user_access'];
echo json_encode($returnObj);// 0 false > 0 true
});
$app->get('/logout',function(){
$_SESSION['user_access'] = 0;
$returnObj['status']=1;
echo json_encode($returnObj);// 0 false > 0 true
});
$app->post('/subject',function() use ($app){
$allPostVars = $app->request->post();
echo createSubject($allPostVars);//in manager.php
});
$app->post('/subject/update',function() use ($app){
$allPostVars = $app->request->post();
$updateObj = $allPostVars['update'];
$constraints = $allPostVars['constraint'];
echo update($updateObj, $constraints);//in manager.php
});
$app->post('/login',function() use ($app){
$allPostVars = $app->request->post();
$_SESSION['user_access'] = login($allPostVars['username'], $allPostVars['password']);
$returnObj['status'] = $_SESSION['user_access'];// 0 false, > 0 true
echo json_encode($returnObj);
});
$app->get('/subject/delete/:id', function ($id) {
if($_SESSION['user_access']==1){
echo deleteSubject($id);
}
});
$app->run();
?>