diff options
Diffstat (limited to 'show-user.php')
| -rw-r--r-- | show-user.php | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/show-user.php b/show-user.php new file mode 100644 index 0000000..f0441c7 --- /dev/null +++ b/show-user.php @@ -0,0 +1,133 @@ +<?php +include "setup.php"; +if (session_status() === PHP_SESSION_NONE) { + my_session_start(); +} +$login=false; +if (isset($_SESSION["login"])) { + $login = $_SESSION["login"]; +} + +if ($login !== "admin" and $login !== "user") { + header("Location: index.php"); + exit; +} +?> +<!DOCTYPE html> +<html> +<body> + +<table> +<tr> +<td> + <a href="logout.php">Logout</a> +</td> +</tr> +</table> + +<?php + +// return matrikelnummer or FALSE +function retrieve_get_data () { + if (empty($_GET["matrikelnummer"])) { + return FALSE; + } else { + $mat = $_GET["matrikelnummer"]; + } + // Exactly 9 digits + if (!preg_match("/^[0-9]{7}$/",$mat)) { + return FALSE; + } + return $mat; +} + +if ($login === "admin") { + $matrikelnummer = retrieve_get_data(); +} elseif ($login === "user") { + $matrikelnummer = $_SESSION["mymatrikelnummer"]; +} else { + $matrikelnummer = FALSE; +} + +if ($matrikelnummer and + !empty($students[$matrikelnummer])) { + $vorname = $students[$matrikelnummer]["vorname"]; + $nachname = $students[$matrikelnummer]["nachname"]; + echo "<h1>$nachname, $vorname ($matrikelnummer)</h1>"; + echo "<h3>Status</h3>"; + echo "<table>"; + echo "<tr>"; + echo "<th>Fach</th>"; + echo "<th>Labor</th>"; + echo "<th>Klausur</th>"; + echo "</tr>"; + foreach ($students[$matrikelnummer]["noten"] as $fach => $notenliste) { + $fachname = $pfp[$fach]["name"]; + if (!empty($notenliste["klausur"])) { + $klausurnote = $notenliste["klausur"]; + } else { + $klausurnote = "-"; + } + if (!empty($notenliste["labor"])) { + $labornote = $notenliste["labor"]; + } else { + $labornote = "-"; + } + echo "<tr>"; + echo "<td>$fachname</td>"; + echo "<td>$labornote</td>"; + echo "<td>$klausurnote</td>"; + echo "</tr>"; + } + echo "</table>"; + + echo "<h3>Gruppen</h3>"; + echo "<table>"; + echo "<tr>"; + echo "<th>Semester</th>"; + echo "<th>Fach</th>"; + echo "<th>Gruppenname</th>"; + echo "<th>Teilnehmer</th>"; + echo "</tr>"; + foreach ($groups as $semestername => $fachliste) { + foreach ($fachliste as $fachname => $gruppenliste) { + foreach ($gruppenliste as $gname => $teilnehmerliste) { + if (in_array($matrikelnummer, $teilnehmerliste)) { + $tnnamensliste = ""; + foreach ($teilnehmerliste as $tnmat) { + if (empty($tnnamensliste)) { + $tnnamensliste = $students[$tnmat]["nachname"]; + } else { + $tnnamensliste = $tnnamensliste.", ".$students[$tnmat]["nachname"]; + } + } + echo "<tr>"; + echo "<td>$semestername</td>"; + echo "<td>$fachname</td>"; + echo "<td>$gname</td>"; + echo "<td>$tnnamensliste</td>"; + echo "</tr>"; + } + } + } + } + echo "</table>"; + + echo "<h3>Geschichte</h3>"; + echo "<table>"; + echo "<tr>"; + echo "<th>Ereignisliste</th>"; + echo "</tr>"; + foreach ($students[$matrikelnummer]["history"] as $ereignis) { + echo "<tr>"; + echo "<td>$ereignis</td>"; + echo "</tr>"; + } + echo "</table>"; +} else { + echo "<h1>Error</h1>"; +} +?> + +</body> +</html>
\ No newline at end of file |
