PageRenderTime 71ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/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

Large files files are truncated, but you can click here to view the full file

  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 ru…

Large files files are truncated, but you can click here to view the full file