4 This plugin is used as SetupWizard and initializes the database with
5 the distributed default pages from the ./init-pages directory. It
6 gives some configuration advice, when it thinks this is necessary.
8 You need this plugin to run only once (when you first run the Wiki),
9 afterwards you can and should comment out the include() directive which
14 $ewiki_plugins["handler"][-125] = "ewiki_initialization_wizard";
15 $ewiki_plugins["page_init"][] = "ewiki_initialization_wizard2";
18 function ewiki_initialization_wizard2($id, &$data, $action) {
19 global $ewiki_plugins;
21 #-- disable the default handler
22 unset($ewiki_plugins["handler"][-105]);
25 function ewiki_initialization_wizard($id, &$data, &$action) {
27 global $ewiki_plugins;
29 #-- proceed only if frontpage missing or explicetely requested
30 if ((strtolower($id)=="wikisetupwizard") ||
($id==EWIKI_PAGE_INDEX
) && ($action=="edit") && empty($data["version"]) && !($_REQUEST["abort"])) {
32 if ($_REQUEST["abort"]) {
35 #-- first print some what-would-we-do-stats
36 elseif (empty($_REQUEST["init"])) {
38 $o = "<h2>WikiSetupWizard</h2>\n";
39 $o .= "You don't have any pages in your Wiki yet, so we should try to read-in the default ones from <tt>init-pages/</tt> now.<br /><br />";
41 $o .= '<a href="'.ewiki_script("",$id,array("init"=>"now")).'">[InitializeWikiDatabase]</a>';
43 $o .= '<a href="'.ewiki_script("",$id,array("abort"=>"this")).'">[NoThanks]</a>';
46 #-- analyze and print settings and misconfigurations
47 $pf_db = $ewiki_plugins["database"][0];
48 $db = substr($pf_db, strrpos($pf_db, "_") +
1);
49 $o .= '<table border="0" width="90%" class="diagnosis">';
50 $o .= '<tr><td>DatabaseBackend</td><td>';
51 $o .= "<b>" . $db . "</b><br />";
53 $o .= "<small>_DBFILES_DIR='</small><tt>" . EWIKI_DBFILES_DIRECTORY
. "'</tt>";
54 if (strpos(EWIKI_DBFILES_DIRECTORY
, "tmp")) {
55 $o .= "<br /><b>Warning</b>: Storing your pages into a temporary directory is not what you want (there they would get deleted randomly), except for testing purposes of course. See the README.";
63 $o .= '<tr><td>WikiSoftware</td><td>ewiki '.EWIKI_VERSION
."</td></tr>";
67 if (ini_get("magic_quotes")) {
68 $o.= "<b>Warning</b>: Your PHP interpreter has enabled the ugly and outdated '<i>magic_quotes</i>'. This will lead to problems, so please ask your provider to correct it; or fix it yourself with .htaccess settings as documented in the README. Otherwise don't forget to include() the <tt>fragments/strip_wonderful_slashes.php</tt> (it's ok to proceed for the moment).<br /><br />";
70 if (ini_get("register_globals")) {
71 $o.= "<b>Security warning</b>: The horrible '<i>register_globals</i>' setting is enabled. Without always using <tt>fragments/strike_register_globals.php</tt> or letting your provider fix that, you could get into trouble some day.<br /><br />";
74 return('<div class="wiki view WikiSetupWizard">' . $o . '</div>');
78 #-- actually initialize the database
80 ewiki_database("INIT", array());
81 if ($dh = @opendir
($path=EWIKI_INIT_PAGES
)) {
82 while ($filename = readdir($dh)) {
83 if (preg_match('/^(['.EWIKI_CHARS_U
.']+['.EWIKI_CHARS_L
.']+\w*)+/', $filename)) {
84 $found = ewiki_database("FIND", array($filename));
85 if (! $found[$filename]) {
86 $content = implode("", file("$path/$filename"));
87 ewiki_scan_wikiwords($content, $ewiki_links, "_STRIP_EMAIL=1");
88 $refs = "\n\n" . implode("\n", array_keys($ewiki_links)) . "\n\n";
93 "content" => $content,
94 "author" => ewiki_author("ewiki_initialize"),
96 "lastmodified" => filemtime("$path/$filename"),
97 "created" => filectime("$path/$filename") // (not exact)
99 ewiki_database("WRITE", $save);
106 return("<b>ewiki error</b>: could not read from directory ". realpath($path) ."<br />\n");
109 #-- try to view/ that newly inserted page
110 if ($data = ewiki_database("GET", array("id"=>$id))) {
114 #-- let ewiki_page() proceed as usual