2 rcs_id('$Id: main.php,v 1.139 2004-05-02 15:10:07 rurban Exp $');
4 define ('USE_PREFS_IN_PAGE', true);
6 //include "lib/config.php";
7 require_once("lib/stdlib.php");
8 require_once('lib/Request.php');
9 require_once('lib/WikiDB.php');
11 require_once("lib/WikiUserNew.php");
13 require_once("lib/WikiUser.php");
14 require_once("lib/WikiGroup.php");
15 require_once("lib/PagePerm.php");
17 class WikiRequest extends Request {
20 function WikiRequest () {
21 $this->_dbi = WikiDB::open($GLOBALS['DBParams']);
23 include_once('lib/DB_Session.php');
24 $prefix = isset($GLOBALS['DBParams']['prefix']) ? $GLOBALS['DBParams']['prefix'] : '';
25 if (in_array('File',$GLOBALS['USER_AUTH_ORDER'])) {
26 include_once('lib/pear/File_Passwd.php');
28 $dbi = $this->getDbh();
29 $this->_dbsession = & new DB_Session($dbi,$prefix . $GLOBALS['DBParams']['db_session_table']);
31 // Fixme: Does pear reset the error mask to 1? We have to find the culprit
32 $x = error_reporting();
37 $this->setArg('pagename', $this->_deducePagename());
38 $this->setArg('action', $this->_deduceAction());
40 // Restore auth state. This doesn't check for proper authorization!
41 if (ENABLE_USER_NEW) {
42 $userid = $this->_deduceUsername();
43 if (isset($this->_user) and
44 !empty($this->_user->_authhow) and
45 $this->_user->_authhow == 'session')
47 // users might switch in a session between the two objects.
48 // restore old auth level here or in updateAuthAndPrefs?
49 //$user = $this->getSessionVar('wiki_user');
50 // revive db handle, because these don't survive sessions
51 if (isset($this->_user) and
52 ( ! isa($this->_user,WikiUserClassname())
53 or (strtolower(get_class($this->_user)) == '_passuser')))
55 $this->_user = WikiUser($userid,$this->_user->_prefs);
57 unset($this->_user->_HomePagehandle);
58 $this->_user->hasHomePage();
59 // update the lockfile filehandle
60 if ( isa($this->_user,'_FilePassUser') and
61 $this->_user->_file->lockfile and
62 !$this->_user->_file->fplock )
64 $this->_user = new _FilePassUser($userid,$this->_user->_prefs,$this->_user->_file->filename);
67 if (!isa($user,WikiUserClassname()) or empty($this->_user->_level)) {
68 $user = UpgradeUser($this->_user,$user);
71 $this->_prefs = & $this->_user->_prefs;
73 $user = WikiUser($userid);
74 $this->_user = & $user;
75 $this->_prefs = & $this->_user->_prefs;
78 $this->_user = new WikiUser($this, $this->_deduceUsername());
79 $this->_prefs = $this->_user->getPreferences();
83 function initializeLang () {
84 if ($user_lang = $this->getPref('lang')) {
85 //trigger_error("DEBUG: initializeLang() ". $user_lang ." calling update_locale()...");
86 update_locale($user_lang);
87 FindLocalizedButtonFile(".",'missing_ok','reinit');
91 function initializeTheme () {
95 if ($user_theme = $this->getPref('theme'))
96 include_once("themes/$user_theme/themeinfo.php");
97 if (empty($Theme) and defined('THEME'))
98 include_once("themes/" . THEME . "/themeinfo.php");
100 include_once("themes/default/themeinfo.php");
101 assert(!empty($Theme));
104 // This really maybe should be part of the constructor, but since it
105 // may involve HTML/template output, the global $request really needs
106 // to be initialized before we do this stuff.
107 function updateAuthAndPrefs () {
109 if (isset($this->_user) and (!isa($this->_user,WikiUserClassname()))) {
110 $this->_user = false;
112 // Handle authentication request, if any.
113 if ($auth_args = $this->getArg('auth')) {
114 $this->setArg('auth', false);
115 $this->_handleAuthRequest($auth_args); // possible NORETURN
117 elseif ( ! $this->_user or
118 (isa($this->_user,WikiUserClassname()) and ! $this->_user->isSignedIn())) {
119 // If not auth request, try to sign in as saved user.
120 if (($saved_user = $this->getPref('userid')) != false) {
121 $this->_signIn($saved_user);
125 // Save preferences in session and cookie
126 if (isset($this->_user) and
127 (!isset($this->_user->_authhow) or $this->_user->_authhow != 'session')) {
129 $this->_user->setPreferences($this->_prefs, $id_only);
131 $this->setSessionVar('wiki_user', $this->_user);
132 //$this->setSessionVar('wiki_prefs', $this->_prefs);
135 // Ensure user has permissions for action
136 $require_level = $this->requiredAuthority($this->getArg('action'));
137 if (! $this->_user->hasAuthority($require_level))
138 $this->_notAuthorized($require_level); // NORETURN
141 function getUser () {
142 if (isset($this->_user))
145 return $GLOBALS['ForbiddenUser'];
148 function getPrefs () {
149 return $this->_prefs;
152 // Convenience function:
153 function getPref ($key) {
154 if (isset($this->_prefs))
155 return $this->_prefs->get($key);
163 * Get requested page from the page database.
164 * By default it will grab the page requested via the URL
166 * This is a convenience function.
167 * @param string $pagename Name of page to get.
168 * @return WikiDB_Page Object with methods to pull data from
169 * database for the page requested.
171 function getPage ($pagename = false) {
172 if (!isset($this->_dbi))
175 $pagename = $this->getArg('pagename');
176 return $this->_dbi->getPage($pagename);
179 /** Get URL for POST actions.
181 * Officially, we should just use SCRIPT_NAME (or some such),
182 * but that causes problems when we try to issue a redirect, e.g.
183 * after saving a page.
185 * Some browsers (at least NS4 and Mozilla 0.97 won't accept
186 * a redirect from a page to itself.)
188 * So, as a HACK, we include pagename and action as query args in
189 * the URL. (These should be ignored when we receive the POST
192 function getPostURL ($pagename=false) {
193 if ($pagename === false)
194 $pagename = $this->getArg('pagename');
195 $action = $this->getArg('action');
196 if (!empty($_GET['start_debug'])) // zend ide support
197 return WikiURL($pagename, array('action' => $action, 'start_debug' => 1));
199 return WikiURL($pagename, array('action' => $action));
202 function _handleAuthRequest ($auth_args) {
203 if (!is_array($auth_args))
206 // Ignore password unless POST'ed.
207 if (!$this->isPost())
208 unset($auth_args['passwd']);
210 $olduser = $this->_user;
211 $user = $this->_user->AuthCheck($auth_args);
212 if (isa($user,WikiUserClassname())) {
213 // Successful login (or logout.)
214 $this->_setUser($user);
216 elseif (is_string($user)) {
217 // Login attempt failed.
218 $fail_message = $user;
219 $auth_args['pass_required'] = true;
220 // If no password was submitted, it's not really
221 // a failure --- just need to prompt for password...
222 if (!ALLOW_USER_PASSWORDS
224 and !isset($auth_args['passwd']))
226 $fail_message = false;
228 $olduser->PrintLoginForm($this, $auth_args, $fail_message);
229 $this->finish(); //NORETURN
232 // Login request cancelled.
237 * Attempt to sign in (bogo-login).
241 * @param $userid string Userid to attempt to sign in as.
244 function _signIn ($userid) {
245 if (ENABLE_USER_NEW) {
247 $this->_user = new _BogoUser($userid);
249 $this->_user = new _PassUser($userid);
251 $user = $this->_user->AuthCheck(array('userid' => $userid));
252 if (isa($user,WikiUserClassname())) {
253 $this->_setUser($user); // success!
257 // login or logout or restore state
258 function _setUser ($user) {
259 $this->_user = $user;
260 $this->setCookieVar('WIKI_ID', $user->getAuthenticatedId(), 365);
261 $this->setSessionVar('wiki_user', $user);
262 if ($user->isSignedIn())
263 $user->_authhow = 'signin';
265 // Save userid to prefs..
266 if (!($this->_prefs = $this->_user->getPreferences()))
267 $this->_prefs = $this->_user->_prefs;
268 $this->_prefs->set('userid',
269 $user->isSignedIn() ? $user->getId() : '');
270 $this->initializeTheme();
273 /* Permission system */
275 function _notAuthorized ($require_level) {
276 // Display the authority message in the Wiki's default
277 // language, in case it is not english.
279 // Note that normally a user will not see such an error once
280 // logged in, unless the admin has altered the default
281 // disallowed wikiactions. In that case we should probably
282 // check the user's language prefs too at this point; this
283 // would be a situation which is not really handled with the
285 if (empty($GLOBALS['LANG']))
286 update_locale(DEFAULT_LANGUAGE);
288 // User does not have required authority. Prompt for login.
289 $what = $this->getActionDescription($this->getArg('action'));
291 if ($require_level == WIKIAUTH_UNOBTAINABLE) {
292 $this->finish(fmt("%s is disallowed on this wiki.",
293 $this->getDisallowedActionDescription($this->getArg('action'))));
295 elseif ($require_level == WIKIAUTH_BOGO)
296 $msg = fmt("You must sign in to %s.", $what);
297 elseif ($require_level == WIKIAUTH_USER)
298 $msg = fmt("You must log in to %s.", $what);
300 $msg = fmt("You must be an administrator to %s.", $what);
301 $pass_required = ($require_level >= WIKIAUTH_USER);
303 $this->_user->PrintLoginForm($this, compact('require_level','pass_required'), $msg);
304 $this->finish(); // NORETURN
307 // Fixme: for PagePermissions we'll need other strings,
308 // relevant to the requested page, not just for the action on the whole wiki.
309 function getActionDescription($action) {
310 static $actionDescriptions;
311 if (! $actionDescriptions) {
313 = array('browse' => _("view this page"),
314 'diff' => _("diff this page"),
315 'dumphtml' => _("dump html pages"),
316 'dumpserial' => _("dump serial pages"),
317 'edit' => _("edit this page"),
318 'create' => _("create this page"),
319 'loadfile' => _("load files into this wiki"),
320 'lock' => _("lock this page"),
321 'remove' => _("remove this page"),
322 'unlock' => _("unlock this page"),
323 'upload' => _("upload a zip dump"),
324 'verify' => _("verify the current action"),
325 'viewsource' => _("view the source of this page"),
326 'xmlrpc' => _("access this wiki via XML-RPC"),
327 'soap' => _("access this wiki via SOAP"),
328 'zip' => _("download a zip dump from this wiki"),
329 'ziphtml' => _("download an html zip dump from this wiki")
332 if (in_array($action, array_keys($actionDescriptions)))
333 return $actionDescriptions[$action];
337 function getDisallowedActionDescription($action) {
338 static $disallowedActionDescriptions;
339 if (! $disallowedActionDescriptions) {
340 $disallowedActionDescriptions
341 = array('browse' => _("Browsing pages"),
342 'diff' => _("Diffing pages"),
343 'dumphtml' => _("Dumping html pages"),
344 'dumpserial' => _("Dumping serial pages"),
345 'edit' => _("Editing pages"),
346 'create' => _("Creating pages"),
347 'loadfile' => _("Loading files"),
348 'lock' => _("Locking pages"),
349 'remove' => _("Removing pages"),
350 'unlock' => _("Unlocking pages"),
351 'upload' => _("Uploading zip dumps"),
352 'verify' => _("Verify the current action"),
353 'viewsource' => _("Viewing the source of pages"),
354 'xmlrpc' => _("XML-RPC access"),
355 'soap' => _("SOAP access"),
356 'zip' => _("Downloading zip dumps"),
357 'ziphtml' => _("Downloading html zip dumps")
360 if (in_array($action, array_keys($disallowedActionDescriptions)))
361 return $disallowedActionDescriptions[$action];
366 function requiredAuthority ($action) {
367 $auth = $this->requiredAuthorityForAction($action);
368 if (!ALLOW_ANON_USER) return WIKIAUTH_USER;
371 * This is a hook for plugins to require authority
372 * for posting to them.
374 * IMPORTANT: this is not a secure check, so the plugin
375 * may not assume that any POSTs to it are authorized.
376 * All this does is cause PhpWiki to prompt for login
377 * if the user doesn't have the required authority.
379 if ($this->isPost()) {
380 $post_auth = $this->getArg('require_authority_for_post');
381 if ($post_auth !== false)
382 $auth = max($auth, $post_auth);
387 function requiredAuthorityForAction ($action) {
388 if (class_exists("PagePermission")) {
389 return requiredAuthorityForPage($action);
399 return WIKIAUTH_ANON;
403 if (defined('ZIPDUMP_AUTH') && ZIPDUMP_AUTH)
404 return WIKIAUTH_ADMIN;
405 return WIKIAUTH_ANON;
409 if (defined('REQUIRE_SIGNIN_BEFORE_EDIT') && REQUIRE_SIGNIN_BEFORE_EDIT)
410 return WIKIAUTH_BOGO;
411 return WIKIAUTH_ANON;
412 // return WIKIAUTH_BOGO;
415 $page = $this->getPage();
416 $current = $page->getCurrentRevision();
417 if ($current->hasDefaultContents())
418 return $this->requiredAuthorityForAction('edit');
419 return $this->requiredAuthorityForAction('browse');
429 return WIKIAUTH_ADMIN;
431 global $WikiNameRegexp;
432 if (preg_match("/$WikiNameRegexp\Z/A", $action))
433 return WIKIAUTH_ANON; // ActionPage.
435 return WIKIAUTH_ADMIN;
439 /* End of Permission system */
441 function possiblyDeflowerVirginWiki () {
442 if ($this->getArg('action') != 'browse')
444 if ($this->getArg('pagename') != HOME_PAGE)
447 $page = $this->getPage();
448 $current = $page->getCurrentRevision();
449 if ($current->getVersion() > 0)
450 return; // Homepage exists.
452 include('lib/loadsave.php');
454 $this->finish(); // NORETURN
457 function handleAction () {
458 $action = $this->getArg('action');
459 $method = "action_$action";
460 if (method_exists($this, $method)) {
463 elseif ($page = $this->findActionPage($action)) {
464 $this->actionpage($page);
467 $this->finish(fmt("%s: Bad action", $action));
471 function finish ($errormsg = false) {
475 exit(); // just in case CloseDataBase calls us
478 if (!empty($this->_dbi) && !USE_DB_SESSION)
479 $this->_dbi->close();
482 global $ErrorManager;
483 $ErrorManager->flushPostponedErrors();
485 if (!empty($errormsg)) {
488 HTML::h2(_("Fatal PhpWiki Error")),
491 echo "\n</body></html>";
495 if (!empty($this->_dbi))
496 $this->_dbi->close();
502 function _deducePagename () {
503 if ($this->getArg('pagename'))
504 return $this->getArg('pagename');
507 $pathinfo = $this->get('PATH_INFO');
508 $tail = substr($pathinfo, strlen(PATH_INFO_PREFIX));
510 if ($tail != '' and $pathinfo == PATH_INFO_PREFIX . $tail) {
514 elseif ($this->isPost()) {
516 * In general, for security reasons, HTTP_GET_VARS should be ignored
517 * on POST requests, but we make an exception here (only for pagename).
519 * The justifcation for this hack is the following
520 * asymmetry: When POSTing with USE_PATH_INFO set, the
521 * pagename can (and should) be communicated through the
522 * request URL via PATH_INFO. When POSTing with
523 * USE_PATH_INFO off, this cannot be done --- the only way
524 * to communicate the pagename through the URL is via
525 * QUERY_ARGS (HTTP_GET_VARS).
527 global $HTTP_GET_VARS;
528 if (isset($HTTP_GET_VARS['pagename'])) {
529 return $HTTP_GET_VARS['pagename'];
534 * Support for PhpWiki 1.2 style requests.
536 $query_string = $this->get('QUERY_STRING');
537 if (preg_match('/^[^&=]+$/', $query_string)) {
538 return urldecode($query_string);
544 function _deduceAction () {
545 if (!($action = $this->getArg('action'))) {
546 // Detect XML-RPC requests
548 && $this->get('CONTENT_TYPE') == 'text/xml') {
549 global $HTTP_RAW_POST_DATA;
550 if (strstr($HTTP_RAW_POST_DATA, '<methodCall>')) {
555 return 'browse'; // Default if no action specified.
558 if (method_exists($this, "action_$action"))
561 // Allow for, e.g. action=LikePages
562 if ($this->isActionPage($action))
565 trigger_error("$action: Unknown action", E_USER_NOTICE);
569 function _deduceUsername() {
570 global $HTTP_SERVER_VARS, $HTTP_ENV_VARS;
571 if (!empty($this->args['auth']) and !empty($this->args['auth']['userid']))
572 return $this->args['auth']['userid'];
573 if (!empty($HTTP_SERVER_VARS['PHP_AUTH_USER']))
574 return $HTTP_SERVER_VARS['PHP_AUTH_USER'];
575 if (!empty($HTTP_ENV_VARS['REMOTE_USER']))
576 return $HTTP_ENV_VARS['REMOTE_USER'];
578 if ($user = $this->getSessionVar('wiki_user')) {
579 $this->_user = $user;
580 $this->_user->_authhow = 'session';
581 return ENABLE_USER_NEW ? $user->UserName() : $this->_user;
583 if ($userid = $this->getCookieVar('WIKI_ID')) {
584 if (!empty($userid) and substr($userid,0,2) != 's:') {
585 $this->_user->authhow = 'cookie';
592 function _isActionPage ($pagename) {
593 $dbi = $this->getDbh();
594 $page = $dbi->getPage($pagename);
595 $rev = $page->getCurrentRevision();
596 // FIXME: more restrictive check for sane plugin?
597 if (strstr($rev->getPackedContent(), '<?plugin'))
599 if (!$rev->hasDefaultContents())
600 trigger_error("$pagename: Does not appear to be an 'action page'", E_USER_NOTICE);
604 function findActionPage ($action) {
607 // check for translated version, as per users preferred language
608 // (or system default in case it is not en)
609 $translation = gettext($action);
611 if (isset($cache) and isset($cache[$translation]))
612 return $cache[$translation];
614 // check for cached translated version
615 if ($this->_isActionPage($translation))
616 return $cache[$action] = $translation;
618 // Allow for, e.g. action=LikePages
619 global $WikiNameRegexp;
620 if (!preg_match("/$WikiNameRegexp\\Z/A", $action))
621 return $cache[$action] = false;
623 // check for translated version (default language)
625 if ($LANG != DEFAULT_LANGUAGE and $LANG != "en") {
627 //trigger_error("DEBUG: findActionPage() ". DEFAULT_LANGUAGE." calling update_locale()...");
628 update_locale(DEFAULT_LANGUAGE);
629 $default = gettext($action);
630 //trigger_error("DEBUG: findActionPage() ". $save_lang." restoring save_lang, calling update_locale()...");
631 update_locale($save_lang);
632 if ($this->_isActionPage($default))
633 return $cache[$action] = $default;
636 $default = $translation;
639 // check for english version
640 if ($action != $translation and $action != $default) {
641 if ($this->_isActionPage($action))
642 return $cache[$action] = $action;
645 trigger_error("$action: Cannot find action page", E_USER_NOTICE);
646 return $cache[$action] = false;
649 function isActionPage ($pagename) {
650 return $this->findActionPage($pagename);
653 function action_browse () {
654 $this->buffer_output();
655 include_once("lib/display.php");
659 function action_verify () {
660 $this->action_browse();
663 function actionpage ($action) {
664 $this->buffer_output();
665 include_once("lib/display.php");
666 actionPage($this, $action);
669 function action_diff () {
670 $this->buffer_output();
671 include_once "lib/diff.php";
675 function action_search () {
676 // This is obsolete: reformulate URL and redirect.
677 // FIXME: this whole section should probably be deleted.
678 if ($this->getArg('searchtype') == 'full') {
679 $search_page = _("FullTextSearch");
682 $search_page = _("TitleSearch");
684 $this->redirect(WikiURL($search_page,
685 array('s' => $this->getArg('searchterm')),
689 function action_edit () {
690 $this->buffer_output();
691 include "lib/editpage.php";
692 $e = new PageEditor ($this);
696 function action_create () {
697 $this->action_edit();
700 function action_viewsource () {
701 $this->buffer_output();
702 include "lib/editpage.php";
703 $e = new PageEditor ($this);
707 function action_lock () {
708 $page = $this->getPage();
709 $page->set('locked', true);
710 $this->action_browse();
713 function action_unlock () {
714 // FIXME: This check is redundant.
715 //$user->requireAuth(WIKIAUTH_ADMIN);
716 $page = $this->getPage();
717 $page->set('locked', false);
718 $this->action_browse();
721 function action_remove () {
722 // FIXME: This check is redundant.
723 //$user->requireAuth(WIKIAUTH_ADMIN);
724 $pagename = $this->getArg('pagename');
725 if (strstr($pagename,_('PhpWikiAdministration'))) {
726 $this->action_browse();
728 include('lib/removepage.php');
733 function action_xmlrpc () {
734 include_once("lib/XmlRpcServer.php");
735 $xmlrpc = new XmlRpcServer($this);
739 function action_zip () {
740 include_once("lib/loadsave.php");
742 // I don't think it hurts to add cruft at the end of the zip file.
743 echo "\n========================================================\n";
744 echo "PhpWiki " . PHPWIKI_VERSION . " source:\n$GLOBALS[RCS_IDS]\n";
747 function action_ziphtml () {
748 include_once("lib/loadsave.php");
749 MakeWikiZipHtml($this);
750 // I don't think it hurts to add cruft at the end of the zip file.
751 echo "\n========================================================\n";
752 echo "PhpWiki " . PHPWIKI_VERSION . " source:\n$GLOBALS[RCS_IDS]\n";
755 function action_dumpserial () {
756 include_once("lib/loadsave.php");
760 function action_dumphtml () {
761 include_once("lib/loadsave.php");
762 DumpHtmlToDir($this);
765 function action_upload () {
766 include_once("lib/loadsave.php");
770 function action_upgrade () {
771 include_once("lib/loadsave.php");
772 include_once("lib/upgrade.php");
776 function action_loadfile () {
777 include_once("lib/loadsave.php");
778 LoadFileOrDir($this);
783 function is_safe_action ($action) {
784 return WikiRequest::requiredAuthorityForAction($action) < WIKIAUTH_ADMIN;
787 function validateSessionPath() {
788 // Try to defer any session.save_path PHP errors before any html
789 // is output, which causes some versions of IE to display a blank
790 // page (due to its strict mode while parsing a page?).
791 if (! is_writeable(ini_get('session.save_path'))) {
794 (sprintf(_("%s is not writable."),
795 _("The session.save_path directory"))
797 . sprintf(_("Please ensure that %s is writable, or redefine %s in index.php."),
798 sprintf(_("the directory '%s'"),
799 ini_get('session.save_path')),
802 . sprintf(_("Attempting to use the directory '%s' instead."),
805 if (! is_writeable($tmpdir)) {
807 (sprintf(_("%s is not writable."), $tmpdir)
809 . _("Users will not be able to sign in.")
813 ini_set('session.save_path', $tmpdir);
819 validateSessionPath();
823 if (DEBUG and extension_loaded("apd"))
824 apd_set_session_trace(9);
825 $request = new WikiRequest();
828 * Allow for disabling of markup cache.
829 * (Mostly for debugging ... hopefully.)
831 * See also <?plugin WikiAdminUtils action=purge-cache ?>
833 if (!defined('WIKIDB_NOCACHE_MARKUP') and $request->getArg('nocache'))
834 define('WIKIDB_NOCACHE_MARKUP', $request->getArg('nocache'));
836 // Initialize with system defaults in case user not logged in.
837 // Should this go into constructor?
838 $request->initializeTheme();
840 $request->updateAuthAndPrefs();
841 $request->initializeLang();
843 // Enable the output of most of the warning messages.
844 // The warnings will screw up zip files though.
845 global $ErrorManager;
846 if (substr($request->getArg('action'), 0, 3) != 'zip') {
847 $ErrorManager->setPostponedErrorMask(E_NOTICE|E_USER_NOTICE);
848 //$ErrorManager->setPostponedErrorMask(0);
852 //if ($user->is_authenticated())
853 // $LogEntry->user = $user->getId();
855 $request->possiblyDeflowerVirginWiki();
857 if (defined('WIKI_XMLRPC') and WIKI_XMLRPC) return;
858 if (defined('WIKI_SOAP') and WIKI_SOAP) return;
860 $validators = array('wikiname' => WIKI_NAME,
861 'args' => hash($request->getArgs()),
862 'prefs' => hash($request->getPrefs()));
863 if (CACHE_CONTROL == 'STRICT') {
864 $dbi = $request->getDbh();
865 $timestamp = $dbi->getTimestamp();
866 $validators['mtime'] = $timestamp;
867 $validators['%mtime'] = (int)$timestamp;
869 // FIXME: we should try to generate strong validators when possible,
870 // but for now, our validator is weak, since equal validators do not
871 // indicate byte-level equality of content. (Due to DEBUG timing output, etc...)
873 // (If DEBUG if off, this may be a strong validator, but I'm going
874 // to go the paranoid route here pending further study and testing.)
876 $validators['%weak'] = true;
878 $request->setValidators($validators);
880 $request->handleAction();
882 if (defined('DEBUG') and DEBUG & 4) phpinfo(INFO_VARIABLES);
886 $x = error_reporting(); // why is it 1 here? should be E_ALL
887 error_reporting(E_ALL);
891 // $Log: not supported by cvs2svn $
892 // Revision 1.138 2004/05/01 15:59:29 rurban
893 // more php-4.0.6 compatibility: superglobals
895 // Revision 1.137 2004/04/29 19:39:44 rurban
896 // special support for formatted plugins (one-liners)
897 // like <small><plugin BlaBla ></small>
898 // iter->asArray() helper for PopularNearby
899 // db_session for older php's (no &func() allowed)
901 // Revision 1.136 2004/04/29 17:18:19 zorloc
902 // Fixes permission failure issues. With PagePermissions and Disabled Actions when user did not have permission WIKIAUTH_FORBIDDEN was returned. In WikiUser this was ok because WIKIAUTH_FORBIDDEN had a value of 11 -- thus no user could perform that action. But WikiUserNew has a WIKIAUTH_FORBIDDEN value of -1 -- thus a user without sufficent permission to do anything. The solution is a new high value permission level (WIKIAUTH_UNOBTAINABLE) to be the default level for access failure.
904 // Revision 1.135 2004/04/26 12:15:01 rurban
905 // check default config values
907 // Revision 1.134 2004/04/23 06:46:37 zorloc
908 // Leave DB connection open when USE_DB_SESSION is true so that session info can be written to the DB.
910 // Revision 1.133 2004/04/20 18:10:31 rurban
911 // config refactoring:
912 // FileFinder is needed for WikiFarm scripts calling index.php
913 // config run-time calls moved to lib/IniConfig.php:fix_configs()
914 // added PHPWIKI_DIR smart-detection code (Theme finder)
915 // moved FileFind to lib/FileFinder.php
916 // cleaned lib/config.php
918 // Revision 1.132 2004/04/19 21:51:41 rurban
919 // php5 compatibility: it works!
921 // Revision 1.131 2004/04/19 18:27:45 rurban
922 // Prevent from some PHP5 warnings (ref args, no :: object init)
923 // php5 runs now through, just one wrong XmlElement object init missing
924 // Removed unneccesary UpgradeUser lines
925 // Changed WikiLink to omit version if current (RecentChanges)
927 // Revision 1.130 2004/04/18 00:25:53 rurban
928 // allow "0" pagename
930 // Revision 1.129 2004/04/07 23:13:19 rurban
931 // fixed pear/File_Passwd for Windows
932 // fixed FilePassUser sessions (filehandle revive) and password update
934 // Revision 1.128 2004/04/02 15:06:55 rurban
935 // fixed a nasty ADODB_mysql session update bug
936 // improved UserPreferences layout (tabled hints)
937 // fixed UserPreferences auth handling
938 // improved auth stability
939 // improved old cookie handling: fixed deletion of old cookies with paths
941 // Revision 1.127 2004/03/25 17:00:31 rurban
942 // more code to convert old-style pref array to new hash
944 // Revision 1.126 2004/03/24 19:39:03 rurban
945 // php5 workaround code (plus some interim debugging code in XmlElement)
946 // php5 doesn't work yet with the current XmlElement class constructors,
947 // WikiUserNew does work better than php4.
948 // rewrote WikiUserNew user upgrading to ease php5 update
949 // fixed pref handling in WikiUserNew
950 // added Email Notification
951 // added simple Email verification
952 // removed emailVerify userpref subclass: just a email property
953 // changed pref binary storage layout: numarray => hash of non default values
954 // print optimize message only if really done.
955 // forced new cookie policy: delete pref cookies, use only WIKI_ID as plain string.
956 // prefs should be stored in db or homepage, besides the current session.
958 // Revision 1.125 2004/03/14 16:30:52 rurban
959 // db-handle session revivification, dba fixes
961 // Revision 1.124 2004/03/12 15:48:07 rurban
962 // fixed explodePageList: wrong sortby argument order in UnfoldSubpages
963 // simplified lib/stdlib.php:explodePageList
965 // Revision 1.123 2004/03/10 15:41:27 rurban
966 // use default pref mysql table
968 // Revision 1.122 2004/03/08 18:17:09 rurban
969 // added more WikiGroup::getMembersOf methods, esp. for special groups
970 // fixed $LDAP_SET_OPTIONS
971 // fixed _AuthInfo group methods
973 // Revision 1.121 2004/03/01 13:48:45 rurban
975 // p[] consistency fix
977 // Revision 1.120 2004/03/01 10:22:41 rurban
978 // initializeTheme optimize
980 // Revision 1.119 2004/02/26 20:45:06 rurban
981 // check for ALLOW_ANON_USER = false
983 // Revision 1.118 2004/02/26 01:32:03 rurban
984 // fixed session login with old WikiUser object. strangely, the errormask gets corruoted to 1, Pear???
986 // Revision 1.117 2004/02/24 17:19:37 rurban
987 // debugging helpers only
989 // Revision 1.116 2004/02/24 15:17:14 rurban
990 // improved auth errors with individual pages. the fact that you may not browse a certain admin page does not conclude that you may not browse the whole wiki. renamed browse => view
992 // Revision 1.115 2004/02/15 21:34:37 rurban
993 // PageList enhanced and improved.
994 // fixed new WikiAdmin... plugins
995 // editpage, Theme with exp. htmlarea framework
996 // (htmlarea yet committed, this is really questionable)
997 // WikiUser... code with better session handling for prefs
998 // enhanced UserPreferences (again)
999 // RecentChanges for show_deleted: how should pages be deleted then?
1001 // Revision 1.114 2004/02/15 17:30:13 rurban
1002 // workaround for lost db connnection handle on session restauration (->_auth_dbi)
1003 // fixed getPreferences() (esp. from sessions)
1004 // fixed setPreferences() (update and set),
1005 // fixed AdoDb DB statements,
1006 // update prefs only at UserPreferences POST (for testing)
1007 // unified db prefs methods (but in external pref classes yet)
1009 // Revision 1.113 2004/02/12 13:05:49 rurban
1010 // Rename functional for PearDB backend
1011 // some other minor changes
1012 // SiteMap comes with a not yet functional feature request: includepages (tbd)
1014 // Revision 1.112 2004/02/09 03:58:12 rurban
1015 // for now default DB_SESSION to false
1017 // * not existing perms will now query the parent, and not
1018 // return the default perm
1019 // * added pagePermissions func which returns the object per page
1020 // * added getAccessDescription
1022 // * added global ->prepare (not yet used) with smart user/pref/member table prefixing.
1023 // * force init of authdbh in the 2 db classes
1025 // * fixed session handling (not triple auth request anymore)
1026 // * don't store cookie prefs with sessions
1027 // stdlib: global obj2hash helper from _AuthInfo, also needed for PagePerm
1029 // Revision 1.111 2004/02/07 10:41:25 rurban
1030 // fixed auth from session (still double code but works)
1032 // fixed DbPassUser upgrade and policy=old
1035 // Revision 1.110 2004/02/03 09:45:39 rurban
1036 // LDAP cleanup, start of new Pref classes
1038 // Revision 1.109 2004/01/30 19:57:58 rurban
1039 // fixed DBAuthParams['pref_select']: wrong _auth_dbi object used.
1041 // Revision 1.108 2004/01/28 14:34:14 rurban
1042 // session table takes the common prefix
1043 // + various minor stuff
1044 // reallow password changing
1046 // Revision 1.107 2004/01/27 23:23:39 rurban
1047 // renamed ->Username => _userid for consistency
1048 // renamed mayCheckPassword => mayCheckPass
1049 // fixed recursion problem in WikiUserNew
1050 // fixed bogo login (but not quite 100% ready yet, password storage)
1052 // Revision 1.106 2004/01/26 09:17:49 rurban
1053 // * changed stored pref representation as before.
1054 // the array of objects is 1) bigger and 2)
1055 // less portable. If we would import packed pref
1056 // objects and the object definition was changed, PHP would fail.
1057 // This doesn't happen with an simple array of non-default values.
1058 // * use $prefs->retrieve and $prefs->store methods, where retrieve
1059 // understands the interim format of array of objects also.
1060 // * simplified $prefs->get() and fixed $prefs->set()
1061 // * added $user->_userid and class '_WikiUser' portability functions
1062 // * fixed $user object ->_level upgrading, mostly using sessions.
1063 // this fixes yesterdays problems with loosing authorization level.
1064 // * fixed WikiUserNew::checkPass to return the _level
1065 // * fixed WikiUserNew::isSignedIn
1066 // * added explodePageList to class PageList, support sortby arg
1067 // * fixed UserPreferences for WikiUserNew
1068 // * fixed WikiPlugin for empty defaults array
1069 // * UnfoldSubpages: added pagename arg, renamed pages arg,
1070 // removed sort arg, support sortby arg
1072 // Revision 1.105 2004/01/25 03:57:15 rurban
1073 // WikiUserNew support (temp. ENABLE_USER_NEW constant)
1075 // Revision 1.104 2003/12/26 06:41:16 carstenklapp
1076 // Bugfix: Try to defer OS errors about session.save_path and ACCESS_LOG,
1077 // so they don't prevent IE from partially (or not at all) rendering the
1078 // page. This should help a little for the IE user who encounters trouble
1079 // when setting up a new PhpWiki for the first time.
1081 // Revision 1.103 2003/12/02 00:10:00 carstenklapp
1082 // Bugfix: Ongoing work to untangle UserPreferences/WikiUser/request code
1083 // mess: UserPreferences should take effect immediately now upon signing
1086 // Revision 1.102 2003/11/25 22:55:32 carstenklapp
1087 // Localization bugfix: For wikis where English is not the default system
1088 // language, make sure that the authority error message (i.e. "You must
1089 // sign in to edit pages in this wiki" etc.) is displayed in the wiki's
1090 // default language. Previously it would always display in English.
1091 // (Added call to update_locale() before displaying any messages prior to
1092 // the login prompt.)
1094 // Revision 1.101 2003/11/25 21:49:44 carstenklapp
1095 // Bugfix: For a non-english wiki or when the user's preference is not
1096 // english, the wiki would always use the english ActionPage first if it
1097 // was present rather than the appropriate localised variant. (PhpWikis
1098 // running only in english or Wikis running ONLY without any english
1099 // ActionPages would not notice this bug, only when both english and
1100 // localised ActionPages were in the DB.) Now we check for the localised
1103 // Revision 1.100 2003/11/18 16:54:18 carstenklapp
1104 // Reformatting only: Tabs to spaces, added rcs log.
1111 // c-basic-offset: 4
1112 // c-hanging-comment-ender-p: nil
1113 // indent-tabs-mode: nil