-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlast.php
375 lines (362 loc) · 17.8 KB
/
last.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<?php
session_start();
// Dépendances
include_once("vendor/autoload.php");
// Changement de semestre
if (!isset($_COOKIE['semestre'])) {
header('Location: ./');
} else {
$semestre = htmlspecialchars($_COOKIE['semestre']);
}
if (isset($_GET['change'])) {
// MMI-1 Accès uniquement au S1/S2
if ($semestre == 's1') {
setcookie("semestre", "s2", strtotime('+360 days'));
$semestre = 's2';
} elseif ($semestre == 's2') {
setcookie("semestre", "s1", strtotime('+360 days'));
$semestre = 's1';
}
// MMI-2 Accès uniquement au S3/S4
if ($semestre == 's3') {
setcookie("semestre", "s4", strtotime('+360 days'));
$semestre = 's4';
} elseif ($semestre == 's4') {
setcookie("semestre", "s3", strtotime('+360 days'));
$semestre = 's3';
}
// Modification de l'URL si paramètre GET
echo '<script>
window.history.replaceState({}, document.title, location.pathname);
</script>';
}
// Récupération des variables d'environnement
$dotenv = Dotenv\Dotenv::createImmutable($_SERVER['DOCUMENT_ROOT']);
$dotenv->load();
$hostname = $_ENV['BDD_HOST'];
$dbname = $_ENV['BDD_NAME'];
$username = $_ENV['BDD_LOGIN'];
$password = $_ENV['BDD_PASSWD'];
// Connexion bdd
try {
$bdd = new PDO("mysql:host=$hostname;dbname=$dbname", $username, $password);
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$bdd->exec('SET NAMES utf8');
} catch (PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
// Récupération Numéro Étudiant du formulaire
if (!empty($_POST["numEtu"]) && is_numeric($_POST["numEtu"])) {
$id_etu = htmlspecialchars($_POST["numEtu"]);
$_SESSION['id_etu'] = $id_etu;
} else if (!empty($_SESSION['id_etu']) && is_numeric($_SESSION['id_etu'])) {
$id_etu = $_SESSION['id_etu'];
} else {
header('Location: ./');
exit();
}
// Set cookie ETU
if (!isset($_COOKIE['idEtuFirst'])) {
setcookie("idEtuFirst", $id_etu, strtotime('+30 mins'));
}
// Include
include "assets/include/moy.php";
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="title" content="NoteUniv, IUT Haguenau">
<meta name="description" content="Retrouvez plus facilement vos notes de l'IUT de Haguenau grâce à NoteUniv !">
<meta name="keywords" content="noteuniv, haguenau, note iut haguenau, emploi du temps mmi, note mmi, noteuniv mmi">
<meta name="robots" content="index, follow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="French">
<meta name="revisit-after" content="15 days">
<meta name="author" content="Ynohtna, Quentium">
<title>NoteUniv | Last</title>
<!-- FAVICON -->
<link rel="apple-touch-icon" sizes="57x57" href="assets/images/favicon/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="assets/images/favicon/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="assets/images/favicon/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="assets/images/favicon/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="assets/images/favicon/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="assets/images/favicon/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="assets/images/favicon/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="assets/images/favicon/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="assets/images/favicon/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="assets/images/favicon/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="assets/images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="assets/images/favicon/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon/favicon-16x16.png">
<link rel="manifest" href="assets/images/favicon/manifest.json">
<meta name="msapplication-TileColor" content="#110133">
<meta name="msapplication-TileImage" content="assets/images/favicon/ms-icon-144x144.png">
<meta name="theme-color" content="#110133">
<!-- CSS EXT-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flexboxgrid2" type="text/css">
<!-- CSS PERSO-->
<link rel="stylesheet" href="assets/css/stylePanel.css" type="text/css">
<!-- Cookie -->
<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" data-cbid="0df23692-fee1-4280-97ef-7c0506f2621d" data-blockingmode="auto" type="text/javascript"></script>
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
_paq.push(["setCookieDomain", "*.noteuniv.fr"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u = "//stats.noteuniv.fr/";
_paq.push(['setTrackerUrl', u + 'matomo.php']);
_paq.push(['setSiteId', '1']);
var d = document,
g = d.createElement('script'),
s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.async = true;
g.src = u + 'matomo.js';
s.parentNode.insertBefore(g, s);
})();
</script>
<noscript>
<p><img src="//stats.noteuniv.fr/matomo.php?idsite=1&rec=1" style="border:0;" alt="" /></p>
</noscript>
<!-- End Matomo Code -->
</head>
<body>
<div class="row center-xs start-lg">
<!-- ANCHOR CARD/ASIDE RIGHT-->
<aside class="col-sm col-lg-3">
<div class="row center-sm card">
<div class="col-sm-12">
<a href="./">
<div class="logos">
<img src="assets/images/noteuniv_logo.svg" alt="Logo NoteUniv" class="img-fluid img-ico">
<img src="assets/images/noteuniv_text.svg" alt="Texte NoteUniv" class="img-fluid img-txt">
</div>
</a>
<p class="as-etu">Étudiant</p>
<p>N°<?= $id_etu ?></p>
<p class="as-small">Je suis actuellement en :</p>
<span class="btn btn-etu">
<span class="tippy-note" data-tippy-content="T'as bien fait, c'est les meilleurs ;)"><?= $_COOKIE['promo'] ?></span>
</span>
<br>
<?php if ($_COOKIE['promo'] === 'MMI') { ?>
<a href="?change=true">
<span class="btn btn-etu">
<span class="tippy-note" data-tippy-content="Changement de semestre">SEMESTRE <?= $semestre[-1] ?></span>
</span>
</a>
<?php } ?>
<p class="as-small">Ma moyenne générale est :</p>
<?php
$moyenne = calcAverage($id_etu);
if ($id_etu === "1") {
echo '<p class="red">Toutes les notes sont aléatoires pour la démo !</p>';
}
if ($moyenne >= 15) {
echo '<span class="btn btn-green">';
$tmp = '<p class="green">Un Dieu !</p>';
} else if ($moyenne >= 13) {
echo '<span class="btn btn-green">';
$tmp = '<p class="green">Honnêtement ? OKLM gros !</p>';
} elseif ($moyenne >= 10) {
echo '<span class="btn btn-orange">';
$tmp = '<p class="orange">ALLEEEZZZ ! Ça passe !</p>';
} else {
echo '<span class="btn btn-red">';
$tmp = '<p class="red">Aïe, trql on se motive !</p>';
}
echo '<span class="tippy-note" data-tippy-content="<a href=\'ranking.php\'>Besoin de voir ta grandeur ?</a>">' . $moyenne . ' / 20</span>';
echo '</span>';
echo $tmp;
?>
<a href="edt.php"><span class="btn btn-logout">Emploi du temps</span></a>
<a href="panel.php"><span class="btn btn-logout">Récapitulatif</span></a>
</div>
</div>
</aside>
<!-- ANCHOR LEFT SIDE -->
<div class="col-lg-9 col-sm-12">
<section class="note">
<?php
if ($notExists === true) include "assets/include/soon.php";
$nb_notes = $bdd->query("SELECT COUNT(*) FROM global_$semestre")->fetchColumn();
?>
<!-- Phrase différentes selon le viewport, afin de gagner de la place -->
<h1 class="hidden-xs hidden-sm">Mes dernières notes (<?= $nb_notes ?> au total)</h1>
<h1 class="hidden-md hidden-lg hidden-xl">Mes dernières notes (<?= $nb_notes ?> au total)</h1>
<div class="row ue-tab hidden-xs">
<div class="col-sm-2 ue-nbr">
<p>Matière</p>
</div>
<div class="col-sm-6">
<div class="row note-overlay center-sm">
<div class="col-sm">
<p>Note</p>
</div>
<div class="col-sm">
<p>Moyenne</p>
</div>
<div class="col-sm">
<p>Note Min</p>
</div>
<div class="col-sm">
<p>Note Max</p>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="row center-sm">
<div class="col-sm-5">
<p>Coeff</p>
</div>
<div class="col-sm-7">
<p>Nom du devoir</p>
</div>
</div>
</div>
</div>
<?php
$sql_all_notes = "SELECT name_note, name_pdf, note_date_c, average, minimum, maximum, note_code, note_coeff, type_note, type_exam, note_semester FROM global_$semestre ORDER BY note_date_c DESC";
$list_notes = $bdd->query($sql_all_notes);
while ($note = $list_notes->fetch()) { // note = matière + date (nom du PDF)
$name = str_replace("_", " ", $note['name_note']);
$pdf = $note['name_pdf'];
$noteMoyenne = round($note['average'], 2);
$minimum = $note['minimum'];
$maximum = $note['maximum'];
$coeff = $note['note_coeff'];
$subject = $note['note_code'];
$type = $note['type_note'];
$exam = $note['type_exam'];
$sqlNote = "SELECT note_etu FROM `$note[name_pdf]` WHERE id_etu = $id_etu";
$myNote = $bdd->query($sqlNote);
$noteEtu = $myNote->fetch();
if ($noteEtu === false) {
$noteEtu = 0;
} else {
$noteEtu = $noteEtu['note_etu'];
}
if ($id_etu === '1') {
$noteEtu = random_int(10, 20);
}
?>
<?php
if ($type !== "Note unique" && $type !== "Moyenne de notes (+M)") {
echo '<article class="row all-note faded">';
} else {
echo '<article class="row all-note">';
}
?>
<div class="col-sm-2 matiere first-xs">
<p class='titre-mobile'>
<?php
if (preg_match("/AV\d?/i", $subject)) { // Easter egg
?>
<span class="tippy-note" data-tippy-content="<a href='https://youtu.be/CobknKR0t6k' target='_BLANK' class='green'>Tu veux voir un vrai truc en AV ? Clique !</a>"><?= $subject ?></span>
<?php
} else if ($type !== "Note unique" && $type !== "Moyenne de notes (+M)") {
echo '<span class="grey">' . $subject . '*</span>';
} else if ($noteEtu == 100) {
echo '<span class="red">' . $subject . '</span>';
} else {
echo $subject;
}
?>
</p>
</div>
<!-- Si mobile, on affiche les notes à la fin, et les coef en 2ème -->
<div class="col-sm-6 last-xs initial-order-sm">
<div class="row center-sm note-par-matiere">
<div class="col-sm col-xs-6">
<p>
<span class="hidden-sm hidden-md hidden-lg hidden-xl">Note<br><br></span>
<?php
if ($noteEtu == 100) { // 100 = abs
echo '<span class="orange">ABS</span>';
} else {
if ($noteEtu < 10) {
echo '<span class="red">' . $noteEtu . '</span>';
} elseif ($noteEtu < $noteMoyenne) {
echo '<span class="orange">' . $noteEtu . '</span>';
} else {
echo '<span class="green">' . $noteEtu . '</span>';
}
}
?>
</p>
</div>
<div class="col-sm col-xs-6">
<p>
<span class="hidden-sm hidden-md hidden-lg hidden-xl">Moyenne<br><br></span>
<?= $noteMoyenne ?>
</p>
</div>
<div class="col-sm col-xs-6">
<p>
<span class="hidden-sm hidden-md hidden-lg hidden-xl">Note Min<br><br></span>
<?= $minimum ?>
</p>
</div>
<div class="col-sm col-xs-6">
<p>
<span class="hidden-sm hidden-md hidden-lg hidden-xl">Note Max<br><br></span>
<?= $maximum ?>
</p>
</a>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="row start-xs center-sm">
<div class="col-xs-12 col-sm-5 first-sm">
<p>
<span class="hidden-sm hidden-md hidden-lg hidden-xl">Coeff :</span>
<?= $coeff ?>
</p>
</div>
<div class="col-xs-12 col-sm-7 first-xs">
<p>
<span class="hidden-sm hidden-md hidden-lg hidden-xl">Nom du devoir :</span>
<?php
if ($type == "Moyenne de notes (+M)") {
echo "Moyenne des notes intermédiaires " . $exam;
} else {
echo $name;
} ?>
</p>
</div>
</div>
</div>
</article>
<?php
}
?>
<div class="row">
<div class="col-xs-12">
<p>*: Note Intermédiaire. Pas prise en compte dans la moyenne. Uniquement pour affichage</p>
</div>
</div>
</section>
</div>
</div>
<footer>
<div class="row center-xs">
<div class="col-xs-12">
<p class="as-small">Made with ❤️ by <a href="https://oserya.fr/" target="_BLANK">Oserya</a> | <span class="tippy-note" data-tippy-content="QuentiumYT#0207 | Ynohtna#0001 / [email protected] | [email protected]">Nous contacter</span> | <a href="terms.html">Mentions légales</a></p>
</div>
</div>
<!-- SCRIPT EXT -->
<script src="https://unpkg.com/@popperjs/core"></script>
<script src="https://unpkg.com/tippy.js"></script>
<!-- SCRIPT PERSO -->
<script src="assets/js/app.js"></script>
</footer>
</body>
</html>