-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
3332 lines (3120 loc) · 159 KB
/
index.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
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
<?php
/*
moziloWiki - index.php
A small flatfile-based wiki with lightweight user management.
moziloWiki bases on the free roWiki by Marc Rohlfing and is
distributed under GPL (see license.txt for details). Feel
free to suit it to your personal purposes.
moziloWiki 2021 <[email protected]>
*/
// finish script even if user connection broke
ignore_user_abort(true);
// Initial: Fehlerausgabe unterdrücken, um Path-Disclosure-Attacken ins Leere laufen zu lassen
@ini_set("display_errors", 0);
require_once("WikiBacklinks.php"); // wiki backlinks
require_once("WikiGlobals.php"); // global wiki data
require_once("WikiGroups.php"); // wiki group data
require_once("WikiLanguage.php"); // wiki language
require_once("WikiPageversions.php"); // wiki page versions
require_once("WikiSettings.php"); // wiki main settings
require_once("WikiSmileys.php"); // wiki smileys
require_once("WikiStatistics.php"); // wiki statistics
require_once("WikiStringCleaner.php"); // clean string from special characters functions
require_once("WikiSyntax.php"); // wiki syntax conversion
require_once("WikiUsers.php"); // wiki user data
session_start();
// Session Fixation durch Vergabe einer neuen Session-ID beim ersten Login verhindern
if (!isset($_SESSION['PHPSESSID'])) {
session_regenerate_id(true);
$_SESSION['PHPSESSID'] = true;
}
// DEEEEEEEEEEEBUG ;)
// Return all given values for debugging
/*
echo "<h2>POST</h2>";
echo "<h2>GET</h2>";
foreach ($_GET as $a => $b)
echo $a." -> ".$b."<br />";
foreach ($_POST as $a => $b)
echo $a." -> ".$b."<br />";
echo "<h2>SESSION</h2>";
foreach ($_SESSION as $a => $b)
echo $a." -> ".$b."<br />";
*/
// get action parameter
$ACTION = strip_tags(htmlentities($_GET["action"]));
// MAIN SETTINGS
$mainsettings = new WikiSettings();
// USER MANAGEMENT
$wikiusers = new WikiUsers();
$wikigroups = new WikiGroups();
// get current user
$CURRENTUSER = $_SESSION['username'];
if ($CURRENTUSER == "") {
// if anonymous acess isn't allowed, send to login
if ($mainsettings->getAnonymousAccess() == "true") {
$GRP_ANONYMOUS = true;
$GRP_CHANGEPW = false;
$GRP_EDITCONTENT = false;
$GRP_EDITUSERS = false;
}
else
header("location:login.php?logout=true");
}
// prepare statistics
$wikistats = new WikiStatistics();
// look for users inactive more than setted value or with expired lifetime
foreach ($wikiusers->getAllUsers($query) as $key => $value) {
// kick inactive users
if (($wikiusers->isOnline($key)) && (time() - $wikiusers->getLastAction($key) > $mainsettings->getUserIdleTime()*60))
$wikiusers->setIsOnline($key, "false");
// ban expired users permenantly
if (
($wikiusers->getLifeTime($key) <> 0)
&& ($wikiusers->getLifeTime($key) <> "")
&& ($wikiusers->getFirstAction($key) <> "")
&& ((time() - $wikiusers->getFirstAction($key)) > ($wikiusers->getLifeTime($key)*24*60*60))
) {
$wikiusers->setIsBanned($key, time());
$wikiusers->setBanTime($key, 0);
}
// unban user, if bantime expired
if (($wikiusers->getIsBanned($key) > 0) && ($wikiusers->getBanTime($key) > 0) && (time() - $wikiusers->getIsBanned($key) > $wikiusers->getBanTime($key)*60)) {
$wikiusers->setIsBanned($key, 0);
$wikiusers->setBanTime($key, 0);
}
}
if (!$GRP_ANONYMOUS) {
// get the user group's rights
$GRP_ANONYMOUS = $wikigroups->isAnonymous($wikiusers->getUserGroup($CURRENTUSER));
$GRP_CHANGEPW = $wikigroups->canChangePw($wikiusers->getUserGroup($CURRENTUSER));
$GRP_EDITCONTENT = $wikigroups->canEditContent($wikiusers->getUserGroup($CURRENTUSER));
$GRP_EDITUSERS = $wikigroups->canEditUsers($wikiusers->getUserGroup($CURRENTUSER));
// if user still has his initial pw, show pw change form after login
if (($wikiusers->hasInitialPw($CURRENTUSER)) && ($_GET['login'] == "true") && (!$GRP_ANONYMOUS) && ($ACTION <> "changepw")) {
header("location:index.php?action=changepw");
}
// write first login to stats
if ($wikiusers->getFirstAction($CURRENTUSER) == "")
$wikiusers->setFirstAction($CURRENTUSER, time());
// kick user immediately, if banned
if ($wikiusers->getIsBanned($CURRENTUSER)) {
$wikiusers->setIsOnline($CURRENTUSER, "false");
header("location:login.php?logout=true");
}
}
// prepare backlink data
$wikibacklinks = new WikiBacklinks();
// prepare smileys
$wikismileys = new WikiSmileys();
// prepare language
$lang = $wikiusers->getWikiLanguage($CURRENTUSER);
if ($lang == "")
$lang = $mainsettings->getDefaultWikiLanguage();
$wikilanguage = new WikiLanguage($lang.".prop");
$wikistringcleaner = new WikiStringCleaner($wikilanguage->get("LANG_SPECIALCHARS"), $wikilanguage->get("LANG_REPLACEMENT"));
if (!$GRP_ANONYMOUS) {
// show login page, if "isonline" in users.stats is false and it's not the initial login
if ((!$wikiusers->isOnline($CURRENTUSER)) && (!$_GET['login'] == "true"))
header("location:login.php?logout=true");
// Check login
if (isset($_SESSION['login_okay']) && ($_SESSION['login_okay'] == true)) {
$wikiusers->setIsOnline($CURRENTUSER, "true");
}
else
header("location:login.php?logout=true&page=".htmlentities($_GET['page'])."&action=$ACTION");
// Increase login counter
if (($_GET['login'] == "true") && (!$wikiusers->getIsBanned($CURRENTUSER))) {
$wikiusers->setLoginCount($CURRENTUSER, $wikiusers->getLoginCount($CURRENTUSER)+1);
}
$wikiusers->setLastAction($CURRENTUSER, date("U"));
$wikiusers->setIsOnline($CURRENTUSER, "true");
}
// look for expired lockfiles and delete them
$locksdir = opendir(getcwd() . "/$DIR_LOCKS");
while ($file = readdir($locksdir)) {
if (($file <> ".") && ($file <> "..")) {
if (
(time() - filemtime($DIR_LOCKS . $file) > $mainsettings->getPagesLockTime()*60) // if a lockfile is older than setted value...
|| (!$wikiusers->isOnline(getLocker(substr($file, 0, strlen($file)-strlen($DEFAULT_LOCKSEXT))))) // or locking user isn't online anymore
)
unlink("$DIR_LOCKS$file"); // ...then delete it.
}
}
// look for expired pages and delete them
$pagesdir = opendir(getcwd() . "/$DIR_PAGES");
while (($mainsettings->getPagesLifeTime() <> 0) && ($file = readdir($pagesdir))) {
if (($file <> ".") && ($file <> "..")) {
if ((time() - filemtime($DIR_PAGES . $file)) > ($mainsettings->getPagesLifeTime()*24*60*60)) { // if a page is older than the setted time...
deleteFile("page", substr($file, 0, strlen($file)-strlen($DEFAULT_PAGESEXT)));
}
}
}
// look for expired files and delete them
$filesdir = opendir(getcwd() . "/$DIR_FILES");
while (($mainsettings->getFilesLifeTime() <> 0) && ($file = readdir($filesdir))) {
if (($file <> ".") && ($file <> "..")) {
if ((time() - filemtime($DIR_FILES . $file)) > ($mainsettings->getFilesLifeTime()*24*60*60)) { // if a file is older than the setted time...
deleteFile("file", $file);
}
}
}
// prepare syntax
$wikisyntax = new WikiSyntax($DEFAULT_PAGESEXT,$DIR_FILES,$DIR_PAGES,$GRP_ANONYMOUS,$GRP_EDITCONTENT,$wikilanguage,$wikistringcleaner,false);
// determine page to display
if (!$PAGE_TITLE = stripslashes(strip_tags(htmlentities($_GET["page"])))) {
if (($ACTION == "searchpages") || ($ACTION == "searchfiles") || ($ACTION == "searchusers"))
$PAGE_TITLE = $wikilanguage->get("LANG_SEARCHRESULTSFOR")." \"".strip_tags(htmlentities($_GET[query]))."\"";
elseif ($ACTION == "recentpages")
$PAGE_TITLE = $wikilanguage->get("LANG_RECENTPAGES");
elseif ($ACTION == "recentfiles")
$PAGE_TITLE = $wikilanguage->get("LANG_RECENTFILES");
elseif ($ACTION == "trashfiles")
$PAGE_TITLE = $wikilanguage->get("LANG_TRASHFILES");
elseif ($ACTION == "trashpages")
$PAGE_TITLE = $wikilanguage->get("LANG_TRASHPAGES");
elseif ($ACTION == "allpages")
$PAGE_TITLE = $wikilanguage->get("LANG_ALLPAGES");
elseif ($ACTION == "orphanedpages")
$PAGE_TITLE = $wikilanguage->get("LANG_ORPHANEDPAGES");
elseif ($ACTION == "pageversions")
$PAGE_TITLE = $wikilanguage->get("LANG_PAGEVERSIONS");
elseif ($ACTION == "allfiles")
$PAGE_TITLE = $wikilanguage->get("LANG_ALLFILES");
elseif (($ACTION == "upload") || ($_POST["upload"] == "true"))
$PAGE_TITLE = $wikilanguage->get("LANG_UPLOAD");
elseif ($ACTION == "allusers")
$PAGE_TITLE = $wikilanguage->get("LANG_ALLUSERS");
elseif ($ACTION == "edituser")
$PAGE_TITLE = $wikilanguage->get("LANG_EDITUSERS");
elseif (($ACTION == "changepw") || ($_POST["changepw"] == "true"))
$PAGE_TITLE = $wikilanguage->get("LANG_CHANGEPW");
elseif ($ACTION == "usersettings")
$PAGE_TITLE = $wikilanguage->get("LANG_USERSETTINGS");
elseif ($ACTION == "wikisettings")
$PAGE_TITLE = $wikilanguage->get("LANG_WIKISETTINGS");
elseif ($ACTION == "editpattern")
$PAGE_TITLE = $wikilanguage->get("LANG_EDITPATTERNS");
elseif ($ACTION == "fileinfo")
$PAGE_TITLE = $wikilanguage->get("LANG_FILEINFO");
elseif ($ACTION == "statistics")
$PAGE_TITLE = $wikilanguage->get("LANG_STATISTICS");
else
$PAGE_TITLE = $DEFAULT_STARTPAGE;
}
// prepare page version management
$wikipageversions = new WikiPageversions($DIR_BACKUP);
// catch malicious paths
if (preg_match("/[\/|\.|\\\]/", htmlentities($_GET["page"])))
$PAGE_TITLE = $DEFAULT_STARTPAGE;
// if user cancelled an edit operation, delete lockfile
if ($_GET["unlock"] == true) {
if (file_exists($DIR_LOCKS.$PAGE_TITLE.$DEFAULT_LOCKSEXT))
unlink($DIR_LOCKS.$PAGE_TITLE.$DEFAULT_LOCKSEXT);
if (!file_exists($DIR_PAGES.$PAGE_TITLE.$DEFAULT_PAGESEXT))
$PAGE_TITLE = $DEFAULT_STARTPAGE;
}
// write changes to page, if there are any
if ($_POST["unlock"] == true)
if (file_exists($_POST["lockfile"]))
unlink($_POST["lockfile"]);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// change user's password
if ($_POST["changepw"] == "true") {
$ACTION = "changepw";
}
// upload files
elseif ($_POST["upload"] == "true") {
$ACTION = "upload";
}
else {
$page = $wikistringcleaner->cleanThatString(htmlentities($_POST["page"]), false);
if (($page == "") || (!$file = @fopen($DIR_PAGES.$page.$DEFAULT_PAGESEXT, "w")))
die("Could not write page $page!");
if (get_magic_quotes_gpc())
fputs($file, trim(stripslashes($_POST['content'])));
else
fputs($file, trim($_POST['content']));
fclose($file);
// statistics: save changer
$wikistats->setLastPageChanger($page, $CURRENTUSER);
// save if page is a admin page
if ($_POST['adminpage'] == "on")
$mainsettings->setIsAdminPage($page, true);
else
$mainsettings->setIsAdminPage($page, false);
if ($DIR_BACKUP <> '') {
// write backup of old version to file
savePageBackup($page, "");
$wikipageversions->setChangerOfTime(time(), $page, $CURRENTUSER);
}
header("location:".urlencode(stripslashes($page)));
}
}
// get user's wiki style
if (!$GRP_ANONYMOUS) {
$currentwikistyle = $wikiusers->getWikiStyle($CURRENTUSER);
// if style path doesn't exist, use default wiki style and set it as user style
if (!file_exists($MAINDIR_STYLES.$wikiusers->getWikiStyle($CURRENTUSER))) {
$currentwikistyle = $mainsettings->getDefaultWikiStyle();
$wikiusers->setWikiStyle($CURRENTUSER, $currentwikistyle);
}
}
// else use default wiki style
else
$currentwikistyle = $mainsettings->getDefaultWikiStyle();
// Read and parse template
if (!$file = @fopen($MAINDIR_STYLES.$currentwikistyle."/".$TEMPLATE_FILE, "r"))
die("Could not read template file $TEMPLATE_FILE!");
$template = fread($file, filesize($MAINDIR_STYLES.$currentwikistyle."/".$TEMPLATE_FILE));
fclose($file);
$template = preg_replace("/{STYLE_PATH}/", $MAINDIR_STYLES.$currentwikistyle."/".$CSS_FILE, $template);
if (file_exists($DIR_PAGES.$PAGE_TITLE.$DEFAULT_PAGESEXT)) {
$BACKLINKS = showBacklinks($PAGE_TITLE);
}
else {
$BACKLINKS = "";
}
// Read page contents and time of last change
if (($file = @fopen($DIR_PAGES.$PAGE_TITLE.$DEFAULT_PAGESEXT, "r")) || $ACTION <> "") {
$TIME = strftime($mainsettings->getTimeFormat(), @filemtime($DIR_PAGES.$PAGE_TITLE.$DEFAULT_PAGESEXT));
$PRINTLINK = "<a href=\"print.php?page=".$PAGE_TITLE."\" target=\"_blank\" title=\"".$wikilanguage->get("LANG_SHOWPRINTVIEW").": "$PAGE_TITLE"\" accesskey=\"p\"><img src=\"pic/printpageicon.gif\" alt=\"".$wikilanguage->get("LANG_SHOWPRINTVIEW")."\" /></a>";
$CONTENT = "\n" . @fread($file, @filesize($DIR_PAGES.$PAGE_TITLE.$DEFAULT_PAGESEXT)) . "\n";
@fclose($file);
}
// if page not existent, open it in edit mode
else {
$ACTION = "edit";
$TIME = getNoActionString($wikilanguage->get("LANG_NOTIMEFOUND"));
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
// Determine access mode
if ($ACTION == "trashfiles")
if (
// trash available to delete...
(returnQuery($DIR_TRASHFILES, "", false, false, false, 0) <> null)
&&
// ...last trashfile is not being to removed manually (a few lines later)...
!((count(returnQuery($DIR_TRASHFILES, "", false, false, false, 0)) == 1) && ($_GET["restore"] == "true"))
&&
// ...the whole trash directory is not being to be cleared (a few lines later)
!($_GET["emptytrash"] == "true")
&&
// and current user is admin
$GRP_EDITUSERS
)
$html = preg_replace('/{EDIT}/', "<a href=\"index.php?action=trashfiles&emptytrash=true\">".$wikilanguage->get("LANG_DELETEALL")."</a>", $template);
else
$html = preg_replace('/{EDIT}/', getNoActionString($wikilanguage->get("LANG_NOACTION")), $template);
elseif ($ACTION == "trashpages")
if (
// trash available to delete...
(returnQuery($DIR_TRASHPAGES, "", false, false, false, 0) <> null)
&&
// ...last trashfile is not being to removed manually (a few lines later)...
!((count(returnQuery($DIR_TRASHPAGES, "", false, false, false, 0)) == 1) && ($_GET["restore"] == "true"))
&&
// ...the whole trash directory is not being to be cleared (a few lines later)
!($_GET["emptytrash"] == "true")
&&
// and current user is admin
$GRP_EDITUSERS
)
$html = preg_replace('/{EDIT}/', "<a href=\"index.php?action=trashpages&emptytrash=true\">".$wikilanguage->get("LANG_DELETEALL")."</a>", $template);
else
$html = preg_replace('/{EDIT}/', getNoActionString($wikilanguage->get("LANG_NOACTION")), $template);
elseif (($ACTION == "recentfiles") || ($ACTION == "recentpages"))
$html = preg_replace('/{EDIT}/', "<a href=\"index.php?action=$ACTION&count=10\">10</a> | <a href=\"index.php?action=$ACTION&count=20\">20</a> | <a href=\"index.php?action=$ACTION&count=50\">50</a>", $template);
else if (($ACTION == "edit") || ($ACTION <> "")) {
$html = preg_replace('/{EDIT}/', getNoActionString($wikilanguage->get("LANG_NOACTION")), $template);
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
elseif (fileIsReadonly($DIR_PAGES, $PAGE_TITLE.$DEFAULT_PAGESEXT))
$html = preg_replace('/{EDIT}/', $wikilanguage->get("LANG_ISPROTECTED"), $template);
elseif (!$GRP_EDITCONTENT)
$html = preg_replace('/{EDIT}/', getNoActionString($wikilanguage->get("LANG_NOACTION")), $template);
elseif (entryIsLocked($PAGE_TITLE))
$html = preg_replace('/{EDIT}/', $wikilanguage->get("LANG_EDITLINKLOCKED")." ".$wikiusers->getFullName(getLocker($PAGE_TITLE)), $template);
elseif ($mainsettings->getIsAdminPage($PAGE_TITLE) && !$GRP_EDITUSERS)
$html = preg_replace('/{EDIT}/', getNoActionString($wikilanguage->get("LANG_NOACTION")), $template);
else
$html = preg_replace('/{EDIT}/', "<a href=\"$PAGE_TITLE&action=edit\" title=\"".$wikilanguage->get("LANG_EDITLINK").": "$PAGE_TITLE"\" accesskey=\"e\"><img src=\"pic/editpageicon.gif\" alt=\"".$wikilanguage->get("LANG_EDITLINK")."\" /></a>", $template);
if ($GRP_ANONYMOUS)
$html = preg_replace('/{RECENT_PAGES}/', "", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{RECENT_PAGES}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_RECENTPAGES")."</em>", $html);
elseif ($ACTION == "recentpages")
$html = preg_replace('/{RECENT_PAGES}/', "<a href=\"index.php?action=recentpages&count=$DEFAULT_RECENTCOUNT\" class=\"activemenupoint\">".$wikilanguage->get("LANG_RECENTPAGES")."</a>", $html);
else
$html = preg_replace('/{RECENT_PAGES}/', "<a href=\"index.php?action=recentpages&count=$DEFAULT_RECENTCOUNT\">".$wikilanguage->get("LANG_RECENTPAGES")."</a>", $html);
if ($GRP_ANONYMOUS)
$html = preg_replace('/{RECENT_FILES}/', "", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{RECENT_FILES}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_RECENTFILES")."</em>", $html);
elseif ($ACTION == "recentfiles")
$html = preg_replace('/{RECENT_FILES}/', "<a href=\"index.php?action=recentfiles&count=$DEFAULT_RECENTCOUNT\" class=\"activemenupoint\">".$wikilanguage->get("LANG_RECENTFILES")."</a>", $html);
else
$html = preg_replace('/{RECENT_FILES}/', "<a href=\"index.php?action=recentfiles&count=$DEFAULT_RECENTCOUNT\">".$wikilanguage->get("LANG_RECENTFILES")."</a>", $html);
if (!$GRP_EDITCONTENT)
$html = preg_replace('/{TRASH_FILES}/', "", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{TRASH_FILES}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_TRASHFILES")."</em>", $html);
elseif ($ACTION == "trashfiles")
$html = preg_replace('/{TRASH_FILES}/', "<a href=\"index.php?action=trashfiles\" class=\"activemenupoint\">".$wikilanguage->get("LANG_TRASHFILES")."</a>", $html);
else
$html = preg_replace('/{TRASH_FILES}/', "<a href=\"index.php?action=trashfiles\">".$wikilanguage->get("LANG_TRASHFILES")."</a>", $html);
if (!$GRP_EDITCONTENT)
$html = preg_replace('/{TRASH_PAGES}/', "", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{TRASH_PAGES}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_TRASHPAGES")."</em>", $html);
elseif ($ACTION == "trashpages")
$html = preg_replace('/{TRASH_PAGES}/', "<a href=\"index.php?action=trashpages\" class=\"activemenupoint\">".$wikilanguage->get("LANG_TRASHPAGES")."</a>", $html);
else
$html = preg_replace('/{TRASH_PAGES}/', "<a href=\"index.php?action=trashpages\">".$wikilanguage->get("LANG_TRASHPAGES")."</a>", $html);
if ($ACTION == "allpages")
$html = preg_replace('/{ALL_PAGES}/', "<a href=\"index.php?action=allpages\" class=\"activemenupoint\">".$wikilanguage->get("LANG_ALLPAGES")."</a>", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{ALL_PAGES}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_ALLPAGES")."</em>", $html);
else
$html = preg_replace('/{ALL_PAGES}/', "<a href=\"index.php?action=allpages\">".$wikilanguage->get("LANG_ALLPAGES")."</a>", $html);
if ($GRP_ANONYMOUS)
$html = preg_replace('/{ORPHANED_PAGES}/', "", $html);
elseif ($ACTION == "orphanedpages")
$html = preg_replace('/{ORPHANED_PAGES}/', "<a href=\"index.php?action=orphanedpages\" class=\"activemenupoint\">".$wikilanguage->get("LANG_ORPHANEDPAGES")."</a>", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{ORPHANED_PAGES}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_ORPHANEDPAGES")."</em>", $html);
else
$html = preg_replace('/{ORPHANED_PAGES}/', "<a href=\"index.php?action=orphanedpages\">".$wikilanguage->get("LANG_ORPHANEDPAGES")."</a>", $html);
if ($ACTION == "allfiles")
$html = preg_replace('/{ALL_FILES}/', "<a href=\"index.php?action=allfiles\" class=\"activemenupoint\">".$wikilanguage->get("LANG_ALLFILES")."</a>", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{ALL_FILES}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_ALLFILES")."</em>", $html);
else
$html = preg_replace('/{ALL_FILES}/', "<a href=\"index.php?action=allfiles\">".$wikilanguage->get("LANG_ALLFILES")."</a>", $html);
if (!$GRP_EDITCONTENT)
$html = preg_replace('/{ALL_USERS}/', "", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{ALL_USERS}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_ALLUSERS")."</em>", $html);
elseif ($ACTION == "allusers")
$html = preg_replace('/{ALL_USERS}/', "<a href=\"index.php?action=allusers\" class=\"activemenupoint\">".$wikilanguage->get("LANG_ALLUSERS")."</a>", $html);
else
$html = preg_replace('/{ALL_USERS}/', "<a href=\"index.php?action=allusers\">".$wikilanguage->get("LANG_ALLUSERS")."</a>", $html);
if (!$GRP_EDITCONTENT)
$html = preg_replace('/{SEARCH_USERS}/', "", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{SEARCH_USERS}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("BUTTON_SEARCHUSERS")."</em>", $html);
else
$html = preg_replace('/{SEARCH_USERS}/', "<form name=\"searchusers\" method=\"get\" action=\"index.php\"><input type=\"hidden\" name=\"action\" value=\"searchusers\" /><input class=\"menutext\" type=\"text\" name=\"query\" value=\"\" /><input class=\"menubutton\" type=\"submit\" value=\"".$wikilanguage->get("BUTTON_SEARCHUSERS")."\" /></form>", $html);
if (!$GRP_EDITCONTENT)
$html = preg_replace('/{UPLOAD}/', "", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{UPLOAD}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_UPLOAD")."</em>", $html);
elseif ($ACTION == "upload")
$html = preg_replace('/{UPLOAD}/', "<a href=\"index.php?action=upload\" class=\"activemenupoint\">".$wikilanguage->get("LANG_UPLOAD")."</a>", $html);
else
$html = preg_replace('/{UPLOAD}/', "<a href=\"index.php?action=upload\">".$wikilanguage->get("LANG_UPLOAD")."</a>", $html);
// put values into template
$html = preg_replace('/{PAGE_TITLE}/', "$PAGE_TITLE", $html);
if ($ACTION == "edit")
$html = preg_replace('/{HOME}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_STARTPAGE")."</em>", $html);
elseif ($PAGE_TITLE == $DEFAULT_STARTPAGE)
$html = preg_replace('/{HOME}/', "<a href=\"index.php\" class=\"activemenupoint\">".$wikilanguage->get("LANG_STARTPAGE")."</a>", $html);
else
$html = preg_replace('/{HOME}/', "<a href=\"index.php\">".$wikilanguage->get("LANG_STARTPAGE")."</a>", $html);
if (!$GRP_EDITCONTENT)
$html = preg_replace('/{TESTPAGE}/', "", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{TESTPAGE}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_TESTPAGE")."</em>", $html);
elseif (!file_exists($DIR_PAGES.$DEFAULT_TESTPAGE.$DEFAULT_PAGESEXT))
$html = preg_replace('/{TESTPAGE}/', "<a href=\"$DEFAULT_TESTPAGE\" class=\"pending\">".$wikilanguage->get("LANG_TESTPAGE")."</a>", $html);
elseif ($PAGE_TITLE == $DEFAULT_TESTPAGE)
$html = preg_replace('/{TESTPAGE}/', "<a href=\"$DEFAULT_TESTPAGE\" class=\"activemenupoint\">".$wikilanguage->get("LANG_TESTPAGE")."</a>", $html);
else
$html = preg_replace('/{TESTPAGE}/', "<a href=\"$DEFAULT_TESTPAGE\">".$wikilanguage->get("LANG_TESTPAGE")."</a>", $html);
if (!file_exists($DIR_PAGES.$DEFAULT_FUNCTIONSPAGE.$DEFAULT_PAGESEXT))
$html = preg_replace('/{FUNCTIONS}/', "<a href=\"$DEFAULT_FUNCTIONSPAGE\" class=\"pending\">".$wikilanguage->get("LANG_FUNCTIONSPAGE")."</a>", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{FUNCTIONS}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_FUNCTIONSPAGE")."</em>", $html);
elseif ($PAGE_TITLE == $DEFAULT_FUNCTIONSPAGE)
$html = preg_replace('/{FUNCTIONS}/', "<a href=\"$DEFAULT_FUNCTIONSPAGE\" class=\"activemenupoint\">".$wikilanguage->get("LANG_FUNCTIONSPAGE")."</a>", $html);
else
$html = preg_replace('/{FUNCTIONS}/', "<a href=\"$DEFAULT_FUNCTIONSPAGE\">".$wikilanguage->get("LANG_FUNCTIONSPAGE")."</a>", $html);
if (!$GRP_EDITCONTENT)
$html = preg_replace('/{USER_PAGE}/', "", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{USER_PAGE}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_USERPAGE")."</em>", $html);
elseif (!file_exists($DIR_PAGES.$wikiusers->getFullName($CURRENTUSER).$DEFAULT_PAGESEXT))
$html = preg_replace('/{USER_PAGE}/', "<a href=\"".$wikiusers->getFullName($CURRENTUSER)."\" class=\"pending\">".$wikilanguage->get("LANG_USERPAGE")."</a>", $html);
elseif ($PAGE_TITLE == $wikiusers->getFullName($CURRENTUSER))
$html = preg_replace('/{USER_PAGE}/', "<a href=\"".$wikiusers->getFullName($CURRENTUSER)."\" class=\"activemenupoint\">".$wikilanguage->get("LANG_USERPAGE")."</a>", $html);
else
$html = preg_replace('/{USER_PAGE}/', "<a href=\"".$wikiusers->getFullName($CURRENTUSER)."\">".$wikilanguage->get("LANG_USERPAGE")."</a>", $html);
if (!$GRP_EDITCONTENT)
$html = preg_replace('/{NEW_PAGE}/', "", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{NEW_PAGE}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("BUTTON_NEWPAGE")."</em>", $html);
else
$html = preg_replace('/{NEW_PAGE}/', "<form name=\"new\" method=\"get\" action=\"index.php\"><input class=\"menutext\" type=\"text\" name=\"page\" value=\"\" />".getPagePatternListAsSelect()."<br /><input class=\"menubutton\" type=\"submit\" value=\"".$wikilanguage->get("BUTTON_NEWPAGE")."\" /><input type=\"hidden\" name=\"action\" value=\"cleanparameter\" /></form>", $html);
if ($GRP_ANONYMOUS)
$html = preg_replace('/{USER_SETTINGS}/', "", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{USER_SETTINGS}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_USERSETTINGS")."</em>", $html);
elseif (($ACTION == "usersettings") || ($ACTION == "changepw"))
$html = preg_replace('/{USER_SETTINGS}/', "<a href=\"index.php?action=usersettings\" class=\"activemenupoint\">".$wikilanguage->get("LANG_USERSETTINGS")."</a>", $html);
else
$html = preg_replace('/{USER_SETTINGS}/', "<a href=\"index.php?action=usersettings\">".$wikilanguage->get("LANG_USERSETTINGS")."</a>", $html);
if (!$GRP_EDITUSERS)
$html = preg_replace('/{WIKI_SETTINGS}/', "", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{WIKI_SETTINGS}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_WIKISETTINGS")."</em>", $html);
elseif ($ACTION == "wikisettings")
$html = preg_replace('/{WIKI_SETTINGS}/', "<a href=\"index.php?action=wikisettings\" class=\"activemenupoint\">".$wikilanguage->get("LANG_WIKISETTINGS")."</a>", $html);
else
$html = preg_replace('/{WIKI_SETTINGS}/', "<a href=\"index.php?action=wikisettings\">".$wikilanguage->get("LANG_WIKISETTINGS")."</a>", $html);
if ($GRP_ANONYMOUS)
$html = preg_replace('/{WIKI_STATISTICS}/', "", $html);
elseif ($ACTION == "edit")
$html = preg_replace('/{WIKI_STATISTICS}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_STATISTICS")."</em>", $html);
elseif ($ACTION == "statistics")
$html = preg_replace('/{WIKI_STATISTICS}/', "<a href=\"index.php?action=statistics\" class=\"activemenupoint\">".$wikilanguage->get("LANG_STATISTICS")."</a>", $html);
else
$html = preg_replace('/{WIKI_STATISTICS}/', "<a href=\"index.php?action=statistics\">".$wikilanguage->get("LANG_STATISTICS")."</a>", $html);
if ($GRP_ANONYMOUS) {
$html = preg_replace('/{SEARCH_FILES}/', "", $html);
$html = preg_replace('/{USER_LOGOUT}/', "", $html);
$html = preg_replace('/{LATEST_PAGES_LIST}/', "", $html);
$html = preg_replace('/{LATEST_FILES_LIST}/', "", $html);
$html = preg_replace('/{USER_NAME}/', $mainsettings->getWikiName(), $html);
$html = preg_replace('/{FAVOURITE_LINK}/', getNoActionString($wikilanguage->get("LANG_NOACTION")), $html);
$html = preg_replace('/{LOGIN_FORM}/', getLoginForm(), $html);
}
else {
$html = preg_replace('/{LOGIN_FORM}/', "", $html);
if ($ACTION == "edit") {
$html = preg_replace('/{SEARCH_PAGES}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("BUTTON_SEARCHPAGES")."</em>", $html);
$html = preg_replace('/{SEARCH_FILES}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("BUTTON_SEARCHFILES")."</em>", $html);
$html = preg_replace('/{USER_LOGOUT}/', "<img src=\"pic/logoutinactiveicon.gif\" class=\"noborder\" alt=\"".$wikilanguage->get("LANG_LOGOUT")."\" />", $html);
$html = preg_replace('/{LATEST_PAGES_LIST}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_LATESTPAGESLIST")."</em>", $html);
$html = preg_replace('/{LATEST_FILES_LIST}/', "<em class=\"inactivemenupoint\">".$wikilanguage->get("LANG_LATESTFILESLIST")."</em>", $html);
}
else {
$html = preg_replace('/{USER_LOGOUT}/', "<a href=\"login.php?logout=true&page=".strip_tags(htmlentities($_GET['page']))."\" title=\"".$wikilanguage->get("LANG_LOGOUT")."\" accesskey=\"x\"><img src=\"pic/logouticon.gif\" class=\"noborder\" alt=\"".$wikilanguage->get("LANG_LOGOUT")."\" /></a>", $html);
$html = preg_replace('/{SEARCH_PAGES}/', "<form name=\"searchpages\" method=\"get\" action=\"index.php\"><input type=\"hidden\" name=\"action\" value=\"searchpages\" /><input class=\"menutext\" type=\"text\" name=\"query\" value=\"\" /><input class=\"menubutton\" type=\"submit\" value=\"".$wikilanguage->get("BUTTON_SEARCHPAGES")."\" /></form>", $html);
$html = preg_replace('/{SEARCH_FILES}/', "<form name=\"searchfiles\" method=\"get\" action=\"index.php\"><input type=\"hidden\" name=\"action\" value=\"searchfiles\" /><input class=\"menutext\" type=\"text\" name=\"query\" value=\"\" /><input class=\"menubutton\" type=\"submit\" value=\"".$wikilanguage->get("BUTTON_SEARCHFILES")."\" /></form>", $html);
$html = preg_replace('/{LATEST_PAGES_LIST}/', "<a href=\"index.php?action=recentpages&count=10\">".$wikilanguage->get("LANG_LATESTPAGESLIST")."</a>", $html);
$html = preg_replace('/{LATEST_FILES_LIST}/', "<a href=\"index.php?action=recentfiles&count=10\">".$wikilanguage->get("LANG_LATESTFILESLIST")."</a>", $html);
}
}
$html = preg_replace('/{SEARCH_PAGES}/', "<form name=\"searchpages\" method=\"get\" action=\"index.php\"><input type=\"hidden\" name=\"action\" value=\"searchpages\" /><input class=\"menutext\" type=\"text\" name=\"query\" value=\"\" /><input class=\"menubutton\" type=\"submit\" value=\"".$wikilanguage->get("BUTTON_SEARCHPAGES")."\" /></form>", $html);
$html = preg_replace('/{FAVOURITE_LINK}/', getFavLink($PAGE_TITLE), $html);
$html = preg_replace('/{USER_NAME}/', $wikiusers->getFullName($CURRENTUSER), $html);
$html = preg_replace('/{WIKI_TITLE}/', $mainsettings->getWikiName(), $html);
$html = preg_replace('/{META_DESC}/', $mainsettings->getMetaDesc(), $html);
$html = preg_replace('/{META_KEY}/', $mainsettings->getMetaKey(), $html);
$html = preg_replace('/{LAST_CHANGE}/', $wikilanguage->get("LANG_LASTCHANGED"), $html);
$html = preg_replace('/{AT}/', $wikilanguage->get("LANG_AT"), $html);
$html = preg_replace('/{BY}/', $wikilanguage->get("LANG_BY"), $html);
$html = preg_replace('/{LAST_CHANGER}/', getLastChanger("page", $PAGE_TITLE), $html);
$html = preg_replace('/{PAGES}/', $wikilanguage->get("LANG_PAGES"), $html);
$html = preg_replace('/{FILES}/', $wikilanguage->get("LANG_FILES"), $html);
// edit
if (($ACTION == "edit") && $GRP_EDITCONTENT) {
// no editing for non-admins in admin pages
if ($mainsettings->getIsAdminPage($PAGE_TITLE) && !$GRP_EDITUSERS)
header("location:$PAGE_TITLE");
$lockfile = $DIR_LOCKS.$PAGE_TITLE.$DEFAULT_LOCKSEXT;
if (!file_exists($lockfile)) {
// create lockfile
$handle = fopen($lockfile, "w");
fputs($handle, $CURRENTUSER);
fclose($handle);
if ($CONTENT == "")
$CONTENT = getNewPageContent($PAGE_TITLE);
$CONTENT = "<form method=\"post\" action=\"index.php\" name=\"form\">".getFormatToolbar()."<textarea name=\"content\" rows=\"8\">".htmlentities($CONTENT)."</textarea><input type=\"hidden\" name=\"page\" value=\"$PAGE_TITLE\" /><input type=\"hidden\" name=\"unlock\" value=\"true\" /><input type=\"hidden\" name=\"lockfile\" value=\"$lockfile\" />";
if ($GRP_EDITUSERS) {
$checked = "";
if ($mainsettings->getIsAdminPage($PAGE_TITLE))
$checked = " checked=\"checked\"";
$CONTENT .= "<input type=\"checkbox\" name=\"adminpage\"$checked /> ".$wikilanguage->get("LANG_ADMINPAGE")." ";
}
$CONTENT .= "<input type=\"submit\" value=\"".$wikilanguage->get("BUTTON_SAVE")."\" accesskey=\"s\" /></form> "
."<form method=\"get\" action=\"index.php\"><input type=\"hidden\" name=\"page\" value=\"$PAGE_TITLE\" /><input type=\"hidden\" name=\"unlock\" value=\"true\" /><input type=\"submit\" value=\"".$wikilanguage->get("BUTTON_CANCEL")."\" accesskey=\"a\" /></form>";
}
else
$CONTENT = getWarningReport("<a href=\"$PAGE_TITLE\" class=\"page\">$PAGE_TITLE</a> ".$wikilanguage->get("LANG_ISLOCKED"));
}
// search pages
else if ($ACTION == "searchpages") {
// delete given page
if ($_GET["delete"] == "true")
$CONTENT .= deleteFile("page", $_GET["deletefile"]);
// display pages
$CONTENT .= displayFiles("pages", returnQuery($DIR_PAGES, $_GET["query"], true, false, false, 0));
}
// search files
else if ($ACTION == "searchfiles") {
// delete given file
if ($_GET["delete"] == "true")
$CONTENT .= deleteFile("file", $_GET["deletefile"]);
// display files
$CONTENT .= displayFiles("files", returnQuery($DIR_FILES, $_GET["query"], false, false, false, 0));
}
// display all pages
elseif ($ACTION == "allpages") {
// delete given page
if ($_GET["delete"] == "true")
$CONTENT .= deleteFile("page", $_GET["deletefile"]);
// unlock given page
if ($_GET["unlockpage"] == "true")
$CONTENT .= deleteFile("lock", $_GET["deletefile"]);
// display pages
$CONTENT .= displayFiles("pages", returnQuery($DIR_PAGES, $DEFAULT_PAGESEXT, false, false, false, 0));
}
// display orphaned pages
elseif ($ACTION == "orphanedpages") {
// delete given page
if ($_GET["delete"] == "true")
$CONTENT .= deleteFile("page", $_GET["deletefile"]);
// unlock given page
if ($_GET["unlockpage"] == "true")
$CONTENT .= deleteFile("lock", $_GET["deletefile"]);
// display pages
$CONTENT .= displayFiles("pages", $wikibacklinks->getOrphanesArray(returnQuery($DIR_PAGES, $DEFAULT_PAGESEXT, false, false, false, 0)));
}
// display page versions
elseif ($ACTION == "pageversions") {
$CONTENT .= displayPageVersions();
$TIME = getNoActionString($wikilanguage->get("LANG_NOTIMEFOUND"));
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
// display recent pages
elseif ($ACTION == "recentpages") {
$count = $_GET['count'];
if (!preg_match("/^\d+$/", $count)) // numerals only
$count = $DEFAULT_RECENTCOUNT;
// delete given page
if ($_GET["delete"] == "true")
$CONTENT .= deleteFile("page", $_GET["deletefile"]);
// unlock given page
if ($_GET["unlockpage"] == "true")
$CONTENT .= deleteFile("lock", $_GET["deletefile"]);
// display pages
$CONTENT .= displayFiles("pages", returnQuery($DIR_PAGES, $DEFAULT_PAGESEXT, false, true, true, $count));
}
// display all files
elseif ($ACTION == "allfiles") {
// delete given file
if ($_GET["delete"] == "true")
$CONTENT .= deleteFile("file", $_GET["deletefile"]);
// display files
$CONTENT .= displayFiles("files", returnQuery($DIR_FILES, "", false, false, false, 0));
}
// display all users
elseif ($ACTION == "allusers") {
$CONTENT .= displayUsers("");
$TIME = getNoActionString($wikilanguage->get("LANG_NOTIMEFOUND"));
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
// edit a user
elseif ($ACTION == "edituser") {
$CONTENT .= editUser();
$TIME = getNoActionString($wikilanguage->get("LANG_NOTIMEFOUND"));
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
// search users
elseif ($ACTION == "searchusers") {
$CONTENT .= displayUsers($wikistringcleaner->cleanThatString(htmlentities($_GET["query"]), false));
$TIME = getNoActionString($wikilanguage->get("LANG_NOTIMEFOUND"));
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
// display recent files
elseif ($ACTION == "recentfiles") {
$count = $_GET['count'];
if (!preg_match("/^\d+$/", $count)) // numerals only
$count = $DEFAULT_RECENTCOUNT;
// delete given file
if ($_GET["delete"] == "true")
$CONTENT .= deleteFile("file", $_GET["deletefile"]);
// display files
$CONTENT .= displayFiles("files", returnQuery($DIR_FILES, "", false, true, true, $count));
}
// display trash files
elseif ($ACTION == "trashfiles") {
// delete all trash files
$emptytrash = $_GET["emptytrash"];
$confirm = $_GET["confirm"];
if ($emptytrash == "true") {
if ($confirm == "true")
$CONTENT .= clearTrash("files", $DIR_TRASHFILES);
else
$CONTENT .= getWarningReport($wikilanguage->get("CONFIRM_CLEARTRASHFILES")." <a href=\"index.php?action=trashfiles&emptytrash=true&confirm=true\">".$wikilanguage->get("LANG_YES")."</a> - <a href=\"index.php?action=trashfiles\">".$wikilanguage->get("LANG_NO")."</a>");
}
// restore given file
if ($_GET["restore"] == "true")
$CONTENT .= restoreFile("file", $_GET["restorefile"]);
// display files
$CONTENT .= displayFiles("files", returnQuery($DIR_TRASHFILES, "", false, true, false, 0));
}
// display trash pages
elseif ($ACTION == "trashpages") {
// delete all trash pages
$emptytrash = $_GET["emptytrash"];
$confirm = $_GET["confirm"];
if ($emptytrash == "true") {
if ($confirm == "true")
$CONTENT .= clearTrash("pages", $DIR_TRASHPAGES);
else
$CONTENT .= getWarningReport($wikilanguage->get("CONFIRM_CLEARTRASHPAGES")." <a href=\"index.php?action=trashpages&emptytrash=true&confirm=true\">".$wikilanguage->get("LANG_YES")."</a> - <a href=\"index.php?action=trashpages\">".$wikilanguage->get("LANG_NO")."</a>");
}
// restore given page
if ($_GET["restore"] == "true")
$CONTENT .= restoreFile("page", $_GET["restorefile"]);
// display pages
$CONTENT .= displayFiles("pages", returnQuery($DIR_TRASHPAGES, "", false, true, false, 0));
}
// display upload form
elseif ($ACTION == "upload") {
$CONTENT = showUploadForm();
$TIME = getNoActionString($wikilanguage->get("LANG_NOTIMEFOUND"));
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
// clean given page parameter from special characters
elseif ($ACTION == "cleanparameter") {
header("location:" . $wikistringcleaner->cleanThatString(htmlentities($_GET["page"]), false)."&pattern=".$_GET['pattern']);
}
// display password change
elseif ($ACTION == "changepw") {
$CONTENT = changePassword();
$TIME = getNoActionString($wikilanguage->get("LANG_NOTIMEFOUND"));
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
// display user settings
elseif ($ACTION == "usersettings") {
$CONTENT = showUserSettings();
$TIME = getNoActionString($wikilanguage->get("LANG_NOTIMEFOUND"));
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
// display wiki settings
elseif ($ACTION == "wikisettings") {
$CONTENT = showWikiSettings();
$TIME = getNoActionString($wikilanguage->get("LANG_NOTIMEFOUND"));
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
// edit page patterns
elseif ($ACTION == "editpattern") {
$CONTENT .= editPattern();
$TIME = getNoActionString($wikilanguage->get("LANG_NOTIMEFOUND"));
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
// file infos
elseif ($ACTION == "fileinfo") {
$CONTENT .= showFileInfo();
$TIME = getNoActionString($wikilanguage->get("LANG_NOTIMEFOUND"));
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
// wiki statistics
elseif ($ACTION == "statistics") {
$CONTENT .= showWikiStatistics();
$TIME = getNoActionString($wikilanguage->get("LANG_NOTIMEFOUND"));
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
// page formatting
elseif ($ACTION != "edit") {
// replace wiki syntaxwith HTML
$CONTENT = $wikisyntax->convertWikiSyntax($PAGE_TITLE, $CONTENT, true);
// replace emoticons with smiley graphics
$CONTENT = replaceEmoticons($CONTENT);
// cut first "<br />"
$CONTENT = substr($CONTENT, 6, strlen($CONTENT) - 6);
}
if (!$GRP_ANONYMOUS) {
// add page to favourites
if ((isset($_GET['addfav'])) && ($_GET['addfav'] == "true")) {
$CONTENT = addFav(true).$CONTENT;
$TIME = getNoActionString($wikilanguage->get("LANG_NOTIMEFOUND"));
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
// delete page from favourites
elseif ((isset($_GET['delfav'])) && ($_GET['delfav'] == "true")) {
$CONTENT = addFav(false).$CONTENT;
$TIME = getNoActionString($wikilanguage->get("LANG_NOTIMEFOUND"));
$PRINTLINK = getNoActionString($wikilanguage->get("LANG_NOACTION"));
}
}
// highlight searched phrases
if ((isset($_GET['highlight'])) && ($_GET['highlight'] <> ""))
$CONTENT = highlight($CONTENT, $_GET['highlight']);
// show warning, if erroneous logins occured
if (!$GRP_ANONYMOUS) {
if ($wikiusers->getFalseLoginCount($CURRENTUSER) > 0) {
$CONTENT = getWarningReport($wikilanguage->get("REPORT_FALSELOGINS")." ".$wikiusers->getFalseLoginCount($CURRENTUSER)) . $CONTENT;
$wikiusers->setFalseLoginCount($CURRENTUSER, 0);
}
// ask user to change his password, if it's still the initial one
if ($wikiusers->hasInitialPw($CURRENTUSER) && !$GRP_ANONYMOUS)
if ($ACTION == "changepw")
$CONTENT = getWarningReport($wikilanguage->get("REPORT_STILLHAVEINITIALPW")) . $CONTENT;
else
$CONTENT = getWarningReport($wikilanguage->get("REPORT_PLEASECHANGEPW")) . $CONTENT;
}
// finally: display page
$html = preg_replace('/{USER_FAVOURITES}/', getUserFavourites(), $html);
$html = preg_replace('/{USERSONLINE_LIST}/', getUsersOnlineList(), $html);
$html = preg_replace("/{CONTENT}/", "$CONTENT", $html);
$html = preg_replace('/{TIME}/', $TIME, $html);
$html = preg_replace('/{PRINT_LINK}/', $PRINTLINK, $html);
$html = preg_replace('/{BACKLINKS_LIST}/', $BACKLINKS, $html);
$html = preg_replace('/{LATEST_PAGES_MENU}/', getLatestChanges("page", 10), $html);
$html = preg_replace('/{LATEST_FILES_MENU}/', getLatestChanges("file", 10), $html);
$html = preg_replace('/{WIKI_INFO}/', wikiInfo(), $html);
echo $html;
// ----------------------
// additional functions
// ----------------------
// change password
function changePassword() {
global $wikiusers;
global $wikilanguage;
global $CURRENTUSER;
global $GRP_ANONYMOUS;
// this function doesn't work for anonymous users
if ($GRP_ANONYMOUS) {
header("location:index.php");
}
$old = $_POST["old"];
$new = $_POST["new"];
$repeat = $_POST["repeat"];
if ($_SERVER["REQUEST_METHOD"] == "POST"){
if (
// Alle Felder übergeben...
isset($_POST['old']) && isset($_POST['new']) && isset($_POST['repeat'])
// ...und keines leer?
&& ($_POST['old'] <> "" ) && ($_POST['new'] <> "" ) && ($_POST['repeat'] <> "" )
// Altes PW korrekt?
&& ($_POST['old'] == $wikiusers->getPassword($CURRENTUSER))
// Neues Paßwort zweimal exakt gleich eingegeben?
&& ($_POST['new'] == $_POST['repeat'])
// Neues Paßwort wenigstens sechs Zeichen lang und mindestens aus kleinen und großen Buchstaben sowie Zahlen bestehend?
&& (strlen($_POST['new']) >= 6) && preg_match("/[0-9]/", $_POST['new']) && preg_match("/[a-z]/", $_POST['new']) && preg_match("/[A-Z]/", $_POST['new'])
) {
$wikiusers->addUser($CURRENTUSER, $_POST['new'], $wikiusers->getFullName($CURRENTUSER), $wikiusers->getUserGroup($CURRENTUSER), $wikiusers->getLifeTime($CURRENTUSER), $wikiusers->getIsBanned($CURRENTUSER), $wikiusers->getBanTime($CURRENTUSER), $wikiusers->getWikiStyle($CURRENTUSER), true);
$wikiusers->setHasInitialPw($CURRENTUSER, "false");
$msg = getOkReport($wikilanguage->get("REPORT_PWD_CHANGED"));
}
else
$msg = getWarningReport($wikilanguage->get("REPORT_PWD_ERROR"));
}
$form = "<form method=\"post\" action=\"index.php\"><input type=\"hidden\" name=\"changepw\" value=\"true\" />"
. "<div class=\"myWiki\"><div class=\"myWiki-header\">".$wikilanguage->get("LANG_CHANGEPW")."</div>"
. "<div class=".returnTdClass(0)."><div>".$wikilanguage->get("LANG_PASSWORDOLD")." </div><div><input type=\"password\" name=\"old\" /></div></div>"
. "<div class=".returnTdClass(1)."><div>".$wikilanguage->get("LANG_PASSWORDNEW")." </div><div><input type=\"password\" name=\"new\" /></div></div>"
. "<div class=".returnTdClass(0)."><div>".$wikilanguage->get("LANG_PASSWORDREPEAT")." </div><div><input type=\"password\" name=\"repeat\" /></div></div>"
. "<div class=\"summary\"><input type=\"image\" name=\"submit\" value=\"true\" src=\"pic/okicon.gif\" alt=\"".$wikilanguage->get("LANG_SAVECHANGES")."\" title=\"".$wikilanguage->get("LANG_SAVECHANGES")."\" /><!--<input type=\"submit\" name=\"submit\" value=\"".$wikilanguage->get("LANG_SAVECHANGES")."\" />--></div>"
. "</div></form>";
return $msg.$form;
}
// delete all files in given directory
function clearTrash($type, $path) {
global $DEFAULT_PAGESEXT;
global $DIR_BACKUP;
global $wikistats;
global $wikilanguage;
$type = strip_tags($type);
$path = strip_tags($path);
if ($type == "files")
$dirname = $wikilanguage->get("LANG_TRASHFILES");
else
$dirname = $wikilanguage->get("LANG_TRASHPAGES");
$errorflag = false;
$dir = opendir(getcwd() . "/$path");
while ($file = readdir($dir)) {
if (($file <> ".") && ($file <> "..")) {
if(!unlink($path . $file))
$errorflag = true;
else if ($type == "files") {
// delete from filestats
$wikistats->deleteFileStats($file);
}
elseif ($type == "pages") {
// delete from statistics
$wikistats->deleteLastPageChanger(substr($file, 0, strlen($file) - strlen($DEFAULT_PAGESEXT)));
// also delete page history
if (file_exists($DIR_BACKUP.substr($file, 0, strlen($file) - strlen($DEFAULT_PAGESEXT)))) {
$handle = opendir($DIR_BACKUP.substr($file, 0, strlen($file) - strlen($DEFAULT_PAGESEXT)));
while (($subfile = readdir($handle)) && ($subfile <> ".") && ($subfile <> "..")) {
unlink($DIR_BACKUP.substr($file, 0, strlen($file) - strlen($DEFAULT_PAGESEXT))."/".$subfile);
}
}
}
}
}
// has an error occured?
if ($errorflag)
return getWarningReport($wikilanguage->get("REPORT_DIR_CLEAR_ERROR")." "$dirname"");
else
return getOkReport($wikilanguage->get("REPORT_DIR_CLEAR_SUCCESS")." "$dirname"");
}
// return content for a page to be created
function getNewPageContent($pagename) {
global $CURRENTUSER;
global $DEFAULT_PAGESEXT;
global $DIR_PAGEPATTERNS;
global $mainsettings;
global $wikiusers;
$pagename = strip_tags($pagename);
// load given pattern
if ((file_exists($DIR_PAGEPATTERNS.htmlentities($_GET['pattern']).$DEFAULT_PAGESEXT)) && (htmlentities($_GET['pattern']) <> ""))
$patternfile = $DIR_PAGEPATTERNS.htmlentities($_GET['pattern']).$DEFAULT_PAGESEXT;
// load default pattern
elseif (file_exists($DIR_PAGEPATTERNS.$mainsettings->getDefaultPagePattern().$DEFAULT_PAGESEXT))
$patternfile = $DIR_PAGEPATTERNS.$mainsettings->getDefaultPagePattern().$DEFAULT_PAGESEXT;
else
return "";
if (!$file = @fopen($patternfile, "r"))
die("Could not read ".$patternfile."!");
$pattern = fread($file, filesize($patternfile));
fclose($file);
$pattern = str_replace("{PATTERN_PAGETITLE}", $pagename, $pattern);
$pattern = str_replace("{PATTERN_PAGEDATE}", strftime($mainsettings->getTimeFormat(), time()), $pattern);
$pattern = str_replace("{PATTERN_PAGEUSER}", $wikiusers->getFullName($CURRENTUSER), $pattern);
return $pattern;
}
// delete given file or page
function deleteFile($type, $deletefile) {
global $CURRENTUSER;
global $DIR_FILES;
global $DIR_PAGES;
global $DIR_LOCKS;
global $DEFAULT_LOCKSEXT;
global $DEFAULT_PAGESEXT;
global $DIR_TRASHFILES;
global $DIR_TRASHPAGES;
global $wikibacklinks;
global $wikilanguage;
global $wikistats;
$type = strip_tags($type);
$deletefile = strip_tags(htmlentities($deletefile));
if (($deletefile <> "") && ($deletefile <> ".") && ($deletefile <> "..")) {
// delete file
if ($type == "file") {
if (file_exists($DIR_FILES.$deletefile)) {
if (copy($DIR_FILES.$deletefile, $DIR_TRASHFILES.$deletefile) && unlink($DIR_FILES.$deletefile)) {
$wikistats->setLastFileChanger($deletefile, $CURRENTUSER);
return getOkReport($wikilanguage->get("REPORT_FILE_DEL_SUCCESS")." "$deletefile"");
}
else return getWarningReport($wikilanguage->get("REPORT_NOTHING_DONE")." ".$wikilanguage->get("REPORT_FILE_DEL_ERROR")." "$deletefile"");