-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.php
240 lines (225 loc) · 9.12 KB
/
admin.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
<?php
include("dbconnect.php");
?>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/profit.css.php">
<link rel="shortcut icon" href="sym.ico">
<title>ProFit Wiki</title>
</head>
<body>
<?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
mysqli_query($db, "SET NAMES 'utf8'");
if(!isset($_SESSION['status'])){
echo "Bitte loggen Sie sich ein.<script language=\"JavaScript\" type=\"text/javascript\">setTimeout(\"location.href='login.htm'\", 3000);</script>";
}else if($_SESSION['status']<3){
echo "Sie haben nicht die notwendige Berechtigung für diesen Bereich.";
}else{
if($_SESSION['status']==3){ ?>
<div class="row">
<div class="col-xs-4">
<h2><u><center>Neues Programm:</center></u></h2>
<div class="form-inline">
<label for="programmname">Programm:</label>
<input type="text" name="programmname" class="form-control" id="addProgramText"/>
</div>
<span id="mel_prog_add"></span><br>
<button type="button" class="btn btn-profit" onclick="addProgram()">Programm hinzufügen</button>
</div>
<div class="col-xs-4">
<h2><u><center>Programmname ändern:</center></u></h2>
<select class="form-control" name="programmalt" id="prog_alt">
<?php
$query = "SELECT Name, ID FROM programme";
$result = mysqli_query($db, $query);
while($row = $result->fetch_row()){
echo "<option value=\"".$row[1]."\">".$row[0]."</option>";
}
?>
</select>
<div class="form-inline">
<label for="programmnameneu">Neuer Name:</label>
<input type="text" class="form-control" name="programmnameneu" id="prog_neu"></input>
</div>
<span id="mel_prog_umben"></span><br>
<button type="button" class="btn btn-profit" onclick="changeProgram(prog_alt.value, prog_neu.value)">Programm umbenennen</button>
</div>
<div class="col-xs-4">
</div>
</div>
<div class="row">
<div class="col-lg-12">
<h2><u><center>Neuer Bereich:</center></u></h2>
<form action="addbereich.php" method="post">
<div class="form-inline">
<label for="programm">Programm:</label>
<select class="form-control" name="programm" id="prog_liste">
<?php
$query = "SELECT Name, ID FROM programme";
$result = mysqli_query($db, $query);
while($row = $result->fetch_row()){
echo "<option value=\"".$row[1]."\">".$row[0]."</option>";
}
?>
</select>
</div>
<div class="form-inline">
<label for="bereichname"><center>Bereich:</center></label>
<input type="text" name="bereichname" class="form-control"/>
</div>
<button type="submit" class="btn btn-profit">Bereich hinzufügen</button>
</form>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<h2><u><center>Neues Thema:</center></u></h2>
<div class="form-inline">
<label for="themaname"><center>Thema:</center></label>
<input type="text" name="bereichname" class="form-control" id="thema"/><div id="themastat"></div>
</div>
<button type="button" class="btn btn-profit" onclick="addthema()">Thema hinzufügen</button>
</div>
<div class="col-xs-4">
<h2><u><center>Programmname ändern:</center></u></h2>
<select class="form-control" name="themaalt" id="thema_alt">
<?php
$query = "SELECT Name, ID FROM thema";
$result = mysqli_query($db, $query);
while($row = $result->fetch_row()){
echo "<option value=\"".$row[1]."\">".$row[0]."</option>";
}
?>
</select>
<div class="form-inline">
<label for="themanameneu">Neuer Name:</label>
<input type="text" class="form-control" name="themanameneu" id="thema_neu"></input>
</div>
<span id="mel_thema_umben"></span><br>
<button type="button" class="btn btn-profit" onclick="changeThema(thema_alt.value, thema_neu.value)">Thema umbenennen</button>
</div>
<div class="col-xs-4">
</div>
</div>
<?php }
} ?>
</div>
</body>
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<?php
include("footer.php");
?>
<script>
$("select.selectpicker").dropdown();
</script>
<script>
$("#programm").change(function() {
console.log("Skriptanfang(Admin): programme.change");
console.log(this.value);
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("bereich").innerHTML = this.responseText;
console.log(this.responseText);
}
};
xmlhttp.open("GET", "getpb.php?a=true&bereiche="+this.value, true);
xmlhttp.send();
});
</script>
<script>
function addProgram(){
var name = document.getElementById('addProgramText').value;
if(checkProgramName(name, "#mel_prog_add")){
console.log("checked!");
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("mel_prog_add").innerHTML = this.responseText;
}
};
xmlhttp.open("GET", "addprogram.php?programmname=" + name, true);
xmlhttp.send();
}
}
function changeProgram(alt, neu){
console.log(alt+" "+neu);
if(checkProgramName(neu, "#mel_prog_umben")){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("mel_prog_umben").innerHTML = this.responseText;
$("#prog_neu").val("");
$('#prog_alt option').filter(function () { return $(this).val() == alt; }).text(neu);
$('#prog_liste option').filter(function () { return $(this).val() == alt; }).text(neu);
}
};
xmlhttp.open("GET", "changeprogram.php?alt=" + alt + "&neu=" + neu, true);
xmlhttp.send();
}
}
function checkProgramName(name, ref){
if(name == ""){
$(ref).html("<span style='color:red'>Der Name darf nicht leer sein!</span>");
return false;
}else{
$(ref).html("");
return true;
}
}
function changeThema(alt, neu){
console.log(alt+" "+neu);
if(checkThemaName(neu)){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("mel_thema_umben").innerHTML = this.responseText;
$("#thema_neu").val("");
$('#thema_alt option').filter(function () { return $(this).val() == alt; }).text(neu);
}
};
xmlhttp.open("GET", "changethema.php?alt=" + alt + "&neu=" + neu, true);
xmlhttp.send();
}
}
function checkThemaName(name){
if(name == ""){
$("#mel_thema_umben").html("<span style='color:red'>Der Name darf nicht leer sein!</span>");
return false;
}else{
$("#mel_thema_umben").html("");
return true;
}
}
function addthema(){
console.log("Anfang addthema()");
var thema = document.getElementById('thema').value;
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("themastat").innerHTML = this.responseText;
}
};
xmlhttp.open("GET", "addthema.php?thema="+thema, true);
xmlhttp.send();
}
</script>
</html>
<?php
?>