index.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * This is the main web entry point for MediaWiki.
  4. *
  5. * If you are reading this in your web browser, your server is probably
  6. * not configured correctly to run PHP applications!
  7. *
  8. * See the README, INSTALL, and UPGRADE files for basic setup instructions
  9. * and pointers to the online documentation.
  10. *
  11. * http://www.mediawiki.org/
  12. *
  13. * ----------
  14. *
  15. * Copyright (C) 2001-2009 Magnus Manske, Brion Vibber, Lee Daniel Crocker,
  16. * Tim Starling, Erik Möller, Gabriel Wicke, Ævar Arnfjörð Bjarmason,
  17. * Niklas Laxström, Domas Mituzas, Rob Church, Yuri Astrakhan, Aryeh Gregor,
  18. * Aaron Schulz and others.
  19. *
  20. * This program is free software; you can redistribute it and/or modify
  21. * it under the terms of the GNU General Public License as published by
  22. * the Free Software Foundation; either version 2 of the License, or
  23. * (at your option) any later version.
  24. *
  25. * This program is distributed in the hope that it will be useful,
  26. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. * GNU General Public License for more details.
  29. *
  30. * You should have received a copy of the GNU General Public License along
  31. * with this program; if not, write to the Free Software Foundation, Inc.,
  32. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  33. * http://www.gnu.org/copyleft/gpl.html
  34. *
  35. * @file
  36. */
  37. # Initialise common code
  38. $preIP = dirname( __FILE__ );
  39. require_once( "$preIP/includes/WebStart.php" );
  40. # Initialize MediaWiki base class
  41. require_once( "$preIP/includes/Wiki.php" );
  42. $mediaWiki = new MediaWiki();
  43. wfProfileIn( 'main-misc-setup' );
  44. OutputPage::setEncodings(); # Not really used yet
  45. $maxLag = $wgRequest->getVal( 'maxlag' );
  46. if( !is_null( $maxLag ) && !$mediaWiki->checkMaxLag( $maxLag ) ) {
  47. exit;
  48. }
  49. # Query string fields
  50. $action = $wgRequest->getVal( 'action', 'view' );
  51. $title = $wgRequest->getVal( 'title' );
  52. $wgTitle = $mediaWiki->checkInitialQueries( $title, $action );
  53. if( $wgTitle === NULL ) {
  54. unset( $wgTitle );
  55. }
  56. wfProfileOut( 'main-misc-setup' );
  57. #
  58. # Send Ajax requests to the Ajax dispatcher.
  59. #
  60. if( $wgUseAjax && $action == 'ajax' ) {
  61. require_once( $IP . '/includes/AjaxDispatcher.php' );
  62. $dispatcher = new AjaxDispatcher();
  63. $dispatcher->performAction();
  64. $mediaWiki->restInPeace();
  65. exit;
  66. }
  67. if( $wgUseFileCache && isset( $wgTitle ) ) {
  68. wfProfileIn( 'main-try-filecache' );
  69. // Raw pages should handle cache control on their own,
  70. // even when using file cache. This reduces hits from clients.
  71. if( $action != 'raw' && HTMLFileCache::useFileCache() ) {
  72. /* Try low-level file cache hit */
  73. $cache = new HTMLFileCache( $wgTitle, $action );
  74. if( $cache->isFileCacheGood( /* Assume up to date */ ) ) {
  75. /* Check incoming headers to see if client has this cached */
  76. if( !$wgOut->checkLastModified( $cache->fileCacheTime() ) ) {
  77. $cache->loadFromFileCache();
  78. }
  79. # Do any stats increment/watchlist stuff
  80. $wgArticle = MediaWiki::articleFromTitle( $wgTitle );
  81. $wgArticle->viewUpdates();
  82. # Tell $wgOut that output is taken care of
  83. wfProfileOut( 'main-try-filecache' );
  84. $mediaWiki->restInPeace();
  85. exit;
  86. }
  87. }
  88. wfProfileOut( 'main-try-filecache' );
  89. }
  90. # Setting global variables in mediaWiki
  91. $mediaWiki->setVal( 'action', $action );
  92. $mediaWiki->setVal( 'CommandLineMode', $wgCommandLineMode );
  93. $mediaWiki->setVal( 'DisabledActions', $wgDisabledActions );
  94. $mediaWiki->setVal( 'DisableHardRedirects', $wgDisableHardRedirects );
  95. $mediaWiki->setVal( 'DisableInternalSearch', $wgDisableInternalSearch );
  96. $mediaWiki->setVal( 'EnableCreativeCommonsRdf', $wgEnableCreativeCommonsRdf );
  97. $mediaWiki->setVal( 'EnableDublinCoreRdf', $wgEnableDublinCoreRdf );
  98. $mediaWiki->setVal( 'JobRunRate', $wgJobRunRate );
  99. $mediaWiki->setVal( 'Server', $wgServer );
  100. $mediaWiki->setVal( 'SquidMaxage', $wgSquidMaxage );
  101. $mediaWiki->setVal( 'UseExternalEditor', $wgUseExternalEditor );
  102. $mediaWiki->setVal( 'UsePathInfo', $wgUsePathInfo );
  103. $mediaWiki->initialize( $wgTitle, $wgArticle, $wgOut, $wgUser, $wgRequest );
  104. $mediaWiki->finalCleanup( $wgDeferredUpdateList, $wgOut );
  105. # Not sure when $wgPostCommitUpdateList gets set, so I keep this separate from finalCleanup
  106. $mediaWiki->doUpdates( $wgPostCommitUpdateList );
  107. $mediaWiki->restInPeace();