2 rcs_id('$Id: main.php,v 1.2 2001-02-13 05:54:38 dairiki Exp $');
3 include "lib/config.php";
4 include "lib/stdlib.php";
5 include "lib/userauth.php";
8 function DeducePagename ()
10 global $pagename, $PATH_INFO;
13 return fix_magic_quotes_gpc($pagename);
16 if (ereg('^' . PATH_INFO_PREFIX . '(.*)$', $PATH_INFO, $m))
19 return gettext("FrontPage");
22 $pagename = DeducePagename();
26 $action = trim(fix_magic_quotes_gpc($action));
28 else if (isset($diff))
30 // Fix for compatibility with very old diff links in RecentChanges.
31 // (The [phpwiki:?diff=PageName] style links are fixed elsewhere.)
33 $pagename = fix_magic_quotes_gpc($diff);
42 function IsSafeAction ($action)
44 if (! ZIPDUMP_AUTH and $action == 'zip')
46 return in_array ( $action, array('browse',
47 'info', 'diff', 'search',
53 function get_auth_mode ($action)
61 if (IsSafeAction($action))
64 return 'REQUIRE_AUTH';
68 $user = new WikiUser(get_auth_mode($action));
70 // All requests require the database
71 $dbi = OpenDataBase($WikiPageStore);
73 // if there is no FrontPage, create a basic set of Wiki pages
74 if ( ! IsWikiPage($dbi, gettext("FrontPage")) )
76 include_once("lib/loadsave.php");
81 // FIXME: I think this is redundant.
82 if (!IsSafeAction($action))
83 $user->must_be_admin($action);
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"