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