-
Notifications
You must be signed in to change notification settings - Fork 1
/
station.php
151 lines (135 loc) · 6.83 KB
/
station.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
<?php
include('module.php');
$conn = dbconnect();
if(!angemeldet($conn)){
loginmaske($conn);
}
if(!isset($_GET['stationname'])){
header('https://xn--kpenickralley-imb.de');
echo '
<script>
location.href = "https://xn--kpenickralley-imb.de";
</script>
';
}
if(isset($_GET['fragenid'])){
$fragenid = $_GET['fragenid'];
}else{
$fragenid = 1;
}
$stationname = removesqlinjection($_GET['stationname']);
$stationid = sqlbefehl($conn, "SELECT * FROM stations WHERE Name = '$stationname'");
$stationid = $stationid->fetch_assoc()["ID"];
if(checktableexistence($conn, removetagsbyuml(removeleerzeichen($stationname)))){
$frage = sqlbefehl($conn, "SELECT * FROM ". removetagsbyuml(removeleerzeichen($stationname)). " WHERE ID = $fragenid");
$frage = $frage->fetch_assoc()["Frage"];
}else{
$frage = "ERROR #404 NOT FOUND";
}
if(isset($_GET['antwort'])){
if($_GET['antwort'] != ""){
if(checktableexistence($conn, removetagsbyuml(removeleerzeichen($stationname)))){
if(angemeldet($conn)){
createtable($conn, "Antworten");
if(isset($_SESSION['gruppenname'])){
$groupname = $_SESSION['gruppenname'];
}else {
$groupname = "Error #401";
}
$antwort = removesqlinjection($_GET['antwort']);
$fragenid=$fragenid-1;
//sqlbefehl($conn, "INSERT INTO `Antworten` (`ID`, `Gruppe`, `Station`, `IDFrage`, `Antwort`, `Korrektur`, `Punkte`) Values (NULL, '$groupname', '$stationname', $fragenid-1, '$antwort', 'Ausstehend', 0);");
$sql = "SELECT COUNT(*) AS count FROM Antworten WHERE Gruppe = '$groupname' AND Station = '$stationname' AND IDFrage = $fragenid";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$count = $row['count'];
if ($count > 0) {
$checkSql = "SELECT Antwort FROM Antworten WHERE Gruppe = '$groupname' AND Station = '$stationname' AND IDFrage = $fragenid";
$result = mysqli_query($conn, $checkSql);
$row = mysqli_fetch_assoc($result);
if ($row['Antwort'] != $antwort) {
$updateSql = "UPDATE Antworten SET Antwort = '$antwort', Korrektur = 'Ausstehend', Punkte = -1 WHERE Gruppe = '$groupname' AND Station = '$stationname' AND IDFrage = $fragenid";
mysqli_query($conn, $updateSql);
}
} else {
// Neuen Eintrag hinzufügen
$insertSql = "INSERT INTO Antworten (Gruppe, Station, IDFrage, Antwort, Korrektur, Punkte) VALUES ('$groupname', '$stationname', $fragenid, '$antwort', 'Ausstehend', -1)";
mysqli_query($conn, $insertSql);
}
aktualisiereIds($conn, "Antworten");
$fragenid=$fragenid+1;
autocorrect($conn);
}
}
}
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Station | <?php echo removesqlinjection($_GET['stationname']); ?> </title>
<link rel="stylesheet" href="darksite.css"/>
<link rel="stylesheet" href="station.css"/>
</head>
<body>
<?php
if(angemeldet($conn)){
echo '
<div class="progressbar">';
echo '<a class="home leftbar" href="https://köpenickralley.de">⌂ Home</a>';
$fragenid=$fragenid+1;
if(checktableexistence($conn, removetagsbyuml(removeleerzeichen($stationname)))){
$result = sqlbefehl($conn, "SELECT ID FROM ". removetagsbyuml(removeleerzeichen($stationname)));
if ($result->num_rows > 0) {
$rows = $result->fetch_all(MYSQLI_ASSOC);
foreach ($rows as $index => $row) {
$entry_id = $row['ID'];
$class = ($index === 0) ? 'middlebar' : (($index === count($rows) - 1) ? 'rightbar' : 'middlebar');
if($entry_id==$fragenid-1){
echo '<a class="'. $class.' skip" href="'."https://xn--kpenickralley-imb.de/station.php?stationname=". replaceandandsilicon(removesqlinjection($stationname)). "&fragenid=$fragenid".'">⏩</a>';
}
elseif(hasfinishedquestion($conn, $groupname, $entry_id, $stationname)){
echo "<a class='$class finished 'href='https://xn--kpenickralley-imb.de/station.php?stationname=". replaceandandsilicon(removesqlinjection($stationname)). "&fragenid=$entry_id'>$entry_id </a>";
}else{
echo "<a class='$class pending'href='https://xn--kpenickralley-imb.de/station.php?stationname=". replaceandandsilicon(removesqlinjection($stationname)). "&fragenid=$entry_id'>$entry_id </a>";
}
}
} else {
echo "bums.";
}
}
$fragenid=$fragenid-1;
//<div class="skip middlebar">⏩</div>
echo '
</div>
<div class="frage">';
if($fragenid <= $entry_id){
echo $frage;
echo '
<br style="font-size: 0.1vh;">
</div>
<div class="antwort">
<label for="antwort"></label>
<form action="station.php" method="get">
<input type="hidden" name="stationname" id="stationname" value="'. reformateuml(removesqlinjection($_GET['stationname'])). '"></input>
<input type="hidden" name="fragenid" id="fragenid" value="'. ($fragenid+1).'"></input>
<input type="text" id="antwort" name="antwort" placeholder="Antwort"><button type="submit">→</button></input>
</form>
</div>
';
}else{
echo 'Beendet </div>';
echo '
<script type="text/javascript">
setTimeout(function() {
window.location.href = "https://xn--kpenickralley-imb.de";
}, 3000);
</script>
';
}
}
?>
</body>
</html>