-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
68 lines (62 loc) · 1.94 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
<?php
include("bootstrap.php");
//print_r($_POST);
//print_r($user);
//print_r($_GET);
//print_r($_SERVER);
if (isset($_GET['logout'])) { // logout
$_SESSION['oauth'] = null;
session_destroy();
}
if ($_SERVER['REQUEST_URI'] == '/about') {
$viewToRender = "about";
$template = new index($aApp);
echo $template->render(getView($viewToRender));
exit();
}
if ($_SERVER['REQUEST_URI'] == '/help') {
$viewToRender = "help";
$template = new index($aApp);
echo $template->render(getView($viewToRender));
exit();
}
if ($_SERVER['REQUEST_URI'] == '/install') {
$viewToRender = "install";
$template = new index($aApp);
echo $template->render(getView($viewToRender));
exit();
}
if ($_SERVER['REQUEST_URI'] == '/feedback') {
$viewToRender = "feedback";
$template = new index($aApp);
echo $template->render(getView($viewToRender));
exit();
}
if ($_SERVER['REQUEST_URI'] == '/status') {
$viewToRender = "status";
include APP_ROOT_PATH . 'controllers/status.php';
$template = new status($aApp);
echo $template->render(getView($viewToRender));
exit();
}
if (!$_SESSION['oauth'] && $_POST['action'] == "login") { // loggin approach
$oauth->getAccessToken('password', array('username' => $_POST['username'], 'password' => $_POST['password']));
if ($oauth->access_token == '') { // failed
include APP_ROOT_PATH . 'controllers/login.php';
$viewToRender = "login";
$template = new login($aApp, "Login failed. Please check try again.");
} else { // login ok
$_SESSION['oauth']['refresh_token'] = $oauth->refresh_token;
$viewToRender = "index";
$template = new index($aApp);
}
} else if (!$_SESSION['oauth'] && isset($_POST['action']) == false) { // not loggedin, no loggin approach
include APP_ROOT_PATH . 'controllers/login.php';
$viewToRender = "login";
$template = new login($aApp);
} else { // loggedin
$viewToRender = "index";
$template = new index($aApp);
}
echo $template->render(getView($viewToRender));
?>