]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/main.php
sf.net patch #1438392 by Matt Brown: Bogo Login is broken when ENABLE_PAGEPERM=false
[SourceForge/phpwiki.git] / lib / main.php
1 <?php //-*-php-*-
2 rcs_id('$Id: main.php,v 1.222 2006-03-19 14:53:12 rurban Exp $');
3 /*
4  Copyright 1999,2000,2001,2002,2004,2005 $ThePhpWikiProgrammingTeam
5
6  This file is part of PhpWiki.
7
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.
12
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.
17
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
21  */
22
23 define ('USE_PREFS_IN_PAGE', true);
24
25 //include "lib/config.php";
26 require_once(dirname(__FILE__)."/stdlib.php");
27 require_once('lib/Request.php');
28 require_once('lib/WikiDB.php');
29 if (ENABLE_USER_NEW)
30     require_once("lib/WikiUserNew.php");
31 else
32     require_once("lib/WikiUser.php");
33 require_once("lib/WikiGroup.php");
34 if (ENABLE_PAGEPERM)
35     require_once("lib/PagePerm.php");
36
37 /**
38  * Check permission per page.
39  * Returns true or false.
40  */
41 function mayAccessPage ($access, $pagename) {
42     if (ENABLE_PAGEPERM)
43         return _requiredAuthorityForPagename($access, $pagename); // typically [10-20ms per page]
44     else
45         return true;
46 }
47
48 class WikiRequest extends Request {
49     // var $_dbi;
50
51     function WikiRequest () {
52         $this->_dbi = WikiDB::open($GLOBALS['DBParams']);
53          // first mysql request costs [958ms]! [670ms] is mysql_connect()
54         
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");
58         }
59         if (ENABLE_USER_NEW) {
60             // Preload all necessary userclasses. Otherwise session => __PHP_Incomplete_Class_Name
61             // There's no way to demand-load it later. This way it's much slower, but needs slightly
62             // less memory than loading all.
63             if (ALLOW_BOGO_LOGIN)
64                 include_once("lib/WikiUser/BogoLogin.php");
65             // UserPreferences POST Update doesn't reach this.
66             foreach ($GLOBALS['USER_AUTH_ORDER'] as $method) {
67                 include_once("lib/WikiUser/$method.php");
68                 if ($method == 'Db')
69                     switch( DATABASE_TYPE ) {
70                         case 'SQL'  : include_once("lib/WikiUser/PearDb.php"); break;
71                         case 'ADODB': include_once("lib/WikiUser/AdoDb.php"); break;
72                         case 'PDO'  : include_once("lib/WikiUser/PdoDb.php"); break;
73                     }
74             }
75             unset($method);
76         }
77         if (USE_DB_SESSION) {
78             include_once('lib/DbSession.php');
79             $dbi =& $this->_dbi;
80             $this->_dbsession = new DbSession($dbi, $dbi->getParam('prefix') 
81                                               . $dbi->getParam('db_session_table'));
82         }
83
84 // Fixme: Does pear reset the error mask to 1? We have to find the culprit
85 //$x = error_reporting();
86
87         $this->version = phpwiki_version();
88         $this->Request(); // [90ms]
89
90         // Normalize args...
91         $this->setArg('pagename', $this->_deducePagename());
92         $this->setArg('action', $this->_deduceAction());
93
94         if ((DEBUG & _DEBUG_SQL)
95             or (DATABASE_OPTIMISE_FREQUENCY > 0 and 
96                 (time() % DATABASE_OPTIMISE_FREQUENCY == 0))) {
97             if ($this->_dbi->_backend->optimize())
98                 trigger_error(_("Optimizing database"), E_USER_NOTICE);
99         }
100
101         // Restore auth state. This doesn't check for proper authorization!
102         $userid = $this->_deduceUsername();     
103         if (ENABLE_USER_NEW) {
104             if (isset($this->_user) and 
105                 !empty($this->_user->_authhow) and 
106                 $this->_user->_authhow == 'session')
107             {
108                 // users might switch in a session between the two objects.
109                 // restore old auth level here or in updateAuthAndPrefs?
110                 //$user = $this->getSessionVar('wiki_user');
111                 // revive db handle, because these don't survive sessions
112                 if (isset($this->_user) and 
113                      ( ! isa($this->_user, WikiUserClassname())
114                        or (strtolower(get_class($this->_user)) == '_passuser')))
115                 {
116                     $this->_user = WikiUser($userid, $this->_user->_prefs);
117                 }
118                 // revive other db handle
119                 if (isset($this->_user->_prefs->_method)
120                     and ($this->_user->_prefs->_method == 'SQL' 
121                          or $this->_user->_prefs->_method == 'ADODB' 
122                          or $this->_user->_prefs->_method == 'PDO' 
123                          or $this->_user->_prefs->_method == 'HomePage')) {
124                     $this->_user->_HomePagehandle = $this->getPage($userid);
125                 }
126                 // need to update the lockfile filehandle
127                 if ( isa($this->_user, '_FilePassUser') 
128                      and $this->_user->_file->lockfile 
129                      and !$this->_user->_file->fplock )
130                 {
131                     //$level = $this->_user->_level;
132                     $this->_user = UpgradeUser($this->_user, 
133                                                new _FilePassUser($userid, 
134                                                                  $this->_user->_prefs, 
135                                                                  $this->_user->_file->filename));
136                     //$this->_user->_level = $level;
137                 }
138                 $this->_prefs = & $this->_user->_prefs;
139             } else {
140                 $user = WikiUser($userid);
141                 $this->_user = & $user;
142                 $this->_prefs = & $this->_user->_prefs;
143             }
144         } else {
145             $this->_user = new WikiUser($this, $userid);
146             $this->_prefs = $this->_user->getPreferences();
147         }
148     }
149
150     function initializeLang () {
151         // check non-default pref lang
152         $_lang = @$this->_prefs->_prefs['lang'];
153         if (isset($_lang->lang) and $_lang->lang != $GLOBALS['LANG']) {
154             $user_lang = $_lang->lang;
155             //check changed LANG and THEME inside a session. 
156             // (e.g. by using another baseurl)
157             if (isset($this->_user->_authhow) and $this->_user->_authhow == 'session')
158                 $user_lang = $GLOBALS['LANG'];
159             update_locale($user_lang);
160             FindLocalizedButtonFile(".",'missing_ok','reinit');
161         }
162     }
163
164     function initializeTheme () {
165         global $WikiTheme;
166
167         // Load non-default theme
168         $_theme = @$this->_prefs->_prefs['theme'];
169         if ($_theme and isset($_theme->theme))
170             $user_theme = $_theme->theme;
171         else 
172             $user_theme = $this->getPref('theme');
173         //check changed LANG and THEME inside a session. 
174         // (e.g. by using another baseurl)
175         if (isset($this->_user->_authhow) 
176             and $this->_user->_authhow == 'session' 
177             and !isset($_theme->theme) 
178             and defined('THEME') 
179             and $user_theme != THEME)
180         {
181             include_once("themes/" . THEME . "/themeinfo.php");
182         }
183         if (empty($WikiTheme) and isset($user_theme)) {
184             if (strcspn($user_theme,"./\x00]") != strlen($user_theme)) {
185                 trigger_error(sprintf("invalid theme '%s': Invalid characters detected", $user_theme),
186                               E_USER_WARNING);
187                 $user_theme = "default";
188             }
189             include_once("themes/$user_theme/themeinfo.php");
190         }
191         if (empty($WikiTheme) and defined('THEME'))
192             include_once("themes/" . THEME . "/themeinfo.php");
193         if (empty($WikiTheme))
194             include_once("themes/default/themeinfo.php");
195         assert(!empty($WikiTheme));
196     }
197
198     // This really maybe should be part of the constructor, but since it
199     // may involve HTML/template output, the global $request really needs
200     // to be initialized before we do this stuff.
201     // [50ms]: 36ms if wikidb_page::exists
202     function updateAuthAndPrefs () {
203
204         if (isset($this->_user) and (!isa($this->_user, WikiUserClassname()))) {
205             $this->_user = false;       
206         }
207         // Handle authentication request, if any.
208         if ($auth_args = $this->getArg('auth')) {
209             $this->setArg('auth', false);
210             $this->_handleAuthRequest($auth_args); // possible NORETURN
211         }
212         elseif ( ! $this->_user 
213                  or (isa($this->_user, WikiUserClassname()) 
214                      and ! $this->_user->isSignedIn())) {
215             // If not auth request, try to sign in as saved user.
216             if (($saved_user = $this->getPref('userid')) != false) {
217                 $this->_signIn($saved_user);
218             }
219         }
220         
221         $action = $this->getArg('action');
222
223         // Save preferences in session and cookie
224         if ((defined('WIKI_XMLRPC') and !WIKI_XMLRPC) or $action != 'xmlrpc') {
225             if (isset($this->_user)) {
226                 if (!isset($this->_user->_authhow) or $this->_user->_authhow != 'session') {
227                     $this->_user->setPreferences($this->_prefs, true);
228                 }
229             }
230             $this->setSessionVar('wiki_user', $this->_user);
231         }
232
233         // Ensure user has permissions for action
234         // HACK ALERT: We may not set the request arg to create, 
235         // since the pageeditor has an ugly logic for action == create.
236         if ($action == 'edit' or $action == 'create') {
237             $page = $this->getPage();
238             if (! $page->exists() )
239                 $action = 'create';
240             else
241                 $action = 'edit';
242         }
243         if (! ENABLE_PAGEPERM) { // Bug #1438392 by Matt Brown
244             $require_level = $this->requiredAuthority($action);
245             if (! $this->_user->hasAuthority($require_level))
246                 $this->_notAuthorized($require_level); // NORETURN
247         } else {
248             // novatrope patch to let only _AUTHENTICATED view pages.
249             // If there's not enough authority or forbidden, ask for a password, 
250             // unless it's explicitly unobtainable. Some bad magic though.
251             if ($this->requiredAuthorityForAction($action) == WIKIAUTH_UNOBTAINABLE) {
252                 $require_level = $this->requiredAuthority($action);
253                 $this->_notAuthorized($require_level); // NORETURN
254             }
255         }
256     }
257
258     function & getUser () {
259         if (isset($this->_user))
260             return $this->_user;
261         else
262             return $GLOBALS['ForbiddenUser'];
263     }
264     
265     function & getGroup () {
266         if (isset($this->_user) and isset($this->_user->_group))
267             return $this->_user->_group;
268         else {
269             // Debug Strict: Only variable references should be returned by reference
270             $this->_user->_group = WikiGroup::getGroup();
271             return $this->_user->_group;
272         }
273     }
274
275     function & getPrefs () {
276         return $this->_prefs;
277     }
278
279     // Convenience function:
280     function getPref ($key) {
281         if (isset($this->_prefs)) {
282             return $this->_prefs->get($key);
283         }
284     }
285     function & getDbh () {
286         return $this->_dbi;
287     }
288
289     /**
290      * Get requested page from the page database.
291      * By default it will grab the page requested via the URL
292      *
293      * This is a convenience function.
294      * @param string $pagename Name of page to get.
295      * @return WikiDB_Page Object with methods to pull data from
296      * database for the page requested.
297      */
298     function getPage ($pagename = false) {
299         //if (!isset($this->_dbi)) $this->getDbh();
300         if (!$pagename) 
301             $pagename = $this->getArg('pagename');
302         return $this->_dbi->getPage($pagename);
303     }
304
305     /** Get URL for POST actions.
306      *
307      * Officially, we should just use SCRIPT_NAME (or some such),
308      * but that causes problems when we try to issue a redirect, e.g.
309      * after saving a page.
310      *
311      * Some browsers (at least NS4 and Mozilla 0.97 won't accept
312      * a redirect from a page to itself.)
313      *
314      * So, as a HACK, we include pagename and action as query args in
315      * the URL.  (These should be ignored when we receive the POST
316      * request.)
317      */
318     function getPostURL ($pagename=false) {
319         global $HTTP_GET_VARS;
320
321         if ($pagename === false)
322             $pagename = $this->getArg('pagename');
323         $action = $this->getArg('action');
324         if (!empty($HTTP_GET_VARS['start_debug'])) // zend ide support
325             return WikiURL($pagename, array('action' => $action, 'start_debug' => 1));
326         else
327             return WikiURL($pagename, array('action' => $action));
328     }
329     
330     function _handleAuthRequest ($auth_args) {
331         if (!is_array($auth_args))
332             return;
333
334         // Ignore password unless POST'ed.
335         if (!$this->isPost())
336             unset($auth_args['passwd']);
337
338         $olduser = $this->_user;
339         $user = $this->_user->AuthCheck($auth_args);
340         if (isa($user, WikiUserClassname())) {
341             // Successful login (or logout.)
342             $this->_setUser($user);
343         }
344         elseif (is_string($user)) {
345             // Login attempt failed.
346             $fail_message = $user;
347             $auth_args['pass_required'] = true;
348             // if clicked just on to the "sign in as:" button dont print invalid username.
349             if (!empty($auth_args['login']) and empty($auth_args['userid']))
350                 $fail_message = '';
351             // If no password was submitted, it's not really
352             // a failure --- just need to prompt for password...
353             if (!ALLOW_USER_PASSWORDS 
354                 and ALLOW_BOGO_LOGIN 
355                 and !isset($auth_args['passwd'])) 
356             {
357                 $fail_message = false;
358             }
359             $olduser->PrintLoginForm($this, $auth_args, $fail_message, 'newpage');
360             $this->finish();    //NORETURN
361         }
362         else {
363             // Login request cancelled.
364         }
365     }
366
367     /**
368      * Attempt to sign in (bogo-login).
369      *
370      * Fails silently.
371      *
372      * @param $userid string Userid to attempt to sign in as.
373      * @access private
374      */
375     function _signIn ($userid) {
376         if (ENABLE_USER_NEW) {
377             if (! $this->_user )
378                 $this->_user = new _BogoUser($userid);
379             // FIXME: is this always false? shouldn't we try passuser first?
380             if (! $this->_user ) 
381                 $this->_user = new _PassUser($userid);
382         }
383         $user = $this->_user->AuthCheck(array('userid' => $userid));
384         if (isa($user, WikiUserClassname())) {
385             $this->_setUser($user); // success!
386         }
387     }
388
389     // login or logout or restore state
390     function _setUser (&$user) {
391         $this->_user =& $user;
392         if (defined('MAIN_setUser')) return; // don't set cookies twice
393         $this->setCookieVar('WIKI_ID', $user->getAuthenticatedId(),
394                             COOKIE_EXPIRATION_DAYS, COOKIE_DOMAIN);
395         if ($user->isSignedIn())
396             $user->_authhow = 'signin';
397
398         // Save userid to prefs..
399         if ( empty($this->_user->_prefs)) {
400             $this->_user->_prefs = $this->_user->getPreferences();
401             $this->_prefs =& $this->_user->_prefs;
402         }
403         $this->_user->_group = $this->getGroup();
404         $this->setSessionVar('wiki_user', $user);
405         $this->_prefs->set('userid',
406                            $user->isSignedIn() ? $user->getId() : '');
407         $this->initializeTheme();
408         define('MAIN_setUser', true);
409     }
410
411     /* Permission system */
412     function getLevelDescription($level) {
413         static $levels = false;
414         if (!$levels) // This looks like a Visual Basic hack. For the very same reason. "0"
415             $levels = array('x-1' => _("FORBIDDEN"),
416                             'x0'  => _("ANON"),
417                             'x1'  => _("BOGO"),
418                             'x2'  => _("USER"),
419                             'x10' => _("ADMIN"),
420                             'x100'=> _("UNOBTAINABLE"));
421         if (!empty($level))
422             $level = '0';
423         if (!empty($levels["x".$level]))
424             return $levels["x".$level];
425         else
426             return _("ANON");
427     }
428     
429     function _notAuthorized ($require_level) {
430         // Display the authority message in the Wiki's default
431         // language, in case it is not english.
432         //
433         // Note that normally a user will not see such an error once
434         // logged in, unless the admin has altered the default
435         // disallowed wikiactions. In that case we should probably
436         // check the user's language prefs too at this point; this
437         // would be a situation which is not really handled with the
438         // current code.
439         if (empty($GLOBALS['LANG']))
440             update_locale(DEFAULT_LANGUAGE);
441
442         // User does not have required authority.  Prompt for login.
443         $what = $this->getActionDescription($this->getArg('action'));
444         $pass_required = ($require_level >= WIKIAUTH_USER);
445         if ($require_level == WIKIAUTH_UNOBTAINABLE) {
446             global $DisabledActions;
447             if ($DisabledActions and in_array($action, $DisabledActions)) {
448                 $msg = fmt("%s is disallowed on this wiki.",
449                            $this->getDisallowedActionDescription($this->getArg('action')));
450                 $this->finish();
451                 return;
452             }
453             // Is the reason a missing ACL or just wrong user or password?
454             if (class_exists('PagePermission')) {
455                 $user =& $this->_user;
456                 $status = $user->isAuthenticated() ? _("authenticated") : _("not authenticated");
457                 $msg = fmt("%s %s %s is disallowed on this wiki for %s user '%s' (level: %s).",
458                            _("Missing PagePermission:"),
459                            action2access($this->getArg('action')),
460                            $this->getArg('pagename'),
461                            $status, $user->getId(), $this->getLevelDescription($user->_level));
462                 // TODO: add link to action=setacl
463                 $user->PrintLoginForm($this, compact('pass_required'), $msg);
464                 $this->finish();
465                 return;
466             } else {
467                 $msg = fmt("%s is disallowed on this wiki.",
468                            $this->getDisallowedActionDescription($this->getArg('action')));
469                 $this->_user->PrintLoginForm($this, compact('require_level','pass_required'), $msg);
470                 $this->finish();
471                 return;
472             }
473         }
474         elseif ($require_level == WIKIAUTH_BOGO)
475             $msg = fmt("You must sign in to %s.", $what);
476         elseif ($require_level == WIKIAUTH_USER)
477             $msg = fmt("You must log in to %s.", $what);
478         elseif ($require_level == WIKIAUTH_ANON)
479             $msg = fmt("Access for you is forbidden to %s.", $what);
480         else
481             $msg = fmt("You must be an administrator to %s.", $what);
482
483         $this->_user->PrintLoginForm($this, compact('require_level','pass_required'), $msg);
484         $this->finish();    // NORETURN
485     }
486
487     // Fixme: for PagePermissions we'll need other strings, 
488     // relevant to the requested page, not just for the action on the whole wiki.
489     function getActionDescription($action) {
490         static $actionDescriptions;
491         if (! $actionDescriptions) {
492             $actionDescriptions
493             = array('browse'     => _("view this page"),
494                     'diff'       => _("diff this page"),
495                     'dumphtml'   => _("dump html pages"),
496                     'dumpserial' => _("dump serial pages"),
497                     'edit'       => _("edit this page"),
498                     'revert'     => _("revert to a previous version of this page"),
499                     'create'     => _("create this page"),
500                     'loadfile'   => _("load files into this wiki"),
501                     'lock'       => _("lock this page"),
502                     'remove'     => _("remove this page"),
503                     'unlock'     => _("unlock this page"),
504                     'upload'     => _("upload a zip dump"),
505                     'verify'     => _("verify the current action"),
506                     'viewsource' => _("view the source of this page"),
507                     'xmlrpc'     => _("access this wiki via XML-RPC"),
508                     'soap'       => _("access this wiki via SOAP"),
509                     'zip'        => _("download a zip dump from this wiki"),
510                     'ziphtml'    => _("download a html zip dump from this wiki")
511                     );
512         }
513         if (in_array($action, array_keys($actionDescriptions)))
514             return $actionDescriptions[$action];
515         else
516             return $action;
517     }
518     
519     /**
520      TODO: check against these cases:
521         if ($DisabledActions and in_array($action, $DisabledActions))
522             return WIKIAUTH_UNOBTAINABLE;
523
524         if (ENABLE_PAGEPERM and class_exists("PagePermission")) {
525            return requiredAuthorityForPage($action);
526            
527 => Browsing pages is disallowed on this wiki for authenticated user 'rurban' (level: BOGO).
528     */
529     function getDisallowedActionDescription($action) {
530         static $disallowedActionDescriptions;
531         
532         if (! $disallowedActionDescriptions) {
533             $disallowedActionDescriptions
534             = array('browse'     => _("Browsing pages"),
535                     'diff'       => _("Diffing pages"),
536                     'dumphtml'   => _("Dumping html pages"),
537                     'dumpserial' => _("Dumping serial pages"),
538                     'edit'       => _("Editing pages"),
539                     'revert'     => _("Reverting to a previous version of pages"),
540                     'create'     => _("Creating pages"),
541                     'loadfile'   => _("Loading files"),
542                     'lock'       => _("Locking pages"),
543                     'remove'     => _("Removing pages"),
544                     'unlock'     => _("Unlocking pages"),
545                     'upload'     => _("Uploading zip dumps"),
546                     'verify'     => _("Verify the current action"),
547                     'viewsource' => _("Viewing the source of pages"),
548                     'xmlrpc'     => _("XML-RPC access"),
549                     'soap'       => _("SOAP access"),
550                     'zip'        => _("Downloading zip dumps"),
551                     'ziphtml'    => _("Downloading html zip dumps")
552                     );
553         }
554         if (in_array($action, array_keys($disallowedActionDescriptions)))
555             return $disallowedActionDescriptions[$action];
556         else
557             return $action;
558     }
559
560     function requiredAuthority ($action) {
561         $auth = $this->requiredAuthorityForAction($action);
562         if (!ALLOW_ANON_USER) return WIKIAUTH_USER;
563         
564         /*
565          * This is a hook for plugins to require authority
566          * for posting to them.
567          *
568          * IMPORTANT: This is not a secure check, so the plugin
569          * may not assume that any POSTs to it are authorized.
570          * All this does is cause PhpWiki to prompt for login
571          * if the user doesn't have the required authority.
572          */
573         if ($this->isPost()) {
574             $post_auth = $this->getArg('require_authority_for_post');
575             if ($post_auth !== false)
576                 $auth = max($auth, $post_auth);
577         }
578         return $auth;
579     }
580         
581     function requiredAuthorityForAction ($action) {
582         global $DisabledActions;
583         
584         if ($DisabledActions and in_array($action, $DisabledActions))
585             return WIKIAUTH_UNOBTAINABLE;
586             
587         if (ENABLE_PAGEPERM and class_exists("PagePermission")) {
588            return requiredAuthorityForPage($action);
589         } else {
590           // FIXME: clean up. 
591           switch ($action) {
592             case 'browse':
593             case 'viewsource':
594             case 'diff':
595             case 'select':
596             case 'xmlrpc':
597             case 'search':
598             case 'pdf':
599             case 'captcha':
600                 return WIKIAUTH_ANON;
601
602             case 'zip':
603             case 'ziphtml':
604                 if (defined('ZIPDUMP_AUTH') && ZIPDUMP_AUTH)
605                     return WIKIAUTH_ADMIN;
606                 return WIKIAUTH_ANON;
607
608             case 'edit':
609             case 'revert':
610             case 'soap':
611                 if (defined('REQUIRE_SIGNIN_BEFORE_EDIT') && REQUIRE_SIGNIN_BEFORE_EDIT)
612                     return WIKIAUTH_BOGO;
613                 return WIKIAUTH_ANON;
614                 // return WIKIAUTH_BOGO;
615
616             case 'create':
617                 $page = $this->getPage();
618                 $current = $page->getCurrentRevision();
619                 if ($current->hasDefaultContents())
620                     return $this->requiredAuthorityForAction('edit');
621                 return $this->requiredAuthorityForAction('browse');
622
623             case 'upload':
624             case 'dumpserial':
625             case 'dumphtml':
626             case 'loadfile':
627             case 'remove':
628             case 'lock':
629             case 'unlock':
630             case 'upgrade':
631             case 'chown':
632             case 'setacl':
633             case 'rename':
634                 return WIKIAUTH_ADMIN;
635
636             /* authcheck occurs only in the plugin.
637                required actionpage RateIt */
638             /*
639             case 'rate':
640             case 'delete_rating':
641                 // Perhaps this should be WIKIAUTH_USER
642                 return WIKIAUTH_BOGO;
643             */
644
645             default:
646                 global $WikiNameRegexp;
647                 if (preg_match("/$WikiNameRegexp\Z/A", $action))
648                     return WIKIAUTH_ANON; // ActionPage.
649                 else
650                     return WIKIAUTH_ADMIN;
651           }
652         }
653     }
654     /* End of Permission system */
655
656     function possiblyDeflowerVirginWiki () {
657         if ($this->getArg('action') != 'browse')
658             return;
659         if ($this->getArg('pagename') != HOME_PAGE)
660             return;
661
662         $page = $this->getPage();
663         $current = $page->getCurrentRevision();
664         if ($current->getVersion() > 0)
665             return;             // Homepage exists.
666
667         include_once('lib/loadsave.php');
668         SetupWiki($this);
669         $this->finish();        // NORETURN
670     }
671     
672     // [574ms] mainly template:printexpansion: 393ms and template::expandsubtemplate [100+70+60ms]
673     function handleAction () {
674         $action = $this->getArg('action');
675         if ($this->isPost() and !$this->_user->isAdmin() and $action != 'browse') {
676             $page = $this->getPage();
677             if ( $page->get('moderation') ) {
678                 require_once("lib/WikiPlugin.php");
679                 $loader = new WikiPluginLoader();
680                 $plugin = $loader->getPlugin("ModeratedPage");
681                 if ($plugin->handler($this, $page)) {
682                     $CONTENT = HTML::div
683                         (
684                          array('class' => 'wiki-edithelp'),
685                          fmt("%s: action forwarded to a moderator.", 
686                              $action), 
687                          HTML::br(),
688                          _("This action requires moderator approval. Please be patient."));
689                     if (!empty($plugin->_tokens['CONTENT']))
690                         $plugin->_tokens['CONTENT']->pushContent
691                             (
692                              HTML::br(),
693                              _("You must wait for moderator approval."));
694                     else
695                         $plugin->_tokens['CONTENT'] = $CONTENT;
696                     require_once("lib/Template.php");
697                     $title = WikiLink($page->getName());
698                     $title->pushContent(' : ', WikiLink(_("ModeratedPage")));
699                     GeneratePage(Template('browse', $plugin->_tokens), 
700                                  $title,
701                                  $page->getCurrentRevision());
702                     $this->finish();
703                 }
704             }
705         }
706         $method = "action_$action";
707         if (method_exists($this, $method)) {
708             $this->{$method}();
709         }
710         elseif ($page = $this->findActionPage($action)) {
711             $this->actionpage($page);
712         }
713         else {
714             $this->finish(fmt("%s: Bad action", $action));
715         }
716     }
717     
718     function finish ($errormsg = false) {
719         static $in_exit = 0;
720
721         if ($in_exit)
722             exit();        // just in case CloseDataBase calls us
723         $in_exit = true;
724
725         global $ErrorManager;
726         $ErrorManager->flushPostponedErrors();
727
728         if (!empty($errormsg)) {
729             PrintXML(HTML::br(),
730                      HTML::hr(),
731                      HTML::h2(_("Fatal PhpWiki Error")),
732                      $errormsg);
733             // HACK:
734             echo "\n</body></html>";
735         }
736         if (is_object($this->_user)) {
737             $this->_user->page   = $this->getArg('pagename');
738             $this->_user->action = $this->getArg('action');
739             unset($this->_user->_HomePagehandle);
740             unset($this->_user->_auth_dbi);
741         }
742         Request::finish();
743         exit;
744     }
745
746     /**
747      * Generally pagename is rawurlencoded for older browsers or mozilla.
748      * Typing a pagename into the IE bar will utf-8 encode it, so we have to 
749      * fix that with fixTitleEncoding().
750      * If USE_PATH_INFO = true, the pagename is stripped from the "/DATA_PATH/PageName&arg=value" line.
751      * If false, we support either "/index.php?pagename=PageName&arg=value",
752      * or the first arg (1.2.x style): "/index.php?PageName&arg=value"
753      */
754     function _deducePagename () {
755         if (trim(rawurldecode($this->getArg('pagename'))))
756             return fixTitleEncoding(rawurldecode($this->getArg('pagename')));
757
758         if (USE_PATH_INFO) {
759             $pathinfo = $this->get('PATH_INFO');
760             if (empty($pathinfo)) { // fix for CGI
761                 $path = $this->get('REQUEST_URI');
762                 $script = $this->get('SCRIPT_NAME');
763                 $pathinfo = substr($path,strlen($script));
764                 $pathinfo = preg_replace('/\?.+$/','',$pathinfo);
765             }
766             $tail = substr($pathinfo, strlen(PATH_INFO_PREFIX));
767
768             if (trim($tail) != '' and $pathinfo == PATH_INFO_PREFIX . $tail) {
769                 return fixTitleEncoding($tail);
770             }
771         }
772         elseif ($this->isPost()) {
773             /*
774              * In general, for security reasons, HTTP_GET_VARS should be ignored
775              * on POST requests, but we make an exception here (only for pagename).
776              *
777              * The justification for this hack is the following
778              * asymmetry: When POSTing with USE_PATH_INFO set, the
779              * pagename can (and should) be communicated through the
780              * request URL via PATH_INFO.  When POSTing with
781              * USE_PATH_INFO off, this cannot be done --- the only way
782              * to communicate the pagename through the URL is via
783              * QUERY_ARGS (HTTP_GET_VARS).
784              */
785             global $HTTP_GET_VARS;
786             if (isset($HTTP_GET_VARS['pagename']) and trim($HTTP_GET_VARS['pagename'])) { 
787                 return fixTitleEncoding(rawurldecode($HTTP_GET_VARS['pagename']));
788             }
789         }
790
791         /*
792          * Support for PhpWiki 1.2 style requests.
793          * Strip off "&" args (?PageName&action=...&start_debug,...)
794          */
795         $query_string = $this->get('QUERY_STRING');
796         if (trim(rawurldecode($query_string)) and preg_match('/^([^&=]+)(&.+)?$/', $query_string, $m)) {
797             return fixTitleEncoding(rawurldecode($m[1]));
798         }
799
800         return fixTitleEncoding(HOME_PAGE);
801     }
802
803     function _deduceAction () {
804         if (!($action = $this->getArg('action'))) {
805             // TODO: improve this SOAP.php hack by letting SOAP use index.php 
806             // or any other virtual url as with xmlrpc
807             if (defined('WIKI_SOAP')   and WIKI_SOAP)
808                 return 'soap';
809             // Detect XML-RPC requests.
810             if ($this->isPost()
811                 && $this->get('CONTENT_TYPE') == 'text/xml'
812                 && strstr($GLOBALS['HTTP_RAW_POST_DATA'], '<methodCall>')
813                )
814             {
815                 return 'xmlrpc';
816             }
817             return 'browse';    // Default if no action specified.
818         }
819
820         if (method_exists($this, "action_$action"))
821             return $action;
822
823         // Allow for, e.g. action=LikePages
824         if ($this->isActionPage($action))
825             return $action;
826
827         // Handle untranslated actionpages in non-english
828         // (people playing with switching languages)
829         if (0 and $GLOBALS['LANG'] != 'en') {
830             require_once("lib/plugin/_WikiTranslation.php");
831             $trans = new WikiPlugin__WikiTranslation();
832             $en_action = $trans->translate($action,'en',$GLOBALS['LANG']);
833             if ($this->isActionPage($en_action))
834                 return $en_action;
835         }
836
837         trigger_error("$action: Unknown action", E_USER_NOTICE);
838         return 'browse';
839     }
840
841     function _deduceUsername() {
842         global $HTTP_SERVER_VARS, $HTTP_ENV_VARS;
843
844         if (!empty($this->args['auth']) and !empty($this->args['auth']['userid']))
845             return $this->args['auth']['userid'];
846
847         if ($user = $this->getSessionVar('wiki_user')) {
848             // switched auth between sessions. 
849             // Note: There's no way to demandload a missing class-definition 
850             // afterwards! (Stupid php)
851             if (isa($user, WikiUserClassname())) {
852                 $this->_user = $user;
853                 $this->_user->_authhow = 'session';
854                 return ENABLE_USER_NEW ? $user->UserName() : $this->_user;
855             }
856         }
857
858         // Sessions override http auth
859         if (!empty($HTTP_SERVER_VARS['PHP_AUTH_USER']))
860             return $HTTP_SERVER_VARS['PHP_AUTH_USER'];
861         // pubcookie et al
862         if (!empty($HTTP_SERVER_VARS['REMOTE_USER']))
863             return $HTTP_SERVER_VARS['REMOTE_USER'];
864         if (!empty($HTTP_ENV_VARS['REMOTE_USER']))
865             return $HTTP_ENV_VARS['REMOTE_USER'];
866
867         if ($userid = $this->getCookieVar('WIKI_ID')) {
868             if (!empty($userid) and substr($userid,0,2) != 's:') {
869                 $this->_user->authhow = 'cookie';
870                 return $userid;
871             }
872         }
873
874         if ($this->getArg('action') == 'xmlrpc') { // how about SOAP?
875             // wiki.putPage has special otional userid/passwd arguments. check that later.
876             $userid = '';
877             if (isset($HTTP_SERVER_VARS['REMOTE_USER']))
878                 $userid = $HTTP_SERVER_VARS['REMOTE_USER'];
879             elseif (isset($HTTP_SERVER_VARS['REMOTE_ADDR']))
880                 $userid = $HTTP_SERVER_VARS['REMOTE_ADDR'];
881             elseif (isset($HTTP_ENV_VARS['REMOTE_ADDR']))
882                 $userid = $HTTP_ENV_VARS['REMOTE_ADDR'];
883             elseif (isset($GLOBALS['REMOTE_ADDR']))
884                 $userid = $GLOBALS['REMOTE_ADDR'];
885             return $userid;
886         }
887
888         return false;
889     }
890     
891     function _isActionPage ($pagename) {
892         $dbi = $this->getDbh();
893         $page = $dbi->getPage($pagename);
894         if (!$page) return false;
895         $rev = $page->getCurrentRevision();
896         // FIXME: more restrictive check for sane plugin?
897         if (strstr($rev->getPackedContent(), '<?plugin'))
898             return true;
899         if (!$rev->hasDefaultContents())
900             trigger_error("$pagename: Does not appear to be an 'action page'", E_USER_NOTICE);
901         return false;
902     }
903
904     function findActionPage ($action) {
905         static $cache;
906
907         // check for translated version, as per users preferred language
908         // (or system default in case it is not en)
909         $translation = gettext($action);
910
911         if (isset($cache) and isset($cache[$translation]))
912             return $cache[$translation];
913
914         // check for cached translated version
915         if ($this->_isActionPage($translation))
916             return $cache[$action] = $translation;
917
918         // Allow for, e.g. action=LikePages
919         if (!isWikiWord($action))
920             return $cache[$action] = false;
921
922         // check for translated version (default language)
923         global $LANG;
924         if ($LANG != "en") {
925             require_once("lib/WikiPlugin.php");
926             require_once("lib/plugin/_WikiTranslation.php");
927             $trans = new WikiPlugin__WikiTranslation();
928             $trans->lang = $LANG;
929             $default = $trans->translate_to_en($action, $LANG);
930             if ($this->_isActionPage($default))
931                 return $cache[$action] = $default;
932         } else {
933             $default = $translation;
934         }
935         
936         // check for english version
937         if ($action != $translation and $action != $default) {
938             if ($this->_isActionPage($action))
939                 return $cache[$action] = $action;
940         }
941
942         trigger_error("$action: Cannot find action page", E_USER_NOTICE);
943         return $cache[$action] = false;
944     }
945     
946     function isActionPage ($pagename) {
947         return $this->findActionPage($pagename);
948     }
949
950     function action_browse () {
951         $this->buffer_output();
952         include_once("lib/display.php");
953         displayPage($this);
954     }
955
956     function action_verify () {
957         $this->action_browse();
958     }
959
960     function actionpage ($action) {
961         $this->buffer_output();
962         include_once("lib/display.php");
963         actionPage($this, $action);
964     }
965
966     function adminActionSubpage ($subpage) {
967         $page = _("PhpWikiAdministration")."/".$subpage;
968         $action = $this->findActionPage($page);
969         if ($action) {
970             $this->setArg('s',$this->getArg('pagename'));
971             $this->setArg('verify',1);
972             $this->setArg('action',$action);
973             $this->actionpage($action);
974         } else {
975             trigger_error($page.": Cannot find action page", E_USER_WARNING);
976         }
977     }
978
979     function action_chown () {
980         $this->adminActionSubpage(_("Chown"));
981     }
982
983     function action_setacl () {
984         $this->adminActionSubpage(_("SetAcl"));
985     }
986
987     function action_rename () {
988         $this->adminActionSubpage(_("Rename"));
989     }
990
991     function action_dump () {
992         $action = $this->findActionPage(_("PageDump"));
993         if ($action) {
994             $this->actionpage($action);
995         } else {
996             // redirect to action=upgrade if admin?
997             trigger_error(_("PageDump").": Cannot find action page", E_USER_WARNING);
998         }
999     }
1000
1001     function action_diff () {
1002         $this->buffer_output();
1003         include_once "lib/diff.php";
1004         showDiff($this);
1005     }
1006
1007     function action_search () {
1008         // This is obsolete: reformulate URL and redirect.
1009         // FIXME: this whole section should probably be deleted.
1010         if ($this->getArg('searchtype') == 'full') {
1011             $search_page = _("FullTextSearch");
1012         }
1013         else {
1014             $search_page = _("TitleSearch");
1015         }
1016         $this->redirect(WikiURL($search_page,
1017                                 array('s' => $this->getArg('searchterm')),
1018                                 'absolute_url'));
1019     }
1020
1021     function action_edit () {
1022         $this->buffer_output();
1023         include "lib/editpage.php";
1024         $e = new PageEditor ($this);
1025         $e->editPage();
1026     }
1027
1028     function action_create () {
1029         $this->action_edit();
1030     }
1031     
1032     function action_viewsource () {
1033         $this->buffer_output();
1034         include "lib/editpage.php";
1035         $e = new PageEditor ($this);
1036         $e->viewSource();
1037     }
1038
1039     function action_lock () {
1040         $page = $this->getPage();
1041         $page->set('locked', true);
1042         $this->_dbi->touch();
1043         // check ModeratedPage hook
1044         if ($moderated = $page->get('moderated')) {
1045             require_once("lib/WikiPlugin.php");
1046             $plugin = WikiPluginLoader::getPlugin("ModeratedPage");
1047             if ($retval = $plugin->lock_check($this, $page, $moderated))
1048                 $this->setArg('errormsg', $retval);
1049         } 
1050         // check if a link to ModeratedPage exists
1051         elseif ($action_page = $page->existLink(_("ModeratedPage"))) {
1052             require_once("lib/WikiPlugin.php");
1053             $plugin = WikiPluginLoader::getPlugin("ModeratedPage");
1054             if ($retval = $plugin->lock_add($this, $page, $action_page))
1055                 $this->setArg('errormsg', $retval);
1056         }
1057         $this->action_browse();
1058     }
1059
1060     function action_unlock () {
1061         $page = $this->getPage();
1062         $page->set('locked', false);
1063         $this->_dbi->touch();
1064         $this->action_browse();
1065     }
1066
1067     function action_remove () {
1068         // This check is now redundant.
1069         //$user->requireAuth(WIKIAUTH_ADMIN);
1070         $pagename = $this->getArg('pagename');
1071         if (strstr($pagename, _("PhpWikiAdministration"))) {
1072             $this->action_browse();
1073         } else {
1074             include('lib/removepage.php');
1075             RemovePage($this);
1076         }
1077     }
1078
1079     function action_xmlrpc () {
1080         include_once("lib/XmlRpcServer.php");
1081         $xmlrpc = new XmlRpcServer($this);
1082         $xmlrpc->service();
1083     }
1084     
1085     function action_revert () {
1086         include_once "lib/loadsave.php";
1087         RevertPage($this);
1088     }
1089
1090     function action_zip () {
1091         include_once("lib/loadsave.php");
1092         MakeWikiZip($this);
1093         // I don't think it hurts to add cruft at the end of the zip file.
1094         //echo "\n========================================================\n";
1095         //echo "PhpWiki " . PHPWIKI_VERSION . " source:\n$GLOBALS[RCS_IDS]\n";
1096     }
1097
1098     function action_ziphtml () {
1099         include_once("lib/loadsave.php");
1100         MakeWikiZipHtml($this);
1101         // I don't think it hurts to add cruft at the end of the zip file.
1102         echo "\n========================================================\n";
1103         echo "PhpWiki " . PHPWIKI_VERSION . " source:\n$GLOBALS[RCS_IDS]\n";
1104     }
1105
1106     function action_dumpserial () {
1107         include_once("lib/loadsave.php");
1108         DumpToDir($this);
1109     }
1110
1111     function action_dumphtml () {
1112         include_once("lib/loadsave.php");
1113         DumpHtmlToDir($this);
1114     }
1115
1116     function action_upload () {
1117         include_once("lib/loadsave.php");
1118         LoadPostFile($this);
1119     }
1120
1121     function action_upgrade () {
1122         include_once("lib/loadsave.php");
1123         include_once("lib/upgrade.php");
1124         DoUpgrade($this);
1125     }
1126
1127     function action_loadfile () {
1128         include_once("lib/loadsave.php");
1129         LoadFileOrDir($this);
1130     }
1131
1132     function action_pdf () {
1133         include_once("lib/pdf.php");
1134         ConvertAndDisplayPdf($this);
1135     }
1136
1137     function action_captcha () {
1138         include_once "lib/Captcha.php";
1139         $captcha = new Captcha();
1140         $captcha->image ( $captcha->captchaword() ); 
1141     }
1142     
1143 }
1144
1145 //FIXME: deprecated with ENABLE_PAGEPERM (?)
1146 function is_safe_action ($action) {
1147     global $request;
1148     return $request->requiredAuthorityForAction($action) < WIKIAUTH_ADMIN;
1149 }
1150
1151 function validateSessionPath() {
1152     // Try to defer any session.save_path PHP errors before any html
1153     // is output, which causes some versions of IE to display a blank
1154     // page (due to its strict mode while parsing a page?).
1155     if (! is_writeable(ini_get('session.save_path'))) {
1156         $tmpdir = (defined('SESSION_SAVE_PATH') and SESSION_SAVE_PATH) ? SESSION_SAVE_PATH : '/tmp';
1157         if (!is_writeable($tmpdir))
1158             $tmpdir = '/tmp';
1159         trigger_error
1160             (sprintf(_("%s is not writable."),
1161                      _("The session.save_path directory"))
1162              . "\n"
1163              . sprintf(_("Please ensure that %s is writable, or redefine %s in config/config.ini."),
1164                        sprintf(_("the session.save_path directory '%s'"),
1165                                ini_get('session.save_path')),
1166                        'SESSION_SAVE_PATH')
1167              . "\n"
1168              . sprintf(_("Attempting to use the directory '%s' instead."),
1169                        $tmpdir)
1170              , E_USER_NOTICE);
1171         if (! is_writeable($tmpdir)) {
1172             trigger_error
1173                 (sprintf(_("%s is not writable."), $tmpdir)
1174                  . "\n"
1175                  . _("Users will not be able to sign in.")
1176                  , E_USER_NOTICE);
1177         }
1178         else
1179             @ini_set('session.save_path', $tmpdir);
1180     }
1181 }
1182
1183 function main () {
1184     if ( !USE_DB_SESSION )
1185         validateSessionPath();
1186
1187     global $request;
1188     if ((DEBUG & _DEBUG_APD) and extension_loaded("apd"))
1189         apd_set_session_trace(9);
1190
1191     // Postpone warnings
1192     global $ErrorManager;
1193     if (defined('E_STRICT')) // and (E_ALL & E_STRICT)) // strict php5?
1194         $ErrorManager->setPostponedErrorMask(E_NOTICE|E_USER_NOTICE|E_USER_WARNING|E_WARNING|E_STRICT);
1195     else
1196         $ErrorManager->setPostponedErrorMask(E_NOTICE|E_USER_NOTICE|E_USER_WARNING|E_WARNING);
1197     $request = new WikiRequest();
1198
1199     $action = $request->getArg('action');
1200     if (substr($action, 0, 3) != 'zip') {
1201         if ($action == 'pdf')
1202             $ErrorManager->setPostponedErrorMask(-1); // everything
1203         //else // reject postponing of warnings
1204         //    $ErrorManager->setPostponedErrorMask(E_NOTICE|E_USER_NOTICE);
1205     }
1206
1207     /*
1208      * Allow for disabling of markup cache.
1209      * (Mostly for debugging ... hopefully.)
1210      *
1211      * See also <?plugin WikiAdminUtils action=purge-cache ?>
1212      */
1213     if (!defined('WIKIDB_NOCACHE_MARKUP')) {
1214         if ($request->getArg('nocache')) // 1 or purge
1215             define('WIKIDB_NOCACHE_MARKUP', $request->getArg('nocache'));
1216         else
1217             define('WIKIDB_NOCACHE_MARKUP', false); // redundant, but explicit
1218     }
1219     
1220     // Initialize with system defaults in case user not logged in.
1221     // Should this go into constructor?
1222     $request->initializeTheme();
1223
1224     $request->updateAuthAndPrefs();
1225     $request->initializeLang();
1226     
1227     //FIXME:
1228     //if ($user->is_authenticated())
1229     //  $LogEntry->user = $user->getId();
1230
1231     // Memory optimization:
1232     // http://www.procata.com/blog/archives/2004/05/27/rephlux-and-php-memory-usage/
1233     // kill the global PEAR _PEAR_destructor_object_list
1234     if (!empty($_PEAR_destructor_object_list))
1235         $_PEAR_destructor_object_list = array();
1236     $request->possiblyDeflowerVirginWiki();
1237     
1238 // hack! define proper actions for these.
1239 if (defined('WIKI_XMLRPC') and WIKI_XMLRPC) return;
1240 if (defined('WIKI_SOAP')   and WIKI_SOAP)   return;
1241
1242     $validators = array('wikiname' => WIKI_NAME,
1243                         'args'     => wikihash($request->getArgs()),
1244                         'prefs'    => wikihash($request->getPrefs()));
1245     if (CACHE_CONTROL == 'STRICT') {
1246         $dbi = $request->getDbh();
1247         $timestamp = $dbi->getTimestamp();
1248         $validators['mtime'] = $timestamp;
1249         $validators['%mtime'] = (int)$timestamp;
1250     }
1251     // FIXME: we should try to generate strong validators when possible,
1252     // but for now, our validator is weak, since equal validators do not
1253     // indicate byte-level equality of content.  (Due to DEBUG timing output, etc...)
1254     //
1255     // (If DEBUG if off, this may be a strong validator, but I'm going
1256     // to go the paranoid route here pending further study and testing.)
1257     //
1258     $validators['%weak'] = true;
1259     $request->setValidators($validators);
1260    
1261     $request->handleAction();
1262
1263     if (DEBUG and DEBUG & _DEBUG_INFO) phpinfo(INFO_VARIABLES | INFO_MODULES);
1264     $request->finish();
1265 }
1266
1267 //$x = error_reporting();  // DEBUG: why is it 1 here? should be E_ALL
1268 if (defined('E_STRICT') and (E_ALL & E_STRICT)) // strict php5?
1269     error_reporting(E_ALL & ~E_STRICT);         // exclude E_STRICT
1270 else
1271     error_reporting(E_ALL); // php4
1272 // don't run the main loop for special requests (test, getimg, xmlrpc, soap, ...)
1273 if (!defined('PHPWIKI_NOMAIN') or !PHPWIKI_NOMAIN)
1274     main();
1275
1276
1277 // $Log: not supported by cvs2svn $
1278 // Revision 1.221  2006/03/19 14:23:51  rurban
1279 // sf.net patch #1377011 by Matt Brown: add DATABASE_OPTIMISE_FREQUENCY
1280 //
1281 // Revision 1.220  2006/03/07 21:04:15  rurban
1282 // wikihash for php-5.1
1283 //
1284 // Revision 1.219  2005/10/30 14:20:42  rurban
1285 // move Captcha specific vars and methods into a Captcha object
1286 // randomize Captcha chars positions and angles (smoothly)
1287 //
1288 // Revision 1.218  2005/10/29 14:18:06  rurban
1289 // fix typo
1290 //
1291 // Revision 1.217  2005/09/18 12:44:00  rurban
1292 // novatrope patch to let only _AUTHENTICATED view pages
1293 //
1294 // Revision 1.216  2005/08/27 09:40:46  rurban
1295 // fix login with HttpAuth
1296 //
1297 // Revision 1.215  2005/08/07 10:50:27  rurban
1298 // postpone guard
1299 //
1300 // Revision 1.214  2005/08/07 09:14:03  rurban
1301 // fix cookie logout; let the WIKI_ID cookie get deleted
1302 //
1303 // Revision 1.213  2005/06/10 06:10:35  rurban
1304 // ensure Update Preferences gets through
1305 //
1306 // Revision 1.212  2005/04/25 20:17:14  rurban
1307 // captcha feature by Benjamin Drieu. Patch #1110699
1308 //
1309 // Revision 1.211  2005/04/11 19:42:54  rurban
1310 // reformatting, SESSION_SAVE_PATH check
1311 //
1312 // Revision 1.210  2005/04/07 06:06:34  rurban
1313 // add _SERVER[REMOTE_USER] check for pubcookie et al, Bug #1177259 (iamjpr)
1314 //
1315 // Revision 1.209  2005/04/06 06:19:30  rurban
1316 // Revert the previous wrong bugfix #1175761: USECACHE was mixed with WIKIDB_NOCACHE_MARKUP.
1317 // Fix WIKIDB_NOCACHE_MARKUP in main (always set it) and clarify it in WikiDB
1318 //
1319 // Revision 1.208  2005/02/28 21:24:32  rurban
1320 // ignore forbidden ini_set warnings. Bug #1117254 by Xavier Roche
1321 //
1322 // Revision 1.207  2005/02/10 19:03:37  rurban
1323 // try to avoid duoplicate lang/theme init
1324 //
1325 // Revision 1.206  2005/02/04 11:30:10  rurban
1326 // remove old comments
1327 //
1328 // Revision 1.205  2005/01/29 20:41:47  rurban
1329 // some minor php5 strictness fixes
1330 //
1331 // Revision 1.204  2005/01/25 07:35:42  rurban
1332 // add TODO comment
1333 //
1334 // Revision 1.203  2005/01/21 14:11:23  rurban
1335 // better moderation class tag
1336 //
1337 // Revision 1.202  2005/01/21 12:02:32  rurban
1338 // deduce username for xmlrpc also
1339 //
1340 // Revision 1.201  2005/01/20 10:18:17  rurban
1341 // reformatting
1342 //
1343 // Revision 1.200  2004/12/26 17:08:36  rurban
1344 // php5 fixes: case-sensitivity, no & new
1345 //
1346 // Revision 1.199  2004/12/19 00:58:01  rurban
1347 // Enforce PASSWORD_LENGTH_MINIMUM in almost all PassUser checks,
1348 // Provide an errormessage if so. Just PersonalPage and BogoLogin not.
1349 // Simplify httpauth logout handling and set sessions for all methods.
1350 // fix main.php unknown index "x" getLevelDescription() warning.
1351 //
1352 // Revision 1.198  2004/12/17 16:49:51  rurban
1353 // avoid Invalid username message on Sign In button click
1354 //
1355 // Revision 1.197  2004/12/17 16:39:55  rurban
1356 // enable sessions for HttpAuth
1357 //
1358 // Revision 1.196  2004/12/10 02:36:43  rurban
1359 // More help with the new native xmlrpc lib. no warnings, no user cookie on xmlrpc.
1360 //
1361 // Revision 1.195  2004/12/09 22:24:44  rurban
1362 // optimize on _DEBUG_SQL only. but now again on every 50th request, not just save.
1363 //
1364 // Revision 1.194  2004/11/30 17:46:49  rurban
1365 // added ModeratedPage POST action hook (part 2/3)
1366 //
1367 // Revision 1.193  2004/11/30 07:51:08  rurban
1368 // fixed SESSION_SAVE_PATH warning msg
1369 //
1370 // Revision 1.192  2004/11/21 11:59:20  rurban
1371 // remove final \n to be ob_cache independent
1372 //
1373 // Revision 1.191  2004/11/19 19:22:03  rurban
1374 // ModeratePage part1: change status
1375 //
1376 // Revision 1.190  2004/11/15 15:56:40  rurban
1377 // don't load PagePerm on ENABLE_PAGEPERM = false to save memory. Move mayAccessPage() to main.php
1378 //
1379 // Revision 1.189  2004/11/09 17:11:16  rurban
1380 // * revert to the wikidb ref passing. there's no memory abuse there.
1381 // * use new wikidb->_cache->_id_cache[] instead of wikidb->_iwpcache, to effectively
1382 //   store page ids with getPageLinks (GleanDescription) of all existing pages, which
1383 //   are also needed at the rendering for linkExistingWikiWord().
1384 //   pass options to pageiterator.
1385 //   use this cache also for _get_pageid()
1386 //   This saves about 8 SELECT count per page (num all pagelinks).
1387 // * fix passing of all page fields to the pageiterator.
1388 // * fix overlarge session data which got broken with the latest ACCESS_LOG_SQL changes
1389 //
1390 // Revision 1.188  2004/11/07 16:02:52  rurban
1391 // new sql access log (for spam prevention), and restructured access log class
1392 // dbh->quote (generic)
1393 // pear_db: mysql specific parts seperated (using replace)
1394 //
1395 // Revision 1.187  2004/11/05 22:08:52  rurban
1396 // Ok: Fix loading all required userclasses beforehand. This is much slower than before but safes a few bytes RAM
1397 //
1398 // Revision 1.186  2004/11/05 20:53:35  rurban
1399 // login cleanup: better debug msg on failing login,
1400 // checked password less immediate login (bogo or anon),
1401 // checked olduser pref session error,
1402 // better PersonalPage without password warning on minimal password length=0
1403 //   (which is default now)
1404 //
1405 // Revision 1.185  2004/11/01 13:55:05  rurban
1406 // fix against switching user new/old between sessions
1407 //
1408 // Revision 1.184  2004/11/01 10:43:57  rurban
1409 // seperate PassUser methods into seperate dir (memory usage)
1410 // fix WikiUser (old) overlarge data session
1411 // remove wikidb arg from various page class methods, use global ->_dbi instead
1412 // ...
1413 //
1414 // Revision 1.183  2004/10/14 19:23:58  rurban
1415 // remove debugging prints
1416 //
1417 // Revision 1.182  2004/10/12 13:13:19  rurban
1418 // php5 compatibility (5.0.1 ok)
1419 //
1420 // Revision 1.181  2004/10/07 16:08:58  rurban
1421 // fixed broken FileUser session handling.
1422 //   thanks to Arnaud Fontaine for detecting this.
1423 // enable file user Administrator membership.
1424 //
1425 // Revision 1.180  2004/10/04 23:39:34  rurban
1426 // just aesthetics
1427 //
1428 // Revision 1.179  2004/09/25 18:57:42  rurban
1429 // better ACL error message: view not browse, change not setacl, ...
1430 //
1431 // Revision 1.178  2004/09/25 16:27:36  rurban
1432 // better not allowed description: on global disallowed, and on missing pageperms
1433 //
1434 // Revision 1.177  2004/09/14 10:31:09  rurban
1435 // 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
1436 //
1437 // Revision 1.176  2004/08/05 17:33:22  rurban
1438 // aesthetic typo
1439 //
1440 // Revision 1.175  2004/07/13 13:08:25  rurban
1441 // fix PEAR memory waste issues
1442 //
1443 // Revision 1.174  2004/07/08 13:50:32  rurban
1444 // various unit test fixes: print error backtrace on _DEBUG_TRACE; allusers fix; new PHPWIKI_NOMAIN constant for omitting the mainloop
1445 //
1446 // Revision 1.173  2004/07/05 12:57:54  rurban
1447 // add mysql timeout
1448 //
1449 // Revision 1.172  2004/07/03 08:04:19  rurban
1450 // fixed implicit PersonalPage login (e.g. on edit), fixed to check against create ACL on create, not edit
1451 //
1452 // Revision 1.171  2004/06/29 09:30:42  rurban
1453 // force string hash
1454 //
1455 // Revision 1.170  2004/06/25 14:29:20  rurban
1456 // WikiGroup refactoring:
1457 //   global group attached to user, code for not_current user.
1458 //   improved helpers for special groups (avoid double invocations)
1459 // new experimental config option ENABLE_XHTML_XML (fails with IE, and document.write())
1460 // fixed a XHTML validation error on userprefs.tmpl
1461 //
1462 // Revision 1.169  2004/06/20 14:42:54  rurban
1463 // various php5 fixes (still broken at blockparser)
1464 //
1465 // Revision 1.168  2004/06/17 10:39:18  rurban
1466 // fix reverse translation of possible actionpage
1467 //
1468 // Revision 1.167  2004/06/16 13:21:16  rurban
1469 // stabilize on failing ldap queries or bind
1470 //
1471 // Revision 1.166  2004/06/15 09:15:52  rurban
1472 // IMPORTANT: fixed passwd handling for passwords stored in prefs:
1473 //   fix encrypted usage, actually store and retrieve them from db
1474 //   fix bogologin with passwd set.
1475 // fix php crashes with call-time pass-by-reference (references wrongly used
1476 //   in declaration AND call). This affected mainly Apache2 and IIS.
1477 //   (Thanks to John Cole to detect this!)
1478 //
1479 // Revision 1.165  2004/06/14 11:31:37  rurban
1480 // renamed global $Theme to $WikiTheme (gforge nameclash)
1481 // inherit PageList default options from PageList
1482 //   default sortby=pagename
1483 // use options in PageList_Selectable (limit, sortby, ...)
1484 // added action revert, with button at action=diff
1485 // added option regex to WikiAdminSearchReplace
1486 //
1487 // Revision 1.164  2004/06/13 13:54:25  rurban
1488 // Catch fatals on the four dump calls (as file and zip, as html and mimified)
1489 // FoafViewer: Check against external requirements, instead of fatal.
1490 // Change output for xhtmldumps: using file:// urls to the local fs.
1491 // Catch SOAP fatal by checking for GOOGLE_LICENSE_KEY
1492 // Import GOOGLE_LICENSE_KEY and FORTUNE_DIR from config.ini.
1493 //
1494 // Revision 1.163  2004/06/13 11:35:32  rurban
1495 // check for create action on action=edit not to fool PagePerm checks
1496 //
1497 // Revision 1.162  2004/06/08 10:05:11  rurban
1498 // simplified admin action shortcuts
1499 //
1500 // Revision 1.161  2004/06/07 22:58:40  rurban
1501 // simplified chown, setacl, dump actions
1502 //
1503 // Revision 1.160  2004/06/07 22:44:14  rurban
1504 // added simplified chown, setacl actions
1505 //
1506 // Revision 1.159  2004/06/06 16:58:51  rurban
1507 // added more required ActionPages for foreign languages
1508 // install now english ActionPages if no localized are found. (again)
1509 // fixed default anon user level to be 0, instead of -1
1510 //   (wrong "required administrator to view this page"...)
1511 //
1512 // Revision 1.158  2004/06/04 20:32:53  rurban
1513 // Several locale related improvements suggested by Pierrick Meignen
1514 // LDAP fix by John Cole
1515 // reanable admin check without ENABLE_PAGEPERM in the admin plugins
1516 //
1517 // Revision 1.157  2004/06/04 12:40:21  rurban
1518 // Restrict valid usernames to prevent from attacks against external auth or compromise
1519 // possible holes.
1520 // Fix various WikiUser old issues with default IMAP,LDAP,POP3 configs. Removed these.
1521 // Fxied more warnings
1522 //
1523 // Revision 1.156  2004/06/03 17:58:16  rurban
1524 // support immediate LANG and THEME switch inside a session
1525 //
1526 // Revision 1.155  2004/06/03 10:18:19  rurban
1527 // fix FileUser locking issues, new config ENABLE_PAGEPERM
1528 //
1529 // Revision 1.154  2004/06/02 18:01:46  rurban
1530 // init global FileFinder to add proper include paths at startup
1531 //   adds PHPWIKI_DIR if started from another dir, lib/pear also
1532 // fix slashify for Windows
1533 // fix USER_AUTH_POLICY=old, use only USER_AUTH_ORDER methods (besides HttpAuth)
1534 //
1535 // Revision 1.153  2004/06/01 15:28:00  rurban
1536 // AdminUser only ADMIN_USER not member of Administrators
1537 // some RateIt improvements by dfrankow
1538 // edit_toolbar buttons
1539 //
1540 // Revision 1.152  2004/05/27 17:49:06  rurban
1541 // renamed DB_Session to DbSession (in CVS also)
1542 // added WikiDB->getParam and WikiDB->getAuthParam method to get rid of globals
1543 // remove leading slash in error message
1544 // added force_unlock parameter to File_Passwd (no return on stale locks)
1545 // fixed adodb session AffectedRows
1546 // added FileFinder helpers to unify local filenames and DATA_PATH names
1547 // editpage.php: new edit toolbar javascript on ENABLE_EDIT_TOOLBAR
1548 //
1549 // Revision 1.151  2004/05/25 12:40:48  rurban
1550 // trim the pagename
1551 //
1552 // Revision 1.150  2004/05/25 10:18:44  rurban
1553 // Check for UTF-8 URLs; Internet Explorer produces these if you
1554 // type non-ASCII chars in the URL bar or follow unescaped links.
1555 // Fixes sf.net bug #953949
1556 // src: languages/Language.php:checkTitleEncoding() from mediawiki
1557 //
1558 // Revision 1.149  2004/05/18 13:31:19  rurban
1559 // hold warnings until headers are sent. new Error-style with collapsed output of repeated messages
1560 //
1561 // Revision 1.148  2004/05/17 17:43:29  rurban
1562 // CGI: no PATH_INFO fix
1563 //
1564 // Revision 1.147  2004/05/15 19:48:33  rurban
1565 // fix some too loose PagePerms for signed, but not authenticated users
1566 //  (admin, owner, creator)
1567 // no double login page header, better login msg.
1568 // moved action_pdf to lib/pdf.php
1569 //
1570 // Revision 1.146  2004/05/15 18:31:01  rurban
1571 // some action=pdf Request fixes: With MSIE it works now. Now the work with the page formatting begins.
1572 //
1573 // Revision 1.145  2004/05/12 10:49:55  rurban
1574 // require_once fix for those libs which are loaded before FileFinder and
1575 //   its automatic include_path fix, and where require_once doesn't grok
1576 //   dirname(__FILE__) != './lib'
1577 // upgrade fix with PearDB
1578 // navbar.tmpl: remove spaces for IE &nbsp; button alignment
1579 //
1580 // Revision 1.144  2004/05/06 19:26:16  rurban
1581 // improve stability, trying to find the InlineParser endless loop on sf.net
1582 //
1583 // remove end-of-zip comments to fix sf.net bug #777278 and probably #859628
1584 //
1585 // Revision 1.143  2004/05/06 17:30:38  rurban
1586 // CategoryGroup: oops, dos2unix eol
1587 // improved phpwiki_version:
1588 //   pre -= .0001 (1.3.10pre: 1030.099)
1589 //   -p1 += .001 (1.3.9-p1: 1030.091)
1590 // improved InstallTable for mysql and generic SQL versions and all newer tables so far.
1591 // abstracted more ADODB/PearDB methods for action=upgrade stuff:
1592 //   backend->backendType(), backend->database(),
1593 //   backend->listOfFields(),
1594 //   backend->listOfTables(),
1595 //
1596 // Revision 1.142  2004/05/04 22:34:25  rurban
1597 // more pdf support
1598 //
1599 // Revision 1.141  2004/05/03 13:16:47  rurban
1600 // fixed UserPreferences update, esp for boolean and int
1601 //
1602 // Revision 1.140  2004/05/02 21:26:38  rurban
1603 // limit user session data (HomePageHandle and auth_dbi have to invalidated anyway)
1604 //   because they will not survive db sessions, if too large.
1605 // extended action=upgrade
1606 // some WikiTranslation button work
1607 // revert WIKIAUTH_UNOBTAINABLE (need it for main.php)
1608 // some temp. session debug statements
1609 //
1610 // Revision 1.139  2004/05/02 15:10:07  rurban
1611 // new finally reliable way to detect if /index.php is called directly
1612 //   and if to include lib/main.php
1613 // new global AllActionPages
1614 // SetupWiki now loads all mandatory pages: HOME_PAGE, action pages, and warns if not.
1615 // WikiTranslation what=buttons for Carsten to create the missing MacOSX buttons
1616 // PageGroupTestOne => subpages
1617 // renamed PhpWikiRss to PhpWikiRecentChanges
1618 // more docs, default configs, ...
1619 //
1620 // Revision 1.138  2004/05/01 15:59:29  rurban
1621 // more php-4.0.6 compatibility: superglobals
1622 //
1623 // Revision 1.137  2004/04/29 19:39:44  rurban
1624 // special support for formatted plugins (one-liners)
1625 //   like <small><plugin BlaBla ></small>
1626 // iter->asArray() helper for PopularNearby
1627 // db_session for older php's (no &func() allowed)
1628 //
1629 // Revision 1.136  2004/04/29 17:18:19  zorloc
1630 // Fixes permission failure issues.  With PagePermissions and Disabled
1631 // Actions when user did not have permission WIKIAUTH_FORBIDDEN was
1632 // returned.  In WikiUser this was ok because WIKIAUTH_FORBIDDEN had a
1633 // value of 11 -- thus no user could perform that action.  But
1634 // WikiUserNew has a WIKIAUTH_FORBIDDEN value of -1 -- thus a user
1635 // without sufficent permission to do anything.  The solution is a new
1636 // high value permission level (WIKIAUTH_UNOBTAINABLE) to be the
1637 // default level for access failure.
1638 //
1639 // Revision 1.135  2004/04/26 12:15:01  rurban
1640 // check default config values
1641 //
1642 // Revision 1.134  2004/04/23 06:46:37  zorloc
1643 // Leave DB connection open when USE_DB_SESSION is true so that session info can be written to the DB.
1644 //
1645 // Revision 1.133  2004/04/20 18:10:31  rurban
1646 // config refactoring:
1647 //   FileFinder is needed for WikiFarm scripts calling index.php
1648 //   config run-time calls moved to lib/IniConfig.php:fix_configs()
1649 //   added PHPWIKI_DIR smart-detection code (Theme finder)
1650 //   moved FileFind to lib/FileFinder.php
1651 //   cleaned lib/config.php
1652 //
1653 // Revision 1.132  2004/04/19 21:51:41  rurban
1654 // php5 compatibility: it works!
1655 //
1656 // Revision 1.131  2004/04/19 18:27:45  rurban
1657 // Prevent from some PHP5 warnings (ref args, no :: object init)
1658 //   php5 runs now through, just one wrong XmlElement object init missing
1659 // Removed unneccesary UpgradeUser lines
1660 // Changed WikiLink to omit version if current (RecentChanges)
1661 //
1662 // Revision 1.130  2004/04/18 00:25:53  rurban
1663 // allow "0" pagename
1664 //
1665 // Revision 1.129  2004/04/07 23:13:19  rurban
1666 // fixed pear/File_Passwd for Windows
1667 // fixed FilePassUser sessions (filehandle revive) and password update
1668 //
1669 // Revision 1.128  2004/04/02 15:06:55  rurban
1670 // fixed a nasty ADODB_mysql session update bug
1671 // improved UserPreferences layout (tabled hints)
1672 // fixed UserPreferences auth handling
1673 // improved auth stability
1674 // improved old cookie handling: fixed deletion of old cookies with paths
1675 //
1676 // Revision 1.127  2004/03/25 17:00:31  rurban
1677 // more code to convert old-style pref array to new hash
1678 //
1679 // Revision 1.126  2004/03/24 19:39:03  rurban
1680 // php5 workaround code (plus some interim debugging code in XmlElement)
1681 //   php5 doesn't work yet with the current XmlElement class constructors,
1682 //   WikiUserNew does work better than php4.
1683 // rewrote WikiUserNew user upgrading to ease php5 update
1684 // fixed pref handling in WikiUserNew
1685 // added Email Notification
1686 // added simple Email verification
1687 // removed emailVerify userpref subclass: just a email property
1688 // changed pref binary storage layout: numarray => hash of non default values
1689 // print optimize message only if really done.
1690 // forced new cookie policy: delete pref cookies, use only WIKI_ID as plain string.
1691 //   prefs should be stored in db or homepage, besides the current session.
1692 //
1693 // Revision 1.125  2004/03/14 16:30:52  rurban
1694 // db-handle session revivification, dba fixes
1695 //
1696 // Revision 1.124  2004/03/12 15:48:07  rurban
1697 // fixed explodePageList: wrong sortby argument order in UnfoldSubpages
1698 // simplified lib/stdlib.php:explodePageList
1699 //
1700 // Revision 1.123  2004/03/10 15:41:27  rurban
1701 // use default pref mysql table
1702 //
1703 // Revision 1.122  2004/03/08 18:17:09  rurban
1704 // added more WikiGroup::getMembersOf methods, esp. for special groups
1705 // fixed $LDAP_SET_OPTIONS
1706 // fixed _AuthInfo group methods
1707 //
1708 // Revision 1.121  2004/03/01 13:48:45  rurban
1709 // rename fix
1710 // p[] consistency fix
1711 //
1712 // Revision 1.120  2004/03/01 10:22:41  rurban
1713 // initializeTheme optimize
1714 //
1715 // Revision 1.119  2004/02/26 20:45:06  rurban
1716 // check for ALLOW_ANON_USER = false
1717 //
1718 // Revision 1.118  2004/02/26 01:32:03  rurban
1719 // fixed session login with old WikiUser object. 
1720 // strangely, the errormask gets corrupted to 1, Pear???
1721 //
1722 // Revision 1.117  2004/02/24 17:19:37  rurban
1723 // debugging helpers only
1724 //
1725 // Revision 1.116  2004/02/24 15:17:14  rurban
1726 // improved auth errors with individual pages. the fact that you may
1727 // not browse a certain admin page does not conclude that you may not
1728 // browse the whole wiki. renamed browse => view
1729 //
1730 // Revision 1.115  2004/02/15 21:34:37  rurban
1731 // PageList enhanced and improved.
1732 // fixed new WikiAdmin... plugins
1733 // editpage, Theme with exp. htmlarea framework
1734 //   (htmlarea yet committed, this is really questionable)
1735 // WikiUser... code with better session handling for prefs
1736 // enhanced UserPreferences (again)
1737 // RecentChanges for show_deleted: how should pages be deleted then?
1738 //
1739 // Revision 1.114  2004/02/15 17:30:13  rurban
1740 // workaround for lost db connnection handle on session restauration (->_auth_dbi)
1741 // fixed getPreferences() (esp. from sessions)
1742 // fixed setPreferences() (update and set),
1743 // fixed AdoDb DB statements,
1744 // update prefs only at UserPreferences POST (for testing)
1745 // unified db prefs methods (but in external pref classes yet)
1746 //
1747 // Revision 1.113  2004/02/12 13:05:49  rurban
1748 // Rename functional for PearDB backend
1749 // some other minor changes
1750 // SiteMap comes with a not yet functional feature request: includepages (tbd)
1751 //
1752 // Revision 1.112  2004/02/09 03:58:12  rurban
1753 // for now default DB_SESSION to false
1754 // PagePerm:
1755 //   * not existing perms will now query the parent, and not
1756 //     return the default perm
1757 //   * added pagePermissions func which returns the object per page
1758 //   * added getAccessDescription
1759 // WikiUserNew:
1760 //   * added global ->prepare (not yet used) with smart user/pref/member table prefixing.
1761 //   * force init of authdbh in the 2 db classes
1762 // main:
1763 //   * fixed session handling (not triple auth request anymore)
1764 //   * don't store cookie prefs with sessions
1765 // stdlib: global obj2hash helper from _AuthInfo, also needed for PagePerm
1766 //
1767 // Revision 1.111  2004/02/07 10:41:25  rurban
1768 // fixed auth from session (still double code but works)
1769 // fixed GroupDB
1770 // fixed DbPassUser upgrade and policy=old
1771 // added GroupLdap
1772 //
1773 // Revision 1.110  2004/02/03 09:45:39  rurban
1774 // LDAP cleanup, start of new Pref classes
1775 //
1776 // Revision 1.109  2004/01/30 19:57:58  rurban
1777 // fixed DBAuthParams['pref_select']: wrong _auth_dbi object used.
1778 //
1779 // Revision 1.108  2004/01/28 14:34:14  rurban
1780 // session table takes the common prefix
1781 // + various minor stuff
1782 // reallow password changing
1783 //
1784 // Revision 1.107  2004/01/27 23:23:39  rurban
1785 // renamed ->Username => _userid for consistency
1786 // renamed mayCheckPassword => mayCheckPass
1787 // fixed recursion problem in WikiUserNew
1788 // fixed bogo login (but not quite 100% ready yet, password storage)
1789 //
1790 // Revision 1.106  2004/01/26 09:17:49  rurban
1791 // * changed stored pref representation as before.
1792 //   the array of objects is 1) bigger and 2)
1793 //   less portable. If we would import packed pref
1794 //   objects and the object definition was changed, PHP would fail.
1795 //   This doesn't happen with an simple array of non-default values.
1796 // * use $prefs->retrieve and $prefs->store methods, where retrieve
1797 //   understands the interim format of array of objects also.
1798 // * simplified $prefs->get() and fixed $prefs->set()
1799 // * added $user->_userid and class '_WikiUser' portability functions
1800 // * fixed $user object ->_level upgrading, mostly using sessions.
1801 //   this fixes yesterdays problems with loosing authorization level.
1802 // * fixed WikiUserNew::checkPass to return the _level
1803 // * fixed WikiUserNew::isSignedIn
1804 // * added explodePageList to class PageList, support sortby arg
1805 // * fixed UserPreferences for WikiUserNew
1806 // * fixed WikiPlugin for empty defaults array
1807 // * UnfoldSubpages: added pagename arg, renamed pages arg,
1808 //   removed sort arg, support sortby arg
1809 //
1810 // Revision 1.105  2004/01/25 03:57:15  rurban
1811 // WikiUserNew support (temp. ENABLE_USER_NEW constant)
1812 //
1813 // Revision 1.104  2003/12/26 06:41:16  carstenklapp
1814 // Bugfix: Try to defer OS errors about session.save_path and ACCESS_LOG,
1815 // so they don't prevent IE from partially (or not at all) rendering the
1816 // page. This should help a little for the IE user who encounters trouble
1817 // when setting up a new PhpWiki for the first time.
1818 //
1819 // Revision 1.103  2003/12/02 00:10:00  carstenklapp
1820 // Bugfix: Ongoing work to untangle UserPreferences/WikiUser/request code
1821 // mess: UserPreferences should take effect immediately now upon signing
1822 // in.
1823 //
1824 // Revision 1.102  2003/11/25 22:55:32  carstenklapp
1825 // Localization bugfix: For wikis where English is not the default system
1826 // language, make sure that the authority error message (i.e. "You must
1827 // sign in to edit pages in this wiki" etc.) is displayed in the wiki's
1828 // default language. Previously it would always display in English.
1829 // (Added call to update_locale() before displaying any messages prior to
1830 // the login prompt.)
1831 //
1832 // Revision 1.101  2003/11/25 21:49:44  carstenklapp
1833 // Bugfix: For a non-english wiki or when the user's preference is not
1834 // english, the wiki would always use the english ActionPage first if it
1835 // was present rather than the appropriate localised variant. (PhpWikis
1836 // running only in english or Wikis running ONLY without any english
1837 // ActionPages would not notice this bug, only when both english and
1838 // localised ActionPages were in the DB.) Now we check for the localised
1839 // variant first.
1840 //
1841 // Revision 1.100  2003/11/18 16:54:18  carstenklapp
1842 // Reformatting only: Tabs to spaces, added rcs log.
1843 //
1844
1845
1846 // Local Variables:
1847 // mode: php
1848 // tab-width: 8
1849 // c-basic-offset: 4
1850 // c-hanging-comment-ender-p: nil
1851 // indent-tabs-mode: nil
1852 // End:
1853 ?>