-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
72 lines (59 loc) · 1.51 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
<?php
define('ROOT_PATH', dirname(__DIR__) . '/');
include 'vendor/autoload.php';
require_once 'config.php';
require_once 'storage/log.php';
//include basic template engine and router
require_once 'lib/tokens.php';
require_once 'lib/sanitize.php';
require_once 'lib/renderTemplate.php';
require_once 'lib/router.php';
//include all our models and controllers
require_once 'models/model.php';
require_once 'controllers/controller.php';
error_log(session_status());
session_set_cookie_params([
'lifetime' => 600,
'path' => '/',
'domain' => $_SERVER['HTTP_HOST'],
'secure' => true,
'httponly' => false,
'samesite' => 'lax'
]);
//Sometimes this doesn't start so calling session start once helps.
if (session_status() == PHP_SESSION_NONE) {
error_log('starting session..');
session_start();
}
//define our routes here
route('/',function(){
return render('main');
});
route('/login',function(){
//renderLogin
return renderLogin();
});
route('/login/post',function(){
return postLogin();
});
route('/logout',function(){
return logout();
});
route('/register/post',function(){
return postRegister();
});
//admin routes here
route('/admin',function(){
return index();
});
route('/admin/books', function(){
return getBooks();
});
route('/admin/pages',function(){
return getPages();
});
route('/admin/update-pages',function(){
return updatePageFromBookView();
});
$action = $_SERVER['REQUEST_URI'];
dispatch($action);