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