-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
170 lines (146 loc) · 6.19 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
require_once(__DIR__ . "/classes/helpers/CurlController.php");
require_once(__DIR__ . "/classes/helpers/RepositoryController.php");
require_once(__DIR__ . "/classes/controllers/UpdateController.php");
require_once(__DIR__ . "/classes/controllers/UserActionController.php");
require_once(__DIR__ . "/classes/controllers/LectureController.php");
require_once(__DIR__ . "/classes/models/StudentDetail.php");
require_once(__DIR__ . "/classes/models/Update.php");
require_once(__DIR__ . "/classes/models/Lecture.php");
require_once(__DIR__ . "/partials/error-display.php");
$curlController = new CurlController();
$output = $curlController->getHeader(URL);
$array = $curlController->deserializeHeader($output);
$curlController->closeUrl();
session_start();
if (isset($array["etag"])) {
$updateController = new UpdateController();
$update = $updateController->getByEtag(trim($array["etag"]));
if (is_null($update)) {
$update = new Update();
$update->setEtag(trim($array["etag"]));
$updateController->insertUpdate($update);
$repoController = new RepositoryController();
$repoController->updateRepository(URL . "/contents/");
$diff = true;
} else {
$diff = false;
}
} else {
$diff = false;
}
$_SESSION["etag"] = trim($array["etag"]);
?>
<html lang="sk">
<head>
<title>CURL - prednášky</title>
<meta charset="UTF-8">
<meta name="author" content="Juraj Lapčák">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<!-- DATATABLES -->
<link href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css" rel="stylesheet">
<script src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script>
<link href="/CURL/assets/css/style.css" rel="stylesheet">
<script src="/CURL/assets/js/script.js"></script>
<script src="/CURL/assets/js/jquery-script.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="row mt-3 mb-1">
<header class="col-lg mb-2 site-header">
<div class="mt-2 d-flex flex-row">
<div class="p-2 flex-column" style="margin-left: 5%">
<a href="https://wt98.fei.stuba.sk/CURL/"><h1 id="main-branding">Dochádzka</h1></a>
</div>
<div class="p-2 flex-column" style="margin-left: auto; margin-right: 5%">
<h3>
<?php echo "Bol vykonaný update dát? " . (($diff) ? "Áno" : "Nie"); ?>
</h3>
</div>
</div>
<div class="mb-2 d-flex flex-row">
<div class="p-2 flex-column" style="margin-left: 5%">
<a href="https://wt98.fei.stuba.sk/CURL/graph.php"><h1 id="main-branding">Graf</h1></a>
</div>
</div>
</header>
</div>
<div class="row mt-5">
<div class="col-lg ">
<main class="site-content">
<?php
$userController = new UserActionController();
$lectureController = new LectureController();
$lectures = $lectureController->getLectures();
$names = $userController->getAllNames();
$lecturesCount = count($lectures);
?>
<div class="row mt-4">
<table class="table table-bordered table-striped" id="students">
<thead class="table-dark">
<tr class="table-head">
<th scope="col" id="name">
Meno a priezvisko
</th>
<?php foreach ($lectures as $lecture) {
echo $lecture->getRowHead();
} ?>
<th scope="col" id="attendances">
Počet účastí
</th>
<th scope="col" id="minutes">
Počet minút na prednáškach
</th>
</tr>
</thead>
<tbody id="students-body">
<?php
foreach ($names as $name) {
$studentDetail = $userController->getStudentDetail($name["name"]);
echo $studentDetail->getRow($lecturesCount);
}
?>
</tbody>
</table>
</div>
</main>
</div>
</div>
</div>
<div class="modal" tabindex="-1" role="dialog" id="myModal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modal-title"></h5>
</div>
<div class="modal-body">
<h6 class="modal-title">Prednáška č. <span id="lecture-title"></span></h6>
<br>
<table class="table table-striped table-dark">
<thead>
<tr class="table-head">
<th scope="col" id="joined">
Pripojil
</th>
<th scope="col" id="left">
Odpojil
</th>
</tr>
</thead>
<tbody id="attendance-body">
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="close">Close</button>
</div>
</div>
</div>
</div>
<?php include(__DIR__ . "/partials/footer.php"); ?>
</body>
</html>