2 rcs_id('$Id: main.php,v 1.4 2001-02-15 19:32:34 dairiki Exp $');
3 include "lib/config.php";
4 include "lib/stdlib.php";
5 include "lib/userauth.php";
7 if (USE_PATH_INFO && !isset($PATH_INFO))
9 header("Location: " . SERVER_URL . $REQUEST_URI);
13 function DeducePagename ()
15 global $pagename, $PATH_INFO;
18 return fix_magic_quotes_gpc($pagename);
20 if (USE_PATH_INFO && isset($PATH_INFO))
22 fix_magic_quotes_gpc($PATH_INFO);
23 if (ereg('^' . PATH_INFO_PREFIX . '(..*)$', $PATH_INFO, $m))
27 return gettext("FrontPage");
30 $pagename = DeducePagename();
34 $action = trim(fix_magic_quotes_gpc($action));
36 else if (isset($diff))
38 // Fix for compatibility with very old diff links in RecentChanges.
39 // (The [phpwiki:?diff=PageName] style links are fixed elsewhere.)
41 $pagename = fix_magic_quotes_gpc($diff);
49 function IsSafeAction ($action)
51 if (! ZIPDUMP_AUTH and $action == 'zip')
53 return in_array ( $action, array('browse',
54 'info', 'diff', 'search',
60 function get_auth_mode ($action)
68 if (IsSafeAction($action))
71 return 'REQUIRE_AUTH';
75 $user = new WikiUser(get_auth_mode($action));
77 // All requests require the database
78 $dbi = OpenDataBase($WikiPageStore);
80 // if there is no FrontPage, create a basic set of Wiki pages
81 if ( ! IsWikiPage($dbi, gettext("FrontPage")) )
83 include_once("lib/loadsave.php");
88 // FIXME: I think this is redundant.
89 if (!IsSafeAction($action))
90 $user->must_be_admin($action);
91 if (isset($DisabledActions) && in_array($action, $DisabledActions))
92 ExitWiki(gettext("Action $action is disabled in this wiki."));
94 // Enable the output of most of the warning messages.
95 // The warnings will screw up zip files and setpref though.
96 if ($action != 'zip' && $action != 'setprefs')
97 PostponeErrorMessages(E_NOTICE);
101 include "lib/editpage.php";
105 if (isset($searchtype) && ($searchtype == 'full')) {
106 include "lib/fullsearch.php";
109 include "lib/search.php";
114 include "lib/savepage.php";
117 include "lib/pageinfo.php";
120 include "lib/diff.php";
124 include_once("lib/loadsave.php");
125 MakeWikiZip($dbi, isset($include) && $include == 'all');
126 // I don't think it hurts to add cruft at the end of the zip file.
127 echo "\n========================================================\n";
128 echo "PhpWiki " . PHPWIKI_VERSION . " source:\n$RCS_IDS\n";
132 include_once("lib/loadsave.php");
133 LoadPostFile($dbi, 'file');
137 if (empty($directory))
138 ExitWiki(gettext("You must specify a directory to dump to"));
140 include_once("lib/loadsave.php");
141 DumpToDir($dbi, fix_magic_quotes_gpc($directory));
146 ExitWiki(gettext("You must specify a source to read from"));
148 include_once("lib/loadsave.php");
149 LoadFileOrDir($dbi, fix_magic_quotes_gpc($source));
153 include 'admin/removepage.php';
158 include "admin/lockpage.php";
159 include "lib/display.php";
163 $prefs = $user->getPreferences($GLOBALS);
164 if (!empty($edit_area_width))
165 $prefs['edit_area.width'] = $edit_area_width;
166 if (!empty($edit_area_height))
167 $prefs['edit_area.height'] = $edit_area_height;
168 $user->setPreferences($prefs);
170 PostponeErrorMessages(E_ALL & ~E_NOTICE);
172 include "lib/display.php";
178 include "lib/display.php";
182 echo QElement('p', sprintf("Bad action: '%s'", urlencode($action)));
191 // c-file-style: "ellemtel"