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