-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfreigabe.php
225 lines (210 loc) · 8.02 KB
/
freigabe.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
<?php
include("dbconnect.php");
?>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" href="css/bootstrap.min.css" TYPE="text/css"/>
<link rel="stylesheet" href="css/profit.css.php" TYPE="text/css"/>
<link rel="shortcut icon" href="sym.ico">
<title>ProFit Wiki</title>
</head>
<body id="bootstrap-overrides">
<?php
session_start();
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) {
//Zeit ueberpruefen
session_unset();
session_destroy();
}
$_SESSION['LAST_ACTIVITY'] = time();
?>
<?php
include("header.php");
?>
<div class="container">
<?php
if(isset($_SESSION['status'])){
if($_SESSION['status']=='3'){
if(isset($_POST['auswahl'])){
$auswahl = $_POST['auswahl'];
}else{
$auswahl = 1;
}
if($auswahl == 1){
?><div class="row" style="border:none;">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<button type="submit" class="btn btn-profit" name="auswahl" value="1"style="background-color:grey" disabled>Beantrage Löschungen</button>
<button type="submit" class="btn btn-profit" name="auswahl" value="2">Beantragte Freigaben</button>
</form>
</div><?php
}else{
?><div class="row" style="border:none;">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<button type="submit" class="btn btn-profit" name="auswahl" value="1">Beantrage Löschungen</button>
<button type="submit" class="btn btn-profit" name="auswahl" value="2" style="background-color:grey" disabled>Beantragte Freigaben</button>
</form>
</div><?php
}
mysqli_query($db, "SET NAMES 'utf8'");
$programmArray = getProgrammArray($db);
$bereichArray = getBereichArray($db);
$themaArray = getThemaArray($db);
$such_query = "SELECT ID, Frage, Antwort, ProgrammID, BereichID, Ranking, ThemaID FROM faq WHERE geloescht = '$auswahl'";
$such_result=mysqli_query($db, $such_query);
if($such_result!=null){
while($row = $such_result->fetch_row()){
?>
<div class="row" class="question">
<div class="borderclass">
<?php
printf ("<div class=\"col-lg-8\">
<b>Frage:</b> <textarea class=\"form-control\" name='frage' id=\"frage-%s\">%s</textarea>
</div>
<div class=\"col-lg-4\">
<b>ID:</b> %s <br>
<b>Programmname:</b> %s<br>
<b>Bereich:</b> %s<br>
<b>Thema:</b> <select name=\"thema\" class=\"form-control\" id=\"thema-%s\"> %s</select>
<b>Ranking:</b> <span id=\"ranknr-%s\">%s</span>
</div>",
$row[0], $row[1], $row[0], $programmArray[$row[3]], $bereichArray[$row[4]], $row[0], getThemaBox($row[6], $themaArray), $row[0], $row[5]
);
?>
<div class="col-lg-12" style="padding:1em;">
<?php printf ("<b>Antwort:</b> <textarea class=\"form-control\" rows='4' name='antwort' id=\"antwort-%s\">%s</textarea>", $row[0], $row[2]); ?>
</div>
<div class="col-lg-4">
<button class="btn btn-profit" type="button" onclick="revokedelete(<?php echo $row[0].", ".$auswahl;?>)"><?php if($auswahl==1){echo "Löschvorschlag ablehnen";}else{echo "Freigabe erteilen";}?></button>
<button class="btn btn-profit" type="button" onclick="deleteID(<?php echo $row[0];?>)">Löschen</button>
<button class="btn btn-profit" type="button" onclick="getHistorie(<?php echo $row[0];?>)">Historie</button>
</div>
<div class="col-lg-8">
<div id="status-<?php echo $row[0];?>"></div>
</div>
<div class="col-lg-12">
<div class="panel panel-default" id="<?php echo "Historie-".$row[0]; ?>" style="display: none;">
<!-- Wird von getHistorie(id) gefuellt -->
</div>
</div>
</div>
</div>
<?php
}
$such_result->close();
}else{
echo "<br>Keine Einträge zum Löschen vorgemerkt!";
}
}else{
echo "Die notwendige Berechtigung fehlt!";
}
}else{
echo "Bitte loggen Sie sich ein!";
}
?>
</div>
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<?php
include("footer.php");
?>
<script>
function getHistorie(id){
var xmlhttp = new XMLHttpRequest();
var hist = "Historie-"+id;
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById(hist).innerHTML = this.responseText;
$("#"+hist).slideToggle("slow");
}
};
xmlhttp.open("GET", "getHistorie.php?id=" + id, true);
xmlhttp.send();
}
function revokedelete(id, auswahl){
var xmlhttp = new XMLHttpRequest();
var stat = "status-"+id;
var th = "thema-"+id;
var thema = document.getElementById(th).value;
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById(stat).innerHTML = this.responseText;
}
};
xmlhttp.open("GET", "delete.php?revoke=" + id + "&thema=" + thema, true);
xmlhttp.send();
}
function deleteID(id){
var xmlhttp = new XMLHttpRequest();
var stat = "status-"+id;
console.log("Loeschen von: " +id);
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById(stat).innerHTML = this.responseText;
}
};
xmlhttp.open("GET", "delete.php?delete=" + id, true);
xmlhttp.send();
}
</script>
<?php
function getProgrammArray($db){
if(!$db)
{
exit("Verbindungsfehler: ".mysqli_connect_error());
}
$result=mysqli_query($db, "SELECT ID, Name FROM programme");
$programmArray[0]="Keines";
while($row = $result->fetch_row()){
$programmArray[$row[0]]=$row[1];
}
echo "<script>console.log('getProgrammArray() end')</script>";
$result->close();
return $programmArray;
}
function getBereichArray($db){
if(!$db)
{
exit("Verbindungsfehler: ".mysqli_connect_error());
}
$result=mysqli_query($db, "SELECT ID, Name FROM bereiche");
$bereichArray[0]="Keiner";
while($row = $result->fetch_row()){
$bereichArray[$row[0]]=$row[1];
}
echo "<script>console.log('getBereichArray() end')</script>";
$result->close();
return $bereichArray;
}
function getThemaArray($db){
if(!$db)
{
exit("Verbindungsfehler: ".mysqli_connect_error());
}
$result=mysqli_query($db, "SELECT ID, Name FROM thema");
$themaArray[0]="Kein Thema";
while($row = $result->fetch_row()){
$themaArray[$row[0]]=$row[1];
}
echo "<script>console.log('getThemaArray() end')</script>";
$result->close();
return $themaArray;
}
function getThemaBox($selected, $themaArray){
$ret_string = "";
if($selected == 0){
$ret_string = "<option value=\"0\">Kein Thema</option>";
}else{
$ret_string = "<option value=\"$selected\">".$themaArray[$selected]."</option>";
}
foreach($themaArray as $index => $item){
if($item === $themaArray[$selected]){
}else{
$ret_string .= "<option value=\"".$index."\">".$item."</option>";
}
}
return $ret_string;
}
?>
</body>
</html>