function ewiki_initialization_wizard($id, &$data, &$action) { global $ewiki_plugins; #-- proceed only if frontpage missing or explicetely requested if (strtolower($id) == "wikisetupwizard" || $id == EWIKI_PAGE_INDEX && $action == "edit" && empty($data["version"]) && !$_REQUEST["abort"]) { if ($_REQUEST["abort"]) { } elseif (empty($_REQUEST["init"])) { $o = "<h2>WikiSetupWizard</h2>\n"; $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 />"; $o .= '<a href="' . ewiki_script("", $id, array("init" => "now")) . '">[InitializeWikiDatabase]</a>'; $o .= " "; $o .= '<a href="' . ewiki_script("", $id, array("abort" => "this")) . '">[NoThanks]</a>'; $o .= "<br /><br />"; #-- analyze and print settings and misconfigurations $pf_db = $ewiki_plugins["database"][0]; $db = substr("_{$pf_db}", strrpos($pf_db, "_") + 1); $o .= '<table border="0" width="90%" class="diagnosis">'; $o .= '<tr><td>DatabaseBackend</td><td>'; $o .= "<b>" . $db . "</b><br />"; if ($db == "files" || strstr($db, "f2")) { $o .= "<small>_DBFILES_DIR='</small><tt>" . EWIKI_DBFILES_DIRECTORY . "'</tt>"; if (strpos(EWIKI_DBFILES_DIRECTORY, "tmp")) { $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."; } } else { $o .= "(looks ok)"; } $o .= "</td></tr>"; $o .= '<tr><td>WikiSoftware</td><td>ewiki ' . EWIKI_VERSION . "</td></tr>"; $o .= "</table>"; #-- more diagnosis if (ini_get("magic_quotes")) { $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 />"; } if (ini_get("register_globals")) { $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 />"; } return '<div class="wiki view WikiSetupWizard">' . $o . '</div>'; } else { ewiki_db::INIT(); if ($dh = @opendir($path = EWIKI_INIT_PAGES)) { while ($filename = readdir($dh)) { if (preg_match('/^([' . EWIKI_CHARS_U . ']+[' . EWIKI_CHARS_L . ']+\\w*)+/', $filename)) { $found = ewiki_db::FIND(array($filename)); if (!$found[$filename]) { $content = implode("", file("{$path}/{$filename}")); ewiki_scan_wikiwords($content, $ewiki_links, "_STRIP_EMAIL=1"); $refs = "\n\n" . implode("\n", array_keys($ewiki_links)) . "\n\n"; $save = array("id" => "{$filename}", "version" => "1", "flags" => "1", "content" => $content, "author" => ewiki_author("ewiki_initialize"), "refs" => $refs, "lastmodified" => filemtime("{$path}/{$filename}"), "created" => filectime("{$path}/{$filename}")); ewiki_db::WRITE($save); } } } closedir($dh); ewiki_log("initializing database", 0); } else { return "<b>ewiki error</b>: could not read from directory " . realpath($path) . "<br />\n"; } #-- try to view/ that newly inserted page if ($data = ewiki_db::GET($id)) { $action = "view"; } #-- let ewiki_page() proceed as usual return ""; } } }