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