3 This is an convinience wrapper around the ewiki PowerSearch page. It
4 should be used to catch 404 errors ("page not found") and let the
5 wiki try to find the correct page.
7 To set it up, link this wrapper (or move it) to the docroot or where your
8 ewiki wrapper script is located. Then edit the .htaccess and add
9 following (for Apache webservers):
11 ErrorDocument 404 404finder.php
13 This wrapper should then call your ewiki wrapper/layout script, this is
14 what the $include variable is for:
17 $include = "example-1.php";
20 #-- try to guess the 'search string' from the requested URL path
21 if (isset($_REQUEST["id"])) {
26 ($url = $_SERVER["REDIRECT_URL"])
28 ($url = $_SERVER["PATH_INFO"])
30 ($url = $_SERVER["REQUEST_URI"]);
34 #-- extract $_REQUEST, strip query_string
35 if ($p = strpos($url, "?")) {
37 parse_str(substr($url, $p), $_GET);
38 $_REQUEST = array_merge($_REQUEST, $_GET);
40 $url = substr($url, 0, $p);
43 #-- strip existing parts out of the URL
45 chdir($_SERVER["DOCUMENT_ROOT"]);
46 $url = trim($url, "/");
49 while ($l = strpos($url, "/", $l+1)) {
51 if (file_exists("./" . substr($url, 0, $l))) {
53 $new_url = substr($url, $l+1);
63 #-- now use it as search string
64 $_REQUEST["id"] = "PowerSearch";
65 $_REQUEST["where"] = "content";
66 $_REQUEST["q"] = strtr("$url", "/", " ");
67 unset($_SERVER["QUERY_STRING"]);
75 foreach (array($include,"example-1.php","index.php") as $include) {
76 for ($subdir=0; $subdir<3; $subdir++) {
77 $dir = str_repeat("../",$subdir);
78 if (file_exists($dir.$include)) {