2 rcs_id('$Id: main.php,v 1.3 2001-02-14 22:02:05 dairiki Exp $');
3 include "lib/config.php";
4 include "lib/stdlib.php";
5 include "lib/userauth.php";
7 function DeducePagename ()
9 global $pagename, $PATH_INFO;
12 return fix_magic_quotes_gpc($pagename);
15 if (ereg('^' . PATH_INFO_PREFIX . '(..*)$', $PATH_INFO, $m))
18 return gettext("FrontPage");
21 $pagename = DeducePagename();
25 $action = trim(fix_magic_quotes_gpc($action));
27 else if (isset($diff))
29 // Fix for compatibility with very old diff links in RecentChanges.
30 // (The [phpwiki:?diff=PageName] style links are fixed elsewhere.)
32 $pagename = fix_magic_quotes_gpc($diff);
40 function IsSafeAction ($action)
42 if (! ZIPDUMP_AUTH and $action == 'zip')
44 return in_array ( $action, array('browse',
45 'info', 'diff', 'search',
51 function get_auth_mode ($action)
59 if (IsSafeAction($action))
62 return 'REQUIRE_AUTH';
66 $user = new WikiUser(get_auth_mode($action));
68 // All requests require the database
69 $dbi = OpenDataBase($WikiPageStore);
71 // if there is no FrontPage, create a basic set of Wiki pages
72 if ( ! IsWikiPage($dbi, gettext("FrontPage")) )
74 include_once("lib/loadsave.php");
79 // FIXME: I think this is redundant.
80 if (!IsSafeAction($action))
81 $user->must_be_admin($action);
82 if (isset($DisabledActions) && in_array($action, $DisabledActions))
83 ExitWiki(gettext("Action $action is disabled in this wiki."));
85 // Enable the output of most of the warning messages.
86 // The warnings will screw up zip files and setpref though.
87 if ($action != 'zip' && $action != 'setprefs')
88 PostponeErrorMessages(E_NOTICE);
92 include "lib/editpage.php";
96 if (isset($searchtype) && ($searchtype == 'full')) {
97 include "lib/fullsearch.php";
100 include "lib/search.php";
105 include "lib/savepage.php";
108 include "lib/pageinfo.php";
111 include "lib/diff.php";
115 include_once("lib/loadsave.php");
116 MakeWikiZip($dbi, isset($include) && $include == 'all');
117 // I don't think it hurts to add cruft at the end of the zip file.
118 echo "\n========================================================\n";
119 echo "PhpWiki " . PHPWIKI_VERSION . " source:\n$RCS_IDS\n";
123 include_once("lib/loadsave.php");
124 LoadPostFile($dbi, 'file');
128 if (empty($directory))
129 ExitWiki(gettext("You must specify a directory to dump to"));
131 include_once("lib/loadsave.php");
132 DumpToDir($dbi, fix_magic_quotes_gpc($directory));
137 ExitWiki(gettext("You must specify a source to read from"));
139 include_once("lib/loadsave.php");
140 LoadFileOrDir($dbi, fix_magic_quotes_gpc($source));
144 include 'admin/removepage.php';
149 include "admin/lockpage.php";
150 include "lib/display.php";
154 $prefs = $user->getPreferences($GLOBALS);
155 if (!empty($edit_area_width))
156 $prefs['edit_area.width'] = $edit_area_width;
157 if (!empty($edit_area_height))
158 $prefs['edit_area.height'] = $edit_area_height;
159 $user->setPreferences($prefs);
161 PostponeErrorMessages(E_ALL & ~E_NOTICE);
163 include "lib/display.php";
169 include "lib/display.php";
173 echo QElement('p', sprintf("Bad action: '%s'", urlencode($action)));
182 // c-file-style: "ellemtel"