-
Notifications
You must be signed in to change notification settings - Fork 2
/
logevents.php
94 lines (80 loc) · 5.19 KB
/
logevents.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
90
91
92
93
94
<?php
require_once('core/Main.php');
if (!$userSystem->isLoggedIn()) {
$log->info('logevents.php', 'User was not logged in');
$redirect->redirectTo('login.php');
}
if ($currentUser->getRole() != Constants::USER_ROLES['admin']) {
$log->error('logevents.php', 'User was not admin');
$redirect->redirectTo('lectures.php');
}
$page = 0;
$username = '';
$level = '';
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
$pageValue = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_ENCODED);
if (is_numeric($pageValue)) {
$page = intval($pageValue);
} else {
if ($pageValue != '') {
$log->error('logevents.php', 'Page value is not numeric: ' . $pageValue);
}
}
$username = filter_input(INPUT_GET, 'username', FILTER_SANITIZE_ENCODED);
$level = filter_input(INPUT_GET, 'level', FILTER_SANITIZE_ENCODED);
}
echo $header->getHeader($i18n->get('title'), $i18n->get('logEvents'), array('protocols.css', 'button.css'));
echo $mainMenu->getMainMenu($i18n, $currentUser);
echo '<center>
<details open>
<summary class="styledButton" style="line-height: 10px; margin: 5px;">' . $i18n->get('filter') . '</summary>
<div style="width: 50%; display: inline-block; text-align: center; margin: 0px;">
<form action="logevents.php" method="GET">
<input type="text" name="username" value="' . $username . '" placeholder="' . $i18n->get('username') . '">
<input type="submit" value="' . $i18n->get('ok') . '">
</form>
</div>
<div style="width: 49%; display: inline-block; text-align: center; margin: 0px;">
<a href="?level=" class="styledButtonGreen" style="margin: 0px;">' . $i18n->get('reset') . '</a>
<a href="?level=' . Constants::LOG_LEVELS[0] . '" class="styledButtonGreen" style="margin: 0px;">' . Constants::LOG_LEVELS[0] . '</a>
<a href="?level=' . Constants::LOG_LEVELS[1] . '" class="styledButtonGreen" style="margin: 0px;">' . Constants::LOG_LEVELS[1] . '</a>
<a href="?level=' . Constants::LOG_LEVELS[2] . '" class="styledButtonGreen" style="margin: 0px;">' . Constants::LOG_LEVELS[2] . '</a>
<a href="?level=' . Constants::LOG_LEVELS[3] . '" class="styledButtonGreen" style="margin: 0px;">' . Constants::LOG_LEVELS[3] . '</a>
<a href="?level=' . Constants::LOG_LEVELS[4] . '" class="styledButtonGreen" style="margin: 0px;">' . Constants::LOG_LEVELS[4] . '</a>
</div>
</details>
</center>';
$numberOfLogEventsTotal = $logEventSystem->getNumberOfLogEventsTotal($username, $level);
echo $pagedContentUtil->getNavigation($page, Constants::NUMBER_OF_ENTRIES_PER_PAGE, $numberOfLogEventsTotal);
echo '<br><br>';
echo '<div style="width: 5%; display: inline-block; text-align: center;">' . $i18n->get('ID') . '</div>' .
'<div style="width: 20%; display: inline-block;">' . $i18n->get('date') . '</div>' .
'<div style="width: 10%; display: inline-block;">' . $i18n->get('username') . '</div>' .
'<div style="width: 10%; display: inline-block;">' . $i18n->get('level') . '</div>' .
'<div style="width: 35%; display: inline-block;">' . $i18n->get('remark') . '</div>' .
'<div style="width: 20%; display: inline-block;">' . $i18n->get('origin') . '</div>';
$allLogEvents = $logEventSystem->getLogEvents(Constants::NUMBER_OF_ENTRIES_PER_PAGE, $page, $username, $level);
foreach ($allLogEvents as &$event) {
$color = '';
if ($event->getLevel() == Constants::LOG_LEVELS[1]) {
$color = 'background-color: #aaaafa; ';
} else if ($event->getLevel() == Constants::LOG_LEVELS[2]) {
$color = 'background-color: yellow; ';
} else if ($event->getLevel() == Constants::LOG_LEVELS[3]) {
$color = 'background-color: orange; ';
} else if ($event->getLevel() == Constants::LOG_LEVELS[4]) {
$color = 'background-color: red; ';
}
echo '<form method="POST" action="examprotocolslist.php" style="' . $color . '">' .
'<div style="width: 5%; display: inline-block; text-align: center;">' . $event->getID() . '</div>' .
'<div style="width: 20%; display: inline-block;">' . $dateUtil->dateTimeToString($event->getDate()) . '</div>' .
'<div style="width: 10%; display: inline-block;">' . $event->getUsername() . '</div>' .
'<div style="width: 10%; display: inline-block;">' . $event->getLevel() . '</div>' .
'<div style="width: 35%; display: inline-block;">' . $event->getRemark() . '</div>' .
'<div style="width: 20%; display: inline-block;">' . $event->getOrigin() . '</div>' .
'</form>';
}
echo '<br>';
echo $pagedContentUtil->getNavigation($page, Constants::NUMBER_OF_ENTRIES_PER_PAGE, $numberOfLogEventsTotal);
echo $footer->getFooter();
?>