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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
|
<?php
function lredirect($goto){
global $user;
if ( $user->isLoggedIn() != 1){
redirect("login&goto=".$goto);
}
}
function redirect($goto){
header($_SERVER["SERVER_PROTOCOL"] . " 302 Moved");
header("Location: /?page=".$goto);
ob_clean();
exit;
}
function failure($reason, $httpcode, $ajax = true, $heading = NULL){
# send header with $httpcode
header($_SERVER['SERVER_PROTOCOL'] . " " . $httpcode);
# just echo the reason to the ajax response
if($ajax){
echo $reason;
exit;
}
// TODO: Put pretty HTML here, please
# print full error page
if($heading != NULL)
echo $heading;
echo $reason;
# exit the script here
exit;
}
function print_login($option = false){
if( isset($_GET["goto"]) && $_GET["goto"] != "" ) {
$goto = htmlentities($_GET["goto"]);
} else {
$goto = "index";
}
global $user;
if ( $user->isLoggedIn() ){
redirect("index");
}
?>
<form class="form-horizontal" method="POST" action="/?page=action&task=login&goto=<?php echo $goto; ?>">
<fieldset>
<!-- Form Name -->
<legend><h1>Junge Gemeinde Adlershof</h1>
<?php
if ( ! $option ){
?>
<p>Login required</p>
<?php
} else if ( $option == "logout" ){
?>
<p style="color:red">Logout erfolgreich!</p>
<?php
} else if ( $option == "password" ) {
?>
<p style="color:red">Nutzer/Passwort falsch</p>
<?php
} else if ( $option == "missing") {
?>
<p style="color:red">Bitte fülle alle Felder aus!</p>
<?php
}
?>
</legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="name">Username*</label>
<div class="col-md-4">
<input id="name" name="name" placeholder="Name (Pflicht)" class="form-control input-md" required="" type="text">
</div>
</div>
<!-- Password input-->
<div class="form-group">
<label class="col-md-4 control-label" for="password">Password*</label>
<div class="col-md-4">
<input id="password" name="password" placeholder="Passwort (Pflicht)" class="form-control input-md" required="" type="password">
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="submit"></label>
<div class="col-md-4">
<button id="submit" name="submit" class="btn btn-info"><span class="glyphicon glyphicon-log-in"></span> Lass mich rein</button>
</div>
</div>
</fieldset>
</form>
<br>
<p><strong>Mit * markierte Felder sind Pflichtfelder.</strong></p>
</div>
<div class="row">
<a href="/?page=recover" title="Recover your password">[Passwort vergessen?]</a>
</div>
<?php
}
function print_logout(){
global $cache;
$cache = false;
global $user;
if ( $user->isLoggedIn() ){
$user->logout();
header($_SERVER["SERVER_PROTOCOL"] . " 301 Moved");
header("Location: ".DOMAIN."/?page=logout");
}
print_login("logout");
}
function print_index(){
?>
<h1>Junge Gemeinde Adlershof</h1>
<br>
</div>
<div class="row">
<div class="ec">
<img src="/static/kitten-prays-small.jpg" alt="praing kitten" class="img-responsive">
</div>
</div>
<br>
<div class="row">
<p>Wir sind die Junge Gemeinde in Adlershof.</p>
<p>Wir treffen uns immer Donnerstags um 19:30 Uhr in der Remise Arndtstraße 12a.</p>
<p>Am besten sind wir über unsere <span id="mail"><strong>Aktiviere JavaScript um die E-Mail Adresse zu sehen!</strong></span> erreichbar.</p>
</div>
<script type='text/javascript'>var a = new Array('s.de','iamfabulou','nde@lists.','jungegemei');document.getElementById('mail').innerHTML="<a href='mailto:"+a[3]+a[2]+a[1]+a[0]+"'>E-Mail Adresse</a>";</script>
<?php
}
function print_list($option = false){
lredirect("liste");
global $db;
global $c;
$result = $db->doQuery("SELECT * FROM " . DBPREFIX . "member;");
?>
<h1>Adress Liste</h1>
<?php
if ( $option == "update"){
?>
<h4 style="color:red;">Es existiert kein Mitglied mit dieser ID</h4>
<br>
<?php
} else if ( $option == false ) {
?>
<br>
<?php
}
?>
</div>
<div class="row">
<div class="table-responsive">
<table width='60%' class='table table-striped'>
<thead>
<tr>
<th><p>#</p></th>
<th><p>Name</p></th>
<th><p>Adresse</p></th>
<th><p>Telefon</p></th>
<th><p>Handynummer</p></th>
<th><p>E-Mail</p></th>
<th><p>Geburtstag</p></th>
<th><p>ändern</p></th>
</tr>
</thead>
<tbody>
<?php
$count = 1;
while ( $row = $result->fetch_array(MYSQLI_ASSOC) ){
echo "<tr>
<td>$count</td>
<td>".htmlentities($row['name'])."</td>
<td>".htmlentities($row['adresse'])."</td>
<td>".htmlentities($row['telefonnummer'])."</td>
<td>".htmlentities($row['handynummer'])."</td>
<td>".htmlentities($row['email'])."</td>
<td>".htmlentities($row['geburtstag'])."</td>
<!--td><a href='/?page=update&id=".htmlentities($row['member_id'])."' onclick=\"window.location='/?page=update&id=".htmlentities($row['member_id'])."'\"><input type='checkbox' name='change' value='true'></a></td-->
<td><a href='/?page=update&id=".htmlentities($row['member_id'])."'><span class='glyphicon glyphicon-pencil'></span></a></td>
</tr>";
$count++;
}
?>
</tbody>
</table>
</div>
<form method="POST" action="/?page=add&_flush=<?php echo $c->token; ?>">
<button id="singlebutton" class="btn btn-info" type="submit"><span class="glyphicon glyphicon-ok-sign"></span> Füge jemanden hinzu</button>
</form>
</div>
</div>
<?php
}
function print_update_list($id){
lredirect("liste");
global $db;
$sql = $db->prepare("SELECT * FROM " . DBPREFIX . "member WHERE member_id = %d", $id);
$result = $db->doQuery($sql);
if(!$result){
print_list("update");
exit;
}
if ( $row = $result->fetch_array(MYSQLI_ASSOC) ){
?>
<h1>Änderung für <?php echo htmlentities($row['name']); ?></h1>
</div>
<div class="row">
<form method='POST' action='/?page=action&task=update&id=<?php echo htmlentities($row['member_id']); ?>&goto=liste'>
<div class="table-responsive">
<table class='table'>
<thead>
<tr>
<th>Name</th>
<th>Adresse</th>
<th>Telefon</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type='text' name='name' value='<?php echo htmlentities($row['name']); ?>'></td>
<td><input type='text' name='adresse' value='<?php echo htmlentities($row['adresse']); ?>'></td>
<td><input type='text' name='telefonnummer' value='<?php echo htmlentities($row['telefonnummer']); ?>'></td>
</tr>
</tbody>
<thead>
<tr>
<th>Handynummer</th>
<th>E-Mail</th>
<th>Geburtstag</th>
</tr>
<tbody>
<tr>
<td><input type='text' name='handynummer' value='<?php echo htmlentities($row['handynummer']); ?>'></td>
<td><input type='text' name='email' value='<?php echo htmlentities($row['email']); ?>'></td>
<td><input type='text' name='geburtstag' value='<?php echo htmlentities($row['geburtstag']); ?>'></td>
</tr>
</tbody>
</table>
</div>
<button id="singlebutton" name="singlebutton" class="btn btn-info" type="submit"><span class="glyphicon glyphicon-cog"></span> Ändere!</button>
</form>
</div>
<br>
<form method="POST" action="/?page=action&task=delete&id=<?php echo htmlentities($_GET["id"]); ?>" class="form-horizontal">
<fieldset>
<legend>Lösche "<?php echo $row["name"]; ?>" von der Liste</legend>
<div class="form-group">
<label class="col-md-4 control-label" for="singlebutton"></label>
<div class="col-md-4">
<button id="singlebutton" name="singlebutton" class="btn btn-danger" type="submit" onclick="return confirm('Bist du dir sicher? Der Datensatz wird unwiederbringlich gelöscht werden!');"><span class="glyphicon glyphicon-warning-sign"></span> Löschen!</button>
</div>
</div>
</fieldset>
</form>
<?php
} else {
print_list("update");
}
}
function print_add_entry_to_list(){
lredirect("liste");
?>
<h1>Füge die Daten hinzu</h1>
</div>
<div class="row">
<form method='POST' action='/?page=action&task=add&goto=liste&_flush=<?php echo htmlentities($_GET["_flush"]); ?>'>
<div class="table-responsive">
<table class='table'>
<thead>
<tr>
<th>Name</th>
<th>Adresse</th>
<th>Telefon</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type='text' name='name' placeholder='Name'></td>
<td><input type='text' name='adresse' placeholder='Adresse'></td>
<td><input type='text' name='telefonnummer' placeholder='Telefonnummer'></td>
</tr>
</tbody>
<thead>
<tr>
<th>Handynummer</th>
<th>E-Mail</th>
<th>Geburtstag</th>
</tr>
<tbody>
<tr>
<td><input type='text' name='handynummer' placeholder='Handynummer'></td>
<td><input type='text' name='email' placeholder='E-Mail'></td>
<td><input type='text' name='geburtstag' placeholder='Geburtstag'></td>
</tr>
</tbody>
</table>
</div>
<button id="singlebutton" name="singlebutton" class="btn btn-info" type="submit"><span class="glyphicon glyphicon-check"></span> Hinzufügen!</button>
</form>
</div>
<?php
}
function _add_entry(){
lredirect("liste");
global $db;
$sql = $db->prepare("INSERT INTO " . DPREFIX . "member (id, name, adresse, telefonnummer, handynummer, email, geburtstag) VALUES (NULL. %s, %s, %s, %s, %s, %s);", $_POST['name'], $_POST['adresse'], $_POST['telefonnummer'], $_POST['handynummer'], $_POST['email'], $_POST['geburtstag']);
if( ! $db->doQuery($sql) )
return false;
else
return true;
}
function print_404(){
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
global $cache;
$cache = false;
?>
<!--h1 style="color:red;font-size:3.0em;">404 - Not Found</h1-->
<h1>Error 404 - Not Found</h1>
<!--h4>The requested page (<?php echo htmlentities($_SERVER['REQUEST_URI']); ?>) wasn't found on this server.</h4-->
<br>
</div>
<div class="row video">
<div class="embed-responsive embed-responsive-16by9">
<!--video class="embed-responsive-item" src="/static/error.webm" controls autoplay loop></video-->
<video class="embed-responsive-item" autoplay loop>
<source src="/static/error.webm" type="video/webm" media="all and (min-width: 720px)">
<source src="/static/error-480.webm" type="video/webm" media="all and (min-width: 480px)">
<source src="/static/error-320.webm" type="video/webm" media="all and (max-width: 479px)">
Tja, tut mir Leid. Leider unterstützt dein Browser keine HTML5 Videos. Schon mal über ein Upgrade nachgedacht?
</video>
</div>
<br>
<p>Wir haben die Seite <strong>'<?php echo htmlentities($_SERVER['REQUEST_URI']); ?>'</strong> nicht gefunden!</p>
<a href="javascript:history.go(-1)" title="Index">Geh eins zurück!</a>
</div>
<?php
}
function print_register($option = false){
global $user;
if ( $user->isLoggedIn() ){
redirect("index");
}
?>
<form class="form-horizontal" method='POST' action='/?page=action&task=register&goto=account'>
<fieldset>
<!-- Form Name -->
<legend><h1>Junge Gemeinde Adlershof</h1>
<?php
if ( $option == false ){
?>
<p>Register</p>
<?php
} else if ( $option == "password") {
?>
<p style="color:red;">Passwörter stimmen nicht überein!</p>
<?php
} else if ( $option == "missing") {
?>
<p style="color:red;">Bitte fülle alle mit '*' markierten Felder aus!</p>
<?php
} else if ( $option == "key") {
?>
<p style="color:red;">Registrierung verweigert!</p>
<?php
} else if ( $option == "double") {
?>
<p style="color:red;">Nutzer/E-Mail gibt es schon!</p>
<?php
} else if ( $option == "double") {
?>
<p style="color:red;">Interner Fehler!</p>
<?php
}
?>
</legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="name">Name*</label>
<div class="col-md-4">
<input id="name" name="name" placeholder="Name (Pflicht)" class="form-control input-md" required="" type="text">
</div>
</div>
<!-- Password input-->
<div class="form-group">
<label class="col-md-4 control-label" for="password">Passwort*</label>
<div class="col-md-4">
<input id="password" name="password" placeholder="Passwort (Pflicht)" class="form-control input-md" required="" type="password">
</div>
</div>
<!-- Password input-->
<div class="form-group">
<label class="col-md-4 control-label" for="confirm">Bestätige Passwort*</label>
<div class="col-md-4">
<input id="confirm" name="confirm" placeholder="Passwort (Pflicht)" class="form-control input-md" required="" type="password">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="email">E-Mail</label>
<div class="col-md-4">
<input id="email" name="email" placeholder="E-Mail" class="form-control input-md" type="text">
<span class="help-block">Deine E-Mail wird gebraucht, wenn du dein Passwort vergessen hast.</span>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="key">Key*</label>
<div class="col-md-4">
<input id="key" name="key" placeholder="Schlüssel (Pflicht)" class="form-control input-md" required="" type="password">
<span class="help-block">Du solltest den Schlüssel in einer Mail bekommen haben.</span>
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="submit"></label>
<div class="col-md-4">
<button id="submit" name="submit" class="btn btn-info"><span class="glyphicon glyphicon-share-alt"></span> Registrieren</button>
</div>
</div>
</fieldset>
</form>
<br>
<p><strong>Mit * markierte Felder sind Pflichtfelder.</strong></p>
</div>
<?php
}
function print_account($option = false){
global $cache;
$cache = false;
lredirect("account");
global $user;
?>
<form class="form-horizontal" method="POST" action="/?page=action&task=account&goto=account">
<fieldset>
<!-- Form Name -->
<legend>
<h1><?php echo htmlentities($_SESSION["username"]);?></h1>
<?php
if ( $option == false && ! isset($_GET["success"]) && $_GET["success"] != 1){
?>
<p>Ändere deine Daten</p>
<?php
} else if ( $option == "info" ){
?>
<p style="color:red;">Bitte fülle alle notwendigen Felder aus!</p>
<?php
} else if ( $option == "password" ){
?>
<p style="color:red;">Dein Passwort stimmt nicht!</p>
<?php
} else if ( $option == "double" ){
?>
<p style="color:red;">Nutzer/E-Mail schon vergeben!</p>
<?php
} else if ( $option == "database" ){
?>
<p style="color:red;">Interner Fehler!</p>
<?php
} else if ( $option == "success" || $_GET["success"] == 1 ){
?>
<p style="color:green;">Erfolgreich aktualisiert!</p>
<?php
}
?>
</legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="name">Name*</label>
<div class="col-md-4">
<input id="name" name="name" placeholder="Neuer Name" class="form-control input-md" type="text" value="<?php echo $_SESSION["username"];?>" required="">
<span class="help-block">Wechsle deinen Namen hier.</span>
</div>
</div>
<!-- Password input-->
<div class="form-group">
<label class="col-md-4 control-label" for="passwordinput">Neues Passwort</label>
<div class="col-md-4">
<input id="passwordinput" name="password" placeholder="Neues Passwort" class="form-control input-md" type="password">
<span class="help-block">Ändere dein Passwort. Lass das Feld leer, wenn du es nicht ändern möchtest.</span>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="textinput">E-Mail</label>
<div class="col-md-4">
<input id="textinput" name="email" placeholder="E-Mail" class="form-control input-md" type="text" value="<?php echo $user->getEmail(); ?>">
<span class="help-block">Ändere deine E-Mail Adresse.</span>
</div>
</div>
<!-- Password input-->
<div class="form-group">
<label class="col-md-4 control-label" for="confirm">Passwort*</label>
<div class="col-md-4">
<input id="confirm" name="confirm" placeholder="Bestätige mit deinem alten Passwort." class="form-control input-md" required="" type="password">
<span class="help-block">Bestätige die Angaben mit deinem gültigen Passwort.</span>
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="submit"></label>
<div class="col-md-4">
<button id="submit" name="submit" class="btn btn-primary"><span class="glyphicon glyphicon-cog"></span> Ändere!</button>
</div>
</div>
</fieldset>
</form>
<br>
<p><strong>Mit * markierte Felder sind Pflichtfelder.</strong></p>
</div>
<?php
}
function print_recover($option = false){
?>
<form class="form-horizontal" method='POST' action='/?page=action&task=recover'>
<fieldset>
<!-- Form Name -->
<legend><h1>Junge Gemeinde Adlershof</h1>
<?php
if(isset($_GET["track"])){
if ($_GET["track"] == 1) {
?>
<p style="color:green;">Passwort zugeschickt!</p>
<?php
} else {
?>
<p style="color:red;">Fehler! Passwort konnte nicht geändert werden.</p>
<?php
}
} else {
?>
<p>Passwort wiederherstellen</p>
<?php
}
?>
</legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="email">E-Mail*</label>
<div class="col-md-4">
<input id="email" name="email" placeholder="Deine hinterlegte E-Mail Adresse." class="form-control input-md" required="" type="text">
<span class="help-block">Wenn deine E-Mail gespeichert ist, wird dir das neue Passwort automatisch zugestellt.</span>
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="submit"></label>
<div class="col-md-4">
<button id="submit" name="submit" class="btn btn-primary"><span class="glyphicon glyphicon-export"></span> Recover!</button>
</div>
</div>
</fieldset>
</form>
</div>
<?php
}
function print_download(){
global $cache;
$cache = false;
if ( ! isset($_GET["type"]) || $_GET["type"] == "plain" )
$type = "plain";
else
$type = "csv";
lredirect("download;type=".$type);
header($_SERVER["SERVER_PROTOCOL"] . " 302 Moved");
header("Refresh: 2; ".DOMAIN."/?page=action&task=download&type=".$type);
?>
<h1>Download</h1>
<h4>Der Download der Adressliste (vom Typ 'text/<?php echo $type; ?>') sollte automatisch starten.</h4>
<hr>
</div>
<div class="row">
<strong><p>Ansonsten klick hier</p></strong>
<a href="/?page=action&task=download&type=<?php echo $type; ?>" class="btn btn-primary" title="Download Link"><span class="glyphicon glyphicon-arrow-down"></span> Download</a>
</div>
<?php
}
function flush_cache(){
lredirect("cache");
global $c;
$c->flush();
global $cache;
$cache = false;
?>
<h1>Cache flushed!</h1>
</div>
<?php
}
function minify($buffer){
$search = array(
'/\>[^\S ]+/s', // strip whitespaces after tags, except space
'/[^\S ]+\</s', // strip whitespaces before tags, except space
'/(\s)+/s' // shorten multiple whitespace sequences
);
$replace = array(
'>',
'<',
'\\1'
);
$buffer = preg_replace($search, $replace, $buffer);
return $buffer;
}
|