]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/main.php
renamed global $Theme to $WikiTheme (gforge nameclash)
[SourceForge/phpwiki.git] / lib / main.php
1 <?php //-*-php-*-
2 rcs_id('$Id: main.php,v 1.165 2004-06-14 11:31:37 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                 unset($this->_user->_HomePagehandle);
58                 $this->_user->hasHomePage();
59                 // update the lockfile filehandle
60                 if (  isa($this->_user,'_FilePassUser') and 
61                       $this->_user->_file->lockfile and 
62                       !$this->_user->_file->fplock  )
63                 {
64                     $this->_user = new _FilePassUser($userid, $this->_user->_prefs, $this->_user->_file->filename);
65                 }
66                 /*
67                 if (!isa($user,WikiUserClassname()) or empty($this->_user->_level)) {
68                     $user = UpgradeUser($this->_user,$user);
69                 }
70                 */
71                 $this->_prefs = & $this->_user->_prefs;
72             } else {
73                 $user = WikiUser($userid);
74                 $this->_user = & $user;
75                 $this->_prefs = & $this->_user->_prefs;
76             }
77         } else {
78             $this->_user = new WikiUser($this, $this->_deduceUsername());
79             $this->_prefs = $this->_user->getPreferences();
80         }
81     }
82
83     function initializeLang () {
84         $user_lang = $this->getPref('lang');
85         $_lang = @$this->_prefs->_prefs['lang'];
86         //check changed LANG and THEME inside a session. 
87         // (e.g. by using another baseurl)
88         if (isset($this->_user->_authhow) and 
89             $this->_user->_authhow == 'session' and 
90             !isset($_lang->lang) and 
91             $user_lang != $GLOBALS['LANG'])
92         {
93             $user_lang = $GLOBALS['LANG'];
94         }
95         if (isset($user_lang)) {
96             //trigger_error("DEBUG: initializeLang() ". $user_lang ." calling update_locale()...");
97             update_locale($user_lang);
98             FindLocalizedButtonFile(".",'missing_ok','reinit');
99         }
100     }
101
102     function initializeTheme () {
103         global $WikiTheme;
104
105         // Load theme
106         $user_theme = $this->getPref('theme');
107         $_theme = @$this->_prefs->_prefs['theme'];
108         //check changed LANG and THEME inside a session. 
109         // (e.g. by using another baseurl)
110         if (isset($this->_user->_authhow) and 
111             $this->_user->_authhow == 'session' and 
112             !isset($_theme->theme) and
113             defined('THEME') and 
114             $user_theme != THEME)
115         {
116             include_once("themes/" . THEME . "/themeinfo.php");
117         }
118         if (empty($WikiTheme) and isset($user_theme))
119             include_once("themes/$user_theme/themeinfo.php");
120         if (empty($WikiTheme) and defined('THEME'))
121             include_once("themes/" . THEME . "/themeinfo.php");
122         if (empty($WikiTheme))
123             include_once("themes/default/themeinfo.php");
124         assert(!empty($WikiTheme));
125     }
126
127     // This really maybe should be part of the constructor, but since it
128     // may involve HTML/template output, the global $request really needs
129     // to be initialized before we do this stuff.
130     function updateAuthAndPrefs () {
131
132         if (isset($this->_user) and (!isa($this->_user,WikiUserClassname()))) {
133             $this->_user = false;       
134         }
135         // Handle authentication request, if any.
136         if ($auth_args = $this->getArg('auth')) {
137             $this->setArg('auth', false);
138             $this->_handleAuthRequest($auth_args); // possible NORETURN
139         }
140         elseif ( ! $this->_user or 
141                  (isa($this->_user,WikiUserClassname()) and ! $this->_user->isSignedIn())) {
142             // If not auth request, try to sign in as saved user.
143             if (($saved_user = $this->getPref('userid')) != false) {
144                 $this->_signIn($saved_user);
145             }
146         }
147
148         // Save preferences in session and cookie
149         if (isset($this->_user) and 
150             (!isset($this->_user->_authhow) or $this->_user->_authhow != 'session')) {
151             $id_only = true; 
152             $this->_user->setPreferences($this->_prefs, $id_only);
153         } else {
154             $this->setSessionVar('wiki_user', $this->_user);
155             //$this->setSessionVar('wiki_prefs', $this->_prefs);
156         }
157
158         // Ensure user has permissions for action
159         // HACK ALERT: We may not set the request arg to create, 
160         // since the pageeditor has an ugly logic for action == create.
161         $action = $this->getArg('action');
162         if ($action == 'edit' or $action == 'create') {
163             $page = $this->getPage();
164             if (! $page->exists() )
165                 $action = 'create';
166             else
167                 $action = 'edit';
168         }
169         $require_level = $this->requiredAuthority($action);
170         if (! $this->_user->hasAuthority($require_level))
171             $this->_notAuthorized($require_level); // NORETURN
172     }
173
174     function getUser () {
175         if (isset($this->_user))
176             return $this->_user;
177         else
178             return $GLOBALS['ForbiddenUser'];
179     }
180
181     function getPrefs () {
182         return $this->_prefs;
183     }
184
185     // Convenience function:
186     function getPref ($key) {
187         if (isset($this->_prefs))
188             return $this->_prefs->get($key);
189     }
190
191     function getDbh () {
192         return $this->_dbi;
193     }
194
195     /**
196      * Get requested page from the page database.
197      * By default it will grab the page requested via the URL
198      *
199      * This is a convenience function.
200      * @param string $pagename Name of page to get.
201      * @return WikiDB_Page Object with methods to pull data from
202      * database for the page requested.
203      */
204     function getPage ($pagename = false) {
205         if (!isset($this->_dbi))
206             $this->getDbh();
207         if (!$pagename) 
208             $pagename = $this->getArg('pagename');
209         return $this->_dbi->getPage($pagename);
210     }
211
212     /** Get URL for POST actions.
213      *
214      * Officially, we should just use SCRIPT_NAME (or some such),
215      * but that causes problems when we try to issue a redirect, e.g.
216      * after saving a page.
217      *
218      * Some browsers (at least NS4 and Mozilla 0.97 won't accept
219      * a redirect from a page to itself.)
220      *
221      * So, as a HACK, we include pagename and action as query args in
222      * the URL.  (These should be ignored when we receive the POST
223      * request.)
224      */
225     function getPostURL ($pagename=false) {
226         global $HTTP_GET_VARS;
227
228         if ($pagename === false)
229             $pagename = $this->getArg('pagename');
230         $action = $this->getArg('action');
231         if (!empty($HTTP_GET_VARS['start_debug'])) // zend ide support
232             return WikiURL($pagename, array('action' => $action, 'start_debug' => 1));
233         else
234             return WikiURL($pagename, array('action' => $action));
235     }
236     
237     function _handleAuthRequest ($auth_args) {
238         if (!is_array($auth_args))
239             return;
240
241         // Ignore password unless POST'ed.
242         if (!$this->isPost())
243             unset($auth_args['passwd']);
244
245         $olduser = $this->_user;
246         $user = $this->_user->AuthCheck($auth_args);
247         if (isa($user, WikiUserClassname())) {
248             // Successful login (or logout.)
249             $this->_setUser($user);
250         }
251         elseif (is_string($user)) {
252             // Login attempt failed.
253             $fail_message = $user;
254             $auth_args['pass_required'] = true;
255             // If no password was submitted, it's not really
256             // a failure --- just need to prompt for password...
257             if (!ALLOW_USER_PASSWORDS 
258                 and ALLOW_BOGO_LOGIN 
259                 and !isset($auth_args['passwd'])) 
260             {
261                 $fail_message = false;
262             }
263             $olduser->PrintLoginForm($this, $auth_args, $fail_message, 'newpage');
264             $this->finish();    //NORETURN
265         }
266         else {
267             // Login request cancelled.
268         }
269     }
270
271     /**
272      * Attempt to sign in (bogo-login).
273      *
274      * Fails silently.
275      *
276      * @param $userid string Userid to attempt to sign in as.
277      * @access private
278      */
279     function _signIn ($userid) {
280         if (ENABLE_USER_NEW) {
281             if (! $this->_user )
282                 $this->_user = new _BogoUser($userid);
283             if (! $this->_user )
284                 $this->_user = new _PassUser($userid);
285         }
286         $user = $this->_user->AuthCheck(array('userid' => $userid));
287         if (isa($user,WikiUserClassname())) {
288             $this->_setUser($user); // success!
289         }
290     }
291
292     // login or logout or restore state
293     function _setUser ($user) {
294         $this->_user = $user;
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.164  2004/06/13 13:54:25  rurban
1053 // Catch fatals on the four dump calls (as file and zip, as html and mimified)
1054 // FoafViewer: Check against external requirements, instead of fatal.
1055 // Change output for xhtmldumps: using file:// urls to the local fs.
1056 // Catch SOAP fatal by checking for GOOGLE_LICENSE_KEY
1057 // Import GOOGLE_LICENSE_KEY and FORTUNE_DIR from config.ini.
1058 //
1059 // Revision 1.163  2004/06/13 11:35:32  rurban
1060 // check for create action on action=edit not to fool PagePerm checks
1061 //
1062 // Revision 1.162  2004/06/08 10:05:11  rurban
1063 // simplified admin action shortcuts
1064 //
1065 // Revision 1.161  2004/06/07 22:58:40  rurban
1066 // simplified chown, setacl, dump actions
1067 //
1068 // Revision 1.160  2004/06/07 22:44:14  rurban
1069 // added simplified chown, setacl actions
1070 //
1071 // Revision 1.159  2004/06/06 16:58:51  rurban
1072 // added more required ActionPages for foreign languages
1073 // install now english ActionPages if no localized are found. (again)
1074 // fixed default anon user level to be 0, instead of -1
1075 //   (wrong "required administrator to view this page"...)
1076 //
1077 // Revision 1.158  2004/06/04 20:32:53  rurban
1078 // Several locale related improvements suggested by Pierrick Meignen
1079 // LDAP fix by John Cole
1080 // reanable admin check without ENABLE_PAGEPERM in the admin plugins
1081 //
1082 // Revision 1.157  2004/06/04 12:40:21  rurban
1083 // Restrict valid usernames to prevent from attacks against external auth or compromise
1084 // possible holes.
1085 // Fix various WikiUser old issues with default IMAP,LDAP,POP3 configs. Removed these.
1086 // Fxied more warnings
1087 //
1088 // Revision 1.156  2004/06/03 17:58:16  rurban
1089 // support immediate LANG and THEME switch inside a session
1090 //
1091 // Revision 1.155  2004/06/03 10:18:19  rurban
1092 // fix FileUser locking issues, new config ENABLE_PAGEPERM
1093 //
1094 // Revision 1.154  2004/06/02 18:01:46  rurban
1095 // init global FileFinder to add proper include paths at startup
1096 //   adds PHPWIKI_DIR if started from another dir, lib/pear also
1097 // fix slashify for Windows
1098 // fix USER_AUTH_POLICY=old, use only USER_AUTH_ORDER methods (besides HttpAuth)
1099 //
1100 // Revision 1.153  2004/06/01 15:28:00  rurban
1101 // AdminUser only ADMIN_USER not member of Administrators
1102 // some RateIt improvements by dfrankow
1103 // edit_toolbar buttons
1104 //
1105 // Revision 1.152  2004/05/27 17:49:06  rurban
1106 // renamed DB_Session to DbSession (in CVS also)
1107 // added WikiDB->getParam and WikiDB->getAuthParam method to get rid of globals
1108 // remove leading slash in error message
1109 // added force_unlock parameter to File_Passwd (no return on stale locks)
1110 // fixed adodb session AffectedRows
1111 // added FileFinder helpers to unify local filenames and DATA_PATH names
1112 // editpage.php: new edit toolbar javascript on ENABLE_EDIT_TOOLBAR
1113 //
1114 // Revision 1.151  2004/05/25 12:40:48  rurban
1115 // trim the pagename
1116 //
1117 // Revision 1.150  2004/05/25 10:18:44  rurban
1118 // Check for UTF-8 URLs; Internet Explorer produces these if you
1119 // type non-ASCII chars in the URL bar or follow unescaped links.
1120 // Fixes sf.net bug #953949
1121 // src: languages/Language.php:checkTitleEncoding() from mediawiki
1122 //
1123 // Revision 1.149  2004/05/18 13:31:19  rurban
1124 // hold warnings until headers are sent. new Error-style with collapsed output of repeated messages
1125 //
1126 // Revision 1.148  2004/05/17 17:43:29  rurban
1127 // CGI: no PATH_INFO fix
1128 //
1129 // Revision 1.147  2004/05/15 19:48:33  rurban
1130 // fix some too loose PagePerms for signed, but not authenticated users
1131 //  (admin, owner, creator)
1132 // no double login page header, better login msg.
1133 // moved action_pdf to lib/pdf.php
1134 //
1135 // Revision 1.146  2004/05/15 18:31:01  rurban
1136 // some action=pdf Request fixes: With MSIE it works now. Now the work with the page formatting begins.
1137 //
1138 // Revision 1.145  2004/05/12 10:49:55  rurban
1139 // require_once fix for those libs which are loaded before FileFinder and
1140 //   its automatic include_path fix, and where require_once doesn't grok
1141 //   dirname(__FILE__) != './lib'
1142 // upgrade fix with PearDB
1143 // navbar.tmpl: remove spaces for IE &nbsp; button alignment
1144 //
1145 // Revision 1.144  2004/05/06 19:26:16  rurban
1146 // improve stability, trying to find the InlineParser endless loop on sf.net
1147 //
1148 // remove end-of-zip comments to fix sf.net bug #777278 and probably #859628
1149 //
1150 // Revision 1.143  2004/05/06 17:30:38  rurban
1151 // CategoryGroup: oops, dos2unix eol
1152 // improved phpwiki_version:
1153 //   pre -= .0001 (1.3.10pre: 1030.099)
1154 //   -p1 += .001 (1.3.9-p1: 1030.091)
1155 // improved InstallTable for mysql and generic SQL versions and all newer tables so far.
1156 // abstracted more ADODB/PearDB methods for action=upgrade stuff:
1157 //   backend->backendType(), backend->database(),
1158 //   backend->listOfFields(),
1159 //   backend->listOfTables(),
1160 //
1161 // Revision 1.142  2004/05/04 22:34:25  rurban
1162 // more pdf support
1163 //
1164 // Revision 1.141  2004/05/03 13:16:47  rurban
1165 // fixed UserPreferences update, esp for boolean and int
1166 //
1167 // Revision 1.140  2004/05/02 21:26:38  rurban
1168 // limit user session data (HomePageHandle and auth_dbi have to invalidated anyway)
1169 //   because they will not survive db sessions, if too large.
1170 // extended action=upgrade
1171 // some WikiTranslation button work
1172 // revert WIKIAUTH_UNOBTAINABLE (need it for main.php)
1173 // some temp. session debug statements
1174 //
1175 // Revision 1.139  2004/05/02 15:10:07  rurban
1176 // new finally reliable way to detect if /index.php is called directly
1177 //   and if to include lib/main.php
1178 // new global AllActionPages
1179 // SetupWiki now loads all mandatory pages: HOME_PAGE, action pages, and warns if not.
1180 // WikiTranslation what=buttons for Carsten to create the missing MacOSX buttons
1181 // PageGroupTestOne => subpages
1182 // renamed PhpWikiRss to PhpWikiRecentChanges
1183 // more docs, default configs, ...
1184 //
1185 // Revision 1.138  2004/05/01 15:59:29  rurban
1186 // more php-4.0.6 compatibility: superglobals
1187 //
1188 // Revision 1.137  2004/04/29 19:39:44  rurban
1189 // special support for formatted plugins (one-liners)
1190 //   like <small><plugin BlaBla ></small>
1191 // iter->asArray() helper for PopularNearby
1192 // db_session for older php's (no &func() allowed)
1193 //
1194 // Revision 1.136  2004/04/29 17:18:19  zorloc
1195 // 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.
1196 //
1197 // Revision 1.135  2004/04/26 12:15:01  rurban
1198 // check default config values
1199 //
1200 // Revision 1.134  2004/04/23 06:46:37  zorloc
1201 // Leave DB connection open when USE_DB_SESSION is true so that session info can be written to the DB.
1202 //
1203 // Revision 1.133  2004/04/20 18:10:31  rurban
1204 // config refactoring:
1205 //   FileFinder is needed for WikiFarm scripts calling index.php
1206 //   config run-time calls moved to lib/IniConfig.php:fix_configs()
1207 //   added PHPWIKI_DIR smart-detection code (Theme finder)
1208 //   moved FileFind to lib/FileFinder.php
1209 //   cleaned lib/config.php
1210 //
1211 // Revision 1.132  2004/04/19 21:51:41  rurban
1212 // php5 compatibility: it works!
1213 //
1214 // Revision 1.131  2004/04/19 18:27:45  rurban
1215 // Prevent from some PHP5 warnings (ref args, no :: object init)
1216 //   php5 runs now through, just one wrong XmlElement object init missing
1217 // Removed unneccesary UpgradeUser lines
1218 // Changed WikiLink to omit version if current (RecentChanges)
1219 //
1220 // Revision 1.130  2004/04/18 00:25:53  rurban
1221 // allow "0" pagename
1222 //
1223 // Revision 1.129  2004/04/07 23:13:19  rurban
1224 // fixed pear/File_Passwd for Windows
1225 // fixed FilePassUser sessions (filehandle revive) and password update
1226 //
1227 // Revision 1.128  2004/04/02 15:06:55  rurban
1228 // fixed a nasty ADODB_mysql session update bug
1229 // improved UserPreferences layout (tabled hints)
1230 // fixed UserPreferences auth handling
1231 // improved auth stability
1232 // improved old cookie handling: fixed deletion of old cookies with paths
1233 //
1234 // Revision 1.127  2004/03/25 17:00:31  rurban
1235 // more code to convert old-style pref array to new hash
1236 //
1237 // Revision 1.126  2004/03/24 19:39:03  rurban
1238 // php5 workaround code (plus some interim debugging code in XmlElement)
1239 //   php5 doesn't work yet with the current XmlElement class constructors,
1240 //   WikiUserNew does work better than php4.
1241 // rewrote WikiUserNew user upgrading to ease php5 update
1242 // fixed pref handling in WikiUserNew
1243 // added Email Notification
1244 // added simple Email verification
1245 // removed emailVerify userpref subclass: just a email property
1246 // changed pref binary storage layout: numarray => hash of non default values
1247 // print optimize message only if really done.
1248 // forced new cookie policy: delete pref cookies, use only WIKI_ID as plain string.
1249 //   prefs should be stored in db or homepage, besides the current session.
1250 //
1251 // Revision 1.125  2004/03/14 16:30:52  rurban
1252 // db-handle session revivification, dba fixes
1253 //
1254 // Revision 1.124  2004/03/12 15:48:07  rurban
1255 // fixed explodePageList: wrong sortby argument order in UnfoldSubpages
1256 // simplified lib/stdlib.php:explodePageList
1257 //
1258 // Revision 1.123  2004/03/10 15:41:27  rurban
1259 // use default pref mysql table
1260 //
1261 // Revision 1.122  2004/03/08 18:17:09  rurban
1262 // added more WikiGroup::getMembersOf methods, esp. for special groups
1263 // fixed $LDAP_SET_OPTIONS
1264 // fixed _AuthInfo group methods
1265 //
1266 // Revision 1.121  2004/03/01 13:48:45  rurban
1267 // rename fix
1268 // p[] consistency fix
1269 //
1270 // Revision 1.120  2004/03/01 10:22:41  rurban
1271 // initializeTheme optimize
1272 //
1273 // Revision 1.119  2004/02/26 20:45:06  rurban
1274 // check for ALLOW_ANON_USER = false
1275 //
1276 // Revision 1.118  2004/02/26 01:32:03  rurban
1277 // fixed session login with old WikiUser object. strangely, the errormask gets corruoted to 1, Pear???
1278 //
1279 // Revision 1.117  2004/02/24 17:19:37  rurban
1280 // debugging helpers only
1281 //
1282 // Revision 1.116  2004/02/24 15:17:14  rurban
1283 // 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
1284 //
1285 // Revision 1.115  2004/02/15 21:34:37  rurban
1286 // PageList enhanced and improved.
1287 // fixed new WikiAdmin... plugins
1288 // editpage, Theme with exp. htmlarea framework
1289 //   (htmlarea yet committed, this is really questionable)
1290 // WikiUser... code with better session handling for prefs
1291 // enhanced UserPreferences (again)
1292 // RecentChanges for show_deleted: how should pages be deleted then?
1293 //
1294 // Revision 1.114  2004/02/15 17:30:13  rurban
1295 // workaround for lost db connnection handle on session restauration (->_auth_dbi)
1296 // fixed getPreferences() (esp. from sessions)
1297 // fixed setPreferences() (update and set),
1298 // fixed AdoDb DB statements,
1299 // update prefs only at UserPreferences POST (for testing)
1300 // unified db prefs methods (but in external pref classes yet)
1301 //
1302 // Revision 1.113  2004/02/12 13:05:49  rurban
1303 // Rename functional for PearDB backend
1304 // some other minor changes
1305 // SiteMap comes with a not yet functional feature request: includepages (tbd)
1306 //
1307 // Revision 1.112  2004/02/09 03:58:12  rurban
1308 // for now default DB_SESSION to false
1309 // PagePerm:
1310 //   * not existing perms will now query the parent, and not
1311 //     return the default perm
1312 //   * added pagePermissions func which returns the object per page
1313 //   * added getAccessDescription
1314 // WikiUserNew:
1315 //   * added global ->prepare (not yet used) with smart user/pref/member table prefixing.
1316 //   * force init of authdbh in the 2 db classes
1317 // main:
1318 //   * fixed session handling (not triple auth request anymore)
1319 //   * don't store cookie prefs with sessions
1320 // stdlib: global obj2hash helper from _AuthInfo, also needed for PagePerm
1321 //
1322 // Revision 1.111  2004/02/07 10:41:25  rurban
1323 // fixed auth from session (still double code but works)
1324 // fixed GroupDB
1325 // fixed DbPassUser upgrade and policy=old
1326 // added GroupLdap
1327 //
1328 // Revision 1.110  2004/02/03 09:45:39  rurban
1329 // LDAP cleanup, start of new Pref classes
1330 //
1331 // Revision 1.109  2004/01/30 19:57:58  rurban
1332 // fixed DBAuthParams['pref_select']: wrong _auth_dbi object used.
1333 //
1334 // Revision 1.108  2004/01/28 14:34:14  rurban
1335 // session table takes the common prefix
1336 // + various minor stuff
1337 // reallow password changing
1338 //
1339 // Revision 1.107  2004/01/27 23:23:39  rurban
1340 // renamed ->Username => _userid for consistency
1341 // renamed mayCheckPassword => mayCheckPass
1342 // fixed recursion problem in WikiUserNew
1343 // fixed bogo login (but not quite 100% ready yet, password storage)
1344 //
1345 // Revision 1.106  2004/01/26 09:17:49  rurban
1346 // * changed stored pref representation as before.
1347 //   the array of objects is 1) bigger and 2)
1348 //   less portable. If we would import packed pref
1349 //   objects and the object definition was changed, PHP would fail.
1350 //   This doesn't happen with an simple array of non-default values.
1351 // * use $prefs->retrieve and $prefs->store methods, where retrieve
1352 //   understands the interim format of array of objects also.
1353 // * simplified $prefs->get() and fixed $prefs->set()
1354 // * added $user->_userid and class '_WikiUser' portability functions
1355 // * fixed $user object ->_level upgrading, mostly using sessions.
1356 //   this fixes yesterdays problems with loosing authorization level.
1357 // * fixed WikiUserNew::checkPass to return the _level
1358 // * fixed WikiUserNew::isSignedIn
1359 // * added explodePageList to class PageList, support sortby arg
1360 // * fixed UserPreferences for WikiUserNew
1361 // * fixed WikiPlugin for empty defaults array
1362 // * UnfoldSubpages: added pagename arg, renamed pages arg,
1363 //   removed sort arg, support sortby arg
1364 //
1365 // Revision 1.105  2004/01/25 03:57:15  rurban
1366 // WikiUserNew support (temp. ENABLE_USER_NEW constant)
1367 //
1368 // Revision 1.104  2003/12/26 06:41:16  carstenklapp
1369 // Bugfix: Try to defer OS errors about session.save_path and ACCESS_LOG,
1370 // so they don't prevent IE from partially (or not at all) rendering the
1371 // page. This should help a little for the IE user who encounters trouble
1372 // when setting up a new PhpWiki for the first time.
1373 //
1374 // Revision 1.103  2003/12/02 00:10:00  carstenklapp
1375 // Bugfix: Ongoing work to untangle UserPreferences/WikiUser/request code
1376 // mess: UserPreferences should take effect immediately now upon signing
1377 // in.
1378 //
1379 // Revision 1.102  2003/11/25 22:55:32  carstenklapp
1380 // Localization bugfix: For wikis where English is not the default system
1381 // language, make sure that the authority error message (i.e. "You must
1382 // sign in to edit pages in this wiki" etc.) is displayed in the wiki's
1383 // default language. Previously it would always display in English.
1384 // (Added call to update_locale() before displaying any messages prior to
1385 // the login prompt.)
1386 //
1387 // Revision 1.101  2003/11/25 21:49:44  carstenklapp
1388 // Bugfix: For a non-english wiki or when the user's preference is not
1389 // english, the wiki would always use the english ActionPage first if it
1390 // was present rather than the appropriate localised variant. (PhpWikis
1391 // running only in english or Wikis running ONLY without any english
1392 // ActionPages would not notice this bug, only when both english and
1393 // localised ActionPages were in the DB.) Now we check for the localised
1394 // variant first.
1395 //
1396 // Revision 1.100  2003/11/18 16:54:18  carstenklapp
1397 // Reformatting only: Tabs to spaces, added rcs log.
1398 //
1399
1400
1401 // Local Variables:
1402 // mode: php
1403 // tab-width: 8
1404 // c-basic-offset: 4
1405 // c-hanging-comment-ender-p: nil
1406 // indent-tabs-mode: nil
1407 // End:
1408 ?>