-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
114 lines (84 loc) · 2.94 KB
/
Copy pathindex.php
File metadata and controls
114 lines (84 loc) · 2.94 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
require_once "/lib/DataMapper.php";
require_once "/lib/functions.php";
require_once "/lib/PDO.php";
$token = null;
$mapper = new DataMapper($DBH);
$pages = ceil($mapper->getLastId() / $recordsPerPage);
if (getUserID()) {
$isRegistered = getUserID();
$token = createXsrfCookie();
} else {
$isRegistered = 'Регистрация';
}
if (isset($_POST['exit'])&& $_POST['token']==$token) {
logOut();
header("Location: $currentPage");
die;
}
$title = "Студенты";
$Arrow['name'] = "";
$Arrow['group'] = "";
$Arrow['points'] = "";
$searchText = "";
$search = "";
$directionName = "ASC";
$directionGroup = "ASC";
$directionPoints = "DESC";
$num = 0;
if (isset($_GET['num'])) {
$num = $_GET['num'];
}
$sort = 'points';
$order = 'ASC';
if (isset($_GET['order'])) {
$sort = $_GET['order'];
$order = $_GET['direction'];
if ($_GET['direction'] != 'DESC') {
switch ($_GET['order']) {
case 'name':
$directionName = "DESC";
break;
case 'groupindex':
$directionGroup = "DESC";
break;
case 'points':
$directionPoints = "DESC";
break;
}
}
}
if ($sort == 'points' && $order == "DESC") {
$directionPoints = "ASC";
}
if ($order == 'ASC') {
$arrow = "↑";
} else {
$arrow = "↓";
}
switch ($sort) {
case 'name':
$Arrow['name'] = $arrow;
break;
case 'groupindex':
$Arrow['group'] = $arrow;
break;
case 'points':
$Arrow['points'] = $arrow;
break;
}
if (isset($_GET['search']) && trim($_GET['search'])!= "") {
$search = trim($_GET['search']);
$pages = ceil($mapper->getSearchCount($search) / $recordsPerPage);
$table = $mapper->searchStudents($search, $num, $recordsPerPage, $sort, $order);
$searchText = "Показываются только студенты, найденные по словам $search";
} else {
$table = $mapper->showStudents($sort, $order, $num, $recordsPerPage);
}
$link = htmlspecialchars($currentPage) . "?order=" . htmlspecialchars(urlencode($sort), ENT_QUOTES) . "&direction=" . htmlspecialchars(urlencode($order), ENT_QUOTES);
$searchLink = htmlspecialchars(urlencode($currentPage)) . "?order=" . htmlspecialchars(urlencode($sort), ENT_QUOTES) . "&direction=" . htmlspecialchars(urlencode($order), ENT_QUOTES) . "&search=" . htmlspecialchars(urlencode($search), ENT_QUOTES);
$tableLink['name'] = "order=name&direction=" . $directionName . "&num=0";
$tableLink['groupindex'] = "order=groupindex&direction=" . $directionGroup . "&num=0";
$tableLink['points'] = "order=points&direction=" . $directionPoints . "&num=0";
include "/templates/main.html";
include "/templates/footer.html";