2 #apd_set_pprof_trace();
3 # Main wiki script; see design.doc
5 $wgRequestTime = microtime();
8 @ini_set
( 'allow_url_fopen', 0 ); # For security...
9 if( !file_exists( 'LocalSettings.php' ) ) {
10 define( 'MEDIAWIKI', true );
11 require_once( 'includes/DefaultSettings.php' ); # used for printing the version
13 <!DOCTYPE html
PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
14 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en" lang
="en">
16 <title
>MediaWiki
<?php
echo $wgVersion ?
></title
>
17 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8" />
19 <style type
='text/css' media
='screen, projection'>
22 background
-color
: #fff;
33 <img src
='skins/common/images/wiki.png' alt
='The MediaWiki logo' />
35 <h1
>MediaWiki
<?php
echo $wgVersion ?
></h1
>
38 if ( file_exists( 'config/LocalSettings.php' ) ) {
39 echo( "To complete the installation, move <tt>config/LocalSettings.php</tt> to the parent directory." );
41 echo( "You'll have to <a href='config/index.php' title='setup'>set the wiki up</a> first!" );
52 # Valid web server entry point, enable includes.
53 # Please don't move this line to includes/Defines.php. This line essentially defines
54 # a valid entry point. If you put it in includes/Defines.php, then any script that includes
55 # it becomes an entry point, thereby defeating its purpose.
56 define( 'MEDIAWIKI', true );
58 require_once( './includes/Defines.php' );
59 require_once( './LocalSettings.php' );
60 require_once( 'includes/Setup.php' );
62 wfProfileIn( 'main-misc-setup' );
63 OutputPage
::setEncodings(); # Not really used yet
66 $action = $wgRequest->getVal( 'action', 'view' );
67 $title = $wgRequest->getVal( 'title' );
69 $action = strtolower( trim( $action ) );
70 if ($wgRequest->getVal( 'printable' ) == 'yes') {
71 $wgOut->setPrintable();
74 if ( '' == $title && 'delete' != $action ) {
75 $wgTitle = Title
::newFromText( wfMsgForContent( 'mainpage' ) );
76 } elseif ( $curid = $wgRequest->getInt( 'curid' ) ) {
77 # URLs like this are generated by RC, because rc_title isn't always accurate
78 $wgTitle = Title
::newFromID( $curid );
80 $wgTitle = Title
::newFromURL( $title );
82 wfProfileOut( 'main-misc-setup' );
84 # Debug statement for user levels
87 # If the user is not logged in, the Namespace:title of the article must be in
88 # the Read array in order for the user to see it. (We have to check here to
89 # catch special pages etc. We check again in Article::view())
90 if ( !is_null( $wgTitle ) && !$wgTitle->userCanRead() ) {
96 wfProfileIn( 'main-action' );
98 $search = $wgRequest->getText( 'search' );
99 if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
100 require_once( 'includes/SpecialSearch.php' );
101 $wgTitle = Title
::makeTitle( NS_SPECIAL
, 'Search' );
103 } else if( !$wgTitle or $wgTitle->getDBkey() == '' ) {
104 $wgTitle = Title
::newFromText( wfMsgForContent( 'badtitle' ) );
105 $wgOut->errorpage( 'badtitle', 'badtitletext' );
106 } else if ( $wgTitle->getInterwiki() != '' ) {
107 if( $rdfrom = $wgRequest->getVal( 'rdfrom' ) ) {
108 $url = $wgTitle->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
110 $url = $wgTitle->getFullURL();
112 # Check for a redirect loop
113 if ( !preg_match( '/^' . preg_quote( $wgServer, '/' ) . '/', $url ) && $wgTitle->isLocal() ) {
114 $wgOut->redirect( $url );
116 $wgTitle = Title
::newFromText( wfMsgForContent( 'badtitle' ) );
117 $wgOut->errorpage( 'badtitle', 'badtitletext' );
119 } else if ( ( $action == 'view' ) &&
120 (!isset( $_GET['title'] ) ||
$wgTitle->getPrefixedDBKey() != $_GET['title'] ) &&
121 !count( array_diff( array_keys( $_GET ), array( 'action', 'title' ) ) ) )
123 /* redirect to canonical url, make it a 301 to allow caching */
124 $wgOut->setSquidMaxage( 1200 );
125 $wgOut->redirect( $wgTitle->getFullURL(), '301');
126 } else if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
127 # actions that need to be made when we have a special pages
128 require_once( 'includes/SpecialPage.php' );
129 SpecialPage
::executePath( $wgTitle );
131 if ( NS_MEDIA
== $wgTitle->getNamespace() ) {
132 $wgTitle = Title
::makeTitle( NS_IMAGE
, $wgTitle->getDBkey() );
135 switch( $wgTitle->getNamespace() ) {
137 require_once( 'includes/ImagePage.php' );
138 $wgArticle = new ImagePage( $wgTitle );
141 if ( $wgUseCategoryMagic ) {
142 require_once( 'includes/CategoryPage.php' );
143 $wgArticle = new CategoryPage( $wgTitle );
146 # NO break if wgUseCategoryMagic is false, drop through to next (default).
147 # Don't insert other cases between NS_CATEGORY and default.
149 $wgArticle = new Article( $wgTitle );
152 if ( in_array( $action, $wgDisabledActions ) ) {
153 $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
157 $wgOut->setSquidMaxage( $wgSquidMaxage );
168 case 'markpatrolled':
170 $wgArticle->$action();
176 if( !$wgEnableDublinCoreRdf ) {
177 wfHttpError( 403, 'Forbidden', wfMsg( 'nodublincore' ) );
179 require_once( 'includes/Metadata.php' );
180 wfDublinCoreRdf( $wgArticle );
183 case 'creativecommons':
184 if( !$wgEnableCreativeCommonsRdf ) {
185 wfHttpError( 403, 'Forbidden', wfMsg('nocreativecommons') );
187 require_once( 'includes/Metadata.php' );
188 wfCreativeCommonsRdf( $wgArticle );
192 require_once( 'includes/Credits.php' );
193 showCreditsPage( $wgArticle );
196 if( !$wgCommandLineMode && !$wgRequest->checkSessionCookie() ) {
197 # Send a cookie so anons get talk message notifications
198 User
::SetupSession();
202 $internal = $wgRequest->getVal( 'internaledit' );
203 $external = $wgRequest->getVal( 'externaledit' );
204 $section = $wgRequest->getVal( 'section' );
205 $oldid = $wgRequest->getVal( 'oldid' );
206 if(!$wgUseExternalEditor ||
$action=='submit' ||
$internal ||
207 $section ||
$oldid ||
(!$wgUser->getOption('externaleditor') && !$external)) {
208 require_once( 'includes/EditPage.php' );
209 $editor = new EditPage( $wgArticle );
211 } elseif($wgUseExternalEditor && ($external ||
$wgUser->getOption('externaleditor'))) {
212 require_once( 'includes/ExternalEdit.php' );
213 $mode = $wgRequest->getVal( 'mode' );
214 $extedit = new ExternalEdit( $wgArticle, $mode );
219 if ($_SERVER['REQUEST_URI'] == $wgTitle->getInternalURL('action=history')) {
220 $wgOut->setSquidMaxage( $wgSquidMaxage );
222 require_once( 'includes/PageHistory.php' );
223 $history = new PageHistory( $wgArticle );
227 require_once( 'includes/RawPage.php' );
228 $raw = new RawPage( $wgArticle );
232 wfPurgeSquidServers(array($wgTitle->getInternalURL()));
233 $wgOut->setSquidMaxage( $wgSquidMaxage );
234 $wgTitle->invalidateCache();
238 if (wfRunHooks('UnknownAction', $action, $wgArticle)) {
239 $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
244 wfProfileOut( 'main-action' );
246 # Deferred updates aren't really deferred anymore. It's important to report errors to the
247 # user, and that means doing this before OutputPage::output(). Note that for page saves,
248 # the client will wait until the script exits anyway before following the redirect.
249 wfProfileIn( 'main-updates' );
250 foreach ( $wgDeferredUpdateList as $up ) {
253 wfProfileOut( 'main-updates' );
255 wfProfileIn( 'main-cleanup' );
256 $wgLoadBalancer->saveMasterPos();
258 # Now commit any transactions, so that unreported errors after output() don't roll back the whole thing
259 $wgLoadBalancer->commitAll();
263 foreach ( $wgPostCommitUpdateList as $up ) {
267 wfProfileOut( 'main-cleanup' );
270 $wgLoadBalancer->closeAll();
271 wfDebug( "Request ended normally\n" );