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 );
12 require_once( './includes/Defines.php' );
13 require_once( 'includes/DefaultSettings.php' ); # used for printing the version
15 <!DOCTYPE html
PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
16 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en" lang
="en">
18 <title
>MediaWiki
<?php
echo $wgVersion ?
></title
>
19 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8" />
21 <style type
='text/css' media
='screen, projection'>
24 background
-color
: #fff;
35 <img src
='skins/common/images/wiki.png' alt
='The MediaWiki logo' />
37 <h1
>MediaWiki
<?php
echo $wgVersion ?
></h1
>
40 if ( file_exists( 'config/LocalSettings.php' ) ) {
41 echo( "To complete the installation, move <tt>config/LocalSettings.php</tt> to the parent directory." );
43 echo( "You'll have to <a href='config/index.php' title='setup'>set the wiki up</a> first!" );
54 # Valid web server entry point, enable includes.
55 # Please don't move this line to includes/Defines.php. This line essentially defines
56 # a valid entry point. If you put it in includes/Defines.php, then any script that includes
57 # it becomes an entry point, thereby defeating its purpose.
58 define( 'MEDIAWIKI', true );
60 require_once( './includes/Defines.php' );
61 require_once( './LocalSettings.php' );
62 require_once( 'includes/Setup.php' );
64 wfProfileIn( 'main-misc-setup' );
65 OutputPage
::setEncodings(); # Not really used yet
68 $action = $wgRequest->getVal( 'action', 'view' );
69 $title = $wgRequest->getVal( 'title' );
71 $action = strtolower( trim( $action ) );
72 if ($wgRequest->getVal( 'printable' ) == 'yes') {
73 $wgOut->setPrintable();
76 if ( '' == $title && 'delete' != $action ) {
77 $wgTitle = Title
::newFromText( wfMsgForContent( 'mainpage' ) );
78 } elseif ( $curid = $wgRequest->getInt( 'curid' ) ) {
79 # URLs like this are generated by RC, because rc_title isn't always accurate
80 $wgTitle = Title
::newFromID( $curid );
82 $wgTitle = Title
::newFromURL( $title );
84 wfProfileOut( 'main-misc-setup' );
86 # Debug statement for user levels
89 # If the user is not logged in, the Namespace:title of the article must be in
90 # the Read array in order for the user to see it. (We have to check here to
91 # catch special pages etc. We check again in Article::view())
92 if ( !is_null( $wgTitle ) && !$wgTitle->userCanRead() ) {
98 wfProfileIn( 'main-action' );
100 $search = $wgRequest->getText( 'search' );
101 if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
102 require_once( 'includes/SpecialSearch.php' );
103 $wgTitle = Title
::makeTitle( NS_SPECIAL
, 'Search' );
105 } else if( !$wgTitle or $wgTitle->getDBkey() == '' ) {
106 $wgTitle = Title
::newFromText( wfMsgForContent( 'badtitle' ) );
107 $wgOut->errorpage( 'badtitle', 'badtitletext' );
108 } else if ( $wgTitle->getInterwiki() != '' ) {
109 if( $rdfrom = $wgRequest->getVal( 'rdfrom' ) ) {
110 $url = $wgTitle->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
112 $url = $wgTitle->getFullURL();
114 # Check for a redirect loop
115 if ( !preg_match( '/^' . preg_quote( $wgServer, '/' ) . '/', $url ) && $wgTitle->isLocal() ) {
116 $wgOut->redirect( $url );
118 $wgTitle = Title
::newFromText( wfMsgForContent( 'badtitle' ) );
119 $wgOut->errorpage( 'badtitle', 'badtitletext' );
121 } else if ( ( $action == 'view' ) &&
122 (!isset( $_GET['title'] ) ||
$wgTitle->getPrefixedDBKey() != $_GET['title'] ) &&
123 !count( array_diff( array_keys( $_GET ), array( 'action', 'title' ) ) ) )
125 /* redirect to canonical url, make it a 301 to allow caching */
126 $wgOut->setSquidMaxage( 1200 );
127 $wgOut->redirect( $wgTitle->getFullURL(), '301');
128 } else if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
129 # actions that need to be made when we have a special pages
130 require_once( 'includes/SpecialPage.php' );
131 SpecialPage
::executePath( $wgTitle );
133 if ( NS_MEDIA
== $wgTitle->getNamespace() ) {
134 $wgTitle = Title
::makeTitle( NS_IMAGE
, $wgTitle->getDBkey() );
137 switch( $wgTitle->getNamespace() ) {
139 require_once( 'includes/ImagePage.php' );
140 $wgArticle = new ImagePage( $wgTitle );
143 if ( $wgUseCategoryMagic ) {
144 require_once( 'includes/CategoryPage.php' );
145 $wgArticle = new CategoryPage( $wgTitle );
148 # NO break if wgUseCategoryMagic is false, drop through to next (default).
149 # Don't insert other cases between NS_CATEGORY and default.
151 $wgArticle = new Article( $wgTitle );
154 if ( in_array( $action, $wgDisabledActions ) ) {
155 $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
159 $wgOut->setSquidMaxage( $wgSquidMaxage );
170 case 'markpatrolled':
172 $wgArticle->$action();
178 if( !$wgEnableDublinCoreRdf ) {
179 wfHttpError( 403, 'Forbidden', wfMsg( 'nodublincore' ) );
181 require_once( 'includes/Metadata.php' );
182 wfDublinCoreRdf( $wgArticle );
185 case 'creativecommons':
186 if( !$wgEnableCreativeCommonsRdf ) {
187 wfHttpError( 403, 'Forbidden', wfMsg('nocreativecommons') );
189 require_once( 'includes/Metadata.php' );
190 wfCreativeCommonsRdf( $wgArticle );
194 require_once( 'includes/Credits.php' );
195 showCreditsPage( $wgArticle );
198 if( !$wgCommandLineMode && !$wgRequest->checkSessionCookie() ) {
199 # Send a cookie so anons get talk message notifications
200 User
::SetupSession();
204 $internal = $wgRequest->getVal( 'internaledit' );
205 $external = $wgRequest->getVal( 'externaledit' );
206 $section = $wgRequest->getVal( 'section' );
207 $oldid = $wgRequest->getVal( 'oldid' );
208 if(!$wgUseExternalEditor ||
$action=='submit' ||
$internal ||
209 $section ||
$oldid ||
(!$wgUser->getOption('externaleditor') && !$external)) {
210 require_once( 'includes/EditPage.php' );
211 $editor = new EditPage( $wgArticle );
213 } elseif($wgUseExternalEditor && ($external ||
$wgUser->getOption('externaleditor'))) {
214 require_once( 'includes/ExternalEdit.php' );
215 $mode = $wgRequest->getVal( 'mode' );
216 $extedit = new ExternalEdit( $wgArticle, $mode );
221 if ($_SERVER['REQUEST_URI'] == $wgTitle->getInternalURL('action=history')) {
222 $wgOut->setSquidMaxage( $wgSquidMaxage );
224 require_once( 'includes/PageHistory.php' );
225 $history = new PageHistory( $wgArticle );
229 require_once( 'includes/RawPage.php' );
230 $raw = new RawPage( $wgArticle );
234 wfPurgeSquidServers(array($wgTitle->getInternalURL()));
235 $wgOut->setSquidMaxage( $wgSquidMaxage );
236 $wgTitle->invalidateCache();
240 if (wfRunHooks('UnknownAction', $action, $wgArticle)) {
241 $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
246 wfProfileOut( 'main-action' );
248 # Deferred updates aren't really deferred anymore. It's important to report errors to the
249 # user, and that means doing this before OutputPage::output(). Note that for page saves,
250 # the client will wait until the script exits anyway before following the redirect.
251 wfProfileIn( 'main-updates' );
252 foreach ( $wgDeferredUpdateList as $up ) {
255 wfProfileOut( 'main-updates' );
257 wfProfileIn( 'main-cleanup' );
258 $wgLoadBalancer->saveMasterPos();
260 # Now commit any transactions, so that unreported errors after output() don't roll back the whole thing
261 $wgLoadBalancer->commitAll();
265 foreach ( $wgPostCommitUpdateList as $up ) {
269 wfProfileOut( 'main-cleanup' );
272 $wgLoadBalancer->closeAll();
273 wfDebug( "Request ended normally\n" );