mirrored from git://git.moodle.org/moodle.git
/
ewiki.php
3543 lines (2908 loc) · 110 KB
/
ewiki.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
<script language="PHP"> @define("EWIKI_VERSION", "R1.01d");
/*
ErfurtWiki - an embedable, fast and user-friendly wiki engine
¯¯¯¯¯¯¯¯¯¯
This is Public Domain (no license, no warranty); but feel free
to redistribute it under GPL or anything else you like.
http://erfurtwiki.sourceforge.net/
Mario Salzer <mario*erphesfurt·de> and many others(tm)
Use it from inside yoursite.php like that:
<html><body>...
<?php
include("ewiki.php");
echo ewiki_page();
?>
*/
#-- you could also establish a mysql connection in here, of course:
// mysql_connect(":/var/run/mysqld/mysqld.sock", "user", "pw")
// and mysql_query("USE mydatabase");
#-------------------------------------------------------- config ---
#-- I'm sorry for that, but all the @ annoy me
error_reporting(0x0000377 & error_reporting());
# error_reporting(E_ALL^E_NOTICE);
#-- the position of your ewiki-wrapper script
define("EWIKI_SCRIPT", "?id="); # relative/absolute to docroot
# define("EWIKI_SCRIPT_URL", "http://...?id="); # absolute URL
#-- change to your needs (site lang)
define("EWIKI_NAME", "ErfurtWiki");
define("EWIKI_PAGE_INDEX", "ErfurtWiki");
define("EWIKI_PAGE_NEWEST", "NewestPages");
define("EWIKI_PAGE_SEARCH", "SearchPages");
define("EWIKI_PAGE_HITS", "MostVisitedPages");
define("EWIKI_PAGE_VERSIONS", "MostOftenChangedPages");
define("EWIKI_PAGE_UPDATES", "UpdatedPages");
#-- default settings are good settings - most often ;)
#- look & feel
define("EWIKI_PRINT_TITLE", 1); # <h2>WikiPageName</h2> on top
define("EWIKI_SPLIT_TITLE", 0); # <h2>Wiki Page Name</h2>
define("EWIKI_CONTROL_LINE", 1); # EditThisPage-link at bottom
define("EWIKI_LIST_LIMIT", 20); # listing limit
#- behaviour
define("EWIKI_AUTO_EDIT", 1); # edit box for non-existent pages
define("EWIKI_EDIT_REDIRECT", 1); # redirect after edit save
define("EWIKI_DEFAULT_ACTION", "view"); # (keep!)
define("EWIKI_CASE_INSENSITIVE", 1); # wikilink case sensitivity
define("EWIKI_HIT_COUNTING", 1);
define("UNIX_MILLENNIUM", 1000000000);
#- rendering
define("EWIKI_ALLOW_HTML", 0); # often a very bad idea
define("EWIKI_HTML_CHARS", 1); # allows for È
define("EWIKI_ESCAPE_AT", 1); # "@" -> "@"
#- http/urls
define("EWIKI_HTTP_HEADERS", 1); # most often a good thing
define("EWIKI_NO_CACHE", 1); # browser+proxy shall not cache
define("EWIKI_URLENCODE", 1); # disable when _USE_PATH_INFO
define("EWIKI_URLDECODE", 1);
define("EWIKI_USE_PATH_INFO", 1 &&!strstr($_SERVER["SERVER_SOFTWARE"],"Apache"));
define("EWIKI_USE_ACTION_PARAM", 1);
define("EWIKI_ACTION_SEP_CHAR", "/");
define("EWIKI_UP_PAGENUM", "n"); # _UP_ means "url parameter"
define("EWIKI_UP_PAGEEND", "e");
define("EWIKI_UP_BINARY", "binary");
define("EWIKI_UP_UPLOAD", "upload");
#- other stuff
define("EWIKI_DEFAULT_LANG", "en");
define("EWIKI_CHARSET", "ISO-8859-1");
#- user permissions
define("EWIKI_PROTECTED_MODE", 0); # disable funcs + require auth
define("EWIKI_PROTECTED_MODE_HIDING", 0); # hides disallowed actions
define("EWIKI_AUTH_DEFAULT_RING", 3); # 0=root 1=priv 2=user 3=view
define("EWIKI_AUTO_LOGIN", 1); # [auth_query] on startup
#-- allowed WikiPageNameCharacters
#### BEGIN MOODLE CHANGES - to remove auto-camelcase linking.
global $moodle_disable_camel_case;
if ($moodle_disable_camel_case) {
define("EWIKI_CHARS_L", "");
define("EWIKI_CHARS_U", "");
}
else {
#### END MOODLE CHANGES
define("EWIKI_CHARS_L", "a-z_µ¤$\337-\377");
define("EWIKI_CHARS_U", "A-Z0-9\300-\336");
#### BEGIN MOODLE CHANGES
}
#### END MOODLE CHANGES
define("EWIKI_CHARS", EWIKI_CHARS_L.EWIKI_CHARS_U);
#-- database
define("EWIKI_DB_TABLE_NAME", "ewiki"); # MySQL / ADOdb
define("EWIKI_DBFILES_DIRECTORY", "/tmp"); # see "db_flat_files.php"
define("EWIKI_DBA", "/tmp/ewiki.dba"); # see "db_dba.php"
define("EWIKI_DBQUERY_BUFFER", 512*1024); # 512K
define("EWIKI_INIT_PAGES", "./init-pages"); # for initialization
define("EWIKI_DB_F_TEXT", 1<<0);
define("EWIKI_DB_F_BINARY", 1<<1);
define("EWIKI_DB_F_DISABLED", 1<<2);
define("EWIKI_DB_F_HTML", 1<<3);
define("EWIKI_DB_F_READONLY", 1<<4);
define("EWIKI_DB_F_WRITEABLE", 1<<5);
define("EWIKI_DB_F_APPENDONLY", 1<<6); #nyi
define("EWIKI_DB_F_SYSTEM", 1<<7);
define("EWIKI_DB_F_PART", 1<<8);
define("EWIKI_DB_F_TYPE", EWIKI_DB_F_TEXT | EWIKI_DB_F_BINARY | EWIKI_DB_F_DISABLED | EWIKI_DB_F_SYSTEM | EWIKI_DB_F_PART);
define("EWIKI_DB_F_ACCESS", EWIKI_DB_F_READONLY | EWIKI_DB_F_WRITEABLE | EWIKI_DB_F_APPENDONLY);
define("EWIKI_DB_F_COPYMASK", EWIKI_DB_F_TYPE | EWIKI_DB_F_ACCESS);
define("EWIKI_DBFILES_NLR", '\\n');
define("EWIKI_DBFILES_ENCODE", 0 || (DIRECTORY_SEPARATOR != "/"));
define("EWIKI_DBFILES_GZLEVEL", "2");
#-- internal
define("EWIKI_ADDPARAMDELIM", (strstr(EWIKI_SCRIPT,"?") ? "&" : "?"));
#-- binary content (images)
define("EWIKI_SCRIPT_BINARY", /*"/binary.php?binary="*/ ltrim(strtok(" ".EWIKI_SCRIPT,"?"))."?".EWIKI_UP_BINARY."=" );
define("EWIKI_CACHE_IMAGES", 1 &&!headers_sent());
define("EWIKI_IMAGE_MAXSIZE", 64 *1024);
define("EWIKI_IMAGE_MAXWIDTH", 3072);
define("EWIKI_IMAGE_MAXHEIGHT", 2048);
define("EWIKI_IMAGE_MAXALLOC", 1<<19);
define("EWIKI_IMAGE_RESIZE", 1);
define("EWIKI_IMAGE_ACCEPT", "image/jpeg,image/png,image/gif,application/x-shockwave-flash");
define("EWIKI_IDF_INTERNAL", "internal://");
define("EWIKI_ACCEPT_BINARY", 0); # for arbitrary binary data files
#-- misc
define("EWIKI_TMP", $_SERVER["TEMP"] ? $_SERVER["TEMP"] : "/tmp");
define("EWIKI_LOGLEVEL", -1); # 0=error 1=warn 2=info 3=debug
define("EWIKI_LOGFILE", "/tmp/ewiki.log");
#-- plugins (tasks mapped to function names)
$ewiki_plugins["database"][] = "ewiki_database_mysql";
$ewiki_plugins["edit_preview"][] = "ewiki_page_edit_preview";
$ewiki_plugins["render"][] = "ewiki_format";
$ewiki_plugins["init"][-5] = "ewiki_localization";
$ewiki_plugins["init"][-1] = "ewiki_binary";
$ewiki_plugins["handler"][-105] = "ewiki_eventually_initialize";
$ewiki_plugins["handler"][] = "ewiki_intermap_walking";
$ewiki_plugins["view_append"][-1] = "ewiki_control_links";
$ewiki_plugins["view_final"][-1] = "ewiki_add_title";
$ewiki_plugins["page_final"][] = "ewiki_http_headers";
$ewiki_plugins["page_final"][99115115] = "ewiki_page_css_container";
$ewiki_plugins["edit_form_final"][] = "ewiki_page_edit_form_final_imgupload";
$ewiki_plugins["format_block"]["pre"][] = "ewiki_format_pre";
$ewiki_plugins["format_block"]["code"][] = "ewiki_format_pre";
$ewiki_plugins["format_block"]["htm"][] = "ewiki_format_html";
$ewiki_plugins["format_block"]["html"][] = "ewiki_format_html";
$ewiki_plugins["format_block"]["comment"][] = "ewiki_format_comment";
#-- internal pages
$ewiki_plugins["page"][EWIKI_PAGE_NEWEST] = "ewiki_page_newest";
$ewiki_plugins["page"][EWIKI_PAGE_SEARCH] = "ewiki_page_search";
if (EWIKI_HIT_COUNTING) $ewiki_plugins["page"][EWIKI_PAGE_HITS] = "ewiki_page_hits";
$ewiki_plugins["page"][EWIKI_PAGE_VERSIONS] = "ewiki_page_versions";
$ewiki_plugins["page"][EWIKI_PAGE_UPDATES] = "ewiki_page_updates";
#-- page actions
$ewiki_plugins["action"]["edit"] = "ewiki_page_edit";
$ewiki_plugins["action_always"]["links"] = "ewiki_page_links";
$ewiki_plugins["action"]["info"] = "ewiki_page_info";
$ewiki_plugins["action"]["view"] = "ewiki_page_view";
#-- helper vars ---------------------------------------------------
$ewiki_config["idf"]["url"] = array("http://", "mailto:", "internal://", "ftp://", "https://", "irc://", "telnet://", "news://", "chrome://", "file://", "gopher://", "httpz://");
$ewiki_config["idf"]["img"] = array(".jpeg", ".png", ".jpg", ".gif", ".j2k");
$ewiki_config["idf"]["obj"] = array(".swf", ".svg");
#-- entitle actions
$ewiki_config["action_links"]["view"] = @array_merge(array(
"edit" => "EDITTHISPAGE", # ewiki_t() is called on these
"links" => "BACKLINKS",
"info" => "PAGEHISTORY",
"like" => "LIKEPAGES",
), @$ewiki_config["action_links"]["view"]
);
$ewiki_config["action_links"]["info"] = @array_merge(array(
"view" => "browse",
"edit" => "fetchback",
), @$ewiki_config["action_links"]["info"]
);
#-- variable configuration settings (go into '$ewiki_config')
$ewiki_config_DEFAULTSTMP = array(
"edit_thank_you" => 1,
"edit_box_size" => "70x15",
"print_title" => EWIKI_PRINT_TITLE,
"split_title" => EWIKI_SPLIT_TITLE,
"control_line" => EWIKI_CONTROL_LINE,
"list_limit" => EWIKI_LIST_LIMIT,
"script" => EWIKI_SCRIPT,
"script_url" => (defined("EWIKI_SCRIPT_URL")?EWIKI_SCRIPT_URL:NULL),
"script_binary" => EWIKI_SCRIPT_BINARY,
#-- heart of the wiki -- don't try to read this! ;)
"wiki_pre_scan_regex" => '/
(?<![~!])
((?:(?:\w+:)*['.EWIKI_CHARS_U.']+['.EWIKI_CHARS_L.']+){2,}[\w\d]*)
|\^([-'.EWIKI_CHARS_L.EWIKI_CHARS_U.']{3,})
|\[ (?:"[^\]\"]+" | \s+ | [^:\]#]+\|)* ([^\|\"\[\]\#]+) (?:\s+ | "[^\]\"]+")* [\]\#]
|(\w{3,9}:\/\/[^?#\s\[\]\'\"\)\,<]+) /x',
"wiki_link_regex" => "\007 [!~]?(
\#?\[[^<>\[\]\n]+\] |
\^[-".EWIKI_CHARS_U.EWIKI_CHARS_L."]{3,} |
\b([\w]{3,}:)*([".EWIKI_CHARS_U."]+[".EWIKI_CHARS_L."]+){2,}\#?[\w\d]* |
([a-z]{2,9}://|mailto:)[^\s\[\]\'\"\)\,<]+ |
\w[-_.+\w]+@(\w[-_\w]+[.])+\w{2,} ) \007x",
#-- rendering ruleset
"wm_indent" => '<div style="margin-left:15px;" class="indent">',
"wm_table_defaults" => 'cellpadding="2" border="1" cellspacing="0"',
"wm_whole_line" => array(),
"htmlentities" => array(
"&" => "&",
">" => ">",
"<" => "<",
),
"wm_source" => array(
"%%%" => "<br>",
"\t" => " ",
"\n;:" => "\n ", # workaround, replaces the old ;:
),
"wm_list" => array(
"-" => array('ul type="square"', "", "li"),
"*" => array('ul type="circle"', "", "li"),
"#" => array("ol", "", "li"),
":" => array("dl", "dt", "dd"),
#<out># ";" => array("dl", "dt", "dd"),
),
"wm_style" => array(
"'''''" => array("<b><i>", "</i></b>"),
"'''" => array("<b>", "</b>"),
"___" => array("<i><b>", "</b></i>"),
"''" => array("<em>", "</em>"),
"__" => array("<strong>", "</strong>"),
"^^" => array("<sup>", "</sup>"),
"==" => array("<tt>", "</tt>"),
#<off># "***" => array("<b><i>", "</i></b>"),
#<off># "###" => array("<big><b>", "</b></big>"),
"**" => array("<b>", "</b>"),
"##" => array("<big>", "</big>"),
"µµ" => array("<small>", "</small>"),
),
"wm_start_end" => array(
),
#-- rendering plugins
"format_block" => array(
"html" => array("<html>", "</html>", "html", 0x0000),
"htm" => array("<htm>", "</htm>", "html", 0x0003),
"code" => array("<code>", "</code>", false, 0x0000),
"pre" => array("<pre>", "</pre>", false, 0x003F),
"comment" => array("\n<!--", "-->", false, 0x0030),
# "verbatim" => array("<verbatim>", "</verbatim>", false, 0x0000),
),
"format_params" => array(
"scan_links" => 1,
"html" => EWIKI_ALLOW_HTML,
"mpi" => 1,
),
);
foreach ($ewiki_config_DEFAULTSTMP as $set => $val) {
if (!isset($ewiki_config[$set])) {
$ewiki_config[$set] = $val;
}
elseif (is_array($val)) foreach ($val as $vali=>$valv) {
if (is_int($vali)) {
$ewiki_config[$set][] = $valv;
}
elseif (!isset($ewiki_config[$set][$vali])) {
$ewiki_config[$set][$vali] = $valv;
}
}
}
$ewiki_config_DEFAULTSTMP = $valv = $vali = $val = NULL;
#-- init stuff, autostarted parts
ksort($ewiki_plugins["init"]);
if ($pf_a = $ewiki_plugins["init"]) foreach ($pf_a as $pf) {
// Binary Handling starts here
#### MOODLE CHANGE TO BE COMPATIBLE WITH PHP 4.1
#if(headers_sent($file,$line)) {
# error("Headers already sent: $file:$line");
if(headers_sent()) {
error("Headers already sent.");
}
$pf($GLOBALS);
}
unset($ewiki_plugins["init"]);
#-- text (never remove the "C" or "en" sections!)
#
$ewiki_t["C"] = @array_merge(@$ewiki_t["C"], array(
"DATE" => "%a, %d %b %G %T %Z",
"EDIT_TEXTAREA_RESIZE_JS" => '<a href="javascript:ewiki_enlarge()" style="text-decoration:none">+</a><script type="text/javascript"><!--'."\n".'function ewiki_enlarge() {var ta=document.getElementById("ewiki_content");ta.style.width=((ta.cols*=1.1)*10).toString()+"px";ta.style.height=((ta.rows*=1.1)*30).toString()+"px";}'."\n".'//--></script>',
));
#
$ewiki_t["en"] = @array_merge(@$ewiki_t["en"], array(
"EDITTHISPAGE" => "EditThisPage",
"APPENDTOPAGE" => "Add to",
"BACKLINKS" => "BackLinks",
"PAGESLINKINGTO" => "Pages linking to \$title",
"PAGEHISTORY" => "PageInfo",
"INFOABOUTPAGE" => "Information about page",
"LIKEPAGES" => "Pages like this",
"NEWESTPAGES" => "Newest Pages",
"LASTCHANGED" => "last changed on %c",
"DOESNOTEXIST" => "This page does not yet exist, please click on EditThisPage if you'd like to create it.",
"DISABLEDPAGE" => "This page is currently not available.",
"ERRVERSIONSAVE" => "Sorry, while you edited this page someone else
did already save a changed version. Please go back to the
previous screen and copy your changes to your computers
clipboard to insert it again after you reload the edit
screen.",
"ERRORSAVING" => "An error occoured while saving your changes. Please try again.",
"THANKSFORCONTRIBUTION" => "Thank you for your contribution!",
"CANNOTCHANGEPAGE" => "This page cannot be changed.",
"OLDVERCOMEBACK" => "Make this old version come back to replace the current one",
"PREVIEW" => "Preview",
"SAVE" => "Save",
"CANCEL_EDIT" => "CancelEditing",
"UPLOAD_PICTURE_BUTTON" => "upload picture >>>",
"EDIT_FORM_1" => "<a href=\"".EWIKI_SCRIPT."GoodStyle\">GoodStyle</a> is to
write what comes to your mind. Don't care about how it
looks too much now. You can add <a href=\"".EWIKI_SCRIPT."WikiMarkup\">WikiMarkup</a>
also later if you think it is necessary.<br>",
"EDIT_FORM_2" => "<br>Please do not write things, which may make other
people angry. And please keep in mind that you are not all that
anonymous in the internet (find out more about your computers
'<a href=\"http://google.com/search?q=my+computers+IP+address\">IP address</a>' at Google).",
"BIN_IMGTOOLARGE" => "Image file is too large!",
"BIN_NOIMG" => "This is no image file (inacceptable file format)!",
"FORBIDDEN" => "You are not authorized to access this page.",
));
#
$ewiki_t["es"] = @array_merge(@$ewiki_t["es"], array(
"EDITTHISPAGE" => "EditarEstaPágina",
"BACKLINKS" => "EnlacesInversos",
"PAGESLINKINGTO" => "Páginas enlazando \$title",
"PAGEHISTORY" => "InfoPágina",
"INFOABOUTPAGE" => "Información sobre la página",
"LIKEPAGES" => "Páginas como esta",
"NEWESTPAGES" => "Páginas más nuevas",
"LASTCHANGED" => "última modificación %d/%m/%Y a las %H:%M",
"DOESNOTEXIST" => "Esta página aún no existe, por favor eliga EditarEstaPágina si desea crearla.",
"DISABLEDPAGE" => "Esta página no está disponible en este momento.",
"ERRVERSIONSAVE" => "Disculpe, mientras editaba esta página alguién más
salvó una versión modificada. Por favor regrese a
a la pantalla anterior y copie sus cambios a su computador
para insertalos nuevamente después de que cargue
la pantalla de edición.",
"ERRORSAVING" => "Ocurrió un error mientras se salvavan sus cambios. Por favor intente de nuevo.",
"THANKSFORCONTRIBUTION" => "Gracias por su contribución!",
"CANNOTCHANGEPAGE" => "Esta página no puede ser modificada.",
"OLDVERCOMEBACK" => "Hacer que esta versión antigua regrese a remplazar la actual",
"PREVIEW" => "Previsualizar",
"SAVE" => "Salvar",
"CANCEL_EDIT" => "CancelarEdición",
"UPLOAD_PICTURE_BUTTON" => "subir gráfica >>>",
"EDIT_FORM_1" => "<a href=\"".EWIKI_SCRIPT."BuenEstilo\">BuenEstilo</a> es
escribir lo que viene a su mente. No se preocupe mucho
por la apariencia. También puede agregar <a href=\"".EWIKI_SCRIPT."ReglasDeMarcadoWiki\">ReglasDeMarcadoWiki</a>
más adelante si piensa que es necesario.<br>",
"EDIT_FORM_2" => "<br>Por favor no escriba cosas, que puedan
enfadar a otras personas. Y por favor tenga en mente que
usted no es del todo anónimo en Internet
(encuentre más sobre
'<a href=\"http://google.com/search?q=my+computers+IP+address\">IP address</a>' de su computador con Google).",
"BIN_IMGTOOLARGE" => "¡La gráfica es demasiado grande!",
"BIN_NOIMG" => "¡No es un archivo con una gráfica (formato de archivo inaceptable)!",
"FORBIDDEN" => "No está autorizado para acceder a esta página.",
));
#
$ewiki_t["de"] = @array_merge(@$ewiki_t["de"], array(
"EDITTHISPAGE" => "DieseSeiteÄndern",
"APPENDTOPAGE" => "Ergänze",
"BACKLINKS" => "ZurückLinks",
"PAGESLINKINGTO" => "Verweise zur Seite \$title",
"PAGEHISTORY" => "SeitenInfo",
"INFOABOUTPAGE" => "Informationen über Seite",
"LIKEPAGES" => "Ähnliche Seiten",
"NEWESTPAGES" => "Neueste Seiten",
"LASTCHANGED" => "zuletzt geändert am %d.%m.%Y um %H:%M",
"DISABLEDPAGE" => "Diese Seite kann momentan nicht angezeigt werden.",
"ERRVERSIONSAVE" => "Entschuldige, aber während Du an der Seite
gearbeitet hast, hat bereits jemand anders eine geänderte
Fassung gespeichert. Damit nichts verloren geht, browse bitte
zurück und speichere Deine Änderungen in der Zwischenablage
(Bearbeiten->Kopieren) um sie dann wieder an der richtigen
Stelle einzufügen, nachdem du die EditBoxSeite nocheinmal
geladen hast.<br>
Vielen Dank für Deine Mühe.",
"ERRORSAVING" => "Beim Abspeichern ist ein Fehler aufgetreten. Bitte versuche es erneut.",
"THANKSFORCONTRIBUTION" => "Vielen Dank für Deinen Beitrag!",
"CANNOTCHANGEPAGE" => "Diese Seite kann nicht geändert werden.",
"OLDVERCOMEBACK" => "Diese alte Version der Seite wieder zur Aktuellen machen",
"PREVIEW" => "Vorschau",
"SAVE" => "Speichern",
"CANCEL_EDIT" => "ÄnderungenVerwerfen",
"UPLOAD_PICTURE_BUTTON" => "Bild hochladen >>>",
"EDIT_FORM_1" => "<a href=\"".EWIKI_SCRIPT."GuterStil\">GuterStil</a> ist es,
ganz einfach das zu schreiben, was einem gerade in den
Sinn kommt. Du solltest dich jetzt noch nicht so sehr
darum kümmern, wie die Seite aussieht. Du kannst später
immernoch zurückkommen und den Text mit <a href=\"".EWIKI_SCRIPT."FormatierungsRegeln\">WikiTextFormatierungsRegeln</a>
aufputschen.<br>",
"EDIT_FORM_2" => "<br>Bitte schreib keine Dinge, die andere Leute
verärgern könnten. Und bedenke auch, daß es schnell auf
dich zurückfallen kann wenn du verschiedene andere Dinge sagst (mehr Informationen zur
'<a href=\"http://google.de/search?q=computer+IP+adresse\">IP Adresse</a>'
deines Computers findest du bei Google).",
));
#-- InterWiki:Links
$ewiki_config["interwiki"] = @array_merge(
@$ewiki_config["interwiki"],
array(
"javascript" => "", # this actually protects from javascript: links
"url" => "",
# "self" => "this",
"this" => EWIKI_SCRIPT, # better was absolute _URL to ewiki wrapper
"jump" => "",
"ErfurtWiki" => "http://erfurtwiki.sourceforge.net/?id=",
"InterWiki" => "InterWikiSearch",
"InterWikiSearch" => "http://sunir.org/apps/meta.pl?",
"Wiki" => "WardsWiki",
"WardsWiki" => "http://www.c2.com/cgi/wiki?",
"WikiFind" => "http://c2.com/cgi/wiki?FindPage&value=",
"WikiPedia" => "http://www.wikipedia.com/wiki.cgi?",
"MeatBall" => "MeatballWiki",
"MeatballWiki" => "http://www.usemod.com/cgi-bin/mb.pl?",
"UseMod" => "http://www.usemod.com/cgi-bin/wiki.pl?",
"PhpWiki" => "http://phpwiki.sourceforge.net/phpwiki/index.php3?",
"LinuxWiki" => "http://linuxwiki.de/",
"OpenWiki" => "http://openwiki.com/?",
"Tavi" => "http://andstuff.org/tavi/",
"TWiki" => "http://twiki.sourceforge.net/cgi-bin/view/",
"MoinMoin" => "http://www.purl.net/wiki/moin/",
"Google" => "http://google.com/search?q=",
"ISBN" => "http://www.amazon.com/exec/obidos/ISBN=",
"icq" => "http://www.icq.com/",
));
#-------------------------------------------------------------------- main ---
/* this is the main function, which you should preferrably call to
integrate the ewiki into your web site; it chains to most other
parts and plugins (including the edit box);
if you do not supply the requested pages "$id" we will fetch it
from the pre-defined possible URL parameters.
*/
function ewiki_page($id=false) {
global $ewiki_links, $ewiki_plugins, $ewiki_ring, $ewiki_t, $ewiki_errmsg;
#-- output var
$o = "";
#-- selected page
if (!isset($_REQUEST)) {
$_REQUEST = @array_merge($HTTP_GET_VARS, $HTTP_POST_VARS);
}
if (!strlen($id)) {
$id = ewiki_id();
}
#-- page action
$action = EWIKI_DEFAULT_ACTION;
if ($delim = strpos($id, EWIKI_ACTION_SEP_CHAR)) {
$action = substr($id, 0, $delim);
$id = substr($id, $delim + 1);
}
elseif (EWIKI_USE_ACTION_PARAM && isset($_REQUEST["action"])) {
$action = $_REQUEST["action"];
}
$GLOBALS["ewiki_id"] = $id;
$GLOBALS["ewiki_title"] = ewiki_split_title($id);
$GLOBALS["ewiki_action"] = $action;
#-- fetch from db
$dquery = array(
"id" => $id
);
if (!isset($_REQUEST["content"]) && ($dquery["version"] = @$_REQUEST["version"])) {
$dquery["forced_version"] = $dquery["version"];
}
$data = @array_merge($dquery, ewiki_database("GET", $dquery));
#-- stop here if page is not marked as _TEXT,
# perform authentication then, and let only administrators proceed
if (!empty($data["flags"]) && (($data["flags"] & EWIKI_DB_F_TYPE) != EWIKI_DB_F_TEXT)) {
if (($data["flags"] & EWIKI_DB_F_BINARY) && ($pf = $ewiki_plugins["handler_binary"][0])) {
return($pf($id, $data, $action)); //_BINARY entries handled separately
}
elseif (!EWIKI_PROTECTED_MODE || !ewiki_auth($id, $data, $action, 0, 1) && ($ewiki_ring!=0)) {
return(ewiki_t("DISABLEDPAGE"));
}
}
#-- pre-check if actions exist
$pf_page = ewiki_array($ewiki_plugins["page"], $id);
#-- edit <form> for non-existent pages
if (($action==EWIKI_DEFAULT_ACTION) && empty($data["content"]) && empty($pf_page)) {
if (EWIKI_AUTO_EDIT) {
$action = "edit";
}
else {
$data["content"] = ewiki_t("DOESNOTEXIST");
}
}
#-- more initialization
if ($pf_a = @$ewiki_plugins["page_init"]) {
ksort($pf_a);
foreach ($pf_a as $pf) {
$o .= $pf($id, $data, $action);
}
unset($ewiki_plugins["page_init"]);
}
$pf_page = ewiki_array($ewiki_plugins["page"], $id);
#-- require auth
if (EWIKI_PROTECTED_MODE) {
if (!ewiki_auth($id, $data, $action, $ring=false, $force=EWIKI_AUTO_LOGIN)) {
return($o.=$ewiki_errmsg);
}
}
#-- handlers
$handler_o = "";
if ($pf_a = @$ewiki_plugins["handler"]) {
ksort($pf_a);
foreach ($pf_a as $pf) {
if ($handler_o = $pf($id, $data, $action)) { break; }
} }
#-- finished by handler
if ($handler_o) {
$o .= $handler_o;
}
#-- actions that also work for static and internal pages
elseif (($pf = @$ewiki_plugins["action_always"][$action]) && function_exists($pf)) {
$o .= $pf($id, $data, $action);
}
#-- internal pages
elseif ($pf_page && function_exists($pf_page)) {
$o .= $pf_page($id, $data, $action);
}
#-- page actions
else {
$pf = @$ewiki_plugins["action"][$action];
#-- fallback to "view" action
if (empty($pf) || !function_exists($pf)) {
$pf = "ewiki_page_view";
$action = "view"; // we could also allow different (this is a
// catch-all) view variants, but this would lead to some problems
}
$o .= $pf($id, $data, $action);
}
#-- error instead of page?
if (empty($o) && $ewiki_errmsg) {
$o = $ewiki_errmsg;
}
#-- html post processing
if ($pf_a = $ewiki_plugins["page_final"]) {
ksort($pf_a);
foreach ($pf_a as $pf) {
$pf($o, $id, $data, $action);
}
}
(EWIKI_ESCAPE_AT) && ($o = str_replace("@", "@", $o));
return($o);
}
#-- HTTP meta headers
function ewiki_http_headers(&$o, $id, &$data, $action) {
global $ewiki_t;
if (EWIKI_HTTP_HEADERS && !headers_sent()) {
if (!empty($data)) {
if ($uu = @$data["id"]) @header('Content-Disposition: inline; filename="' . urlencode($uu) . '.html"');
if ($uu = @$data["version"]) @header('Content-Version: ' . $uu);
if ($uu = @$data["lastmodified"]) @header('Last-Modified: ' . gmstrftime($ewiki_t["C"]["DATE"], $uu));
}
if (EWIKI_NO_CACHE) {
header('Expires: ' . gmstrftime($ewiki_t["C"]["DATE"], UNIX_MILLENNIUM));
header('Pragma: no-cache');
header('Cache-Control: no-cache, private, must-revalidate');
# change to "C-C: cache, must-revalidate" ??
# private only for authenticated users / _PROT_MODE
}
#-- ETag
if ($data["version"] && ($etag=ewiki_etag($data)) || ($etag=md5($o))) {
$weak = "W/" . urlencode($id) . "." . $data["version"];
header("ETag: \"$etag\""); ###, \"$weak\"");
}
}
}
function ewiki_etag(&$data) {
return( urlencode($data["id"]) . ":" . dechex($data["version"]) . ":ewiki:" .
dechex(crc32($data["content"]) & 0x7FFFBFFF) );
}
#-- encloses whole page output with a descriptive <div>
function ewiki_page_css_container(&$o, &$id, &$data, &$action) {
$o = "<div class=\"wiki $action "
. strtr($id, ' ./ --_!"§$%&()=?²³{[]}`+#*;:,<>| @µöäüÖÄÜߤ^°«»\'\\',
'- -----------------------------------------------')
. "\">\n"
. $o . "\n</div>\n";
}
function ewiki_split_title ($id='', $split=EWIKI_SPLIT_TITLE, $entities=1) {
strlen($id) or ($id = $GLOBALS["ewiki_id"]);
if ($split) {
$id = preg_replace("/([".EWIKI_CHARS_L."])([".EWIKI_CHARS_U."]+)/", "$1 $2", $id);
}
return($entities ? htmlentities($id) : $id);
}
function ewiki_add_title(&$html, $id, &$data, $action, $go_action="links") {
$html = ewiki_make_title($id, '', 1, $action, $go_action) . $html;
}
function ewiki_make_title($id='', $title='', $class=3, $action="view", $go_action="links", $may_split=1) {
global $ewiki_config, $ewiki_plugins, $ewiki_title, $ewiki_id;
#-- advanced handler
if ($pf = @$ewiki_plugins["make_title"][0]) {
return($pf($title, $class, $action, $go_action, $may_split));
}
#-- disabled
elseif (!$ewiki_config["print_title"]) {
return("");
}
#-- get id
if (empty($id)) {
$id = $ewiki_id;
}
#-- get title
if (!strlen($title)) {
$title = $ewiki_title; // already in &html; format
}
elseif ($ewiki_config["split_title"] && $may_split) {
$title = ewiki_split_title($title, $ewiki_config["split_title"], 0&($title!=$ewiki_title));
}
else {
$title = htmlentities($title);
}
#-- title mangling
if ($pf_a = @$ewiki_plugins["title_transform"]) {
foreach ($pf_a as $pf) { $pf($id, $title, $go_action); }
}
#-- clickable link or simple headline
if ($class <= $ewiki_config["print_title"]) {
if ($uu = @$ewiki_config["link_title_action"][$action]) {
$go_action = $uu;
}
if ($uu = @$ewiki_config["link_title_url"]) {
$href = $uu;
unset($ewiki_config["link_title_url"]);
}
else {
$href = ewiki_script($go_action, $id);
}
$o = '<a href="' . $href . '">' . ($title) . '</a>';
}
else {
$o = $title;
}
return('<h2 class="page title">' . $o . '</h2>'."\n");
}
function ewiki_page_view($id, &$data, $action, $all=1) {
global $ewiki_plugins, $ewiki_config;
$o = "";
#-- render requested wiki page <-- goal !!!
$render_args = array(
"scan_links" => 1,
"html" => (EWIKI_ALLOW_HTML||(@$data["flags"]&EWIKI_DB_F_HTML)),
);
$o .= $ewiki_plugins["render"][0] ($data["content"], $render_args);
if (!$all) {
return($o);
}
#### MOODLE CHANGE
/// Add Moodle filters to text porion of wiki.
global $moodle_format; // from wiki/view.php
$o = format_text($o, $moodle_format);
$o.= "<br><br>";
#-- control line + other per-page info stuff
if ($pf_a = $ewiki_plugins["view_append"]) {
ksort($pf_a);
foreach ($pf_a as $n => $pf) { $o .= $pf($id, $data, $action); }
}
if ($pf_a = $ewiki_plugins["view_final"]) {
ksort($pf_a);
foreach ($pf_a as $n => $pf) { $pf($o, $id, $data, $action); }
}
if (!empty($_REQUEST["thankyou"]) && $ewiki_config["edit_thank_you"]) {
$o = ewiki_t("THANKSFORCONTRIBUTION") . $o;
}
if (EWIKI_HIT_COUNTING) {
ewiki_database("HIT", $data);
}
return($o);
}
#-------------------------------------------------------------------- util ---
/* retrieves "$id/$action" string from URL / QueryString / PathInfo,
change this in conjunction with ewiki_script() to customize your URLs
further whenever desired
*/
function ewiki_id() {
($id = @$_REQUEST["id"]) or
($id = @$_REQUEST["name"]) or
($id = @$_REQUEST["page"]) or
($id = @$_REQUEST["file"]) or
(EWIKI_USE_PATH_INFO) and ($id = ltrim(@$_SERVER["PATH_INFO"], "/")) or
(!isset($_REQUEST["id"])) and ($id = trim(strtok($_SERVER["QUERY_STRING"], "&")));
if (!strlen($id) || ($id=="id=")) {
$id = EWIKI_PAGE_INDEX;
}
(EWIKI_URLDECODE) && ($id = urldecode($id));
return($id);
}
/* replaces EWIKI_SCRIPT, works more sophisticated, and
bypasses various design flaws
- if only the first parameter is used (old style), it can contain
a complete "action/WikiPage" - but this is ambigutious
- else $asid is the action, and $id contains the WikiPageName
- $ewiki_config["script"] will now be used in favour of the constant
- needs more work on _BINARY, should be a separate function
*/
## MOODLE-CHANGE: $asid="", Knows the devil why....
function ewiki_script($asid="", $id=false, $params="", $bin=0, $html=1, $script=NULL) {
global $ewiki_config, $ewiki_plugins;
#-- get base script url from config vars
if (empty($script)) {
$script = &$ewiki_config[!$bin?"script":"script_binary"];
}
#-- separate $action and $id for old style requests
if ($id === false) {
if (strpos($asid, EWIKI_ACTION_SEP_CHAR) !== false) {
$asid = strtok($asid, EWIKI_ACTION_SEP_CHAR);
$id = strtok("\000");
}
else {
$id = $asid;
$asid = "";
}
}
#-- prepare params
if (is_array($params)) {
$uu = $params;
$params = "";
if ($uu) foreach ($uu as $k=>$v) {
$params .= (strlen($params)?"&":"") . rawurlencode($k) . "=" . rawurlencode($v);
}
}
#-- action= parameter
if (EWIKI_USE_ACTION_PARAM >= 2) {
$params = "action=$asid" . (strlen($params)?"&":"") . $params;
$asid = "";
}
#-- workaround slashes in $id
if (empty($asid) && (strpos($id, EWIKI_ACTION_SEP_CHAR) !== false) && !$bin) {
$asid = "view";
}
/*paranoia*/ $asid = trim($asid, EWIKI_ACTION_SEP_CHAR);
#-- make url
if (EWIKI_URLENCODE) {
$id = urlencode($id);
$asid = urlencode($asid);
}
else {
# only urlencode &, %, ? for example
}
$url = $script;
if ($asid) {
$id = $asid . EWIKI_ACTION_SEP_CHAR . $id; #= "action/PageName"
}
if (strpos($url, "%s") !== false) {
$url = str_replace("%s", $id, $url);
}
else {
$url .= $id;
}
#-- add url params
if (strlen($params)) {
$url .= (strpos($url,"?")!==false ? "&":"?") . $params;
}
#-- fin
if ($html) {
$url = str_replace("&", "&", $url);
}
return($url);
}
/* this ewiki_script() wrapper is used to generate URLs to binary
content in the ewiki database
*/
function ewiki_script_binary($asid, $id=false, $params=array(), $upload=0) {
$upload |= is_string($params) && strlen($params) || count($params);
#-- generate URL directly to the plainly saved data file,
# see also plugins/binary_store
if (defined("EWIKI_DB_STORE_URL") && !$upload) {
$url = EWIKI_DB_STORE_URL . rawurlencode($id);
}
#-- else get standard URL (thru ewiki.php) from ewiki_script()
else {
$url = ewiki_script($asid, $id, $params, "_BINARY=1");
}
return($url);
}
/* this function returns the absolute ewiki_script url, if EWIKI_SCRIPT_URL
is set, else it guesses the value
*/
function ewiki_script_url() {
global $ewiki_action, $ewiki_id, $ewiki_config;
$scr_template = $ewiki_config["script"];
$scr_current = ewiki_script($ewiki_action, $ewiki_id);
$req_uri = $_SERVER["REQUEST_URI"];
if ($url = $ewiki_config["script_url"]) {
return($url);
}
elseif (strpos($req_uri, $scr_current) !== false) {
$url = str_replace($req_uri, $scr_current, $scr_template);
}
elseif (strpos($req_uri, "?") && (strpos($scr_template, "?") !== false)) {
$url = substr($req_uri, 0, strpos($req_uri, "?"))
. substr($scr_template, strpos($scr_template, "?"));
}
elseif (strpos($req_uri, $sn = $_SERVER["SCRIPT_NAME"])) {
$url = $sn . "?id=";
}
else {
return(NULL); #-- could not guess it
}
#$url = "http://" . $_SERVER["SERVER_NAME"] . $url;
return($url);
}
#------------------------------------------------------------ page plugins ---
function ewiki_page_links($id, &$data, $action) {
$o = ewiki_make_title($id, ewiki_t("PAGESLINKINGTO", array("title"=>$id)), 1, $action, "", "_MAY_SPLIT=1");
if ($pages = ewiki_get_backlinks($id)) {
$o .= ewiki_list_pages($pages);
} else {
$o .= ewiki_t("This page isn't linked from anywhere else.");
}
return($o);
}
function ewiki_get_backlinks($id) {
$result = ewiki_database("SEARCH", array("refs" => $id));
$pages = array();
while ($row = $result->get(0, 0x0020)) {
if ( strpos($row["refs"], "\n$id\n") !== false) {
$pages[] = $row["id"];
}
}
return($pages);
}
function ewiki_get_links($id) {
if ($data = ewiki_database("GET", array("id"=>$id))) {
$refs = explode("\n", trim($data["refs"]));
$r = array();
foreach (ewiki_database("FIND", $refs) as $id=>$exists) {
if ($exists) {
$r[] = $id;
}
}
return($r);
}
}
function ewiki_list_pages($pages=array(), $limit=EWIKI_LIST_LIMIT,
$value_as_title=0, $pf_list=false)
{
global $ewiki_plugins;
$o = "";
$is_num = !empty($pages[0]);
$lines = array();
$n = 0;
foreach ($pages as $id=>$add_text) {
$title = $id;
$params = "";
if (is_array($add_text)) {
list($id, $params, $title, $add_text) = $add_text;
}
elseif ($is_num) {
$id = $title = $add_text;
$add_text = "";
}
elseif ($value_as_title) {
$title = $add_text;
$add_text = "";
}
$lines[] = '<a href="' . ewiki_script("", $id, $params) . '">' . htmlentities($title) . '</a> ' . $add_text;
if (($limit > 0) && ($n++ >= $limit)) {
break;
}
}
if ($pf_a = @$ewiki_plugins["list_transform"])