6401ff5ac60a30270bcb65111acb9f911c312743
[atutor.git] / mods / wiki / doc / README
1
2 ErfurtWiki - a fast, user-friendly, highly configurable Wiki engine in PHP
3 ==========================================================================
4
5
6 README
7 ¯¯¯¯¯¯
8 This is the main documentation for ewiki. It tries to describes the basics,
9 and how to set it up. More detailed explanations on other issues are
10 separated out into the [README.config], [README.plugins], [README.fragments]
11 and [INTERNALS] files, and into the doc/ directory.
12 (Once you have the Wiki running, you could also read this file in hypertext
13 format.)
14
15         1 What is this?
16       1.1 Why "ErfurtWiki"?
17     1.1.1 Unique Features
18     1.1.2 WikiAlternatives
19       1.2 Project Pages
20     1.2.1 Obtaining Support
21     1.2.2 License
22     1.2.3 Authors
23
24         2 HowTo
25       2.1 Integration with yoursite.php
26     2.1.1 What to do if images don't work
27       2.2 Creating a "config.php"
28       2.3 flat file database
29       2.4 tarball directoy structure
30
31         3 other/advanced integration issues
32       3.1 Generation of a "monsterwiki.php" script
33       3.2 Supplying the WikiPageName
34     3.2.1 mod_rewrite or PATH_INFO
35     3.2.2 use with the 404 trick
36       3.3 Security considerations
37     3.3.1 PHP settings (register_globals)
38     3.3.2 The two modes of operation (_protected_mode and _flat_real_mode)
39       3.4 simple usage restrictions via wrappers (a locked PersonalWiki)
40       3.5 PhpWiki compatibility
41     3.5.1 Transition from another WikiWare
42       3.6 Idea Collection
43     3.6.1 Multiple Wikis / InterWiki feature abuse
44
45         4 Tweaking (your own wiki markup and CSS)
46       4.1 Customizing ewiki_format()
47       4.2 Customization using CSS
48       4.3 user style classes in pages
49       4.4 rendered page content
50       4.5 pages enclosed in style classes
51       4.6 plugin output styling
52
53         5 Explanations
54       5.1 Binary and Text content
55     5.1.1 Image Uploading
56     5.1.2 Images Caching
57     5.1.3 Image WikiMarkup
58     5.1.4 binary_store, direct access
59     5.1.5 Arbitrary Binary Content
60       5.2 $action and $id
61     5.2.1 ewiki URLs
62
63         6 Appendix
64       6.1 Apache config
65       6.2 PHP config
66       6.3 error numbers
67
68
69
70
71
72
73   -------------------------------------------------------------------- 1 --
74
75
76
77 What is this?
78 ¯¯¯¯¯¯¯¯¯¯¯¯¯
79 This is a WikiWikiWeb engine implemented in the PHP web scripting
80 language. A WikiWiki is a web site which can be edited by everybody
81 who visits it (most commonly without requiring that user to register
82 before).
83
84 It should allow easy integration into an existing web site (portal
85 or homepage / CMS-like software), as it is more a library and does
86 not output a full .html page - but instead just the formatted wiki
87 text for inclusion in your pages` body/content area.
88
89 Many extension plugins are available and can easily be hooked in
90 (construction set principle). Try the "tools/setup" script.
91
92
93
94 Why "ErfurtWiki"?
95 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
96 The project name comes from the home town of the author (Erfurt is next
97 to Weimar.de); and our internal project name is in fact just "ewiki".
98
99
100
101         Unique Features
102         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
103         ewiki is not just another Wiki engine, it has some features that
104         clearly separate it from other implementations:
105
106         - contained within a single file (see the notes on "monsterwiki")
107         - does not impose a pre-defined layout, because it integrates
108           nicely into yoursite
109         - it is rather fast - uses regexs too, but the formatting kernel
110           uses the simple and quick string functions
111         - it is extremely featureful
112         - ewiki is not GPLed like 98% of all other Wiki implementations
113         - provides case-insensitive Wiki links, multiple database backends,
114           and all extended features are optional (a very exhaustive plugin
115           interface, and over 200 ready to use plugins)
116         - highlights: WikiCommander, OpenSearch, WikiSync, PHP-RPC database,
117           PingBack, TextUpload, click-and-run .xpi plugins, image upload,
118           GaGaLinks, XFN, CSS markup, WikiScript (not yet), TCN, and
119           in-page-macros: TableEditor, WebDAV, ...
120
121
122
123         WikiAlternatives
124         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
125         If you don't like ewiki, then try at least one of these:
126
127         - PhpWiki has a more complete approach than this WikiWare,
128           get it from http://freshmeat.net/projects/phpwiki,
129           it has support for different database types, features localization
130           and comes with an integrated admin area and also lots of plugins
131           made by its gigantic user base and development group. It initially
132           inspired the ewiki project, but also was the reason for starting
133           it.
134         - TikiWiki is a portal system centering around a powerful Wiki
135           implementation. Thousands of plugins and developers, many cool
136           extensions. http://tikiwiki.org/ and the http://tikipro.org/ fork
137         - Pie is a lean and unbloated Wiki implementation using a file based
138           database and storing pages as HTML. <http://pie.ekkaia.org/>
139         - WakkaWiki by Hendrik Mans is also a very powerful PHP implementation,
140           see http://www.wakkawiki.com/
141         - Miki is another nice (small) implementation in PHP from Jukka
142           Zitting.  Get it from http://miki.sourceforge.net/
143         - coWiki - completely OOP and the source code layout is great; looks
144           very featureful, but is more a CMS than a Wiki (authentication
145           bloat) and has also a little weird markup, but better check it out
146           yourself on http://cowiki.org/
147         - PmWiki is one of the more mature Wiki implementations for PHP,
148           it has been around for some time, has a large user base and is
149           still in active development. http://pmwiki.org/
150         - MediaWiki drives the well-known WikiPedia project. It is very
151           powerful, but like Pmwiki comes with features that initially
152           are somehwat overkill for many users. The developer base is
153           huge, and features get added hourly. http://www.mediawiki.org/
154         - PWiki2 was once the rising star in the world of PHP based Wikis,
155           but seems to have frozen in development. http://www.pwiki2.org/
156
157         The BEST PLACE to look for evil concurrent implementations is:
158         http://c2.com/cgi/wiki?WikiEngines
159
160         And there is a new WikiEngine comparison table coming up, which
161         tries to sort them by supported features:
162         http://wikifeatures.wiki.taoriver.net/moin.cgi/WikiEngine
163
164         Why do we recommend "concurrent" projects?  Simple answer: ewiki is
165         not a commercial project, we do not depend upon having thousands of
166         "customers" or users; and it makes especially no sense to persuade
167         people to use it. While ewiki is very flexible, it is not believed
168         to met everybodys needs (that would be silly, wouldn't it?).
169         Choices are good, and the free software community offers a lot here,
170         so please just check them out, and make YOUR choice.
171
172         Also have a visit at http://www.cmsmatrix.org/ if you've got time.
173
174
175
176 Project Pages
177 ¯¯¯¯¯¯¯¯¯¯¯¯¯
178 official freshmeat project page: 
179 - http://freshmeat.net/projects/ewiki
180
181 demo site:
182 - http://erfurtwiki.sourceforge.net/
183
184 newest versions (unstable development releases):
185 - http://erfurtwiki.sourceforge.net/downloads/
186
187 mailing list archive
188 - http://www.freelists.org/archives/ewiki/
189
190 secondary site, WebInstaller:
191 - http://ewiki.berlios.de/
192
193
194
195         Obtaining Support
196         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
197         Getting support for problems with ewiki is possible, but please read
198         this README first. The authors are thankful for BugReports, and of
199         course would like to know where this documentation is not detailed
200         enough and fails to explain things clearly.  However, before you
201         send requests to anyone, please visit following site (this is
202         necessary to get FREE support):
203
204         http://www.catb.org/~esr/faqs/smart-questions.html
205
206         Then please feel free to contact the author or leave notes on the
207         BugReports or UserSuggestion pages on our project site.
208         - http://erfurtwiki.sourceforge.net/BugReports
209         - http://erfurtwiki.sourceforge.net/SupportForum
210
211         Joining our http://erfurtwiki.sourceforge.net/MailingList would
212         allow you to reach a larger audience for your questions. However
213         you need to sign up first, and it's not much faster than the forum.
214         Keep in mind, that answers may come in slowly, and visiting back
215         first after 2 or 3 days is best practice.
216
217         But after all: DON'T BE SHY TO ASK QUESTIONS - only because we
218         have a README here doesn't mean we don't want to give you real
219         support.
220
221
222
223         License
224         ¯¯¯¯¯¯¯
225         ErfurtWiki is PublicDomain, which means that you can do with it
226         whatever you want (that actually means it is free of copyright and
227         any restrictions).  So it is free as in beer, and you can fork it,
228         rename it, commercialize it, or publish a derived version under the
229         GNU GPL, BSD, MPL, CC* licenses or even Microsofts' EULA.
230
231         ADDITIONAL NOTE: a few plugins in the plugins/lib/ directory may not
232         be PD (to date all are, but that could change).  Also the LiveUser
233         auth plugins (plugins/auth-liveuser/) are distributed under the GNU
234         LGPL. Everything that was a GNU GPL extension module was separated
235         out into our "extra"-tarball.
236
237
238
239         Authors
240         ¯¯¯¯¯¯¯
241         Mario Salzer <mario*erphesfurt·de> icq95596825 (+Yahoo,Jabber)
242         Andy Fundinger <andy*burgiss·com> from http://burgiss.com/
243
244         For the complete list of authors and contributors please see the
245         CREDITS file.
246
247         This project is rather mature and well tested now, but to improve it
248         further we need to know what doesn't work or what could be enhanced.
249         Every mail is a contribution (yep, that is not measured in lines of
250         source code).
251
252
253
254
255
256   -------------------------------------------------------------------- 2 --
257
258
259
260
261 HowTo
262 ¯¯¯¯¯
263 ewiki is very easy to set up, you only need a web server with PHP (4.1
264 or later) support. It even runs without a SQL database, but that requires
265 additional configuration (see for "db/flat_files" in [README.plugins]).
266 If you unpacked the tarball you can often simply point your browser to
267 there [http://localhost/ewiki/], to get it running.
268
269 The following paragraphs are assuming you want to integrate the Wiki
270 engine into an existing web site / template. Otherwise you would simply
271 go with one of the supplied examples/, which are often ready to use.
272
273 If you don't want to set it up yourself, you could check out our cool
274 new remote web install service:
275 http://ewiki.berlios.de/installer/
276
277
278
279 Integration with yoursite.php
280 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
281 For the next few paragraphs the "yoursite.php" refers to whatever
282 files and/or scripts belong to your already existing website. This
283 hypothetical script should at least output the <html><body> tags
284 around the output from ewiki. The most simple script to accomplish
285 this could look like this (see also example-2.php):
286  
287     <?php
288        mysql_connect("localhost", "DB-USER-NAME", "PASSWORD");     #[1]
289        mysql_query("use DATABASE-NAME-HERE");
290
291        define("EWIKI_SCRIPT", "yoursite.php?page=");               #[2]
292        include_once("ewiki.php");                                  #[3]
293     ?>
294     <HTML>
295      <head>...</head>
296     <BODY>
297     <?php
298        echo  ewiki_page();                                         #[4]
299     ?>
300     </BODY>
301     </HTML>
302    
303 [1]  The first two commands open a connection to your MySQL database.
304 Usually one saves the result of mysql_connect() in a variable named
305 $db or so, but that was not used in "ewiki.php" at all (because PHP
306 does not depend on it if there is only a single db connection).
307
308 [2]  The define line tells ewiki about the <a href= hyperlinks it
309 shall create for wiki pages.
310
311 [3]  The include_once("ewiki.php") finally loads the ewiki "library" and
312 sets any EWIKI_ constants that have not already been defined here. Instead
313 of "include" we use the safer "include_once" since version R1.02b
314
315 [4]  The final call to the ewiki_page() function returns the wiki page
316 which was requested by the browser as <html> string. The "echo" command
317 lets PHP print it out.
318
319
320
321         What to do if images don't work
322         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
323         If you don't start the yoursite template with a <?php code part as
324         shown in the initial example but have some <HTML> tags before the
325         initial inclusion of the "ewiki.php" script, then ewiki cannot
326         handle binary content (like uploaded images).
327
328         You must ensure, that yoursite.php script starts with <?php and has
329         the include_once("ewiki.php") or include_once("config.php") there:
330
331             <?php
332                mysql_connect(":/var/run/mysqld/mysqld.sock", "USER", "PW");
333                mysql_query("use DBNAME");
334
335                define("EWIKI_SCRIPT", "yoursite.php?page=);
336                error_reporting(0);
337
338                include_once("ewiki.php");
339
340                $content = ewiki_page();
341             ?>
342             <HTML>
343             <HEAD>
344               <TITLE><?php  echo $ewiki_title;  ?>
345             </HEAD>
346             <BODY>
347             <?php
348                echo $content;
349             ?>
350             </BODY>
351             </HTML>
352
353         Please again, note the initial <?php part before the very first plain
354         HTML output - yoursite.php must really start with it, or else binary
355         content (uploaded images) won't work!
356
357         You could, of course use a "binary.php" besides "yoursite.php", to
358         get around this problem; please see fragments/ for an example.
359
360
361
362 Creating a "config.php"
363 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
364 Instead of including the plain "ewiki.php" script as shown in the
365 example above, many people may find it more useful to include_once()
366 a "config.php", which then itself loads the ewiki script.
367
368 Customization of ewiki takes place, by pre-defining() some of the
369 EWIKI_ configuration settings and loading extension plugins (see
370 [README.config] and [README.plugins] for a complete overview). To
371 not move that work and code into yoursite it is recommended to
372 create some sort of "config.php" script, which then contained the
373 various define() and include_once() commands.
374
375 It is sometimes even senseful to establish the database connection
376 (if you use SQL and not the flat_files backend) inside of such a
377 config script, if it wasn't already established in yoursite.
378
379 So such a config.php script could contain:
380  - multiple define() commands, setting ewiki behaviour constants
381  - include_once() commands to load extension plugins
382  - evtl. some include_once() and define() for the db_flat_files plugin
383    (if you don't have a SQL database)
384  - and last but not least - an include_once("ewiki.php");
385
386 If you then include_once() such a config.php, you get a fully functional
387 and preconfigured Wiki to include into yoursite. By using this
388 approach, you still could override some of the EWIKI_ settings with
389 additional define() constants right before the include_once("config.php").
390
391   <?php
392      define("EWIKI_whatever", "...");
393      include_once("includes/ewiki/myconfig.php");
394   ?>
395   <HTML>
396   <BODY>
397   <?php
398      echo  ewiki_page();
399   ?>
400   </BODY>
401   </HTML>
402
403 Note: All path names here are just examples, they will differ for
404 your setup!
405
406 But again, creating a "config.php" script is optional; it is
407 supplied in the ewiki tarball for convinience, not for reference.
408 You may however want to create one of your own, by simply using
409 the "SetupWizard" script. Just point your web browser to
410 [http://localhost/ewiki/tools/t_setup.php] and chose the options and
411 extensions you want. Beware that while it provides a simplified
412 overview, it is not really short.
413
414 IMPORTANT: Please use "include_once()" instead of the "include()"
415 feature. This is to prevent accidential double loading of plugins.
416 We do this since R1.02b, and this is how the generated config scripts
417 will work.
418
419
420
421 flat file database
422 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
423 If you don't have a MySQL database, then you must configure ewiki to
424 store pages in a dedicated directory. You need to include_once() the
425 'plugins/db/flat_files.php' plugin prior to 'ewiki.php'. You must
426 also set the constant EWIKI_DBFILES_DIRECTORY to a location which
427 is world-writable ("chmod 4777 dirname" in FTP/shell). Usually this
428 would look like (in yoursite or a config.php):
429
430    define("EWIKI_DBFILES_DIRECTORY", "./pages/");
431    include_once("plugins/db/fast_files.php");
432    ...
433    include_once("ewiki.php");
434
435 See [README.plugins] for more information on "db/flat_files". You can
436 also use the newer "db/dzf2" which creates a deep directory structure,
437 and seems to be a bit faster on some systems - moreover that one also
438 provided case-insensitive WikiPageLinking under Unix.
439
440
441
442 tarball directoy structure
443 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
444 You get following directories and files, when you unpack the tarball:
445
446 README.*       main documentation
447 doc/           detailed doc on certain subjects
448 ewiki.php      the core script, contains the minimum wiki
449 config.php     example configuration script
450 example-1.php  example yoursite wiki wrapper
451 examples/      more sample layout wrapper scripts
452 plugins/       large directory with extension scripts
453 local/         empty, use for your own/modified plugins
454 fragments/     code snippets, separate files, often not very ewiki specific
455 init-pages/    holds default wiki pages, automatically transfered into DB
456 spages/        "StaticPages" are dynamic/page plugins
457 tools/         database + administration tools, including SetupWizard
458 wiki.css       description of CSS classes used in the core and plugins
459 z.php          interface for Wiki-RPC, WebDAV, ?binary=, OpenSearch, sync, ...
460
461 Feel free to explore especially plugins/ and fragments/ somewhat deeper
462 with your favourite file browser. Every file should carry a little amount
463 of documentation on top. The [README.plugins] file is always somewhat
464 outdated and not meant to describe everything anyhow.
465
466
467
468
469
470   -------------------------------------------------------------------- 3 ---
471
472
473
474 other/advanced integration issues
475 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
476 Once you mastered the basic steps to integrate the wiki into yoursite, you
477 may choose to fine tune the generated URLs, behaviour and appearance.
478
479 The following paragraphs are a selection of common issues and solutions,
480 like using mod_rewrite, setting up simple authentication schemes or changing
481 from another Wiki.
482
483
484
485 Generation of a "monsterwiki.php" script
486 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
487 ewiki over the time grow larger, and nowadays isn't anymore the
488 SINGLE SCRIPT it once was. The distribution ships with over hundred
489 extension plugins. But nevertheless it is still possible to build
490 a single script from it all.
491
492 That being said, the "ewiki.php" script still implements a fully
493 functional Wiki (and just only lacks the advanced features supplied
494 by the plugins). - You could still just include_once() the "ewiki.php"
495 script into yoursite and delete everything else the ewiki tarball
496 contained.
497
498 However, it is also possible to MERGE all wanted plugins and the
499 core script together to built a customized (feature enhanced) Wiki
500 script from it. All you needed to do was:
501
502   /unix/$   cat  ewiki.php plugins/*.*  >  monsterwiki.php
503 or
504   C:\win\   type  ewiki.php plugins/*.*  >  monsterwiki.php
505
506 This way you'd get the "monsterwiki.php" file, which contained the
507 ewiki core script plus all plugins - but of course, you should only
508 copy the ones in, you really need and want (and not all "*.*" as
509 shown in the example above)!
510
511 The UNIX shell script "tools/mkhuge" will do exactly that for you;
512 it accepts a parameter from 0 to 3, which will merge a custom set
513 of useful plugins into the then generated "monsterwiki.php" script.
514 In newer versions, you may want to use the "tools/setup" console
515 tool instead (for Linux), which makes this far easier.
516
517 If you have built a "monsterwiki.php" script, you can include() this
518 instead of the minimal "ewiki.php" into yoursite to integrate a Wiki.
519
520 Eventually you'd also want to merge some configuration settings into
521 this monsterwiki script, so you wouldn't have to put the define(...)
522 commands into yoursite.php before you include("monsterwiki.php");
523 The define() commands however need to be the very first part merged
524 into that monsterwiki script, so it's best to edit the monsterscript
525 after generation and insert the appropriate settings then at the
526 very beginning.
527     You could also merge a (reduced!) "config.php" into the script,
528     using the above "cat" (or "type" for DOS/Win) method.  But
529     beware, that this "config.php" then does not contain any
530     include() command; because else the resulting "monsterwiki.php"
531     script would fail trying to load the "ewiki.php" core script and
532     plugins which were probably already merged in. (The newer and
533     recommended "include_once()" won't help here.)  Even if you merge
534     such a minimal config script at the start of this monsterwiki
535     script, you still could override some settings (at least
536     establishing the database connection) from within yoursite, if
537     you think it's useful.
538
539 Additional note: You could still include() plugins, if you included()
540 such a monsterwiki script into yoursite, provided that the plugin
541 you try to include() wasn't already merged into that monsterwiki.php
542 script before (else it would crash the PHP interpreter, because
543 loading it twice is once too much => error + crash).
544
545 StaticPages (read about "spages" plugin) can also be included, if
546 you first convert them into ordinary ["page"] plugins using the 
547 'mkpageplugin' commandline tool.
548
549
550
551 Supplying the WikiPageName
552 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
553 If you just call ewiki_page() as shown in the first example, it will
554 try to get the name of the requested WikiPage either from the
555 $_SERVER["PATH_INFO"] variable or from one of the GET-variables '?id='
556 or '?name=' or '?page=' or '?file=' (available as $_REQUEST["name"]). 
557 If yoursite.php however uses another way or another varname to receive
558 the WikiPageName you can just give it as first parameter:
559
560   ewiki_page( $id = "WikiPageName" );
561
562 example-4.php shows how this can be used to list a second WikiPage
563 (the list of newest pages) somewhere else on yoursite.php.
564
565
566
567         mod_rewrite or PATH_INFO
568         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
569         If you dedicate a complete directory for your wiki, you should keep
570         in mind, that some of the generated URLs contain slashes (for
571         example "edit/WikiPage"), and will look like subdirectories and thus
572         confuse browsers.
573
574         So you should either set EWIKI_SCRIPT to the absolute directory
575         containing your wiki wrapper script: define(EWIKI_SCRIPT,
576         "http://myserver/wiki/"); or else put a <BASE HREF="..."> into the
577         generated pages. Take this precaution because some of the generated
578         links contain additional slashes (like "edit/ThisPage") and thus may
579         make browsers believe in a changed subdirectory.
580
581         This applies to mod_rewrite usage and if you call your wiki wrapper
582         with the page name as PATH_INFO (like "/wiki/index.php/WikiPage").
583
584         Do not forget to enable EWIKI_USE_PATH_INFO, as it is per default
585         disabled for Apache servers! Also check, if EWIKI_URLENCODE and
586         _URLDECODE suit your needs, else you will find it useful that all URL
587         generation is encapsulated in our ewiki_script() function (so you can
588         easily adjust it).
589
590
591
592         use with the 404 trick
593         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
594         Once I've implemented a way to run a web server below another one
595         (actually Nanoweb below Apache, for more details see
596         http://nanoweb.si.kz/), because the Apache on one of my providers
597         servers was heavily misconfigured - so I handed work over to a
598         secondary WebServer.
599
600         This trick also works without mod_rewrite support, and is therefore
601         also well suited for cheap WebSpace. Put following into the
602         .htaccess of the dedicated wiki directory:
603
604           #-- handle "not found" pages by ewiki
605           ErrorDocument 404 /wiki/index.php
606           DirectoryIndex 404 index.php
607
608         This will allow the "yoursite.php/ewiki.php" script to catch all
609         missed files, which would usually trigger a 404 error. Inside your
610         ewiki wrapper script, you must then however decode the originally
611         requested URL:
612
613           $url = $_SERVER["REQUEST_URL"];               # Apache often uses this one
614           $url = preg_replace("#^/wiki#", "", $url);    # strip wiki subdir name
615           $_SERVER["PATH_INFO"] = $url;                 # make ewiki see it
616
617         The second step is very important, it strips the name of the
618         dedicated subdirectory from the URL, which cannot be done inside
619         ewiki.php.
620
621            The $url from the above example could also be used as $id
622            parameter to ewiki_page().           
623
624         It should be noted, that some Apache implementations are garbaging
625         POST requests in case of a triggered 404 error - but you can simply
626         test this by saving a changed WikiPage.
627
628         See also the "fragments/404finder.php" example on this.
629
630         Do not forget to enable EWIKI_USE_PATH_INFO, as it is per default
631         disabled for Apache servers!
632
633
634
635 Security considerations
636 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
637 ewiki was developed using a PHP5 interpreter, but with limitations of PHP4.3
638 in mind. There are huge differences (a rather instable, bug-prone and still
639 unfinished language) across the 4.x versions of PHP. The 4.0 series is not
640 enough to run ewiki, you'll need at least a PHP 4.1 (4.07) to make it work
641 reliable.
642
643 One must also know, that there are also differences between the settings of
644 providers. Some for example enforce users to run their scripts in so called
645 "safe mode" (crippled mode) in place of real server security guidelines.
646 Other still use pre-4.3 settings for the PHP interpreter (the Win4 php.ini
647 still is outdated). So take care, and adjust settings using .htaccess`
648 php_option for Apache servers if you can.
649  
650
651
652         PHP settings (register_globals)
653         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
654         Because ewiki was developed on later PHP versions (at least 4.3), it
655         heavily uses the $_REQUEST array and assumes a deactivated
656         "register_globals" setting in php.ini
657         If this is not the case for your setup / WebServer or with your
658         provider the ewiki.php script may expose some security leaks
659         (because of uninitialized variables).
660
661         ewiki in general does only use a few global variables, but especially
662         the $ewiki_ring variable (which is used for PROTECTED_MODE) can lead
663         to problems, if you use it without an existing authentication
664         concept.  The $ewiki_plugins is also a very complex task, and I
665         cannot safely state that it won't be able to produce exploits, if
666         the variable is tweaked externally (pushed into by a client).
667
668         So the best thing you could do is to disable register_globals (this
669         can be done from inside a directories .htaccess file by inserting
670         the line "php_option register_globals off").
671
672         A fragments/ include will be added to strike against variables which
673         got set from outside (this is rather easy for variables used by
674         ewiki, because their names all start with "$ewiki_").
675
676
677
678         The two modes of operation (_protected_mode and _flat_real_mode)
679         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
680         While this wiki was originally developed as a real wiki, many people
681         use it for different things now, like private HomePages, easy CMS on
682         commercial web sites.
683
684         This fact lead to the support of a restricted operation mode, now
685         known as the _PROTECTED_MODE. It is often used to require people to
686         log in before they can edit pages or upload things. It is completely
687         optional, and doesn't have much impact on speed when left disabled.
688
689                                   Btw, the standard ewiki operation mode is
690                                         now known as the _FLAT_REAL_MODE ;)
691
692         If you'd like to use authentication, you'll probably want to chain
693         some plugins which enable you to use the user database from
694         yoursite.php, so you do not need a separate .htaccess or an
695         additional relational database for passwords. Please see the section
696         on auth plugins.
697
698         See also the EWIKI_PROTECTED_MODE configuration constant and the
699         separate [plugins/auth/README.auth] file for further and more
700         detailed informations on this feature.
701
702
703
704 simple usage restrictions via wrappers (a locked PersonalWiki)
705 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
706 The easiest way to cripple a Wiki setup to be browseable-only for the larger
707 public, and to allow only a small subset of users to edit pages is to write
708 two wrapper scripts around the ewiki.php library.
709
710 One of the wrapper scripts should include and use ewiki as described in the
711 "Integration with yoursite.php" paragraph. You may want to move this wrapper
712 script into a password protected subdirectory (say "/wikiadmin/index.php")
713 or just include("fragments/funcs/auth.php").
714
715 Another wrapper script should then be provided for the users that are only
716 allowed to view pages. To disallow editing you'll just have to enrich it
717 with commands like:
718
719  unset($ewiki_plugins["action"]["edit"]);       # disables editing
720  unset($ewiki_plugins["action"]["info"]);       # no info/ action
721  unset($ewiki_plugins["page"]["SearchPages"]);  # no search function
722
723 This code must occur after you have 'included("ewiki.php");' the library,
724 but before you call the 'ewiki_page();' function, so the unwanted actions
725 and pages really do not get activated.
726
727 So far the basic approach. If you however have real user authentication
728 code behind the scenes you probably don't want to maintain two different
729 wrapper scripts. You'll then just put the functionality stripping code
730 from above into an if-clause in "yoursite.php" like:
731
732  if (! $user_is_logged_in) {
733    unset($ewiki_plugins["action"]);   # (you should do it less destructive ;)
734  }
735
736 Note: this is again an example. DO NOT copy&paste examples and assume
737 they'll work for you!
738
739
740
741 PhpWiki compatibility
742 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
743 The MySQL database table is partially compatible to PhpWiki versions 1.2.x,
744 but not with the current PhpWiki 1.3.x versions. There is however now a
745 db/phpwiki13 plugin which allows to access those too (rw).
746
747
748
749         Transition from another WikiWare
750         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
751         If you choosed ewiki to replace an already existing wiki script on
752         your site, you should first think about, that the syntax/WikiMarkup
753         isn't equal across all Wikis. There are a few markup extension
754         plugins, that may help you around this, but beware that transition
755         with a larger collection of WikiPages won't be very easy.
756
757         The best way to import the old WikiPages to ewiki, is to first
758         export it using the tools of the previous WikiWare. You can then
759         just put the produced text/plain PageSource into "init-pages/",
760         because all files found therein (note, that there shouldn't be any
761         file name extension like .txt) are feed directly into the ewiki
762         database, when ewiki is run for the very first time (when the
763         EWIKI_PAGE_INDEX is not found in the db).
764
765         There is a "plugins/db/phpwiki13.php" which may be useful in first
766         trying ewiki, but it is not recommended to use it for daily work. 
767         Speaking of PhpWiki you could also use the "tools/t_convertdb.php"
768         to import (and markup convert) all pages from PhpWiki to the ewiki
769         database format.
770
771
772
773 Idea Collection
774 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
775 Here we'll note some tricks, on how to do this and that. Some of the
776 following paragraphs also explain workarounds for currently lacking
777 features.
778
779
780
781         Multiple Wikis / InterWiki feature abuse
782         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
783         Other WikiWare provides means to have multiple namespaces in a wiki,
784         what if fact is contrary to the original Wiki idea suggesting a
785         single flat namespace. ewiki does not support SubWikis or alike, to
786         get multiple Wikis using one ewiki installation you'll need multiple
787         layout and config wrappers (each with its own absolute URL and
788         differen EWIKI_DB_TABLE_NAME or EWIKI_DBFILES_DIRECTORY constants).
789
790         This way you'd get two independent Wikis (with two different SQL
791         database tables, or flat_files directories), and of course links
792         between those two need a special syntax. And the best approach here
793         was to use the InterWiki linking feature.
794
795         To do so, invent to InterWikiAbbreviations for each of your separate
796         Wikis and add it to $ewiki_config["interwiki"] as follows:
797
798           $ewiki_config["interwiki"]["main"] = "/wiki/main/?id=";
799           $ewiki_config["interwiki"]["office"] = "/wiki/office/?id=";
800           $ewiki_config["interwiki"]["tech"] = "http://tech.company.com/?id=";
801           $ewiki_config["interwiki"]["our-www"] = "http://www.company.com/";
802         
803         The last one is an example, on how to use the InterWiki feature to
804         generate references to arbitrary web documents, with a simple syntax
805         like "[our-www:/customers/pub/rules.html]" - it's somehow standard to
806         use "company-url:" or "company-www:" as InterWikiAbbreviation for this
807         purpose.
808
809
810
811
812
813   -------------------------------------------------------------------- 4 --
814
815
816
817
818
819 Tweaking (your own wiki markup and CSS)
820 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
821 (this part of the README is also just a collection of random notes)
822
823
824
825
826 Customizing ewiki_format()
827 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
828 There are various markup extension plugins available for ewiki, which
829 allow you to use BBCode or the syntax of another WikiWare. But if you
830 have a closer look at $ewiki_config (the defaults are in 'ewiki.php'
831 around line 200), you'll notice, that you can configure the WikiMarkup
832 that is to be used.
833 Various "wm_..." entries map our obscure markup to html <tags> (or at
834 least fragments of them). So in order to add a feature you could insert
835 an own rule there. (But keep in mind, that every new WikiMarkup slows
836 down the transformation function.)
837
838 Often you want to append an entry to "wm_style", for example:
839
840    $ewiki_config["wm_style"]["==="] = array("<h1>", "</h1>");
841
842 Would allow you to write "===SomeText===" in a WikiPage, which then would
843 display as an far-too-large headline.
844
845 You can also add markup with different 'start' and 'end' characters, using
846 the "wm_start_end" entry in $ewiki_config. For example the following would
847 render "... ((((some text)))) ..." in a page using the html <kbd> tag:
848
849    $ewiki_config["wm_start_end"][] = array(
850        "((((", "))))",   "<kbd>", "</kbd>",
851    );
852
853 Please see the section on "ewiki_format() internals" on how to write a
854 ["format_..."] or markup plugin, see [README.programming].
855
856
857
858 Customization using CSS
859 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
860 There are now some interesting ways to style ewiki output, just read on.
861
862 Please note, that it in your stylesheets you just write ".wiki" and
863 REALLY NOT ".ewiki" this time.
864
865 Also important is, that we discourage use of the underscore in CSS class
866 names, because it is simply forbidden there, even if current browsers do
867 not complain as loudly as the w3c does. (That's just why you'll now see
868 lots of class names with minus dashes instead of underscores.)
869
870
871
872 pages enclosed in generic style classes
873 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
874 The most powerful way to style the content ewiki includes into your site
875 is to use the generic style class names which enclose every page that comes
876 from ewiki:
877
878    <div class="wiki view PageName">
879       ...
880    </div>
881
882 This <div> is always the outermost tag around the html content that returns
883 from ewiki_page(). It will always contain the class "wiki", after this
884 the current page action/ and PageName (the action is usually "view", but
885 can be also "edit", "info", "links" or something similar).
886
887 If you haven't seen that before, this is in fact valid CSS. It means that
888 this <div> is part of three classes. You can then use either ".wiki" or
889 ".view" or ".PageName" or any compound of the three like ".wiki.view.PageNm"
890 as selectors in your stylesheet.
891
892    Note: Non-word characters in page names are converted into '-' dashes
893    usually (including dots and spaces, underscores, and so on), consecutive
894    dashes are collapsed. If a page name originally started with a number,
895    then "page" will be prepended to it.
896    So for example "99BottlesOfBeer.en" became "page99BottlesOfBeer-en" in
897    the stylesheet.
898
899 Keeping this in mind you can easily style all, a few or even just a single
900 page from ewiki in your stylesheet. (We'll explain it here, because the word
901 of multiple class names and the cascading way of using CSS is not very
902 widespread.)
903
904 .wiki  {                       // this affects every page ewiki returns
905    background-color: #ccccff;
906    font-family: "WikiFont";
907    ...
908 }
909
910 .wiki.view  { ... }            // only applies to pages that are "view"ed
911 .wiki.links  { ... }           // BackLinks
912 .wiki.edit  { ... }            // when a page gets edited
913
914 .wiki.PageIndex  {             // this rule affects only a __single__ page
915    ...                         // regardless what the "action/" is now;
916 }                              // useful for "PowerSearch" or "PageIndex"
917
918 .wiki.edit.ThisVerySpecialPage {   // this css section applies to just one
919    ...                             // page again, and this time only when
920 }                                  // it gets edited
921
922
923
924 page style class fragmentation
925 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
926 Moreover inside that generic <div> the page is fragmented further into
927 its individual parts to make styling it only partially really simple:
928
929    <div class="wiki view PageName">
930
931       <div class="text-head">
932         <h2 class="text-title"> <a>PageName</a> </h2>
933       </div>
934
935       <div class="text-body">
936         here comes the
937         actual page content
938         ...
939       </div>
940
941       <div class="wiki-plugins">
942
943          <div class="action-links">
944             <br/>  <hr/>
945             <a>edit</a>  <a>info</a>  <a>links</a>
946          </div>
947
948       </div>
949    </div>
950
951 So the .wiki class itself is divided into three parts, where .text-head
952 typically only contains the headline (.text-title) and the actual page
953 content comes encapsulated in .text-body
954
955 The part following as .wiki-plugins contains the individually named output
956 blocks from the so called aview-plugins, one of it is the .control-links
957 block containing the EditThisPage, BackLinks, ... actions and control links.
958 But there may be more of it inside of the .wiki-plugins block. See also
959 the paragraph on "plugin output styling".
960
961 Likewise the .text-head block could contain more, but currently no plugin
962 throws other output above the page content or title.
963
964 This further separation allows you for example to give headlines or page
965 content different borders or margins than the action links, so that it
966 matches better into your layout. You however don't need to use that classes
967 at all and could simply apply all styles onto the complete .wiki selector
968 as usual.
969
970
971
972 rendered page content
973 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
974 If you are not interested in walking around the "ewiki.php" script
975 when you want to tune how the output looks, you should try to
976 utilize the (few) CSS classes ewiki defines (it does not include
977 even one color setting or <font> tag):
978
979 <style type="text/css">
980
981    p     { font: ... }          // almost every part of the generated
982                                 // wiki pages is inside a <p>...</p>
983
984    em    { ... }                // you could encolour this, if the browsers
985    strong { ... }               // usual italic is not emphasized enough
986
987    .indent                      // to specify a different space-indentation
988
989 </style>   
990
991
992
993 user style classes in pages
994 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
995 The plugins/markup/css allows you to use CSS classes and style definitions
996 in WikiPages. With the double at "@@" followed by a css classname or command
997 you start styling a paragraph or parts of the text.
998
999   @@classname at the start of a paragraph will
1000   enclose it into a <div class="classname">
1001   completely
1002
1003   But inside of some text, the @@styledef only
1004   affects the part until the next  @@ - everything
1005   that comes later won't be enclosed in a <span>
1006
1007 While the css style classes must be defined in your sites` global stylesheet
1008 to take effect, you could also use direct CSS style commands instead. These
1009 also must follow the @@ immediately and may not contain spaces. So something
1010 like @@color:#ff0000; will work, while specifying font names may not always.
1011
1012
1013
1014 plugin output styling
1015 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1016 There often appear special 'pieces' within a rendered page that ewiki
1017 returns, because not everything in the returned html code belongs to the
1018 requested pages` content.
1019
1020 For example the current pages` title needs its own css class, like does
1021 the block of action links ("EditThisPage, PageInfo, ...") below every page,
1022 so it can be distinguished from the pages` text.
1023
1024 Also note again the use of the '.wiki' selector within the following
1025 stylesheet guide and ewiki CSS class overview:
1026
1027
1028 .wiki  h2.page.title  {         // all titles now have it, while many
1029    ...                          // of them include links as well
1030 }
1031
1032 .wiki.view  .action-links  {    // "EditThisPage, PageInfo, ..." links
1033    ...                          // are inside such a block, like are two
1034 }                               // <hr>'s
1035
1036 .wiki.info  .chunked-result {   // some generated pages (like the history
1037    ...                          // info/ ones) may need to split their
1038 }                               // results; this matches those links
1039
1040   //-- the edit/ pages are separated into
1041   //   following blocks:
1042 .wiki.edit  .edit-box   { ... }
1043 .wiki.edit  .image-upload   { ... }
1044 .wiki.edit  .preview  { ... }
1045
1046   //-- info/ pages contain a history of page versions, each enclosed in
1047   //   a <table class="version-info">, the <tr>s inside can be selected
1048   //   separately:
1049 .wiki.info  table.version-info  { ... }
1050 .wiki.info  .version-info  .action-links  { ... }
1051 .wiki.info  .version-info  .page-author  { ... }
1052 .wiki.info  .page-refs  { ... }
1053 .wiki.info  .page-flags  { ... }
1054
1055
1056 The class naming across most of the extension plugins is not unified, so you
1057 may often need to look it up here - or inside of the plugins source code.
1058 This is at least necessary for calendar and navbar, which follow a very
1059 different naming scheme.
1060
1061 .wiki  .download-entry  { ... }
1062 .wiki  .download-form  { ... }
1063 .wiki  .upload-form  { ... }
1064
1065 .wiki  .image-append  { ... }
1066
1067
1068
1069
1070
1071
1072
1073   -------------------------------------------------------------------- 5 --
1074
1075
1076
1077
1078 Explanations
1079 ¯¯¯¯¯¯¯¯¯¯¯¯
1080 The next few paragraphs shall enlight more detailed how some things are
1081 handled in ewiki (and why it is that way).
1082
1083
1084
1085 Binary and Text content
1086 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1087 Because I'd like to keep it small (see also the "Everything in one
1088 script" paragraph) ewiki also creates just one database table.
1089 Differently from other Wikis this one has the 'flags' setting for
1090 each saved page. And as I successfully used this bad trick in earlier
1091 projects many times to integrate support for hundreds of different
1092 functions (CMS, links, boards/forums, ...) into a single table; I
1093 thought it could be funny to have something like this in ewiki too.
1094
1095 While the image thingi seemed senseful to me, other binary data
1096 cannot be feed into database without helper plugins, because this is
1097 a Wiki script and not an almighty portal software!
1098
1099 Uploading and caching of images requires the EWIKI_SCRIPT_BINARY
1100 constant to be set correctly (no output may be made before "ewiki.php"
1101 is included == "binary safe").
1102 The ewiki_binary() function handles almost all of this, and gets
1103 activated automagically (whenever required) as soon as ewiki.php is
1104 included().
1105
1106 I believe these functions to be rather safe, as there are many sanity checks
1107 throughout the code to separate between _DB_F_BINARY and _DB_F_TEXT content.
1108
1109
1110
1111         Image Uploading
1112         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1113         The currently most important use for the BINARY flag and image
1114         functions is to upload images with the small form below every page
1115         edit box.
1116
1117         The upload/caching functions can be disabled fully if
1118         EWIKI_SCRIPT_BINARY and EWIKI_CACHE_IMAGES are set empty (or zero).
1119
1120         URLs starting with "internal://" represent the uploaded files. The
1121         string is just a md5() sum generated from the contents of the
1122         uploaded file. This way files won't get saved another time if they
1123         are uploaded twice.  For uploading a JavaScript-capable browser is
1124         recommended. It will work without, but then requires the user to
1125         copy the [internal://...] text (from one window to another).
1126
1127         The color of the temporary upload info screen can only be changed
1128         inside the ewiki_binary() function, currently.
1129
1130         Beware that images usually get downscaled if they are larger than
1131         specified with EWIKI_IMAGE_MAXSIZE (per default 64K).
1132
1133
1134
1135         Images Caching
1136         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1137         Images are usually redirected through EWIKI_SCRIPT_BINARY, and ewiki
1138         tries to save them inside the database as with uploaded images. So
1139         most of the facts from the previous paragraph apply to this function
1140         too.
1141
1142         You must enable this feature with EWIKI_IMAGE_CACHING, it is shipped
1143         disabled currently.
1144         Adding a ?nocache to the image URL disables this feature for just one
1145         specific image, if _IMAGE_CACHING was otherwise enabled.
1146
1147         Images are downscaled to fit the maximum defined size in
1148         EWIKI_IMAGE_MAXSIZE (bytes) if the PHP libgd extension is available
1149         (else dropped and then always redirecting clients which request
1150         those image).
1151
1152
1153
1154         Image WikiMarkup
1155         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1156         Usually one writes image references using square brackets around the
1157         url of an image: [http://www.example.com/pics/image.png] or:
1158         [internal://md5md5md5md5md5md5md5md5md5md5md5md5.png]
1159
1160         This will include (inline) the image into the page, when rendered
1161         and viewed.  Using the standard square bracket link entitling syntax
1162         also image references can be named (non-graphics / alternative
1163         text):
1164         [http://www.example.com/pics/image.png | This is an example image]
1165         [http://.../image.pic "or entitle it using double quotes"]
1166
1167         Images can also be "aligned" to either side of the screen, thus the
1168         remaining text will flow around it. To achieve this include spaces
1169         to the left or the right of the image URL:
1170
1171         * picture to the LEFT:   [http://www.example.com/pics/image.png  ]
1172         * picture to the RIGHT:  [  http://www.example.com/pics/image.png]
1173         * CENTRED picture:     [  http://www.example.com/pics/image.png  ]
1174
1175         Note that you must use __two__ spaces, currently!
1176
1177         Image rescaling is possible by appending x=... and y=... as query
1178         string parameters behind the image URL:
1179           [http://www.example.com/pics/image.png?x=160&y=120]
1180         The query string parameters "width" and "height" are also accepted.
1181
1182         If you have an image URL, but you do not want to get that image
1183         inlined into the current page, then just leave out the square
1184         brackets around.
1185
1186
1187
1188         binary_store, direct access
1189         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1190         While storing the binary data together with text pages in the same
1191         database is most often a good thing and suits most sites, there
1192         exists also a workaround/hack to keep this binary data in plain
1193         files. The advantage is a smaller database and possibly a little
1194         speed enhancement (with a large collection of binary things in the
1195         db). However the drawback is, that use of plugins/binary_store is
1196         only transparent to the main ewiki script, but all admin tools/
1197         won't be aware of it.
1198
1199         If you choose to use the binary_store.php plugin, you can also let
1200         ewiki generate URLs directly to the then stored data files if you
1201         just set the EWIKI_DB_STORE_URL constant.
1202
1203         Please see the paragraph on this plugin for more informations on
1204         this.
1205
1206
1207
1208         Arbitrary Binary Content
1209         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1210         Set the EWIKI_ACCEPT_BINARY constant, if you'd like to allow any
1211         binary file to be uploaded and saved in the database using the image
1212         upload function.  Uploaded files will show up as ordinary (except
1213         that "internal://" href prefix) links.
1214
1215         Please also note the "plugins/download.php", which does a much
1216         better job than this constant.
1217
1218
1219
1220 $action and $id
1221 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1222 Inside of ewiki.php you'll see many occurrences of variables named $id and
1223 $action. The $id refers to the current page, which usually is a string like
1224 ThisPage, ThatPage, OrAnotherPage.
1225
1226 Because just having pages wasn't believed to be sufficient enough, there
1227 is also a way to do something with them. That is what the $action tells.
1228 The most often used $action is "view" and is automatically assumed when
1229 no other $action was specified in the current ewiki URL. For non-existent
1230 pages alternatively the "edit" $action may get used instead.
1231
1232 So the $action now delegates control about a requested page to a subfunc
1233 or plugin of ewiki, so the stored data of the page can be used for
1234 something (viewing being again the most common thing to do with it).
1235
1236 "action/ForTheCurrentPage" is how both often looks in conjunction (again:
1237 if there is no "$action/" then "view/" will be assumed). Here the $action
1238 appears in front of the page name separated by a slash. A pagename now can
1239 contain slashes too, because ewiki can figure out, that "view/That/Page"
1240 separates into the $action being "view" and $id is "That/Page" in this
1241 example (the "view" gets mandatory in such cases).
1242
1243
1244
1245         ewiki URLs
1246         ¯¯¯¯¯¯¯¯¯¯
1247         "$action/$id" is most commonly appended as "GET parameter" to an
1248         ewiki URL, after a string like "?id=" or "?page=" - you've already
1249         noticed that!
1250
1251         There are of course other ways to design the URLs ewiki produces
1252         and uses, the PATH_INFO being one of the most favoured alternatives.
1253         (we had a paragraph on this earlier, see on top of this README)
1254
1255         Other Wikis use different URLs too, but you can tweak ewiki easily
1256         to a different behaviour, because you have the chance to pass your
1257         $action and $id to ewiki_page() from different sources. And because
1258         URL generation is encapsulated into the function ewiki_script()
1259         you could easily change just a few lines to make them look like you
1260         desire.
1261
1262         The $action can be passed as "?action=" parameter already (this is
1263         core support), so URLs could for example look like
1264         ".../my/wiki.php?id=ThisPage&action=view" ... or something alike.
1265
1266
1267
1268
1269
1270   -------------------------------------------------------------------- 6 --
1271
1272
1273
1274 Appendix
1275 ¯¯¯¯¯¯¯¯
1276 This sections lists things, that in fact have little to do with ewiki.
1277
1278
1279
1280 Apache config
1281 ¯¯¯¯¯¯¯¯¯¯¯¯¯
1282 You must of course configure your Apache (or any other Webserver) to
1283 feed .php scripts through the PHP interpreter, either libphp (Apache)
1284 or the standalone CGI PHP interpreter.
1285
1286 If your Webserver supports mod_rewrite (Apache, Nanoweb), you may wish
1287 to use it for URL beatification as described in "fragments/htaccess".
1288
1289
1290
1291
1292 PHP config
1293 ¯¯¯¯¯¯¯¯¯¯
1294 ewiki relies upon various settings of the PHP interpreter, which either
1295 can be changed with entries in the php.ini or via option settings from
1296 within .htaccess (only if you have Apache with libphp running).
1297
1298 A .htaccess option setting looks like:
1299
1300   php_option register_globals off
1301
1302 while in the "php.ini" you would just write:
1303
1304   register_globals = off
1305
1306
1307
1308 The recommended settings are:
1309
1310   magic_slashes_gpc = off       ; This was enabled for old PHP versions
1311                                 ; to help newbies writing more secure
1312          ; scripts in regards to database access (makes you wonder, which
1313          ; newbie actually could deal with databases). Nowadays this setting
1314          ; is still enabled by some providers, which try to keep their buggy
1315          ; site running.
1316          ; As a workaround (SlowSlowSlow, and not WikiWiki!) you can use
1317          ; fragments/strip_wonderful_slashes.php
1318
1319   magic_quotes_runtime = off    ; This is even more awful than the above,
1320                                 ; and if you cannot disable it, then you
1321          ; should not run ewiki on your Webserver. It is not believed to
1322          ; work correctly with that setting.
1323
1324   register_globals = off        ; This setting is a security risk, if kept
1325                                 ; enabled, because ewiki was written on a
1326          ; system where it is disabled (like with all newer PHP versions).
1327          ; It once was a very convinient setting, but the PHP language has
1328          ; long lost its sinmplicity and ease.
1329
1330   register_argc_argv = on       ; is important for 'ewikictl' & Co.
1331
1332   safe_mode = off               ; The so called 'Safe Mode' was introduced
1333                                 ; for mass hosters, which didn't want to
1334          ; deal with security guidelines and needed an easy way to "secure"
1335          ; their servers. This setting cripples various PHP functions, and
1336          ; thus will disallow to use multiple ewiki extensions. The Safe
1337          ; Mode renders it completely useless and stupid to run a webserver
1338          ; on the Unix/Linux plattform, because its strenght was to invoke
1339          ; the various fast utilities and filters through pipes. And the
1340          ; lack of this opportunity then disables many ewiki extensions.
1341
1342   allow_url_fopen = on          ; You will need these, if you want ewiki
1343   file_uploads = on             ; to deal with image caching and file
1344                                 ; uploads (of course).
1345
1346   error_reporting = ...         ; You should preferrably have this disabled,
1347                                 ; even if ewiki.php already carries an
1348          ; error_reporting() call to do exactly that.
1349          ; The ewiki code is clean, but no longer cares about PHP "Notices"
1350          ; and sometimes also "Warnings" that much.
1351
1352   cgi.force_redirect = 0        ; This is a stupid PHP option, that is only
1353                                 ; there to fix a "/cgi-bin/ install" of PHP.
1354
1355   cgi.fix_pathinfo = 0          ; PHP scrambles the PATH_INFO if you keep
1356                                 ; this enabled. However Apache 1.3 often
1357          ; returns a broken value, so this may not matter to you anyhow.
1358
1359   cgi.rfc2616_headers = ...     ; If you don't have Apache 1.3 running
1360                                 ; (any earlier versions would do, and laters
1361          ; will be fixed again), then you should enable this; though ewiki
1362          ; does not rely on it.
1363
1364   short_open_tag = ...          ; ewiki does NOT care
1365
1366   output_buffering = ...        ; ewiki does NOT care
1367
1368
1369
1370 error numbers
1371 ¯¯¯¯¯¯¯¯¯¯¯¯¯
1372 A few ewiki error messages are kept uninformative to prevent abuse of
1373 security (misconfiguration) leaks through visitors. Usually you will find
1374 an error number besides (in the tradition of OS/2 ;-), which you can then
1375 lookup here:
1376
1377
1378 ERROR #0257: is triggered by fragments/strike_register_globals to signalise
1379    that your PHP interpreter is still configured with register_globals
1380    enabled. The whole purpose of fragments/strike_... is to prevent variable
1381    injection from outside. Suddenly this is what happened if you've seen this
1382    message - but if you've discovered it yourself, then the reason for this
1383    security problem is a bogus extension plugin, which simply tried to
1384    reinsert values from one innovocation to another in a non-standard (too
1385    direct) way.
1386    Simply disable register_globals and unload the fragments/strike_...
1387    script to get rid of this error.
1388