-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
65 lines (49 loc) · 1.44 KB
/
login.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
<?php
include_once __DIR__ . '/vendor/autoload.php';
use u311\carexperiment\view\View as View;
use u311\carexperiment\component\TrialManager as TrialManager;
use u311\carexperiment\component\Router as Router;
session_start();
unset($_SESSION['trial_start']);
$error_txt = '';
/*
* Get difference from now to start and end.
*/
$diff = TrialManager::getNextTrialTime();
/*
* If the nearest start is in the future. Redirect to the wait page
*/
if( $diff->start > 0 )
{
$_SESSION['trial_start'] = $diff->start;
$router = new Router();
header('Location: ' . $router->getDestination('wait'));
exit();
}
/*
* If the end difference is negative. There is no trial to do atm
*/
if( $diff->end < 0 )
{
echo "There are no pending trials.";
exit();
}
/*
* Otherwise, display the login page.
*/
if (isset($_SESSION['login_err'])) {
if (!empty($_SESSION['login_err'])) {
$error_txt = $_SESSION['login_err'];
unset($_SESSION['login_err']);
}
}
//See if the $_GET['src'] is set. If so, pass it to log in controller for redirect.
unset($_SESSION['dest']);
$dest = \filter_input(INPUT_GET, "src");
if(!is_null($dest)){
$_SESSION['dest'] = $_GET['src'];
}
$view = new View(__DIR__ . '/u311/carexperiment/resources/templates/');
$view->loadTemplate('logintemplate.html.twig');
$page_cont = array("login_err"=>$error_txt);
echo $view->render($page_cont);