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