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
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
|
<?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 --deprecated?
# 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 $c;
$c->bypassCache = true;
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
}
?>
<?php
# start caching
if ( $c->exists(CACHEPREFIX . "adressliste.html")){
echo $c->getValue(CACHEPREFIX . "adressliste.html");
header("X-Cache-Table: Hit");
return;
}
ob_start();
?>
</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><a href='mailto:".htmlentities($row['email'])."' title='Sende ".htmlentities($row['name'])." eine E-Mail'>".htmlentities($row['email'])."</a></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'])."' title='Ändere den Eintrag'><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
$table = ob_get_contents();
$c->setKey(CACHEPREFIX . "adressliste.html", $table);
ob_end_flush();
}
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 $c;
$c->bypassCache=true;
?>
<!--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"><span class="fa fa-hand-o-left"></span> 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 $c;
$c->bypassCache = true;
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 $c;
$c->bypassCache = true;
if ( ! isset($_GET["type"]) || $_GET["type"] == "plain" )
$type = "plain";
else
$type = "csv";
lredirect("download;type=".$type);
header($_SERVER["SERVER_PROTOCOL"] . " 302 Moved");
header("Refresh: 0; ".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 show_gallery(){
if ( isset($_GET["gallery"]) && ! is_null($_GET["gallery"]) && $_GET["gallery"] != "" )
$_SESSION["gallery"] = $_GET["gallery"];
else
$_SESSION["gallery"] = 0;
lredirect("gallery;gallery=".$_SESSION["gallery"]);
global $c;
global $db;
$sql = $db->prepare("SELECT name, description, owner, time FROM " . DBPREFIX . "gallery WHERE id = %d ;", $_GET["gallery"]);
$res = $db->doQuery($sql);
require 'static/modal-new-gallery.html';
if ( $res->num_rows <= 0 ) {
// Start 404
$c->bypassCache=true;
?>
<h1>Keine Galerie gefunden!</h1>
<hr width="50%">
<h4>Vielleicht wäre es angebracht eine neue Galerie zu erstellen?</h4>
<br>
<button class="btn btn-primary " data-toggle="modal" data-target="#modal-new-gallery" data-loading-text="Lade...">
<span class="fa fa-folder-open"></span> Erstelle eine Neue!
</button>
</div>
<?php
// End 404
} else {
// Start non-404
global $moar;
$moar->addHeader( "<style>".file_get_contents('static/gallery.min.css')."</style>" );
$moar->addFooter('<script src="/js/gallery.min.js" defer></script>');
if ( isset($_GET["edit"]) ){
$moar->addFooter('<script>$("#modal-edit-gallery").modal("show");</script>');
}
if ( isset($_GET["new"]) ){
$moar->addFooter('<script>$("#modal-new-gallery").modal("show");</script>');
}
if ( $c->exists2( CACHEPREFIX . "gallery_headline_" . $_SESSION["gallery"] ) ){
echo $c->get2( CACHEPREFIX . "gallery_headline_" . $_SESSION["gallery"] );
} else {
ob_start();
$row = $res->fetch_array(MYSQLI_ASSOC);
$owner = $db->doQuery("SELECT name FROM " . DBPREFIX . "user WHERE id = " . $row["owner"] . ";");
$owner = $owner->fetch_array(MYSQLI_NUM);
$owner = $owner[0];
require 'static/modal-edit-gallery.php';
require 'static/modal-delete-gallery.php';
?>
<ul class="list-inline">
<li><h1><span class="fa fa-camera-retro"></span> <?php echo htmlentities($row["name"]); ?> <span class="desc">|</span> </h1></li>
<li><h5 class="desc">erstellt von <?php echo htmlentities($owner . " am " . date("j.n.Y", $row["time"])); ?></h5></li>
</ul>
<h5><?php echo htmlentities($row["description"]); ?></h5>
<?php
$c->set2( CACHEPREFIX . "gallery_headline_" . $_SESSION["gallery"], ob_get_contents() );
ob_end_flush();
}
?>
</div>
</div>
<div class="row">
<!-- Tab Navigation! -->
<ul class="nav nav-tabs" role="tablist">
<?php
# determines active class for tab naviagation
if ( ! isset($_GET["mode"]) || $_GET["mode"] == "" )
$_GET["mode"] = "show";
$active = array('show' => 'Galerie', 'upload' => 'Hochladen');
foreach($active as $tab => $msg){
if ( $tab == "show" ) {
$span = '<span class="fa fa-picture-o"></span> ';
} elseif ( $tab == "upload") {
$span = '<span class="fa fa-upload"></span> ';
} else {
$span="";
}
if ( $tab == $_GET["mode"] )
echo '<li class="active"><a href="/?page=gallery&gallery='.htmlentities($_GET["gallery"]).'&mode='.$tab.'" role="tab">'.$span.$msg.'</a></li>';
else
echo '<li><a href="/?page=gallery&gallery='.htmlentities($_GET["gallery"]).'&mode='.$tab.'" role="tab">'.$span.$msg.'</a></li>';
}
?>
<li><a href="#change" role="tab" onclick="$('#modal-edit-gallery').modal('show');"><span class="glyphicon glyphicon-cog"></span> Ändern</a></li>
<li><a href="#new" role="tab" onclick="$('#modal-new-gallery').modal('show')"><span class="fa fa-plus"></span> Neu</a></li>
<li><a href="#delete" role="tab" onclick="$('#modal-delete-gallery').modal('show')"><span class="glyphicon glyphicon-trash"></span> Löschen</a></li>
<li><a href="/?page=downloadGallery&gallery=<?php echo htmlentities($_GET["gallery"]); ?>" role="tab"><i class="fa fa-download"></i>
Download</a></li>
</ul>
<div class="tab-content">
<?php
if ( $_GET["mode"] == "show" ){
?>
<!-- Start Tab 'Gallery' -->
<div class="tab-pane active effect" id="galerie">
<div id="blueimp-gallery" class="blueimp-gallery" data-use-bootstrap-modal="false">
<!-- The container for the modal slides -->
<div class="slides"></div>
<!-- Controls for the borderless lightbox -->
<h3 class="title"></h3>
<a class="prev">‹</a>
<a class="next">›</a>
<a class="close">×</a>
<a class="play-pause"></a>
<ol class="indicator"></ol>
<!-- The modal dialog, which will be used to wrap the lightbox content -->
<div class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" aria-hidden="true">×</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body next"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left prev">
<i class="glyphicon glyphicon-chevron-left"></i>
Previous
</button>
<button type="button" class="btn btn-primary next">
Next
<i class="glyphicon glyphicon-chevron-right"></i>
</button>
</div>
</div>
</div>
</div>
</div>
<?php
if ( $c->exists( CACHEPREFIX . "gallery_imagelinks_" . $_SESSION["gallery"] ) ){
echo $c->get2( CACHEPREFIX . "gallery_imagelinks_" . $_SESSION["gallery"] );
} else {
ob_start();
$images = array_diff( scandir(IMAGE_PATH . $_SESSION["gallery"] . '/thumbnail' ), array('..', '.') );
if ( ! is_null($images) ){
echo '<div id="links">';
foreach($images as $image){
echo '<a href="'.IMAGE_URL.'?file='.$image.'&download=1" title="'.$image.'" data-gallery>
<img src="'.IMAGE_URL.'?file='.$image.'&thumb=1" alt="'.$image.'">
</a>';
}
echo "</div>";
} else {
echo "<h4>Keine Bilder in der aktuellen Gallerie vorhanden!</h4>";
}
$c->set2( CACHEPREFIX . "gallery_imagelinks_" . $_SESSION["gallery"], ob_get_contents() );
ob_end_flush();
}
?>
<!-- End Tab 'Galerie' -->
</div>
<?php
} elseif ( $_GET["mode"] == "upload" ){
$moar->addFooter('<script src="/js/upload.min.js" defer></script>');
?>
<!-- Start Tab 'Upload' -->
<div class="tab-pane active effect" id="upload">
<!-- The file upload form used as target for the file upload widget -->
<form id="fileupload" action="/images/" method="POST" enctype="multipart/form-data">
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
<div class="row fileupload-buttonbar">
<div class="col-lg-7">
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Add files...</span>
<input type="file" name="files[]" multiple>
</span>
<button type="submit" class="btn btn-primary start">
<i class="glyphicon glyphicon-upload"></i>
<span>Start upload</span>
</button>
<button type="reset" class="btn btn-warning cancel">
<i class="glyphicon glyphicon-ban-circle"></i>
<span>Cancel upload</span>
</button>
<button type="button" class="btn btn-danger delete">
<i class="glyphicon glyphicon-trash"></i>
<span>Delete</span>
</button>
<input type="checkbox" class="toggle">
<!-- The global file processing state -->
<span class="fileupload-process"></span>
</div>
<!-- The global progress state -->
<div class="col-lg-5 fileupload-progress fade">
<!-- The global progress bar -->
<div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar progress-bar-success" style="width:0%;"></div>
</div>
<!-- The extended global progress state -->
<div class="progress-extended"> </div>
</div>
</div>
<!-- The table listing the files available for upload/download -->
<table role="presentation" class="table table-striped"><tbody class="files"></tbody></table>
</form>
<!-- The blueimp Gallery widget -->
<div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" data-filter=":even">
<div class="slides"></div>
<h3 class="title"></h3>
<a class="prev">‹</a>
<a class="next">›</a>
<a class="close">×</a>
<a class="play-pause"></a>
<ol class="indicator"></ol>
</div>
<!-- End Tab 'Upload' -->
</div>
<!-- The template to display files available for upload -->
<script id="template-upload" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<tr class="template-upload fade">
<td>
<span class="preview"></span>
</td>
<td>
<p class="name">{%=file.name%}</p>
<strong class="error text-danger"></strong>
</td>
<td>
<p class="size">Processing...</p>
<div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="progress-bar progress-bar-success" style="width:0%;"></div></div>
</td>
<td>
{% if (!i && !o.options.autoUpload) { %}
<button class="btn btn-primary start" disabled>
<i class="glyphicon glyphicon-upload"></i>
<span>Start</span>
</button>
{% } %}
{% if (!i) { %}
<button class="btn btn-warning cancel">
<i class="glyphicon glyphicon-ban-circle"></i>
<span>Cancel</span>
</button>
{% } %}
</td>
</tr>
{% } %}
</script>
<!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<tr class="template-download fade">
<td>
<span class="preview">
{% if (file.thumbnailUrl) { %}
<a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery><img src="{%=file.thumbnailUrl%}"></a>
{% } %}
</span>
</td>
<td>
<p class="name">
{% if (file.url) { %}
<a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
{% } else { %}
<span>{%=file.name%}</span>
{% } %}
</p>
{% if (file.error) { %}
<div><span class="label label-danger">Error</span> {%=file.error%}</div>
{% } %}
</td>
<td>
<span class="size">{%=o.formatFileSize(file.size)%}</span>
</td>
<td>
{% if (file.deleteUrl) { %}
<button class="btn btn-danger delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
<i class="glyphicon glyphicon-trash"></i>
<span>Delete</span>
</button>
<input type="checkbox" name="delete" value="1" class="toggle">
{% } else { %}
<button class="btn btn-warning cancel">
<i class="glyphicon glyphicon-ban-circle"></i>
<span>Cancel</span>
</button>
{% } %}
</td>
</tr>
{% } %}
</script>
<?php
} else {
$c->bypassCache = true;
}
?>
<!-- End Tab Content -->
</div>
<?php
// End non-404
}
?>
<?php
}
function list_gallery(){
lredirect("foto");
require 'static/modal-new-gallery.html';
?>
<h1>Liste aller Galerien</h1>
<hr width="%0%">
<!-- End Text-Center-->
</div>
</div>
<div class="row">
<?php
global $c;
if ( $c->exists2( CACHEPREFIX . 'list_all_gallery' ) ){
echo $c->get2( CACHEPREFIX . 'list_all_gallery' );
} else {
global $db;
$res = $db->doQuery("SELECT * FROM " . DBPREFIX . "gallery;");
$numb = $db->affectedRows();
$class = array('fa fa-camera', 'fa fa-camera-retro', 'fa fa-picture-o');
ob_start();
while ( $row = $res->fetch_array(MYSQLI_ASSOC) ){
$res_n = $db->doQuery("SELECT name FROM " . DBPREFIX . "user WHERE id = " . $row["owner"] . ";");
$name = $res_n->fetch_array(MYSQLI_ASSOC);
$name = $name["name"];
$span = '<span class="'.$class[ mt_rand(0, count($class)-1 ) ].' fa-2x a-black"></span> ';
?>
<ul class="list-unstyled effect">
<li>
<ul class="list-inline ">
<li>
<h2><a href="/?page=gallery&gallery=<?php echo $row["id"]; ?>&mode=show" class="a-restore"><?php echo $span . htmlentities($row["name"]);?></a></h2>
</li>
<li>
<h5 class="desc">Erstellt von <u><?php echo htmlentities($name); ?></u> am <?php echo date("j.n.Y", $row["time"]); ?>.</h5>
</li>
<li>
<a href="/?page=gallery&gallery=<?php echo $row["id"]; ?>&edit=1" class="desc"><span class="glyphicon glyphicon-link font-small"></span>edit</a>
</li>
</ul>
</li>
<li>
<h5 class="des"><?php echo htmlentities($row["description"]); ?></h5>
</li>
<li>
<hr width="20%">
</li>
</ul>
<?php
}
?>
<div class="text-center">
<?php
echo "<h3>$numb Ergebnisse gefunden</h3>";
?>
<hr width="50%">
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#modal-new-gallery" data-loading-text="Lade...">
<span class="fa fa-folder-open"></span> Neue Galerie
</button>
</div>
<?php
$c->set2( CACHEPREFIX . 'list_all_gallery', ob_get_contents() );
ob_end_flush();
}
}
function flush_cache(){
lredirect("cache");
global $c;
$c->flushAll();
$c->bypassCache = true;
?>
<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;
}
# remove recursive all directories and files
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir."/".$object) == "dir")
rrmdir($dir."/".$object);
else
unlink($dir."/".$object);
}
}
reset($objects);
rmdir($dir);
}
}
|