PageRenderTime 31ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/gforge/plugins/wiki/www/lib/main.php

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