2 rcs_id('$Id: main.php,v 1.204 2005-01-25 07:35:42 rurban Exp $');
4 Copyright 1999,2000,2001,2002,2004,2005 $ThePhpWikiProgrammingTeam
6 This file is part of PhpWiki.
8 PhpWiki is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 PhpWiki is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with PhpWiki; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 define ('USE_PREFS_IN_PAGE', true);
25 //include "lib/config.php";
26 require_once(dirname(__FILE__)."/stdlib.php");
27 require_once('lib/Request.php');
28 require_once('lib/WikiDB.php');
30 require_once("lib/WikiUserNew.php");
32 require_once("lib/WikiUser.php");
33 require_once("lib/WikiGroup.php");
35 require_once("lib/PagePerm.php");
38 * Check permission per page.
39 * Returns true or false.
41 function mayAccessPage ($access, $pagename) {
43 return _requiredAuthorityForPagename($access, $pagename); // typically [10-20ms per page]
48 class WikiRequest extends Request {
51 function WikiRequest () {
52 $this->_dbi = WikiDB::open($GLOBALS['DBParams']);
53 // first mysql request costs [958ms]! [670ms] is mysql_connect()
55 if (in_array('File', $this->_dbi->getAuthParam('USER_AUTH_ORDER'))) {
56 // force our local copy, until the pear version is fixed.
57 include_once(dirname(__FILE__)."/pear/File_Passwd.php");
59 if (ENABLE_USER_NEW) {
60 // Preload all necessary userclasses. Otherwise session => __PHP_Incomplete_Class_Name
61 // There's no way to demandload it later. This way it's much slower but needs
62 // less memory than loading all
64 include_once("lib/WikiUser/BogoLogin.php");
65 foreach ($GLOBALS['USER_AUTH_ORDER'] as $method) {
66 include_once("lib/WikiUser/$method.php");
68 switch($GLOBALS['DBParams']['dbtype']) {
69 case 'SQL' : include_once("lib/WikiUser/PearDb.php"); break;
70 case 'ADODB': include_once("lib/WikiUser/AdoDb.php"); break;
76 include_once('lib/DbSession.php');
78 $this->_dbsession = new DbSession($dbi, $dbi->getParam('prefix') . $dbi->getParam('db_session_table'));
81 // Fixme: Does pear reset the error mask to 1? We have to find the culprit
82 //$x = error_reporting();
84 $this->version = phpwiki_version();
85 $this->Request(); // [90ms]
88 $this->setArg('pagename', $this->_deducePagename());
89 $this->setArg('action', $this->_deduceAction());
91 if ((DEBUG & _DEBUG_SQL) or (time() % 50 == 0)) {
92 if ($this->_dbi->_backend->optimize())
93 trigger_error(_("Optimizing database"), E_USER_NOTICE);
96 // Restore auth state. This doesn't check for proper authorization!
97 $userid = $this->_deduceUsername();
98 if (ENABLE_USER_NEW) {
99 if (isset($this->_user) and
100 !empty($this->_user->_authhow) and
101 $this->_user->_authhow == 'session')
103 // users might switch in a session between the two objects.
104 // restore old auth level here or in updateAuthAndPrefs?
105 //$user = $this->getSessionVar('wiki_user');
106 // revive db handle, because these don't survive sessions
107 if (isset($this->_user) and
108 ( ! isa($this->_user, WikiUserClassname())
109 or (strtolower(get_class($this->_user)) == '_passuser')))
111 $this->_user = WikiUser($userid, $this->_user->_prefs);
113 // revive other db handle
114 if (isset($this->_user->_prefs->_method)
115 and ($this->_user->_prefs->_method == 'SQL'
116 or $this->_user->_prefs->_method == 'ADODB'
117 or $this->_user->_prefs->_method == 'HomePage')) {
118 $this->_user->_HomePagehandle = $this->getPage($userid);
120 // need to update the lockfile filehandle
121 if ( isa($this->_user,'_FilePassUser')
122 and $this->_user->_file->lockfile
123 and !$this->_user->_file->fplock )
125 //$level = $this->_user->_level;
126 $this->_user = UpgradeUser($this->_user,
127 new _FilePassUser($userid,
128 $this->_user->_prefs,
129 $this->_user->_file->filename));
130 //$this->_user->_level = $level;
132 $this->_prefs = & $this->_user->_prefs;
134 $user = WikiUser($userid);
135 $this->_user = & $user;
136 $this->_prefs = & $this->_user->_prefs;
139 $this->_user = new WikiUser($this, $userid);
140 $this->_prefs = $this->_user->getPreferences();
144 function initializeLang () {
145 $user_lang = $this->getPref('lang');
146 $_lang = @$this->_prefs->_prefs['lang'];
147 //check changed LANG and THEME inside a session.
148 // (e.g. by using another baseurl)
149 if (isset($this->_user->_authhow) and
150 $this->_user->_authhow == 'session' and
151 !isset($_lang->lang) and
152 $user_lang != $GLOBALS['LANG'])
154 $user_lang = $GLOBALS['LANG'];
156 if (isset($user_lang)) {
157 //trigger_error("DEBUG: initializeLang() ". $user_lang ." calling update_locale()...");
158 update_locale($user_lang);
159 FindLocalizedButtonFile(".",'missing_ok','reinit');
163 function initializeTheme () {
167 $user_theme = $this->getPref('theme');
168 $_theme = @$this->_prefs->_prefs['theme'];
169 //check changed LANG and THEME inside a session.
170 // (e.g. by using another baseurl)
171 if (isset($this->_user->_authhow) and
172 $this->_user->_authhow == 'session' and
173 !isset($_theme->theme) and
175 $user_theme != THEME)
177 include_once("themes/" . THEME . "/themeinfo.php");
179 if (empty($WikiTheme) and isset($user_theme)) {
180 if (strcspn($user_theme,"./\x00]") != strlen($user_theme)) {
181 trigger_error(sprintf("invalid theme '%s': Invalid characters detected", $user_theme),
183 $user_theme = "default";
185 include_once("themes/$user_theme/themeinfo.php");
187 if (empty($WikiTheme) and defined('THEME'))
188 include_once("themes/" . THEME . "/themeinfo.php");
189 if (empty($WikiTheme))
190 include_once("themes/default/themeinfo.php");
191 assert(!empty($WikiTheme));
194 // This really maybe should be part of the constructor, but since it
195 // may involve HTML/template output, the global $request really needs
196 // to be initialized before we do this stuff.
197 // [50ms]: 36ms is wikidb_page::exists
198 function updateAuthAndPrefs () {
200 if (isset($this->_user) and (!isa($this->_user, WikiUserClassname()))) {
201 $this->_user = false;
203 // Handle authentication request, if any.
204 if ($auth_args = $this->getArg('auth')) {
205 $this->setArg('auth', false);
206 $this->_handleAuthRequest($auth_args); // possible NORETURN
208 elseif ( ! $this->_user
209 or (isa($this->_user, WikiUserClassname())
210 and ! $this->_user->isSignedIn())) {
211 // If not auth request, try to sign in as saved user.
212 if (($saved_user = $this->getPref('userid')) != false) {
213 $this->_signIn($saved_user);
217 $action = $this->getArg('action');
219 // Save preferences in session and cookie
220 if ((defined('WIKI_XMLRPC') and !WIKI_XMLRPC) or $action != 'xmlrpc') {
221 if (isset($this->_user)) {
222 if (!isset($this->_user->_authhow) or $this->_user->_authhow != 'session') {
223 $this->_user->setPreferences($this->_prefs, true);
226 $this->setSessionVar('wiki_user', $this->_user);
229 // Ensure user has permissions for action
230 // HACK ALERT: We may not set the request arg to create,
231 // since the pageeditor has an ugly logic for action == create.
232 if ($action == 'edit' or $action == 'create') {
233 $page = $this->getPage();
234 if (! $page->exists() )
239 $require_level = $this->requiredAuthority($action);
240 if (! $this->_user->hasAuthority($require_level))
241 $this->_notAuthorized($require_level); // NORETURN
244 function & getUser () {
245 if (isset($this->_user))
248 return $GLOBALS['ForbiddenUser'];
251 function & getGroup () {
252 if (isset($this->_user) and isset($this->_user->_group))
253 return $this->_user->_group;
255 return WikiGroup::getGroup();
258 function & getPrefs () {
259 return $this->_prefs;
262 // Convenience function:
263 function getPref ($key) {
264 if (isset($this->_prefs)) {
265 return $this->_prefs->get($key);
268 function & getDbh () {
273 * Get requested page from the page database.
274 * By default it will grab the page requested via the URL
276 * This is a convenience function.
277 * @param string $pagename Name of page to get.
278 * @return WikiDB_Page Object with methods to pull data from
279 * database for the page requested.
281 function getPage ($pagename = false) {
282 //if (!isset($this->_dbi)) $this->getDbh();
284 $pagename = $this->getArg('pagename');
285 return $this->_dbi->getPage($pagename);
288 /** Get URL for POST actions.
290 * Officially, we should just use SCRIPT_NAME (or some such),
291 * but that causes problems when we try to issue a redirect, e.g.
292 * after saving a page.
294 * Some browsers (at least NS4 and Mozilla 0.97 won't accept
295 * a redirect from a page to itself.)
297 * So, as a HACK, we include pagename and action as query args in
298 * the URL. (These should be ignored when we receive the POST
301 function getPostURL ($pagename=false) {
302 global $HTTP_GET_VARS;
304 if ($pagename === false)
305 $pagename = $this->getArg('pagename');
306 $action = $this->getArg('action');
307 if (!empty($HTTP_GET_VARS['start_debug'])) // zend ide support
308 return WikiURL($pagename, array('action' => $action, 'start_debug' => 1));
310 return WikiURL($pagename, array('action' => $action));
313 function _handleAuthRequest ($auth_args) {
314 if (!is_array($auth_args))
317 // Ignore password unless POST'ed.
318 if (!$this->isPost())
319 unset($auth_args['passwd']);
321 $olduser = $this->_user;
322 $user = $this->_user->AuthCheck($auth_args);
323 if (isa($user, WikiUserClassname())) {
324 // Successful login (or logout.)
325 $this->_setUser($user);
327 elseif (is_string($user)) {
328 // Login attempt failed.
329 $fail_message = $user;
330 $auth_args['pass_required'] = true;
331 // if clicked just on to the "sign in as:" button dont print invalid username.
332 if (!empty($auth_args['login']) and empty($auth_args['userid']))
334 // If no password was submitted, it's not really
335 // a failure --- just need to prompt for password...
336 if (!ALLOW_USER_PASSWORDS
338 and !isset($auth_args['passwd']))
340 $fail_message = false;
342 $olduser->PrintLoginForm($this, $auth_args, $fail_message, 'newpage');
343 $this->finish(); //NORETURN
346 // Login request cancelled.
351 * Attempt to sign in (bogo-login).
355 * @param $userid string Userid to attempt to sign in as.
358 function _signIn ($userid) {
359 if (ENABLE_USER_NEW) {
361 $this->_user = new _BogoUser($userid);
362 // FIXME: is this always false? shouldn't we try passuser first?
364 $this->_user = new _PassUser($userid);
366 $user = $this->_user->AuthCheck(array('userid' => $userid));
367 if (isa($user, WikiUserClassname())) {
368 $this->_setUser($user); // success!
372 // login or logout or restore state
373 function _setUser (&$user) {
374 $this->_user =& $user;
375 if (defined('MAIN_setUser')) return;
376 define('MAIN_setUser',true);
377 $this->setCookieVar('WIKI_ID', $user->getAuthenticatedId(),
378 COOKIE_EXPIRATION_DAYS, COOKIE_DOMAIN);
379 if ($user->isSignedIn())
380 $user->_authhow = 'signin';
382 // Save userid to prefs..
383 if ( empty($this->_user->_prefs)) {
384 $this->_user->_prefs = $this->_user->getPreferences();
385 $this->_prefs =& $this->_user->_prefs;
387 $this->_user->_group = $this->getGroup();
388 $this->setSessionVar('wiki_user', $user);
389 $this->_prefs->set('userid',
390 $user->isSignedIn() ? $user->getId() : '');
391 $this->initializeTheme();
394 /* Permission system */
395 function getLevelDescription($level) {
396 static $levels = false;
398 $levels = array('x-1' => _("FORBIDDEN"),
403 'x100'=> _("UNOBTAINABLE"));
406 if (!empty($levels["x".$level]))
407 return $levels["x".$level];
412 function _notAuthorized ($require_level) {
413 // Display the authority message in the Wiki's default
414 // language, in case it is not english.
416 // Note that normally a user will not see such an error once
417 // logged in, unless the admin has altered the default
418 // disallowed wikiactions. In that case we should probably
419 // check the user's language prefs too at this point; this
420 // would be a situation which is not really handled with the
422 if (empty($GLOBALS['LANG']))
423 update_locale(DEFAULT_LANGUAGE);
425 // User does not have required authority. Prompt for login.
426 $what = $this->getActionDescription($this->getArg('action'));
427 $pass_required = ($require_level >= WIKIAUTH_USER);
428 if ($require_level == WIKIAUTH_UNOBTAINABLE) {
429 global $DisabledActions;
430 if ($DisabledActions and in_array($action, $DisabledActions)) {
431 $msg = fmt("%s is disallowed on this wiki.",
432 $this->getDisallowedActionDescription($this->getArg('action')));
436 // Is the reason a missing ACL or just wrong user or password?
437 if (class_exists('PagePermission')) {
438 $user =& $this->_user;
439 $status = $user->isAuthenticated() ? _("authenticated") : _("not authenticated");
440 $msg = fmt("%s %s %s is disallowed on this wiki for %s user '%s' (level: %s).",
441 _("Missing PagePermission:"),
442 action2access($this->getArg('action')),
443 $this->getArg('pagename'),
444 $status, $user->getId(), $this->getLevelDescription($user->_level));
445 // TODO: add link to action=setacl
446 $user->PrintLoginForm($this, compact('pass_required'), $msg);
450 $msg = fmt("%s is disallowed on this wiki.",
451 $this->getDisallowedActionDescription($this->getArg('action')));
452 $this->_user->PrintLoginForm($this, compact('require_level','pass_required'), $msg);
457 elseif ($require_level == WIKIAUTH_BOGO)
458 $msg = fmt("You must sign in to %s.", $what);
459 elseif ($require_level == WIKIAUTH_USER)
460 $msg = fmt("You must log in to %s.", $what);
461 elseif ($require_level == WIKIAUTH_ANON)
462 $msg = fmt("Access for you is forbidden to %s.", $what);
464 $msg = fmt("You must be an administrator to %s.", $what);
466 $this->_user->PrintLoginForm($this, compact('require_level','pass_required'), $msg);
467 $this->finish(); // NORETURN
470 // Fixme: for PagePermissions we'll need other strings,
471 // relevant to the requested page, not just for the action on the whole wiki.
472 function getActionDescription($action) {
473 static $actionDescriptions;
474 if (! $actionDescriptions) {
476 = array('browse' => _("view this page"),
477 'diff' => _("diff this page"),
478 'dumphtml' => _("dump html pages"),
479 'dumpserial' => _("dump serial pages"),
480 'edit' => _("edit this page"),
481 'revert' => _("revert to a previous version of this page"),
482 'create' => _("create this page"),
483 'loadfile' => _("load files into this wiki"),
484 'lock' => _("lock this page"),
485 'remove' => _("remove this page"),
486 'unlock' => _("unlock this page"),
487 'upload' => _("upload a zip dump"),
488 'verify' => _("verify the current action"),
489 'viewsource' => _("view the source of this page"),
490 'xmlrpc' => _("access this wiki via XML-RPC"),
491 'soap' => _("access this wiki via SOAP"),
492 'zip' => _("download a zip dump from this wiki"),
493 'ziphtml' => _("download an html zip dump from this wiki")
496 if (in_array($action, array_keys($actionDescriptions)))
497 return $actionDescriptions[$action];
503 TODO: check against these cases:
504 if ($DisabledActions and in_array($action, $DisabledActions))
505 return WIKIAUTH_UNOBTAINABLE;
507 if (ENABLE_PAGEPERM and class_exists("PagePermission")) {
508 return requiredAuthorityForPage($action);
510 => Browsing pages is disallowed on this wiki for authenticated user 'rurban' (level: BOGO).
512 function getDisallowedActionDescription($action) {
513 static $disallowedActionDescriptions;
515 if (! $disallowedActionDescriptions) {
516 $disallowedActionDescriptions
517 = array('browse' => _("Browsing pages"),
518 'diff' => _("Diffing pages"),
519 'dumphtml' => _("Dumping html pages"),
520 'dumpserial' => _("Dumping serial pages"),
521 'edit' => _("Editing pages"),
522 'revert' => _("Reverting to a previous version of pages"),
523 'create' => _("Creating pages"),
524 'loadfile' => _("Loading files"),
525 'lock' => _("Locking pages"),
526 'remove' => _("Removing pages"),
527 'unlock' => _("Unlocking pages"),
528 'upload' => _("Uploading zip dumps"),
529 'verify' => _("Verify the current action"),
530 'viewsource' => _("Viewing the source of pages"),
531 'xmlrpc' => _("XML-RPC access"),
532 'soap' => _("SOAP access"),
533 'zip' => _("Downloading zip dumps"),
534 'ziphtml' => _("Downloading html zip dumps")
537 if (in_array($action, array_keys($disallowedActionDescriptions)))
538 return $disallowedActionDescriptions[$action];
543 function requiredAuthority ($action) {
544 $auth = $this->requiredAuthorityForAction($action);
545 if (!ALLOW_ANON_USER) return WIKIAUTH_USER;
548 * This is a hook for plugins to require authority
549 * for posting to them.
551 * IMPORTANT: this is not a secure check, so the plugin
552 * may not assume that any POSTs to it are authorized.
553 * All this does is cause PhpWiki to prompt for login
554 * if the user doesn't have the required authority.
556 if ($this->isPost()) {
557 $post_auth = $this->getArg('require_authority_for_post');
558 if ($post_auth !== false)
559 $auth = max($auth, $post_auth);
564 function requiredAuthorityForAction ($action) {
565 global $DisabledActions;
567 if ($DisabledActions and in_array($action, $DisabledActions))
568 return WIKIAUTH_UNOBTAINABLE;
570 if (ENABLE_PAGEPERM and class_exists("PagePermission")) {
571 return requiredAuthorityForPage($action);
582 return WIKIAUTH_ANON;
586 if (defined('ZIPDUMP_AUTH') && ZIPDUMP_AUTH)
587 return WIKIAUTH_ADMIN;
588 return WIKIAUTH_ANON;
593 if (defined('REQUIRE_SIGNIN_BEFORE_EDIT') && REQUIRE_SIGNIN_BEFORE_EDIT)
594 return WIKIAUTH_BOGO;
595 return WIKIAUTH_ANON;
596 // return WIKIAUTH_BOGO;
599 $page = $this->getPage();
600 $current = $page->getCurrentRevision();
601 if ($current->hasDefaultContents())
602 return $this->requiredAuthorityForAction('edit');
603 return $this->requiredAuthorityForAction('browse');
616 return WIKIAUTH_ADMIN;
618 /* authcheck occurs only in the plugin.
619 required actionpage RateIt */
622 case 'delete_rating':
623 // Perhaps this should be WIKIAUTH_USER
624 return WIKIAUTH_BOGO;
628 global $WikiNameRegexp;
629 if (preg_match("/$WikiNameRegexp\Z/A", $action))
630 return WIKIAUTH_ANON; // ActionPage.
632 return WIKIAUTH_ADMIN;
636 /* End of Permission system */
638 function possiblyDeflowerVirginWiki () {
639 if ($this->getArg('action') != 'browse')
641 if ($this->getArg('pagename') != HOME_PAGE)
644 $page = $this->getPage();
645 $current = $page->getCurrentRevision();
646 if ($current->getVersion() > 0)
647 return; // Homepage exists.
649 include('lib/loadsave.php');
651 $this->finish(); // NORETURN
654 // [574ms] mainly template:printexpansion: 393ms and template::expandsubtemplate [100+70+60ms]
655 function handleAction () {
656 $action = $this->getArg('action');
657 if ($this->isPost() and !$this->_user->isAdmin() and $action != 'browse') {
658 $page = $this->getPage();
659 if ( $page->get('moderation') ) {
660 require_once("lib/WikiPlugin.php");
661 $loader = new WikiPluginLoader();
662 $plugin = $loader->getPlugin("ModeratedPage");
663 if ($plugin->handler($this, $page)) {
664 $CONTENT = HTML::div(array('class' => 'wiki-edithelp'),
665 fmt("%s: action forwarded to a moderator.",
668 // better msg: "This action requires moderator approval. Please be patient."
669 _("You must wait for moderator approval."));
670 if (!empty($plugin->_tokens['CONTENT']))
671 $plugin->_tokens['CONTENT']->pushContent
674 _("You must wait for moderator approval."));
676 $plugin->_tokens['CONTENT'] = $CONTENT;
677 require_once("lib/Template.php");
678 $title = WikiLink($page->getName());
679 $title->pushContent(' : ', WikiLink(_("ModeratedPage")));
680 GeneratePage(Template('browse', $plugin->_tokens),
682 $page->getCurrentRevision());
687 $method = "action_$action";
688 if (method_exists($this, $method)) {
691 elseif ($page = $this->findActionPage($action)) {
692 $this->actionpage($page);
695 $this->finish(fmt("%s: Bad action", $action));
699 function finish ($errormsg = false) {
703 exit(); // just in case CloseDataBase calls us
706 global $ErrorManager;
707 $ErrorManager->flushPostponedErrors();
709 if (!empty($errormsg)) {
712 HTML::h2(_("Fatal PhpWiki Error")),
715 echo "\n</body></html>";
717 if (is_object($this->_user)) {
718 $this->_user->page = $this->getArg('pagename');
719 $this->_user->action = $this->getArg('action');
720 unset($this->_user->_HomePagehandle);
721 unset($this->_user->_auth_dbi);
728 * Generally pagename is rawurlencoded for older browsers or mozilla.
729 * Typing a pagename into the IE bar will utf-8 encode it, so we have to
730 * fix that with fixTitleEncoding().
731 * If USE_PATH_INFO = true, the pagename is stripped from the "/DATA_PATH/PageName&arg=value" line.
732 * If false, we support either "/index.php?pagename=PageName&arg=value",
733 * or the first arg (1.2.x style): "/index.php?PageName&arg=value"
735 function _deducePagename () {
736 if (trim(rawurldecode($this->getArg('pagename'))))
737 return fixTitleEncoding(rawurldecode($this->getArg('pagename')));
740 $pathinfo = $this->get('PATH_INFO');
741 if (empty($pathinfo)) { // fix for CGI
742 $path = $this->get('REQUEST_URI');
743 $script = $this->get('SCRIPT_NAME');
744 $pathinfo = substr($path,strlen($script));
745 $pathinfo = preg_replace('/\?.+$/','',$pathinfo);
747 $tail = substr($pathinfo, strlen(PATH_INFO_PREFIX));
749 if (trim($tail) != '' and $pathinfo == PATH_INFO_PREFIX . $tail) {
750 return fixTitleEncoding($tail);
753 elseif ($this->isPost()) {
755 * In general, for security reasons, HTTP_GET_VARS should be ignored
756 * on POST requests, but we make an exception here (only for pagename).
758 * The justification for this hack is the following
759 * asymmetry: When POSTing with USE_PATH_INFO set, the
760 * pagename can (and should) be communicated through the
761 * request URL via PATH_INFO. When POSTing with
762 * USE_PATH_INFO off, this cannot be done --- the only way
763 * to communicate the pagename through the URL is via
764 * QUERY_ARGS (HTTP_GET_VARS).
766 global $HTTP_GET_VARS;
767 if (isset($HTTP_GET_VARS['pagename']) and trim($HTTP_GET_VARS['pagename'])) {
768 return fixTitleEncoding(rawurldecode($HTTP_GET_VARS['pagename']));
773 * Support for PhpWiki 1.2 style requests.
774 * Strip off "&" args (?PageName&action=...&start_debug,...)
776 $query_string = $this->get('QUERY_STRING');
777 if (trim(rawurldecode($query_string)) and preg_match('/^([^&=]+)(&.+)?$/', $query_string, $m)) {
778 return fixTitleEncoding(rawurldecode($m[1]));
781 return fixTitleEncoding(HOME_PAGE);
784 function _deduceAction () {
785 if (!($action = $this->getArg('action'))) {
786 // Detect XML-RPC requests. TODO: SOAP?
788 && $this->get('CONTENT_TYPE') == 'text/xml'
789 && strstr($GLOBALS['HTTP_RAW_POST_DATA'], '<methodCall>')
794 return 'browse'; // Default if no action specified.
797 if (method_exists($this, "action_$action"))
800 // Allow for, e.g. action=LikePages
801 if ($this->isActionPage($action))
804 // Handle untranslated actionpages in non-english
805 // (people playing with switching languages)
806 if (0 and $GLOBALS['LANG'] != 'en') {
807 require_once("lib/plugin/_WikiTranslation.php");
808 $trans = new WikiPlugin__WikiTranslation();
809 $en_action = $trans->translate($action,'en',$GLOBALS['LANG']);
810 if ($this->isActionPage($en_action))
814 trigger_error("$action: Unknown action", E_USER_NOTICE);
818 function _deduceUsername() {
819 global $HTTP_SERVER_VARS, $HTTP_ENV_VARS;
821 if (!empty($this->args['auth']) and !empty($this->args['auth']['userid']))
822 return $this->args['auth']['userid'];
824 if (!empty($HTTP_SERVER_VARS['PHP_AUTH_USER']))
825 return $HTTP_SERVER_VARS['PHP_AUTH_USER'];
826 if (!empty($HTTP_ENV_VARS['REMOTE_USER']))
827 return $HTTP_ENV_VARS['REMOTE_USER'];
829 if ($user = $this->getSessionVar('wiki_user')) {
830 // switched auth between sessions.
831 // Note: There's no way to demandload a missing class-definition afterwards! (Stupid php)
832 if (isa($user, WikiUserClassname())) {
833 $this->_user = $user;
834 $this->_user->_authhow = 'session';
835 return ENABLE_USER_NEW ? $user->UserName() : $this->_user;
838 if ($userid = $this->getCookieVar('WIKI_ID')) {
839 if (!empty($userid) and substr($userid,0,2) != 's:') {
840 $this->_user->authhow = 'cookie';
845 if ($this->getArg('action') == 'xmlrpc') { // how about SOAP?
846 // wiki.putPage has special otional userid/passwd arguments. check that later.
848 if (isset($HTTP_SERVER_VARS['REMOTE_USER']))
849 $userid = $HTTP_SERVER_VARS['REMOTE_USER'];
850 elseif (isset($HTTP_SERVER_VARS['REMOTE_ADDR']))
851 $userid = $HTTP_SERVER_VARS['REMOTE_ADDR'];
852 elseif (isset($HTTP_ENV_VARS['REMOTE_ADDR']))
853 $userid = $HTTP_ENV_VARS['REMOTE_ADDR'];
854 elseif (isset($GLOBALS['REMOTE_ADDR']))
855 $userid = $GLOBALS['REMOTE_ADDR'];
862 function _isActionPage ($pagename) {
863 $dbi = $this->getDbh();
864 $page = $dbi->getPage($pagename);
865 if (!$page) return false;
866 $rev = $page->getCurrentRevision();
867 // FIXME: more restrictive check for sane plugin?
868 if (strstr($rev->getPackedContent(), '<?plugin'))
870 if (!$rev->hasDefaultContents())
871 trigger_error("$pagename: Does not appear to be an 'action page'", E_USER_NOTICE);
875 function findActionPage ($action) {
878 // check for translated version, as per users preferred language
879 // (or system default in case it is not en)
880 $translation = gettext($action);
882 if (isset($cache) and isset($cache[$translation]))
883 return $cache[$translation];
885 // check for cached translated version
886 if ($this->_isActionPage($translation))
887 return $cache[$action] = $translation;
889 // Allow for, e.g. action=LikePages
890 if (!isWikiWord($action))
891 return $cache[$action] = false;
893 // check for translated version (default language)
896 require_once("lib/WikiPlugin.php");
897 require_once("lib/plugin/_WikiTranslation.php");
898 $trans = new WikiPlugin__WikiTranslation();
899 $trans->lang = $LANG;
900 $default = $trans->translate_to_en($action, $LANG);
901 if ($this->_isActionPage($default))
902 return $cache[$action] = $default;
904 $default = $translation;
907 // check for english version
908 if ($action != $translation and $action != $default) {
909 if ($this->_isActionPage($action))
910 return $cache[$action] = $action;
913 trigger_error("$action: Cannot find action page", E_USER_NOTICE);
914 return $cache[$action] = false;
917 function isActionPage ($pagename) {
918 return $this->findActionPage($pagename);
921 function action_browse () {
922 $this->buffer_output();
923 include_once("lib/display.php");
927 function action_verify () {
928 $this->action_browse();
931 function actionpage ($action) {
932 $this->buffer_output();
933 include_once("lib/display.php");
934 actionPage($this, $action);
937 function adminActionSubpage ($subpage) {
938 $page = _("PhpWikiAdministration")."/".$subpage;
939 $action = $this->findActionPage($page);
941 $this->setArg('s',$this->getArg('pagename'));
942 $this->setArg('verify',1);
943 $this->setArg('action',$action);
944 $this->actionpage($action);
946 trigger_error($page.": Cannot find action page", E_USER_WARNING);
950 function action_chown () {
951 $this->adminActionSubpage(_("Chown"));
954 function action_setacl () {
955 $this->adminActionSubpage(_("SetAcl"));
958 function action_rename () {
959 $this->adminActionSubpage(_("Rename"));
962 function action_dump () {
963 $action = $this->findActionPage(_("PageDump"));
965 $this->actionpage($action);
967 // redirect to action=upgrade if admin?
968 trigger_error(_("PageDump").": Cannot find action page", E_USER_WARNING);
972 function action_diff () {
973 $this->buffer_output();
974 include_once "lib/diff.php";
978 function action_search () {
979 // This is obsolete: reformulate URL and redirect.
980 // FIXME: this whole section should probably be deleted.
981 if ($this->getArg('searchtype') == 'full') {
982 $search_page = _("FullTextSearch");
985 $search_page = _("TitleSearch");
987 $this->redirect(WikiURL($search_page,
988 array('s' => $this->getArg('searchterm')),
992 function action_edit () {
993 $this->buffer_output();
994 include "lib/editpage.php";
995 $e = new PageEditor ($this);
999 function action_create () {
1000 $this->action_edit();
1003 function action_viewsource () {
1004 $this->buffer_output();
1005 include "lib/editpage.php";
1006 $e = new PageEditor ($this);
1010 function action_lock () {
1011 $page = $this->getPage();
1012 $page->set('locked', true);
1013 $this->_dbi->touch();
1014 // check ModeratedPage hook
1015 if ($moderated = $page->get('moderated')) {
1016 require_once("lib/WikiPlugin.php");
1017 $plugin = WikiPluginLoader::getPlugin("ModeratedPage");
1018 if ($retval = $plugin->lock_check($this, $page, $moderated))
1019 $this->setArg('errormsg', $retval);
1021 // check if a link to ModeratedPage exists
1022 elseif ($action_page = $page->existLink(_("ModeratedPage"))) {
1023 require_once("lib/WikiPlugin.php");
1024 $plugin = WikiPluginLoader::getPlugin("ModeratedPage");
1025 if ($retval = $plugin->lock_add($this, $page, $action_page))
1026 $this->setArg('errormsg', $retval);
1028 $this->action_browse();
1031 function action_unlock () {
1032 $page = $this->getPage();
1033 $page->set('locked', false);
1034 $this->_dbi->touch();
1035 $this->action_browse();
1038 function action_remove () {
1039 // FIXME: This check is redundant.
1040 //$user->requireAuth(WIKIAUTH_ADMIN);
1041 $pagename = $this->getArg('pagename');
1042 if (strstr($pagename,_('PhpWikiAdministration'))) {
1043 $this->action_browse();
1045 include('lib/removepage.php');
1050 function action_xmlrpc () {
1051 include_once("lib/XmlRpcServer.php");
1052 $xmlrpc = new XmlRpcServer($this);
1056 function action_revert () {
1057 include_once "lib/loadsave.php";
1061 function action_zip () {
1062 include_once("lib/loadsave.php");
1064 // I don't think it hurts to add cruft at the end of the zip file.
1065 //echo "\n========================================================\n";
1066 //echo "PhpWiki " . PHPWIKI_VERSION . " source:\n$GLOBALS[RCS_IDS]\n";
1069 function action_ziphtml () {
1070 include_once("lib/loadsave.php");
1071 MakeWikiZipHtml($this);
1072 // I don't think it hurts to add cruft at the end of the zip file.
1073 echo "\n========================================================\n";
1074 echo "PhpWiki " . PHPWIKI_VERSION . " source:\n$GLOBALS[RCS_IDS]\n";
1077 function action_dumpserial () {
1078 include_once("lib/loadsave.php");
1082 function action_dumphtml () {
1083 include_once("lib/loadsave.php");
1084 DumpHtmlToDir($this);
1087 function action_upload () {
1088 include_once("lib/loadsave.php");
1089 LoadPostFile($this);
1092 function action_upgrade () {
1093 include_once("lib/loadsave.php");
1094 include_once("lib/upgrade.php");
1098 function action_loadfile () {
1099 include_once("lib/loadsave.php");
1100 LoadFileOrDir($this);
1103 function action_pdf () {
1104 include_once("lib/pdf.php");
1105 ConvertAndDisplayPdf($this);
1111 function is_safe_action ($action) {
1112 return WikiRequest::requiredAuthorityForAction($action) < WIKIAUTH_ADMIN;
1115 function validateSessionPath() {
1116 // Try to defer any session.save_path PHP errors before any html
1117 // is output, which causes some versions of IE to display a blank
1118 // page (due to its strict mode while parsing a page?).
1119 if (! is_writeable(ini_get('session.save_path'))) {
1120 $tmpdir = defined('SESSION_SAVE_PATH') ? SESSION_SAVE_PATH : '/tmp';
1121 if (!is_writeable($tmpdir))
1124 (sprintf(_("%s is not writable."),
1125 _("The session.save_path directory"))
1127 . sprintf(_("Please ensure that %s is writable, or redefine %s in config/config.ini."),
1128 sprintf(_("the session.save_path directory '%s'"),
1129 ini_get('session.save_path')),
1130 'SESSION_SAVE_PATH')
1132 . sprintf(_("Attempting to use the directory '%s' instead."),
1135 if (! is_writeable($tmpdir)) {
1137 (sprintf(_("%s is not writable."), $tmpdir)
1139 . _("Users will not be able to sign in.")
1143 ini_set('session.save_path', $tmpdir);
1148 if (!USE_DB_SESSION)
1149 validateSessionPath();
1152 if ((DEBUG & _DEBUG_APD) and extension_loaded("apd"))
1153 apd_set_session_trace(9);
1155 // Postpone warnings
1156 global $ErrorManager;
1157 if (defined('E_STRICT')) // and (E_ALL & E_STRICT)) // strict php5?
1158 $ErrorManager->setPostponedErrorMask(E_NOTICE|E_USER_NOTICE|E_USER_WARNING|E_WARNING|E_STRICT);
1160 $ErrorManager->setPostponedErrorMask(E_NOTICE|E_USER_NOTICE|E_USER_WARNING|E_WARNING);
1161 $request = new WikiRequest();
1163 $action = $request->getArg('action');
1164 if (substr($action, 0, 3) != 'zip') {
1165 if ($action == 'pdf')
1166 $ErrorManager->setPostponedErrorMask(-1); // everything
1167 //else // reject postponing of warnings
1168 // $ErrorManager->setPostponedErrorMask(E_NOTICE|E_USER_NOTICE);
1172 * Allow for disabling of markup cache.
1173 * (Mostly for debugging ... hopefully.)
1175 * See also <?plugin WikiAdminUtils action=purge-cache ?>
1177 if (!defined('WIKIDB_NOCACHE_MARKUP') and $request->getArg('nocache'))
1178 define('WIKIDB_NOCACHE_MARKUP', $request->getArg('nocache'));
1180 // Initialize with system defaults in case user not logged in.
1181 // Should this go into constructor?
1182 $request->initializeTheme();
1184 $request->updateAuthAndPrefs();
1185 $request->initializeLang();
1188 //if ($user->is_authenticated())
1189 // $LogEntry->user = $user->getId();
1191 // Memory optimization:
1192 // http://www.procata.com/blog/archives/2004/05/27/rephlux-and-php-memory-usage/
1193 // kill the global PEAR _PEAR_destructor_object_list
1194 if (!empty($_PEAR_destructor_object_list))
1195 $_PEAR_destructor_object_list = array();
1196 $request->possiblyDeflowerVirginWiki();
1198 // hack! define proper actions for these.
1199 if (defined('WIKI_XMLRPC') and WIKI_XMLRPC) return;
1200 if (defined('WIKI_SOAP') and WIKI_SOAP) return;
1202 $validators = array('wikiname' => WIKI_NAME,
1203 'args' => hash($request->getArgs()),
1204 'prefs' => hash($request->getPrefs()));
1205 if (CACHE_CONTROL == 'STRICT') {
1206 $dbi = $request->getDbh();
1207 $timestamp = $dbi->getTimestamp();
1208 $validators['mtime'] = $timestamp;
1209 $validators['%mtime'] = (int)$timestamp;
1211 // FIXME: we should try to generate strong validators when possible,
1212 // but for now, our validator is weak, since equal validators do not
1213 // indicate byte-level equality of content. (Due to DEBUG timing output, etc...)
1215 // (If DEBUG if off, this may be a strong validator, but I'm going
1216 // to go the paranoid route here pending further study and testing.)
1218 $validators['%weak'] = true;
1219 $request->setValidators($validators);
1221 $request->handleAction();
1223 if (DEBUG and DEBUG & _DEBUG_INFO) phpinfo(INFO_VARIABLES | INFO_MODULES);
1227 //$x = error_reporting(); // DEBUG: why is it 1 here? should be E_ALL
1228 if (defined('E_STRICT') and (E_ALL & E_STRICT)) // strict php5?
1229 error_reporting(E_ALL & ~E_STRICT); // exclude E_STRICT
1231 error_reporting(E_ALL); // php4
1232 // don't run the main loop for special requests (test, getimg, xmlrpc, soap, ...)
1233 if (!defined('PHPWIKI_NOMAIN') or !PHPWIKI_NOMAIN)
1237 // $Log: not supported by cvs2svn $
1238 // Revision 1.203 2005/01/21 14:11:23 rurban
1239 // better moderation class tag
1241 // Revision 1.202 2005/01/21 12:02:32 rurban
1242 // deduce username for xmlrpc also
1244 // Revision 1.201 2005/01/20 10:18:17 rurban
1247 // Revision 1.200 2004/12/26 17:08:36 rurban
1248 // php5 fixes: case-sensitivity, no & new
1250 // Revision 1.199 2004/12/19 00:58:01 rurban
1251 // Enforce PASSWORD_LENGTH_MINIMUM in almost all PassUser checks,
1252 // Provide an errormessage if so. Just PersonalPage and BogoLogin not.
1253 // Simplify httpauth logout handling and set sessions for all methods.
1254 // fix main.php unknown index "x" getLevelDescription() warning.
1256 // Revision 1.198 2004/12/17 16:49:51 rurban
1257 // avoid Invalid username message on Sign In button click
1259 // Revision 1.197 2004/12/17 16:39:55 rurban
1260 // enable sessions for HttpAuth
1262 // Revision 1.196 2004/12/10 02:36:43 rurban
1263 // More help with the new native xmlrpc lib. no warnings, no user cookie on xmlrpc.
1265 // Revision 1.195 2004/12/09 22:24:44 rurban
1266 // optimize on _DEBUG_SQL only. but now again on every 50th request, not just save.
1268 // Revision 1.194 2004/11/30 17:46:49 rurban
1269 // added ModeratedPage POST action hook (part 2/3)
1271 // Revision 1.193 2004/11/30 07:51:08 rurban
1272 // fixed SESSION_SAVE_PATH warning msg
1274 // Revision 1.192 2004/11/21 11:59:20 rurban
1275 // remove final \n to be ob_cache independent
1277 // Revision 1.191 2004/11/19 19:22:03 rurban
1278 // ModeratePage part1: change status
1280 // Revision 1.190 2004/11/15 15:56:40 rurban
1281 // don't load PagePerm on ENABLE_PAGEPERM = false to save memory. Move mayAccessPage() to main.php
1283 // Revision 1.189 2004/11/09 17:11:16 rurban
1284 // * revert to the wikidb ref passing. there's no memory abuse there.
1285 // * use new wikidb->_cache->_id_cache[] instead of wikidb->_iwpcache, to effectively
1286 // store page ids with getPageLinks (GleanDescription) of all existing pages, which
1287 // are also needed at the rendering for linkExistingWikiWord().
1288 // pass options to pageiterator.
1289 // use this cache also for _get_pageid()
1290 // This saves about 8 SELECT count per page (num all pagelinks).
1291 // * fix passing of all page fields to the pageiterator.
1292 // * fix overlarge session data which got broken with the latest ACCESS_LOG_SQL changes
1294 // Revision 1.188 2004/11/07 16:02:52 rurban
1295 // new sql access log (for spam prevention), and restructured access log class
1296 // dbh->quote (generic)
1297 // pear_db: mysql specific parts seperated (using replace)
1299 // Revision 1.187 2004/11/05 22:08:52 rurban
1300 // Ok: Fix loading all required userclasses beforehand. This is much slower than before but safes a few bytes RAM
1302 // Revision 1.186 2004/11/05 20:53:35 rurban
1303 // login cleanup: better debug msg on failing login,
1304 // checked password less immediate login (bogo or anon),
1305 // checked olduser pref session error,
1306 // better PersonalPage without password warning on minimal password length=0
1307 // (which is default now)
1309 // Revision 1.185 2004/11/01 13:55:05 rurban
1310 // fix against switching user new/old between sessions
1312 // Revision 1.184 2004/11/01 10:43:57 rurban
1313 // seperate PassUser methods into seperate dir (memory usage)
1314 // fix WikiUser (old) overlarge data session
1315 // remove wikidb arg from various page class methods, use global ->_dbi instead
1318 // Revision 1.183 2004/10/14 19:23:58 rurban
1319 // remove debugging prints
1321 // Revision 1.182 2004/10/12 13:13:19 rurban
1322 // php5 compatibility (5.0.1 ok)
1324 // Revision 1.181 2004/10/07 16:08:58 rurban
1325 // fixed broken FileUser session handling.
1326 // thanks to Arnaud Fontaine for detecting this.
1327 // enable file user Administrator membership.
1329 // Revision 1.180 2004/10/04 23:39:34 rurban
1332 // Revision 1.179 2004/09/25 18:57:42 rurban
1333 // better ACL error message: view not browse, change not setacl, ...
1335 // Revision 1.178 2004/09/25 16:27:36 rurban
1336 // better not allowed description: on global disallowed, and on missing pageperms
1338 // Revision 1.177 2004/09/14 10:31:09 rurban
1339 // exclude E_STRICT for php5: untested. I believe this must be set earlier because the parsing step is already strict, and this is called at run-time
1341 // Revision 1.176 2004/08/05 17:33:22 rurban
1344 // Revision 1.175 2004/07/13 13:08:25 rurban
1345 // fix PEAR memory waste issues
1347 // Revision 1.174 2004/07/08 13:50:32 rurban
1348 // various unit test fixes: print error backtrace on _DEBUG_TRACE; allusers fix; new PHPWIKI_NOMAIN constant for omitting the mainloop
1350 // Revision 1.173 2004/07/05 12:57:54 rurban
1351 // add mysql timeout
1353 // Revision 1.172 2004/07/03 08:04:19 rurban
1354 // fixed implicit PersonalPage login (e.g. on edit), fixed to check against create ACL on create, not edit
1356 // Revision 1.171 2004/06/29 09:30:42 rurban
1357 // force string hash
1359 // Revision 1.170 2004/06/25 14:29:20 rurban
1360 // WikiGroup refactoring:
1361 // global group attached to user, code for not_current user.
1362 // improved helpers for special groups (avoid double invocations)
1363 // new experimental config option ENABLE_XHTML_XML (fails with IE, and document.write())
1364 // fixed a XHTML validation error on userprefs.tmpl
1366 // Revision 1.169 2004/06/20 14:42:54 rurban
1367 // various php5 fixes (still broken at blockparser)
1369 // Revision 1.168 2004/06/17 10:39:18 rurban
1370 // fix reverse translation of possible actionpage
1372 // Revision 1.167 2004/06/16 13:21:16 rurban
1373 // stabilize on failing ldap queries or bind
1375 // Revision 1.166 2004/06/15 09:15:52 rurban
1376 // IMPORTANT: fixed passwd handling for passwords stored in prefs:
1377 // fix encrypted usage, actually store and retrieve them from db
1378 // fix bogologin with passwd set.
1379 // fix php crashes with call-time pass-by-reference (references wrongly used
1380 // in declaration AND call). This affected mainly Apache2 and IIS.
1381 // (Thanks to John Cole to detect this!)
1383 // Revision 1.165 2004/06/14 11:31:37 rurban
1384 // renamed global $Theme to $WikiTheme (gforge nameclash)
1385 // inherit PageList default options from PageList
1386 // default sortby=pagename
1387 // use options in PageList_Selectable (limit, sortby, ...)
1388 // added action revert, with button at action=diff
1389 // added option regex to WikiAdminSearchReplace
1391 // Revision 1.164 2004/06/13 13:54:25 rurban
1392 // Catch fatals on the four dump calls (as file and zip, as html and mimified)
1393 // FoafViewer: Check against external requirements, instead of fatal.
1394 // Change output for xhtmldumps: using file:// urls to the local fs.
1395 // Catch SOAP fatal by checking for GOOGLE_LICENSE_KEY
1396 // Import GOOGLE_LICENSE_KEY and FORTUNE_DIR from config.ini.
1398 // Revision 1.163 2004/06/13 11:35:32 rurban
1399 // check for create action on action=edit not to fool PagePerm checks
1401 // Revision 1.162 2004/06/08 10:05:11 rurban
1402 // simplified admin action shortcuts
1404 // Revision 1.161 2004/06/07 22:58:40 rurban
1405 // simplified chown, setacl, dump actions
1407 // Revision 1.160 2004/06/07 22:44:14 rurban
1408 // added simplified chown, setacl actions
1410 // Revision 1.159 2004/06/06 16:58:51 rurban
1411 // added more required ActionPages for foreign languages
1412 // install now english ActionPages if no localized are found. (again)
1413 // fixed default anon user level to be 0, instead of -1
1414 // (wrong "required administrator to view this page"...)
1416 // Revision 1.158 2004/06/04 20:32:53 rurban
1417 // Several locale related improvements suggested by Pierrick Meignen
1418 // LDAP fix by John Cole
1419 // reanable admin check without ENABLE_PAGEPERM in the admin plugins
1421 // Revision 1.157 2004/06/04 12:40:21 rurban
1422 // Restrict valid usernames to prevent from attacks against external auth or compromise
1424 // Fix various WikiUser old issues with default IMAP,LDAP,POP3 configs. Removed these.
1425 // Fxied more warnings
1427 // Revision 1.156 2004/06/03 17:58:16 rurban
1428 // support immediate LANG and THEME switch inside a session
1430 // Revision 1.155 2004/06/03 10:18:19 rurban
1431 // fix FileUser locking issues, new config ENABLE_PAGEPERM
1433 // Revision 1.154 2004/06/02 18:01:46 rurban
1434 // init global FileFinder to add proper include paths at startup
1435 // adds PHPWIKI_DIR if started from another dir, lib/pear also
1436 // fix slashify for Windows
1437 // fix USER_AUTH_POLICY=old, use only USER_AUTH_ORDER methods (besides HttpAuth)
1439 // Revision 1.153 2004/06/01 15:28:00 rurban
1440 // AdminUser only ADMIN_USER not member of Administrators
1441 // some RateIt improvements by dfrankow
1442 // edit_toolbar buttons
1444 // Revision 1.152 2004/05/27 17:49:06 rurban
1445 // renamed DB_Session to DbSession (in CVS also)
1446 // added WikiDB->getParam and WikiDB->getAuthParam method to get rid of globals
1447 // remove leading slash in error message
1448 // added force_unlock parameter to File_Passwd (no return on stale locks)
1449 // fixed adodb session AffectedRows
1450 // added FileFinder helpers to unify local filenames and DATA_PATH names
1451 // editpage.php: new edit toolbar javascript on ENABLE_EDIT_TOOLBAR
1453 // Revision 1.151 2004/05/25 12:40:48 rurban
1454 // trim the pagename
1456 // Revision 1.150 2004/05/25 10:18:44 rurban
1457 // Check for UTF-8 URLs; Internet Explorer produces these if you
1458 // type non-ASCII chars in the URL bar or follow unescaped links.
1459 // Fixes sf.net bug #953949
1460 // src: languages/Language.php:checkTitleEncoding() from mediawiki
1462 // Revision 1.149 2004/05/18 13:31:19 rurban
1463 // hold warnings until headers are sent. new Error-style with collapsed output of repeated messages
1465 // Revision 1.148 2004/05/17 17:43:29 rurban
1466 // CGI: no PATH_INFO fix
1468 // Revision 1.147 2004/05/15 19:48:33 rurban
1469 // fix some too loose PagePerms for signed, but not authenticated users
1470 // (admin, owner, creator)
1471 // no double login page header, better login msg.
1472 // moved action_pdf to lib/pdf.php
1474 // Revision 1.146 2004/05/15 18:31:01 rurban
1475 // some action=pdf Request fixes: With MSIE it works now. Now the work with the page formatting begins.
1477 // Revision 1.145 2004/05/12 10:49:55 rurban
1478 // require_once fix for those libs which are loaded before FileFinder and
1479 // its automatic include_path fix, and where require_once doesn't grok
1480 // dirname(__FILE__) != './lib'
1481 // upgrade fix with PearDB
1482 // navbar.tmpl: remove spaces for IE button alignment
1484 // Revision 1.144 2004/05/06 19:26:16 rurban
1485 // improve stability, trying to find the InlineParser endless loop on sf.net
1487 // remove end-of-zip comments to fix sf.net bug #777278 and probably #859628
1489 // Revision 1.143 2004/05/06 17:30:38 rurban
1490 // CategoryGroup: oops, dos2unix eol
1491 // improved phpwiki_version:
1492 // pre -= .0001 (1.3.10pre: 1030.099)
1493 // -p1 += .001 (1.3.9-p1: 1030.091)
1494 // improved InstallTable for mysql and generic SQL versions and all newer tables so far.
1495 // abstracted more ADODB/PearDB methods for action=upgrade stuff:
1496 // backend->backendType(), backend->database(),
1497 // backend->listOfFields(),
1498 // backend->listOfTables(),
1500 // Revision 1.142 2004/05/04 22:34:25 rurban
1503 // Revision 1.141 2004/05/03 13:16:47 rurban
1504 // fixed UserPreferences update, esp for boolean and int
1506 // Revision 1.140 2004/05/02 21:26:38 rurban
1507 // limit user session data (HomePageHandle and auth_dbi have to invalidated anyway)
1508 // because they will not survive db sessions, if too large.
1509 // extended action=upgrade
1510 // some WikiTranslation button work
1511 // revert WIKIAUTH_UNOBTAINABLE (need it for main.php)
1512 // some temp. session debug statements
1514 // Revision 1.139 2004/05/02 15:10:07 rurban
1515 // new finally reliable way to detect if /index.php is called directly
1516 // and if to include lib/main.php
1517 // new global AllActionPages
1518 // SetupWiki now loads all mandatory pages: HOME_PAGE, action pages, and warns if not.
1519 // WikiTranslation what=buttons for Carsten to create the missing MacOSX buttons
1520 // PageGroupTestOne => subpages
1521 // renamed PhpWikiRss to PhpWikiRecentChanges
1522 // more docs, default configs, ...
1524 // Revision 1.138 2004/05/01 15:59:29 rurban
1525 // more php-4.0.6 compatibility: superglobals
1527 // Revision 1.137 2004/04/29 19:39:44 rurban
1528 // special support for formatted plugins (one-liners)
1529 // like <small><plugin BlaBla ></small>
1530 // iter->asArray() helper for PopularNearby
1531 // db_session for older php's (no &func() allowed)
1533 // Revision 1.136 2004/04/29 17:18:19 zorloc
1534 // 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.
1536 // Revision 1.135 2004/04/26 12:15:01 rurban
1537 // check default config values
1539 // Revision 1.134 2004/04/23 06:46:37 zorloc
1540 // Leave DB connection open when USE_DB_SESSION is true so that session info can be written to the DB.
1542 // Revision 1.133 2004/04/20 18:10:31 rurban
1543 // config refactoring:
1544 // FileFinder is needed for WikiFarm scripts calling index.php
1545 // config run-time calls moved to lib/IniConfig.php:fix_configs()
1546 // added PHPWIKI_DIR smart-detection code (Theme finder)
1547 // moved FileFind to lib/FileFinder.php
1548 // cleaned lib/config.php
1550 // Revision 1.132 2004/04/19 21:51:41 rurban
1551 // php5 compatibility: it works!
1553 // Revision 1.131 2004/04/19 18:27:45 rurban
1554 // Prevent from some PHP5 warnings (ref args, no :: object init)
1555 // php5 runs now through, just one wrong XmlElement object init missing
1556 // Removed unneccesary UpgradeUser lines
1557 // Changed WikiLink to omit version if current (RecentChanges)
1559 // Revision 1.130 2004/04/18 00:25:53 rurban
1560 // allow "0" pagename
1562 // Revision 1.129 2004/04/07 23:13:19 rurban
1563 // fixed pear/File_Passwd for Windows
1564 // fixed FilePassUser sessions (filehandle revive) and password update
1566 // Revision 1.128 2004/04/02 15:06:55 rurban
1567 // fixed a nasty ADODB_mysql session update bug
1568 // improved UserPreferences layout (tabled hints)
1569 // fixed UserPreferences auth handling
1570 // improved auth stability
1571 // improved old cookie handling: fixed deletion of old cookies with paths
1573 // Revision 1.127 2004/03/25 17:00:31 rurban
1574 // more code to convert old-style pref array to new hash
1576 // Revision 1.126 2004/03/24 19:39:03 rurban
1577 // php5 workaround code (plus some interim debugging code in XmlElement)
1578 // php5 doesn't work yet with the current XmlElement class constructors,
1579 // WikiUserNew does work better than php4.
1580 // rewrote WikiUserNew user upgrading to ease php5 update
1581 // fixed pref handling in WikiUserNew
1582 // added Email Notification
1583 // added simple Email verification
1584 // removed emailVerify userpref subclass: just a email property
1585 // changed pref binary storage layout: numarray => hash of non default values
1586 // print optimize message only if really done.
1587 // forced new cookie policy: delete pref cookies, use only WIKI_ID as plain string.
1588 // prefs should be stored in db or homepage, besides the current session.
1590 // Revision 1.125 2004/03/14 16:30:52 rurban
1591 // db-handle session revivification, dba fixes
1593 // Revision 1.124 2004/03/12 15:48:07 rurban
1594 // fixed explodePageList: wrong sortby argument order in UnfoldSubpages
1595 // simplified lib/stdlib.php:explodePageList
1597 // Revision 1.123 2004/03/10 15:41:27 rurban
1598 // use default pref mysql table
1600 // Revision 1.122 2004/03/08 18:17:09 rurban
1601 // added more WikiGroup::getMembersOf methods, esp. for special groups
1602 // fixed $LDAP_SET_OPTIONS
1603 // fixed _AuthInfo group methods
1605 // Revision 1.121 2004/03/01 13:48:45 rurban
1607 // p[] consistency fix
1609 // Revision 1.120 2004/03/01 10:22:41 rurban
1610 // initializeTheme optimize
1612 // Revision 1.119 2004/02/26 20:45:06 rurban
1613 // check for ALLOW_ANON_USER = false
1615 // Revision 1.118 2004/02/26 01:32:03 rurban
1616 // fixed session login with old WikiUser object. strangely, the errormask gets corruoted to 1, Pear???
1618 // Revision 1.117 2004/02/24 17:19:37 rurban
1619 // debugging helpers only
1621 // Revision 1.116 2004/02/24 15:17:14 rurban
1622 // 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
1624 // Revision 1.115 2004/02/15 21:34:37 rurban
1625 // PageList enhanced and improved.
1626 // fixed new WikiAdmin... plugins
1627 // editpage, Theme with exp. htmlarea framework
1628 // (htmlarea yet committed, this is really questionable)
1629 // WikiUser... code with better session handling for prefs
1630 // enhanced UserPreferences (again)
1631 // RecentChanges for show_deleted: how should pages be deleted then?
1633 // Revision 1.114 2004/02/15 17:30:13 rurban
1634 // workaround for lost db connnection handle on session restauration (->_auth_dbi)
1635 // fixed getPreferences() (esp. from sessions)
1636 // fixed setPreferences() (update and set),
1637 // fixed AdoDb DB statements,
1638 // update prefs only at UserPreferences POST (for testing)
1639 // unified db prefs methods (but in external pref classes yet)
1641 // Revision 1.113 2004/02/12 13:05:49 rurban
1642 // Rename functional for PearDB backend
1643 // some other minor changes
1644 // SiteMap comes with a not yet functional feature request: includepages (tbd)
1646 // Revision 1.112 2004/02/09 03:58:12 rurban
1647 // for now default DB_SESSION to false
1649 // * not existing perms will now query the parent, and not
1650 // return the default perm
1651 // * added pagePermissions func which returns the object per page
1652 // * added getAccessDescription
1654 // * added global ->prepare (not yet used) with smart user/pref/member table prefixing.
1655 // * force init of authdbh in the 2 db classes
1657 // * fixed session handling (not triple auth request anymore)
1658 // * don't store cookie prefs with sessions
1659 // stdlib: global obj2hash helper from _AuthInfo, also needed for PagePerm
1661 // Revision 1.111 2004/02/07 10:41:25 rurban
1662 // fixed auth from session (still double code but works)
1664 // fixed DbPassUser upgrade and policy=old
1667 // Revision 1.110 2004/02/03 09:45:39 rurban
1668 // LDAP cleanup, start of new Pref classes
1670 // Revision 1.109 2004/01/30 19:57:58 rurban
1671 // fixed DBAuthParams['pref_select']: wrong _auth_dbi object used.
1673 // Revision 1.108 2004/01/28 14:34:14 rurban
1674 // session table takes the common prefix
1675 // + various minor stuff
1676 // reallow password changing
1678 // Revision 1.107 2004/01/27 23:23:39 rurban
1679 // renamed ->Username => _userid for consistency
1680 // renamed mayCheckPassword => mayCheckPass
1681 // fixed recursion problem in WikiUserNew
1682 // fixed bogo login (but not quite 100% ready yet, password storage)
1684 // Revision 1.106 2004/01/26 09:17:49 rurban
1685 // * changed stored pref representation as before.
1686 // the array of objects is 1) bigger and 2)
1687 // less portable. If we would import packed pref
1688 // objects and the object definition was changed, PHP would fail.
1689 // This doesn't happen with an simple array of non-default values.
1690 // * use $prefs->retrieve and $prefs->store methods, where retrieve
1691 // understands the interim format of array of objects also.
1692 // * simplified $prefs->get() and fixed $prefs->set()
1693 // * added $user->_userid and class '_WikiUser' portability functions
1694 // * fixed $user object ->_level upgrading, mostly using sessions.
1695 // this fixes yesterdays problems with loosing authorization level.
1696 // * fixed WikiUserNew::checkPass to return the _level
1697 // * fixed WikiUserNew::isSignedIn
1698 // * added explodePageList to class PageList, support sortby arg
1699 // * fixed UserPreferences for WikiUserNew
1700 // * fixed WikiPlugin for empty defaults array
1701 // * UnfoldSubpages: added pagename arg, renamed pages arg,
1702 // removed sort arg, support sortby arg
1704 // Revision 1.105 2004/01/25 03:57:15 rurban
1705 // WikiUserNew support (temp. ENABLE_USER_NEW constant)
1707 // Revision 1.104 2003/12/26 06:41:16 carstenklapp
1708 // Bugfix: Try to defer OS errors about session.save_path and ACCESS_LOG,
1709 // so they don't prevent IE from partially (or not at all) rendering the
1710 // page. This should help a little for the IE user who encounters trouble
1711 // when setting up a new PhpWiki for the first time.
1713 // Revision 1.103 2003/12/02 00:10:00 carstenklapp
1714 // Bugfix: Ongoing work to untangle UserPreferences/WikiUser/request code
1715 // mess: UserPreferences should take effect immediately now upon signing
1718 // Revision 1.102 2003/11/25 22:55:32 carstenklapp
1719 // Localization bugfix: For wikis where English is not the default system
1720 // language, make sure that the authority error message (i.e. "You must
1721 // sign in to edit pages in this wiki" etc.) is displayed in the wiki's
1722 // default language. Previously it would always display in English.
1723 // (Added call to update_locale() before displaying any messages prior to
1724 // the login prompt.)
1726 // Revision 1.101 2003/11/25 21:49:44 carstenklapp
1727 // Bugfix: For a non-english wiki or when the user's preference is not
1728 // english, the wiki would always use the english ActionPage first if it
1729 // was present rather than the appropriate localised variant. (PhpWikis
1730 // running only in english or Wikis running ONLY without any english
1731 // ActionPages would not notice this bug, only when both english and
1732 // localised ActionPages were in the DB.) Now we check for the localised
1735 // Revision 1.100 2003/11/18 16:54:18 carstenklapp
1736 // Reformatting only: Tabs to spaces, added rcs log.
1743 // c-basic-offset: 4
1744 // c-hanging-comment-ender-p: nil
1745 // indent-tabs-mode: nil