-
Notifications
You must be signed in to change notification settings - Fork 24
/
index.php
89 lines (71 loc) · 1.74 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
79
80
81
82
83
84
85
86
87
88
89
<?php
ob_start();
session_start();
require 'init.php';
/*
if( isset($_SESSION['valid']) AND !$_SESSION['valid']) {
Flight::redirect('/login');
}
Flight::map('notFound', function(){
});
Flight::route('/accessdeny', function() {
//Flight::render('accessdeny');
});
*/
Flight::route('/logout', function() {
session_destroy();
Flight::redirect('/login');
});
Flight::route('/login', function() {
//var_dump($_SESSION['valid']);
$_G = Flight::get('_G');
$msg = '';
if (isset($_POST['login']) && !empty($_POST['username']) && !empty($_POST['password'])) {
if ( $_G['site_adminuser'] === $_POST['username'] AND $_G['site_adminpass'] === $_POST['password'] ) {
$_SESSION['valid'] = true;
Flight::redirect('/overview');
}else {
$msg = 'Wrong username or password';
}
}
Flight::render('login',array($msg));
});
Flight::route('/', function() {
var_dump($_SESSION['valid']);
if(!isset($_SESSION['valid']) && !$_SESSION['valid'] ) {
Flight::redirect('/login');
} else {
Flight::redirect('/overview');
}
});
/*
//$_G = Flight::get('_G');
//var_dump($_G);
//auth_check();
function get_setting() {
global $db;
$_vtable = "cts_config";
$_S = $db->get($_vtable);
foreach ($_S as $v){
$a = [$v['name'] => $v['value'] ];
}
Flight::set('id',$a);
}
//$id = Flight::get('id');
//var_dump($id);
//get_setting();
*/
Flight::route('/s', function() {
$db = Flight::db();
$_vtable = "cts_config";
$_S = $db->get($_vtable);
//var_dump($_S);
//die('Access Deny!');
//Flight::redirect('/login');
});
//Loader Route
foreach (glob(APP_ROOT. 'app' . DS . 'route' . DS . '*.php') as $filename) {
@include $filename;
}
Flight::start();
?>