]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/main.php
stabilize on failing ldap queries or bind
[SourceForge/phpwiki.git] / lib / main.php
1 <?php //-*-php-*-
2 rcs_id('$Id: main.php,v 1.167 2004-06-16 13:21:16 rurban Exp $');
3
4 define ('USE_PREFS_IN_PAGE', true);
5
6 //include "lib/config.php";
7 require_once(dirname(__FILE__)."/stdlib.php");
8 require_once('lib/Request.php');
9 require_once('lib/WikiDB.php');
10 if (ENABLE_USER_NEW)
11     require_once("lib/WikiUserNew.php");
12 else
13     require_once("lib/WikiUser.php");
14 require_once("lib/WikiGroup.php");
15 require_once("lib/PagePerm.php");
16
17 class WikiRequest extends Request {
18     // var $_dbi;
19
20     function WikiRequest () {
21         $this->_dbi = WikiDB::open($GLOBALS['DBParams']);
22         if (in_array('File', $this->_dbi->getAuthParam('USER_AUTH_ORDER'))) {
23             // force our local copy, until the pear version is fixed.
24             include_once(dirname(__FILE__)."/pear/File_Passwd.php");
25         }
26         if (USE_DB_SESSION) {
27             include_once('lib/DbSession.php');
28             $dbi =& $this->_dbi;
29             $this->_dbsession = & new DbSession($dbi, $dbi->getParam('prefix') . $dbi->getParam('db_session_table'));
30         }
31 // Fixme: Does pear reset the error mask to 1? We have to find the culprit
32 $x = error_reporting();
33 $this->version = phpwiki_version();
34         $this->Request();
35
36         // Normalize args...
37         $this->setArg('pagename', $this->_deducePagename());
38         $this->setArg('action', $this->_deduceAction());
39
40         // Restore auth state. This doesn't check for proper authorization!
41         if (ENABLE_USER_NEW) {
42             $userid = $this->_deduceUsername(); 
43             if (isset($this->_user) and 
44                 !empty($this->_user->_authhow) and 
45                 $this->_user->_authhow == 'session')
46             {
47                 // users might switch in a session between the two objects.
48                 // restore old auth level here or in updateAuthAndPrefs?
49                 //$user = $this->getSessionVar('wiki_user');
50                 // revive db handle, because these don't survive sessions
51                 if (isset($this->_user) and 
52                      ( ! isa($this->_user,WikiUserClassname())
53                        or (strtolower(get_class($this->_user)) == '_passuser')))
54                 {
55                     $this->_user = WikiUser($userid,$this->_user->_prefs);
56                 }
57                 // revive other db handle
58                 if (isset($this->_user->_prefs->_method) and 
59                          ($this->_user->_prefs->_method == 'SQL' or 
60                          $this->_user->_prefs->_method == 'ADODB'))
61                     $this->_user->_HomePagehandle = $this->getPage($userid);
62                 // update the lockfile filehandle
63                 if (  isa($this->_user,'_FilePassUser') and 
64                       $this->_user->_file->lockfile and 
65                       !$this->_user->_file->fplock  )
66                 {
67                     $this->_user = new _FilePassUser($userid, $this->_user->_prefs, $this->_user->_file->filename);
68                 }
69                 $this->_prefs = & $this->_user->_prefs;
70             } else {
71                 $user = WikiUser($userid);
72                 $this->_user = & $user;
73                 $this->_prefs = & $this->_user->_prefs;
74             }
75         } else {
76             $this->_user = new WikiUser($this, $this->_deduceUsername());
77             $this->_prefs = $this->_user->getPreferences();
78         }
79     }
80
81     function initializeLang () {
82         $user_lang = $this->getPref('lang');
83         $_lang = @$this->_prefs->_prefs['lang'];
84         //check changed LANG and THEME inside a session. 
85         // (e.g. by using another baseurl)
86         if (isset($this->_user->_authhow) and 
87             $this->_user->_authhow == 'session' and 
88             !isset($_lang->lang) and 
89             $user_lang != $GLOBALS['LANG'])
90         {
91             $user_lang = $GLOBALS['LANG'];
92         }
93         if (isset($user_lang)) {
94             //trigger_error("DEBUG: initializeLang() ". $user_lang ." calling update_locale()...");
95             update_locale($user_lang);
96             FindLocalizedButtonFile(".",'missing_ok','reinit');
97         }
98     }
99
100     function initializeTheme () {
101         global $WikiTheme;
102
103         // Load theme
104         $user_theme = $this->getPref('theme');
105         $_theme = @$this->_prefs->_prefs['theme'];
106         //check changed LANG and THEME inside a session. 
107         // (e.g. by using another baseurl)
108         if (isset($this->_user->_authhow) and 
109             $this->_user->_authhow == 'session' and 
110             !isset($_theme->theme) and
111             defined('THEME') and 
112             $user_theme != THEME)
113         {
114             include_once("themes/" . THEME . "/themeinfo.php");
115         }
116         if (empty($WikiTheme) and isset($user_theme))
117             include_once("themes/$user_theme/themeinfo.php");
118         if (empty($WikiTheme) and defined('THEME'))
119             include_once("themes/" . THEME . "/themeinfo.php");
120         if (empty($WikiTheme))
121             include_once("themes/default/themeinfo.php");
122         assert(!empty($WikiTheme));
123     }
124
125     // This really maybe should be part of the constructor, but since it
126     // may involve HTML/template output, the global $request really needs
127     // to be initialized before we do this stuff.
128     function updateAuthAndPrefs () {
129
130         if (isset($this->_user) and (!isa($this->_user,WikiUserClassname()))) {
131             $this->_user = false;       
132         }
133         // Handle authentication request, if any.
134         if ($auth_args = $this->getArg('auth')) {
135             $this->setArg('auth', false);
136             $this->_handleAuthRequest($auth_args); // possible NORETURN
137         }
138         elseif ( ! $this->_user or 
139                  (isa($this->_user,WikiUserClassname()) and ! $this->_user->isSignedIn())) {
140             // If not auth request, try to sign in as saved user.
141             if (($saved_user = $this->getPref('userid')) != false) {
142                 $this->_signIn($saved_user);
143             }
144         }
145
146         // Save preferences in session and cookie
147         if (isset($this->_user) and 
148             (!isset($this->_user->_authhow) or $this->_user->_authhow != 'session')) {
149             $id_only = true; 
150             $this->_user->setPreferences($this->_prefs, $id_only);
151         } else {
152             $this->setSessionVar('wiki_user', $this->_user);
153             //$this->setSessionVar('wiki_prefs', $this->_prefs);
154         }
155
156         // Ensure user has permissions for action
157         // HACK ALERT: We may not set the request arg to create, 
158         // since the pageeditor has an ugly logic for action == create.
159         $action = $this->getArg('action');
160         if ($action == 'edit' or $action == 'create') {
161             $page = $this->getPage();
162             if (! $page->exists() )
163                 $action = 'create';
164             else
165                 $action = 'edit';
166         }
167         $require_level = $this->requiredAuthority($action);
168         if (! $this->_user->hasAuthority($require_level))
169             $this->_notAuthorized($require_level); // NORETURN
170     }
171
172     function getUser () {
173         if (isset($this->_user))
174             return $this->_user;
175         else
176             return $GLOBALS['ForbiddenUser'];
177     }
178
179     function getPrefs () {
180         return $this->_prefs;
181     }
182
183     // Convenience function:
184     function getPref ($key) {
185         if (isset($this->_prefs)) {
186             return $this->_prefs->get($key);
187         }
188     }
189
190     function getDbh () {
191         return $this->_dbi;
192     }
193
194     /**
195      * Get requested page from the page database.
196      * By default it will grab the page requested via the URL
197      *
198      * This is a convenience function.
199      * @param string $pagename Name of page to get.
200      * @return WikiDB_Page Object with methods to pull data from
201      * database for the page requested.
202      */
203     function getPage ($pagename = false) {
204         if (!isset($this->_dbi))
205             $this->getDbh();
206         if (!$pagename) 
207             $pagename = $this->getArg('pagename');
208         return $this->_dbi->getPage($pagename);
209     }
210
211     /** Get URL for POST actions.
212      *
213      * Officially, we should just use SCRIPT_NAME (or some such),
214      * but that causes problems when we try to issue a redirect, e.g.
215      * after saving a page.
216      *
217      * Some browsers (at least NS4 and Mozilla 0.97 won't accept
218      * a redirect from a page to itself.)
219      *
220      * So, as a HACK, we include pagename and action as query args in
221      * the URL.  (These should be ignored when we receive the POST
222      * request.)
223      */
224     function getPostURL ($pagename=false) {
225         global $HTTP_GET_VARS;
226
227         if ($pagename === false)
228             $pagename = $this->getArg('pagename');
229         $action = $this->getArg('action');
230         if (!empty($HTTP_GET_VARS['start_debug'])) // zend ide support
231             return WikiURL($pagename, array('action' => $action, 'start_debug' => 1));
232         else
233             return WikiURL($pagename, array('action' => $action));
234     }
235     
236     function _handleAuthRequest ($auth_args) {
237         if (!is_array($auth_args))
238             return;
239
240         // Ignore password unless POST'ed.
241         if (!$this->isPost())
242             unset($auth_args['passwd']);
243
244         $olduser = $this->_user;
245         $user = $this->_user->AuthCheck($auth_args);
246         if (isa($user, WikiUserClassname())) {
247             // Successful login (or logout.)
248             $this->_setUser($user);
249         }
250         elseif (is_string($user)) {
251             // Login attempt failed.
252             $fail_message = $user;
253             $auth_args['pass_required'] = true;
254             // If no password was submitted, it's not really
255             // a failure --- just need to prompt for password...
256             if (!ALLOW_USER_PASSWORDS 
257                 and ALLOW_BOGO_LOGIN 
258                 and !isset($auth_args['passwd'])) 
259             {
260                 $fail_message = false;
261             }
262             $olduser->PrintLoginForm($this, $auth_args, $fail_message, 'newpage');
263             $this->finish();    //NORETURN
264         }
265         else {
266             // Login request cancelled.
267         }
268     }
269
270     /**
271      * Attempt to sign in (bogo-login).
272      *
273      * Fails silently.
274      *
275      * @param $userid string Userid to attempt to sign in as.
276      * @access private
277      */
278     function _signIn ($userid) {
279         if (ENABLE_USER_NEW) {
280             if (! $this->_user )
281                 $this->_user = new _BogoUser($userid);
282             if (! $this->_user )
283                 $this->_user = new _PassUser($userid);
284         }
285         $user = $this->_user->AuthCheck(array('userid' => $userid));
286         if (isa($user,WikiUserClassname())) {
287             $this->_setUser($user); // success!
288         }
289     }
290
291     // login or logout or restore state
292     function _setUser ($user) {
293         $this->_user = $user;
294         if (defined('MAIN_setUser')) return;
295         define('MAIN_setUser',true);
296         $this->setCookieVar('WIKI_ID', $user->getAuthenticatedId(),
297                             COOKIE_EXPIRATION_DAYS, COOKIE_DOMAIN);
298         $this->setSessionVar('wiki_user', $user);
299         if ($user->isSignedIn())
300             $user->_authhow = 'signin';
301
302         // Save userid to prefs..
303         if ( empty($this->_user->_prefs)) {
304             $this->_user->_prefs = $this->_user->getPreferences();
305             $this->_prefs =& $this->_user->_prefs;
306         }
307         $this->_prefs->set('userid',
308                            $user->isSignedIn() ? $user->getId() : '');
309         $this->initializeTheme();
310     }
311
312     /* Permission system */
313     function getLevelDescription($level) {
314         static $levels = false;
315         if (!$levels) 
316             $levels = array('-1'  => _("FORBIDDEN"),
317                              '0'  => _("ANON"),
318                              '1'  => _("BOGO"),
319                              '2'  => _("USER"),
320                              '10' => _("ADMIN"),
321                              '100'=> _("UNOBTAINABLE"));
322         return $levels[$level];
323     }
324     
325     function _notAuthorized ($require_level) {
326         // Display the authority message in the Wiki's default
327         // language, in case it is not english.
328         //
329         // Note that normally a user will not see such an error once
330         // logged in, unless the admin has altered the default
331         // disallowed wikiactions. In that case we should probably
332         // check the user's language prefs too at this point; this
333         // would be a situation which is not really handled with the
334         // current code.
335         if (empty($GLOBALS['LANG']))
336             update_locale(DEFAULT_LANGUAGE);
337
338         // User does not have required authority.  Prompt for login.
339         $what = $this->getActionDescription($this->getArg('action'));
340         $pass_required = ($require_level >= WIKIAUTH_USER);
341         if ($require_level == WIKIAUTH_UNOBTAINABLE) {
342             if (class_exists('PagePermission')) {
343                 $user =& $this->_user;
344                 $status = $user->isAuthenticated() ? _("authenticated") : _("not authenticated");
345                 $msg = fmt("%s is disallowed on this wiki for %s user '%s' (level: %s).",
346                            $this->getDisallowedActionDescription($this->getArg('action')),
347                            $status, $user->getId(),$this->getLevelDescription($user->_level));
348                 $user->PrintLoginForm($this, compact('require_level','pass_required'), $msg);
349                 $this->finish();
350             } else {
351                 $msg = fmt("%s is disallowed on this wiki.",
352                            $this->getDisallowedActionDescription($this->getArg('action')));
353                 $this->_user->PrintLoginForm($this, compact('require_level','pass_required'), $msg);
354                 $this->finish();
355             }
356         }
357         elseif ($require_level == WIKIAUTH_BOGO)
358             $msg = fmt("You must sign in to %s.", $what);
359         elseif ($require_level == WIKIAUTH_USER)
360             $msg = fmt("You must log in to %s.", $what);
361         elseif ($require_level == WIKIAUTH_ANON)
362             $msg = fmt("Access for you is forbidden to %s.", $what);
363         else
364             $msg = fmt("You must be an administrator to %s.", $what);
365
366         $this->_user->PrintLoginForm($this, compact('require_level','pass_required'), $msg);
367         $this->finish();    // NORETURN
368     }
369
370     // Fixme: for PagePermissions we'll need other strings, 
371     // relevant to the requested page, not just for the action on the whole wiki.
372     function getActionDescription($action) {
373         static $actionDescriptions;
374         if (! $actionDescriptions) {
375             $actionDescriptions
376             = array('browse'     => _("view this page"),
377                     'diff'       => _("diff this page"),
378                     'dumphtml'   => _("dump html pages"),
379                     'dumpserial' => _("dump serial pages"),
380                     'edit'       => _("edit this page"),
381                     'revert'     => _("revert to a previous version of this page"),
382                     'create'     => _("create this page"),
383                     'loadfile'   => _("load files into this wiki"),
384                     'lock'       => _("lock this page"),
385                     'remove'     => _("remove this page"),
386                     'unlock'     => _("unlock this page"),
387                     'upload'     => _("upload a zip dump"),
388                     'verify'     => _("verify the current action"),
389                     'viewsource' => _("view the source of this page"),
390                     'xmlrpc'     => _("access this wiki via XML-RPC"),
391                     'soap'       => _("access this wiki via SOAP"),
392                     'zip'        => _("download a zip dump from this wiki"),
393                     'ziphtml'    => _("download an html zip dump from this wiki")
394                     );
395         }
396         if (in_array($action, array_keys($actionDescriptions)))
397             return $actionDescriptions[$action];
398         else
399             return $action;
400     }
401     function getDisallowedActionDescription($action) {
402         static $disallowedActionDescriptions;
403         if (! $disallowedActionDescriptions) {
404             $disallowedActionDescriptions
405             = array('browse'     => _("Browsing pages"),
406                     'diff'       => _("Diffing pages"),
407                     'dumphtml'   => _("Dumping html pages"),
408                     'dumpserial' => _("Dumping serial pages"),
409                     'edit'       => _("Editing pages"),
410                     'revert'     => _("Reverting to a previous version of pages"),
411                     'create'     => _("Creating pages"),
412                     'loadfile'   => _("Loading files"),
413                     'lock'       => _("Locking pages"),
414                     'remove'     => _("Removing pages"),
415                     'unlock'     => _("Unlocking pages"),
416                     'upload'     => _("Uploading zip dumps"),
417                     'verify'     => _("Verify the current action"),
418                     'viewsource' => _("Viewing the source of pages"),
419                     'xmlrpc'     => _("XML-RPC access"),
420                     'soap'       => _("SOAP access"),
421                     'zip'        => _("Downloading zip dumps"),
422                     'ziphtml'    => _("Downloading html zip dumps")
423                     );
424         }
425         if (in_array($action, array_keys($disallowedActionDescriptions)))
426             return $disallowedActionDescriptions[$action];
427         else
428             return $action;
429     }
430
431     function requiredAuthority ($action) {
432         $auth = $this->requiredAuthorityForAction($action);
433         if (!ALLOW_ANON_USER) return WIKIAUTH_USER;
434         
435         /*
436          * This is a hook for plugins to require authority
437          * for posting to them.
438          *
439          * IMPORTANT: this is not a secure check, so the plugin
440          * may not assume that any POSTs to it are authorized.
441          * All this does is cause PhpWiki to prompt for login
442          * if the user doesn't have the required authority.
443          */
444         if ($this->isPost()) {
445             $post_auth = $this->getArg('require_authority_for_post');
446             if ($post_auth !== false)
447                 $auth = max($auth, $post_auth);
448         }
449         return $auth;
450     }
451         
452     function requiredAuthorityForAction ($action) {
453         if (ENABLE_PAGEPERM and class_exists("PagePermission")) {
454            return requiredAuthorityForPage($action);
455         } else {
456           // FIXME: clean up. 
457           switch ($action) {
458             case 'browse':
459             case 'viewsource':
460             case 'diff':
461             case 'select':
462             case 'xmlrpc':
463             case 'search':
464             case 'pdf':
465                 return WIKIAUTH_ANON;
466
467             case 'zip':
468             case 'ziphtml':
469                 if (defined('ZIPDUMP_AUTH') && ZIPDUMP_AUTH)
470                     return WIKIAUTH_ADMIN;
471                 return WIKIAUTH_ANON;
472
473             case 'edit':
474             case 'revert':
475             case 'soap':
476                 if (defined('REQUIRE_SIGNIN_BEFORE_EDIT') && REQUIRE_SIGNIN_BEFORE_EDIT)
477                     return WIKIAUTH_BOGO;
478                 return WIKIAUTH_ANON;
479                 // return WIKIAUTH_BOGO;
480
481             case 'create':
482                 $page = $this->getPage();
483                 $current = $page->getCurrentRevision();
484                 if ($current->hasDefaultContents())
485                     return $this->requiredAuthorityForAction('edit');
486                 return $this->requiredAuthorityForAction('browse');
487
488             case 'upload':
489             case 'dumpserial':
490             case 'dumphtml':
491             case 'loadfile':
492             case 'remove':
493             case 'lock':
494             case 'unlock':
495             case 'upgrade':
496             case 'chown':
497             case 'setacl':
498             case 'rename':
499                 return WIKIAUTH_ADMIN;
500
501             /* authcheck occurs only in the plugin.
502                required actionpage RateIt */
503             /*
504             case 'rate':
505             case 'delete_rating':
506                 // Perhaps this should be WIKIAUTH_USER
507                 return WIKIAUTH_BOGO;
508             */
509
510             default:
511                 global $WikiNameRegexp;
512                 if (preg_match("/$WikiNameRegexp\Z/A", $action))
513                     return WIKIAUTH_ANON; // ActionPage.
514                 else
515                     return WIKIAUTH_ADMIN;
516           }
517         }
518     }
519     /* End of Permission system */
520
521     function possiblyDeflowerVirginWiki () {
522         if ($this->getArg('action') != 'browse')
523             return;
524         if ($this->getArg('pagename') != HOME_PAGE)
525             return;
526
527         $page = $this->getPage();
528         $current = $page->getCurrentRevision();
529         if ($current->getVersion() > 0)
530             return;             // Homepage exists.
531
532         include('lib/loadsave.php');
533         SetupWiki($this);
534         $this->finish();        // NORETURN
535     }
536
537     function handleAction () {
538         $action = $this->getArg('action');
539         $method = "action_$action";
540         if (method_exists($this, $method)) {
541             $this->{$method}();
542         }
543         elseif ($page = $this->findActionPage($action)) {
544             $this->actionpage($page);
545         }
546         else {
547             $this->finish(fmt("%s: Bad action", $action));
548         }
549     }
550     
551     function finish ($errormsg = false) {
552         static $in_exit = 0;
553
554         if ($in_exit)
555             exit();        // just in case CloseDataBase calls us
556         $in_exit = true;
557
558         global $ErrorManager;
559         $ErrorManager->flushPostponedErrors();
560
561         if (!empty($errormsg)) {
562             PrintXML(HTML::br(),
563                      HTML::hr(),
564                      HTML::h2(_("Fatal PhpWiki Error")),
565                      $errormsg);
566             // HACK:
567             echo "\n</body></html>";
568         }
569         if (is_object($this->_user)) {
570             $this->_user->page   = $this->getArg('pagename');
571             $this->_user->action = $this->getArg('action');
572             unset($this->_user->_HomePagehandle);
573             unset($this->_user->_auth_dbi);
574         }
575         if (!empty($this->_dbi)) {
576             session_write_close();
577             $this->_dbi->close();
578             unset($this->_dbi);
579         }
580         Request::finish();
581         exit;
582     }
583
584     /**
585      * Generally pagename is rawurlencoded for older browsers or mozilla.
586      * Typing a pagename into the IE bar will utf-8 encode it, so we have to 
587      * fix that with fixTitleEncoding().
588      * If USE_PATH_INFO = true, the pagename is stripped from the "/DATA_PATH/PageName&arg=value" line.
589      * If false, we support either "/index.php?pagename=PageName&arg=value",
590      * or the first arg (1.2.x style): "/index.php?PageName&arg=value"
591      */
592     function _deducePagename () {
593         if (trim(rawurldecode($this->getArg('pagename'))))
594             return fixTitleEncoding(rawurldecode($this->getArg('pagename')));
595
596         if (USE_PATH_INFO) {
597             $pathinfo = $this->get('PATH_INFO');
598             if (empty($pathinfo)) { // fix for CGI
599                 $path = $this->get('REQUEST_URI');
600                 $script = $this->get('SCRIPT_NAME');
601                 $pathinfo = substr($path,strlen($script));
602                 $pathinfo = preg_replace('/\?.+$/','',$pathinfo);
603             }
604             $tail = substr($pathinfo, strlen(PATH_INFO_PREFIX));
605
606             if (trim($tail) != '' and $pathinfo == PATH_INFO_PREFIX . $tail) {
607                 return fixTitleEncoding($tail);
608             }
609         }
610         elseif ($this->isPost()) {
611             /*
612              * In general, for security reasons, HTTP_GET_VARS should be ignored
613              * on POST requests, but we make an exception here (only for pagename).
614              *
615              * The justification for this hack is the following
616              * asymmetry: When POSTing with USE_PATH_INFO set, the
617              * pagename can (and should) be communicated through the
618              * request URL via PATH_INFO.  When POSTing with
619              * USE_PATH_INFO off, this cannot be done --- the only way
620              * to communicate the pagename through the URL is via
621              * QUERY_ARGS (HTTP_GET_VARS).
622              */
623             global $HTTP_GET_VARS;
624             if (isset($HTTP_GET_VARS['pagename']) and trim($HTTP_GET_VARS['pagename'])) { 
625                 return fixTitleEncoding(rawurldecode($HTTP_GET_VARS['pagename']));
626             }
627         }
628
629         /*
630          * Support for PhpWiki 1.2 style requests.
631          * Strip off "&" args (?PageName&action=...&start_debug,...)
632          */
633         $query_string = $this->get('QUERY_STRING');
634         if (trim(rawurldecode($query_string)) and preg_match('/^([^&=]+)(&.+)?$/', $query_string, $m)) {
635             return fixTitleEncoding(rawurldecode($m[1]));
636         }
637
638         return fixTitleEncoding(HOME_PAGE);
639     }
640
641     function _deduceAction () {
642         if (!($action = $this->getArg('action'))) {
643             // Detect XML-RPC requests
644             if ($this->isPost()
645                 && $this->get('CONTENT_TYPE') == 'text/xml') {
646                 global $HTTP_RAW_POST_DATA;
647                 if (strstr($HTTP_RAW_POST_DATA, '<methodCall>')) {
648                     return 'xmlrpc';
649                 }
650             }
651             return 'browse';    // Default if no action specified.
652         }
653
654         if (method_exists($this, "action_$action"))
655             return $action;
656
657         // Allow for, e.g. action=LikePages
658         if ($this->isActionPage($action))
659             return $action;
660
661         // Handle untranslated actionpages in non-english
662         // (people playing with switching languages)
663         if (0 and $GLOBALS['LANG'] != 'en') {
664             require_once("lib/plugin/_WikiTranslation.php");
665             $trans = new WikiPlugin__WikiTranslation();
666             $en_action = $trans->translate($action,'en',$GLOBALS['LANG']);
667             if ($this->isActionPage($en_action))
668                 return $en_action;
669         }
670
671         trigger_error("$action: Unknown action", E_USER_NOTICE);
672         return 'browse';
673     }
674
675     function _deduceUsername() {
676         global $HTTP_SERVER_VARS, $HTTP_ENV_VARS;
677
678         if (!empty($this->args['auth']) and !empty($this->args['auth']['userid']))
679             return $this->args['auth']['userid'];
680
681         if (!empty($HTTP_SERVER_VARS['PHP_AUTH_USER']))
682             return $HTTP_SERVER_VARS['PHP_AUTH_USER'];
683         if (!empty($HTTP_ENV_VARS['REMOTE_USER']))
684             return $HTTP_ENV_VARS['REMOTE_USER'];
685             
686         if ($user = $this->getSessionVar('wiki_user')) {
687             $this->_user = $user;
688             $this->_user->_authhow = 'session';
689             return ENABLE_USER_NEW ? $user->UserName() : $this->_user;
690         }
691         if ($userid = $this->getCookieVar('WIKI_ID')) {
692             if (!empty($userid) and substr($userid,0,2) != 's:') {
693                 $this->_user->authhow = 'cookie';
694                 return $userid;
695             }
696         }
697         return false;
698     }
699     
700     function _isActionPage ($pagename) {
701         $dbi = $this->getDbh();
702         $page = $dbi->getPage($pagename);
703         if (!$page) return false;
704         $rev = $page->getCurrentRevision();
705         // FIXME: more restrictive check for sane plugin?
706         if (strstr($rev->getPackedContent(), '<?plugin'))
707             return true;
708         if (!$rev->hasDefaultContents())
709             trigger_error("$pagename: Does not appear to be an 'action page'", E_USER_NOTICE);
710         return false;
711     }
712
713     function findActionPage ($action) {
714         static $cache;
715
716         // check for translated version, as per users preferred language
717         // (or system default in case it is not en)
718         $translation = gettext($action);
719
720         if (isset($cache) and isset($cache[$translation]))
721             return $cache[$translation];
722
723         // check for cached translated version
724         if ($this->_isActionPage($translation))
725             return $cache[$action] = $translation;
726
727         // Allow for, e.g. action=LikePages
728         global $WikiNameRegexp;
729         if (!preg_match("/$WikiNameRegexp\\Z/A", $action))
730             return $cache[$action] = false;
731
732         // check for translated version (default language)
733         global $LANG;
734         if ($LANG != DEFAULT_LANGUAGE and $LANG != "en") {
735             $save_lang = $LANG;
736             //trigger_error("DEBUG: findActionPage() ". DEFAULT_LANGUAGE." calling update_locale()...");
737             update_locale(DEFAULT_LANGUAGE);
738             $default = gettext($action);
739             //trigger_error("DEBUG: findActionPage() ". $save_lang." restoring save_lang, calling update_locale()...");
740             update_locale($save_lang);
741             if ($this->_isActionPage($default))
742                 return $cache[$action] = $default;
743         }
744         else {
745             $default = $translation;
746         }
747         
748         // check for english version
749         if ($action != $translation and $action != $default) {
750             if ($this->_isActionPage($action))
751                 return $cache[$action] = $action;
752         }
753
754         trigger_error("$action: Cannot find action page", E_USER_NOTICE);
755         return $cache[$action] = false;
756     }
757     
758     function isActionPage ($pagename) {
759         return $this->findActionPage($pagename);
760     }
761
762     function action_browse () {
763         $this->buffer_output();
764         include_once("lib/display.php");
765         displayPage($this);
766     }
767
768     function action_verify () {
769         $this->action_browse();
770     }
771
772     function actionpage ($action) {
773         $this->buffer_output();
774         include_once("lib/display.php");
775         actionPage($this, $action);
776     }
777
778     function adminActionSubpage ($subpage) {
779         $page = _("PhpWikiAdministration")."/".$subpage;
780         $action = $this->findActionPage($page);
781         if ($action) {
782             $this->setArg('s',$this->getArg('pagename'));
783             $this->setArg('verify',1);
784             $this->setArg('action',$action);
785             $this->actionpage($action);
786         } else {
787             trigger_error($page.": Cannot find action page", E_USER_WARNING);
788         }
789     }
790
791     function action_chown () {
792         $this->adminActionSubpage(_("Chown"));
793     }
794
795     function action_setacl () {
796         $this->adminActionSubpage(_("SetAcl"));
797     }
798
799     function action_rename () {
800         $this->adminActionSubpage(_("Rename"));
801     }
802
803     function action_dump () {
804         $action = $this->findActionPage(_("PageDump"));
805         if ($action) {
806             $this->actionpage($action);
807         } else {
808             // redirect to action=upgrade if admin?
809             trigger_error(_("PageDump").": Cannot find action page", E_USER_WARNING);
810         }
811     }
812
813     function action_diff () {
814         $this->buffer_output();
815         include_once "lib/diff.php";
816         showDiff($this);
817     }
818
819     function action_search () {
820         // This is obsolete: reformulate URL and redirect.
821         // FIXME: this whole section should probably be deleted.
822         if ($this->getArg('searchtype') == 'full') {
823             $search_page = _("FullTextSearch");
824         }
825         else {
826             $search_page = _("TitleSearch");
827         }
828         $this->redirect(WikiURL($search_page,
829                                 array('s' => $this->getArg('searchterm')),
830                                 'absolute_url'));
831     }
832
833     function action_edit () {
834         $this->buffer_output();
835         include "lib/editpage.php";
836         $e = new PageEditor ($this);
837         $e->editPage();
838     }
839
840     function action_create () {
841         $this->action_edit();
842     }
843     
844     function action_viewsource () {
845         $this->buffer_output();
846         include "lib/editpage.php";
847         $e = new PageEditor ($this);
848         $e->viewSource();
849     }
850
851     function action_lock () {
852         $page = $this->getPage();
853         $page->set('locked', true);
854         $this->_dbi->touch();
855         $this->action_browse();
856     }
857
858     function action_unlock () {
859         // FIXME: This check is redundant.
860         //$user->requireAuth(WIKIAUTH_ADMIN);
861         $page = $this->getPage();
862         $page->set('locked', false);
863         $this->_dbi->touch();
864         $this->action_browse();
865     }
866
867     function action_remove () {
868         // FIXME: This check is redundant.
869         //$user->requireAuth(WIKIAUTH_ADMIN);
870         $pagename = $this->getArg('pagename');
871         if (strstr($pagename,_('PhpWikiAdministration'))) {
872             $this->action_browse();
873         } else {
874             include('lib/removepage.php');
875             RemovePage($this);
876         }
877     }
878
879     function action_xmlrpc () {
880         include_once("lib/XmlRpcServer.php");
881         $xmlrpc = new XmlRpcServer($this);
882         $xmlrpc->service();
883     }
884     
885     function action_revert () {
886         include_once "lib/loadsave.php";
887         RevertPage($this);
888     }
889
890     function action_zip () {
891         include_once("lib/loadsave.php");
892         MakeWikiZip($this);
893         // I don't think it hurts to add cruft at the end of the zip file.
894         //echo "\n========================================================\n";
895         //echo "PhpWiki " . PHPWIKI_VERSION . " source:\n$GLOBALS[RCS_IDS]\n";
896     }
897
898     function action_ziphtml () {
899         include_once("lib/loadsave.php");
900         MakeWikiZipHtml($this);
901         // I don't think it hurts to add cruft at the end of the zip file.
902         echo "\n========================================================\n";
903         echo "PhpWiki " . PHPWIKI_VERSION . " source:\n$GLOBALS[RCS_IDS]\n";
904     }
905
906     function action_dumpserial () {
907         include_once("lib/loadsave.php");
908         DumpToDir($this);
909     }
910
911     function action_dumphtml () {
912         include_once("lib/loadsave.php");
913         DumpHtmlToDir($this);
914     }
915
916     function action_upload () {
917         include_once("lib/loadsave.php");
918         LoadPostFile($this);
919     }
920
921     function action_upgrade () {
922         include_once("lib/loadsave.php");
923         include_once("lib/upgrade.php");
924         DoUpgrade($this);
925     }
926
927     function action_loadfile () {
928         include_once("lib/loadsave.php");
929         LoadFileOrDir($this);
930     }
931
932     function action_pdf () {
933         include_once("lib/pdf.php");
934         ConvertAndDisplayPdf($this);
935     }
936     
937 }
938
939 //FIXME: deprecated
940 function is_safe_action ($action) {
941     return WikiRequest::requiredAuthorityForAction($action) < WIKIAUTH_ADMIN;
942 }
943
944 function validateSessionPath() {
945     // Try to defer any session.save_path PHP errors before any html
946     // is output, which causes some versions of IE to display a blank
947     // page (due to its strict mode while parsing a page?).
948     if (! is_writeable(ini_get('session.save_path'))) {
949         $tmpdir = '/tmp';
950         trigger_error
951             (sprintf(_("%s is not writable."),
952                      _("The session.save_path directory"))
953              . "\n"
954              . sprintf(_("Please ensure that %s is writable, or redefine %s in config/config.ini."),
955                        sprintf(_("the directory '%s'"),
956                                ini_get('session.save_path')),
957                        'session.save_path')
958              . "\n"
959              . sprintf(_("Attempting to use the directory '%s' instead."),
960                        $tmpdir)
961              , E_USER_NOTICE);
962         if (! is_writeable($tmpdir)) {
963             trigger_error
964                 (sprintf(_("%s is not writable."), $tmpdir)
965                  . "\n"
966                  . _("Users will not be able to sign in.")
967                  , E_USER_NOTICE);
968         }
969         else
970             ini_set('session.save_path', $tmpdir);
971     }
972 }
973
974 function main () {
975     if (!USE_DB_SESSION)
976         validateSessionPath();
977
978     global $request;
979
980     if ((DEBUG & 4) and extension_loaded("apd"))
981         apd_set_session_trace(9);
982
983     // Postpone warnings
984     global $ErrorManager;
985     $ErrorManager->setPostponedErrorMask(E_NOTICE|E_USER_NOTICE|E_USER_WARNING);
986     $request = new WikiRequest();
987
988     $action = $request->getArg('action');
989     if (substr($action, 0, 3) != 'zip') {
990         if ($action == 'pdf')
991             $ErrorManager->setPostponedErrorMask(-1);
992         else // reject postponing of warnings
993             $ErrorManager->setPostponedErrorMask(E_NOTICE|E_USER_NOTICE);
994     }
995
996     /*
997      * Allow for disabling of markup cache.
998      * (Mostly for debugging ... hopefully.)
999      *
1000      * See also <?plugin WikiAdminUtils action=purge-cache ?>
1001      */
1002     if (!defined('WIKIDB_NOCACHE_MARKUP') and $request->getArg('nocache'))
1003         define('WIKIDB_NOCACHE_MARKUP', $request->getArg('nocache'));
1004     
1005     // Initialize with system defaults in case user not logged in.
1006     // Should this go into constructor?
1007     $request->initializeTheme();
1008
1009     $request->updateAuthAndPrefs();
1010     $request->initializeLang();
1011     
1012     //FIXME:
1013     //if ($user->is_authenticated())
1014     //  $LogEntry->user = $user->getId();
1015
1016     $request->possiblyDeflowerVirginWiki();
1017     
1018 if (defined('WIKI_XMLRPC') and WIKI_XMLRPC) return;
1019 if (defined('WIKI_SOAP')   and WIKI_SOAP)   return;
1020
1021     $validators = array('wikiname' => WIKI_NAME,
1022                         'args'     => hash($request->getArgs()),
1023                         'prefs'    => hash($request->getPrefs()));
1024     if (CACHE_CONTROL == 'STRICT') {
1025         $dbi = $request->getDbh();
1026         $timestamp = $dbi->getTimestamp();
1027         $validators['mtime'] = $timestamp;
1028         $validators['%mtime'] = (int)$timestamp;
1029     }
1030     // FIXME: we should try to generate strong validators when possible,
1031     // but for now, our validator is weak, since equal validators do not
1032     // indicate byte-level equality of content.  (Due to DEBUG timing output, etc...)
1033     //
1034     // (If DEBUG if off, this may be a strong validator, but I'm going
1035     // to go the paranoid route here pending further study and testing.)
1036     //
1037     $validators['%weak'] = true;
1038     $request->setValidators($validators);
1039    
1040     $request->handleAction();
1041
1042 if (defined('DEBUG') and DEBUG & 4) phpinfo(INFO_VARIABLES);
1043     $request->finish();
1044 }
1045
1046 $x = error_reporting(); // why is it 1 here? should be E_ALL
1047 error_reporting(E_ALL);
1048 main();
1049
1050
1051 // $Log: not supported by cvs2svn $
1052 // Revision 1.166  2004/06/15 09:15:52  rurban
1053 // IMPORTANT: fixed passwd handling for passwords stored in prefs:
1054 //   fix encrypted usage, actually store and retrieve them from db
1055 //   fix bogologin with passwd set.
1056 // fix php crashes with call-time pass-by-reference (references wrongly used
1057 //   in declaration AND call). This affected mainly Apache2 and IIS.
1058 //   (Thanks to John Cole to detect this!)
1059 //
1060 // Revision 1.165  2004/06/14 11:31:37  rurban
1061 // renamed global $Theme to $WikiTheme (gforge nameclash)
1062 // inherit PageList default options from PageList
1063 //   default sortby=pagename
1064 // use options in PageList_Selectable (limit, sortby, ...)
1065 // added action revert, with button at action=diff
1066 // added option regex to WikiAdminSearchReplace
1067 //
1068 // Revision 1.164  2004/06/13 13:54:25  rurban
1069 // Catch fatals on the four dump calls (as file and zip, as html and mimified)
1070 // FoafViewer: Check against external requirements, instead of fatal.
1071 // Change output for xhtmldumps: using file:// urls to the local fs.
1072 // Catch SOAP fatal by checking for GOOGLE_LICENSE_KEY
1073 // Import GOOGLE_LICENSE_KEY and FORTUNE_DIR from config.ini.
1074 //
1075 // Revision 1.163  2004/06/13 11:35:32  rurban
1076 // check for create action on action=edit not to fool PagePerm checks
1077 //
1078 // Revision 1.162  2004/06/08 10:05:11  rurban
1079 // simplified admin action shortcuts
1080 //
1081 // Revision 1.161  2004/06/07 22:58:40  rurban
1082 // simplified chown, setacl, dump actions
1083 //
1084 // Revision 1.160  2004/06/07 22:44:14  rurban
1085 // added simplified chown, setacl actions
1086 //
1087 // Revision 1.159  2004/06/06 16:58:51  rurban
1088 // added more required ActionPages for foreign languages
1089 // install now english ActionPages if no localized are found. (again)
1090 // fixed default anon user level to be 0, instead of -1
1091 //   (wrong "required administrator to view this page"...)
1092 //
1093 // Revision 1.158  2004/06/04 20:32:53  rurban
1094 // Several locale related improvements suggested by Pierrick Meignen
1095 // LDAP fix by John Cole
1096 // reanable admin check without ENABLE_PAGEPERM in the admin plugins
1097 //
1098 // Revision 1.157  2004/06/04 12:40:21  rurban
1099 // Restrict valid usernames to prevent from attacks against external auth or compromise
1100 // possible holes.
1101 // Fix various WikiUser old issues with default IMAP,LDAP,POP3 configs. Removed these.
1102 // Fxied more warnings
1103 //
1104 // Revision 1.156  2004/06/03 17:58:16  rurban
1105 // support immediate LANG and THEME switch inside a session
1106 //
1107 // Revision 1.155  2004/06/03 10:18:19  rurban
1108 // fix FileUser locking issues, new config ENABLE_PAGEPERM
1109 //
1110 // Revision 1.154  2004/06/02 18:01:46  rurban
1111 // init global FileFinder to add proper include paths at startup
1112 //   adds PHPWIKI_DIR if started from another dir, lib/pear also
1113 // fix slashify for Windows
1114 // fix USER_AUTH_POLICY=old, use only USER_AUTH_ORDER methods (besides HttpAuth)
1115 //
1116 // Revision 1.153  2004/06/01 15:28:00  rurban
1117 // AdminUser only ADMIN_USER not member of Administrators
1118 // some RateIt improvements by dfrankow
1119 // edit_toolbar buttons
1120 //
1121 // Revision 1.152  2004/05/27 17:49:06  rurban
1122 // renamed DB_Session to DbSession (in CVS also)
1123 // added WikiDB->getParam and WikiDB->getAuthParam method to get rid of globals
1124 // remove leading slash in error message
1125 // added force_unlock parameter to File_Passwd (no return on stale locks)
1126 // fixed adodb session AffectedRows
1127 // added FileFinder helpers to unify local filenames and DATA_PATH names
1128 // editpage.php: new edit toolbar javascript on ENABLE_EDIT_TOOLBAR
1129 //
1130 // Revision 1.151  2004/05/25 12:40:48  rurban
1131 // trim the pagename
1132 //
1133 // Revision 1.150  2004/05/25 10:18:44  rurban
1134 // Check for UTF-8 URLs; Internet Explorer produces these if you
1135 // type non-ASCII chars in the URL bar or follow unescaped links.
1136 // Fixes sf.net bug #953949
1137 // src: languages/Language.php:checkTitleEncoding() from mediawiki
1138 //
1139 // Revision 1.149  2004/05/18 13:31:19  rurban
1140 // hold warnings until headers are sent. new Error-style with collapsed output of repeated messages
1141 //
1142 // Revision 1.148  2004/05/17 17:43:29  rurban
1143 // CGI: no PATH_INFO fix
1144 //
1145 // Revision 1.147  2004/05/15 19:48:33  rurban
1146 // fix some too loose PagePerms for signed, but not authenticated users
1147 //  (admin, owner, creator)
1148 // no double login page header, better login msg.
1149 // moved action_pdf to lib/pdf.php
1150 //
1151 // Revision 1.146  2004/05/15 18:31:01  rurban
1152 // some action=pdf Request fixes: With MSIE it works now. Now the work with the page formatting begins.
1153 //
1154 // Revision 1.145  2004/05/12 10:49:55  rurban
1155 // require_once fix for those libs which are loaded before FileFinder and
1156 //   its automatic include_path fix, and where require_once doesn't grok
1157 //   dirname(__FILE__) != './lib'
1158 // upgrade fix with PearDB
1159 // navbar.tmpl: remove spaces for IE &nbsp; button alignment
1160 //
1161 // Revision 1.144  2004/05/06 19:26:16  rurban
1162 // improve stability, trying to find the InlineParser endless loop on sf.net
1163 //
1164 // remove end-of-zip comments to fix sf.net bug #777278 and probably #859628
1165 //
1166 // Revision 1.143  2004/05/06 17:30:38  rurban
1167 // CategoryGroup: oops, dos2unix eol
1168 // improved phpwiki_version:
1169 //   pre -= .0001 (1.3.10pre: 1030.099)
1170 //   -p1 += .001 (1.3.9-p1: 1030.091)
1171 // improved InstallTable for mysql and generic SQL versions and all newer tables so far.
1172 // abstracted more ADODB/PearDB methods for action=upgrade stuff:
1173 //   backend->backendType(), backend->database(),
1174 //   backend->listOfFields(),
1175 //   backend->listOfTables(),
1176 //
1177 // Revision 1.142  2004/05/04 22:34:25  rurban
1178 // more pdf support
1179 //
1180 // Revision 1.141  2004/05/03 13:16:47  rurban
1181 // fixed UserPreferences update, esp for boolean and int
1182 //
1183 // Revision 1.140  2004/05/02 21:26:38  rurban
1184 // limit user session data (HomePageHandle and auth_dbi have to invalidated anyway)
1185 //   because they will not survive db sessions, if too large.
1186 // extended action=upgrade
1187 // some WikiTranslation button work
1188 // revert WIKIAUTH_UNOBTAINABLE (need it for main.php)
1189 // some temp. session debug statements
1190 //
1191 // Revision 1.139  2004/05/02 15:10:07  rurban
1192 // new finally reliable way to detect if /index.php is called directly
1193 //   and if to include lib/main.php
1194 // new global AllActionPages
1195 // SetupWiki now loads all mandatory pages: HOME_PAGE, action pages, and warns if not.
1196 // WikiTranslation what=buttons for Carsten to create the missing MacOSX buttons
1197 // PageGroupTestOne => subpages
1198 // renamed PhpWikiRss to PhpWikiRecentChanges
1199 // more docs, default configs, ...
1200 //
1201 // Revision 1.138  2004/05/01 15:59:29  rurban
1202 // more php-4.0.6 compatibility: superglobals
1203 //
1204 // Revision 1.137  2004/04/29 19:39:44  rurban
1205 // special support for formatted plugins (one-liners)
1206 //   like <small><plugin BlaBla ></small>
1207 // iter->asArray() helper for PopularNearby
1208 // db_session for older php's (no &func() allowed)
1209 //
1210 // Revision 1.136  2004/04/29 17:18:19  zorloc
1211 // Fixes permission failure issues.  With PagePermissions and Disabled Actions when user did not have permission WIKIAUTH_FORBIDDEN was returned.  In WikiUser this was ok because WIKIAUTH_FORBIDDEN had a value of 11 -- thus no user could perform that action.  But WikiUserNew has a WIKIAUTH_FORBIDDEN value of -1 -- thus a user without sufficent permission to do anything.  The solution is a new high value permission level (WIKIAUTH_UNOBTAINABLE) to be the default level for access failure.
1212 //
1213 // Revision 1.135  2004/04/26 12:15:01  rurban
1214 // check default config values
1215 //
1216 // Revision 1.134  2004/04/23 06:46:37  zorloc
1217 // Leave DB connection open when USE_DB_SESSION is true so that session info can be written to the DB.
1218 //
1219 // Revision 1.133  2004/04/20 18:10:31  rurban
1220 // config refactoring:
1221 //   FileFinder is needed for WikiFarm scripts calling index.php
1222 //   config run-time calls moved to lib/IniConfig.php:fix_configs()
1223 //   added PHPWIKI_DIR smart-detection code (Theme finder)
1224 //   moved FileFind to lib/FileFinder.php
1225 //   cleaned lib/config.php
1226 //
1227 // Revision 1.132  2004/04/19 21:51:41  rurban
1228 // php5 compatibility: it works!
1229 //
1230 // Revision 1.131  2004/04/19 18:27:45  rurban
1231 // Prevent from some PHP5 warnings (ref args, no :: object init)
1232 //   php5 runs now through, just one wrong XmlElement object init missing
1233 // Removed unneccesary UpgradeUser lines
1234 // Changed WikiLink to omit version if current (RecentChanges)
1235 //
1236 // Revision 1.130  2004/04/18 00:25:53  rurban
1237 // allow "0" pagename
1238 //
1239 // Revision 1.129  2004/04/07 23:13:19  rurban
1240 // fixed pear/File_Passwd for Windows
1241 // fixed FilePassUser sessions (filehandle revive) and password update
1242 //
1243 // Revision 1.128  2004/04/02 15:06:55  rurban
1244 // fixed a nasty ADODB_mysql session update bug
1245 // improved UserPreferences layout (tabled hints)
1246 // fixed UserPreferences auth handling
1247 // improved auth stability
1248 // improved old cookie handling: fixed deletion of old cookies with paths
1249 //
1250 // Revision 1.127  2004/03/25 17:00:31  rurban
1251 // more code to convert old-style pref array to new hash
1252 //
1253 // Revision 1.126  2004/03/24 19:39:03  rurban
1254 // php5 workaround code (plus some interim debugging code in XmlElement)
1255 //   php5 doesn't work yet with the current XmlElement class constructors,
1256 //   WikiUserNew does work better than php4.
1257 // rewrote WikiUserNew user upgrading to ease php5 update
1258 // fixed pref handling in WikiUserNew
1259 // added Email Notification
1260 // added simple Email verification
1261 // removed emailVerify userpref subclass: just a email property
1262 // changed pref binary storage layout: numarray => hash of non default values
1263 // print optimize message only if really done.
1264 // forced new cookie policy: delete pref cookies, use only WIKI_ID as plain string.
1265 //   prefs should be stored in db or homepage, besides the current session.
1266 //
1267 // Revision 1.125  2004/03/14 16:30:52  rurban
1268 // db-handle session revivification, dba fixes
1269 //
1270 // Revision 1.124  2004/03/12 15:48:07  rurban
1271 // fixed explodePageList: wrong sortby argument order in UnfoldSubpages
1272 // simplified lib/stdlib.php:explodePageList
1273 //
1274 // Revision 1.123  2004/03/10 15:41:27  rurban
1275 // use default pref mysql table
1276 //
1277 // Revision 1.122  2004/03/08 18:17:09  rurban
1278 // added more WikiGroup::getMembersOf methods, esp. for special groups
1279 // fixed $LDAP_SET_OPTIONS
1280 // fixed _AuthInfo group methods
1281 //
1282 // Revision 1.121  2004/03/01 13:48:45  rurban
1283 // rename fix
1284 // p[] consistency fix
1285 //
1286 // Revision 1.120  2004/03/01 10:22:41  rurban
1287 // initializeTheme optimize
1288 //
1289 // Revision 1.119  2004/02/26 20:45:06  rurban
1290 // check for ALLOW_ANON_USER = false
1291 //
1292 // Revision 1.118  2004/02/26 01:32:03  rurban
1293 // fixed session login with old WikiUser object. strangely, the errormask gets corruoted to 1, Pear???
1294 //
1295 // Revision 1.117  2004/02/24 17:19:37  rurban
1296 // debugging helpers only
1297 //
1298 // Revision 1.116  2004/02/24 15:17:14  rurban
1299 // improved auth errors with individual pages. the fact that you may not browse a certain admin page does not conclude that you may not browse the whole wiki. renamed browse => view
1300 //
1301 // Revision 1.115  2004/02/15 21:34:37  rurban
1302 // PageList enhanced and improved.
1303 // fixed new WikiAdmin... plugins
1304 // editpage, Theme with exp. htmlarea framework
1305 //   (htmlarea yet committed, this is really questionable)
1306 // WikiUser... code with better session handling for prefs
1307 // enhanced UserPreferences (again)
1308 // RecentChanges for show_deleted: how should pages be deleted then?
1309 //
1310 // Revision 1.114  2004/02/15 17:30:13  rurban
1311 // workaround for lost db connnection handle on session restauration (->_auth_dbi)
1312 // fixed getPreferences() (esp. from sessions)
1313 // fixed setPreferences() (update and set),
1314 // fixed AdoDb DB statements,
1315 // update prefs only at UserPreferences POST (for testing)
1316 // unified db prefs methods (but in external pref classes yet)
1317 //
1318 // Revision 1.113  2004/02/12 13:05:49  rurban
1319 // Rename functional for PearDB backend
1320 // some other minor changes
1321 // SiteMap comes with a not yet functional feature request: includepages (tbd)
1322 //
1323 // Revision 1.112  2004/02/09 03:58:12  rurban
1324 // for now default DB_SESSION to false
1325 // PagePerm:
1326 //   * not existing perms will now query the parent, and not
1327 //     return the default perm
1328 //   * added pagePermissions func which returns the object per page
1329 //   * added getAccessDescription
1330 // WikiUserNew:
1331 //   * added global ->prepare (not yet used) with smart user/pref/member table prefixing.
1332 //   * force init of authdbh in the 2 db classes
1333 // main:
1334 //   * fixed session handling (not triple auth request anymore)
1335 //   * don't store cookie prefs with sessions
1336 // stdlib: global obj2hash helper from _AuthInfo, also needed for PagePerm
1337 //
1338 // Revision 1.111  2004/02/07 10:41:25  rurban
1339 // fixed auth from session (still double code but works)
1340 // fixed GroupDB
1341 // fixed DbPassUser upgrade and policy=old
1342 // added GroupLdap
1343 //
1344 // Revision 1.110  2004/02/03 09:45:39  rurban
1345 // LDAP cleanup, start of new Pref classes
1346 //
1347 // Revision 1.109  2004/01/30 19:57:58  rurban
1348 // fixed DBAuthParams['pref_select']: wrong _auth_dbi object used.
1349 //
1350 // Revision 1.108  2004/01/28 14:34:14  rurban
1351 // session table takes the common prefix
1352 // + various minor stuff
1353 // reallow password changing
1354 //
1355 // Revision 1.107  2004/01/27 23:23:39  rurban
1356 // renamed ->Username => _userid for consistency
1357 // renamed mayCheckPassword => mayCheckPass
1358 // fixed recursion problem in WikiUserNew
1359 // fixed bogo login (but not quite 100% ready yet, password storage)
1360 //
1361 // Revision 1.106  2004/01/26 09:17:49  rurban
1362 // * changed stored pref representation as before.
1363 //   the array of objects is 1) bigger and 2)
1364 //   less portable. If we would import packed pref
1365 //   objects and the object definition was changed, PHP would fail.
1366 //   This doesn't happen with an simple array of non-default values.
1367 // * use $prefs->retrieve and $prefs->store methods, where retrieve
1368 //   understands the interim format of array of objects also.
1369 // * simplified $prefs->get() and fixed $prefs->set()
1370 // * added $user->_userid and class '_WikiUser' portability functions
1371 // * fixed $user object ->_level upgrading, mostly using sessions.
1372 //   this fixes yesterdays problems with loosing authorization level.
1373 // * fixed WikiUserNew::checkPass to return the _level
1374 // * fixed WikiUserNew::isSignedIn
1375 // * added explodePageList to class PageList, support sortby arg
1376 // * fixed UserPreferences for WikiUserNew
1377 // * fixed WikiPlugin for empty defaults array
1378 // * UnfoldSubpages: added pagename arg, renamed pages arg,
1379 //   removed sort arg, support sortby arg
1380 //
1381 // Revision 1.105  2004/01/25 03:57:15  rurban
1382 // WikiUserNew support (temp. ENABLE_USER_NEW constant)
1383 //
1384 // Revision 1.104  2003/12/26 06:41:16  carstenklapp
1385 // Bugfix: Try to defer OS errors about session.save_path and ACCESS_LOG,
1386 // so they don't prevent IE from partially (or not at all) rendering the
1387 // page. This should help a little for the IE user who encounters trouble
1388 // when setting up a new PhpWiki for the first time.
1389 //
1390 // Revision 1.103  2003/12/02 00:10:00  carstenklapp
1391 // Bugfix: Ongoing work to untangle UserPreferences/WikiUser/request code
1392 // mess: UserPreferences should take effect immediately now upon signing
1393 // in.
1394 //
1395 // Revision 1.102  2003/11/25 22:55:32  carstenklapp
1396 // Localization bugfix: For wikis where English is not the default system
1397 // language, make sure that the authority error message (i.e. "You must
1398 // sign in to edit pages in this wiki" etc.) is displayed in the wiki's
1399 // default language. Previously it would always display in English.
1400 // (Added call to update_locale() before displaying any messages prior to
1401 // the login prompt.)
1402 //
1403 // Revision 1.101  2003/11/25 21:49:44  carstenklapp
1404 // Bugfix: For a non-english wiki or when the user's preference is not
1405 // english, the wiki would always use the english ActionPage first if it
1406 // was present rather than the appropriate localised variant. (PhpWikis
1407 // running only in english or Wikis running ONLY without any english
1408 // ActionPages would not notice this bug, only when both english and
1409 // localised ActionPages were in the DB.) Now we check for the localised
1410 // variant first.
1411 //
1412 // Revision 1.100  2003/11/18 16:54:18  carstenklapp
1413 // Reformatting only: Tabs to spaces, added rcs log.
1414 //
1415
1416
1417 // Local Variables:
1418 // mode: php
1419 // tab-width: 8
1420 // c-basic-offset: 4
1421 // c-hanging-comment-ender-p: nil
1422 // indent-tabs-mode: nil
1423 // End:
1424 ?>