f0241058216b80e218ebf616392c67ab71d754a4
5 * Make sure index.php ends with the following lines (find the match for the first lines and replace the rest)
11 require_once( './LocalSettings.php' );
12 require_once( 'includes/Setup.php' );
14 # The wiki action class
15 require_once ( "includes/Wiki.php" ) ;
21 #__________________________
27 #____________________________________________________________________________________
30 function act_view ( $action ) {
31 global $wgOut , $wgSquidMaxage , $wgArticle ;
32 $wgOut->setSquidMaxage( $wgSquidMaxage );
36 function act_print ( $action ) {
41 function act_dublincore ( $action ) {
42 global $wgArticle , $wgEnableDublinCoreRdf ;
43 if( !$wgEnableDublinCoreRdf ) {
44 wfHttpError( 403, 'Forbidden', wfMsg( 'nodublincore' ) );
46 require_once( 'includes/Metadata.php' );
47 wfDublinCoreRdf( $wgArticle );
51 function act_creativecommons ( $action ) {
52 global $wgArticle , $wgEnableCreativeCommonsRdf ;
53 if( !$wgEnableCreativeCommonsRdf ) {
54 wfHttpError( 403, 'Forbidden', wfMsg('nocreativecommons') );
56 require_once( 'includes/Metadata.php' );
57 wfCreativeCommonsRdf( $wgArticle );
61 function act_credits ( $action ) {
63 require_once( 'includes/Credits.php' );
64 showCreditsPage( $wgArticle );
67 function act_submit ( $action ) {
68 global $wgCommandLineMode , $wgRequest ;
69 if( !$wgCommandLineMode && !$wgRequest->checkSessionCookie() ) {
70 # Send a cookie so anons get talk message notifications
73 $this->act_edit ( $action ) ;
76 function act_edit ( $action ) {
77 global $wgRequest , $wgUseExternalEditor , $wgUser , $wgArticle ;
78 $internal = $wgRequest->getVal( 'internaledit' );
79 $external = $wgRequest->getVal( 'externaledit' );
80 $section = $wgRequest->getVal( 'section' );
81 $oldid = $wgRequest->getVal( 'oldid' );
82 if(!$wgUseExternalEditor ||
$action=='submit' ||
$internal ||
83 $section ||
$oldid ||
(!$wgUser->getOption('externaleditor') && !$external)) {
84 require_once( 'includes/EditPage.php' );
85 $editor = new EditPage( $wgArticle );
87 } elseif($wgUseExternalEditor && ($external ||
$wgUser->getOption('externaleditor'))) {
88 require_once( 'includes/ExternalEdit.php' );
89 $mode = $wgRequest->getVal( 'mode' );
90 $extedit = new ExternalEdit( $wgArticle, $mode );
95 function act_history ( $action ) {
96 global $wgTitle , $wgArticle , $wgSquidMaxage ;
97 if ($_SERVER['REQUEST_URI'] == $wgTitle->getInternalURL('action=history')) {
98 $wgOut->setSquidMaxage( $wgSquidMaxage );
100 require_once( 'includes/PageHistory.php' );
101 $history = new PageHistory( $wgArticle );
105 function act_raw ( $action ) {
107 require_once( 'includes/RawPage.php' );
108 $raw = new RawPage( $wgArticle );
113 function action_unknown ( $action ) {
114 global $wgArticle , $wgOut ;
115 if (wfRunHooks('UnknownAction', array($action, $wgArticle))) {
116 $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
121 function act_watch ( $action ) { $this->article_action ( $action ) ; }
122 function act_unwatch ( $action ) { $this->article_action ( $action ) ; }
123 function act_delete ( $action ) { $this->article_action ( $action ) ; }
124 function act_revert ( $action ) { $this->article_action ( $action ) ; }
125 function act_rollback ( $action ) { $this->article_action ( $action ) ; }
126 function act_protect ( $action ) { $this->article_action ( $action ) ; }
127 function act_unprotect ( $action ) { $this->article_action ( $action ) ; }
128 function act_info ( $action ) { $this->article_action ( $action ) ; }
129 function act_markpatrolled ( $action ) { $this->article_action ( $action ) ; }
130 function act_render ( $action ) { $this->article_action ( $action ) ; }
131 function act_deletetrackback ( $action ) { $this->article_action ( $action ) ; }
132 function act_purge ( $action ) { $this->article_action ( $action ) ; }
134 function article_action ( $action ) {
136 $wgArticle->$action() ;
140 } ; # end of class MediaWikiType
143 $wgTheWiki = new MediaWikiType
;
149 #global $wgRequest , $wgOut , $wgTitle , $wgContLang ;
150 #global $action , $title , $curid ;
151 OutputPage
::setEncodings(); # Not really used yet
152 wfProfileIn( 'main-misc-setup' );
154 # Query string fields
155 $action = $wgRequest->getVal( 'action', 'view' );
156 $title = $wgRequest->getVal( 'title' );
158 if ($wgRequest->getVal( 'printable' ) == 'yes') {
159 $wgOut->setPrintable();
162 if ( '' == $title && 'delete' != $action ) {
163 $wgTitle = Title
::newFromText( wfMsgForContent( 'mainpage' ) );
164 } elseif ( $curid = $wgRequest->getInt( 'curid' ) ) {
165 # URLs like this are generated by RC, because rc_title isn't always accurate
166 $wgTitle = Title
::newFromID( $curid );
168 $wgTitle = Title
::newFromURL( $title );
169 /* check variant links so that interwiki links don't have to worry about
170 the possible different language variants
172 if( count($wgContLang->getVariants()) > 1 && !is_null($wgTitle) && $wgTitle->getArticleID() == 0 )
173 $wgContLang->findVariantLink( $title, $wgTitle );
176 wfProfileOut( 'main-misc-setup' );
178 #global $search , $wgRequest , $wgTitle ;
179 $search = $wgRequest->getText( 'search' );
180 if( !is_null( $search ) && $search !== '' ) {
181 // Compatibility with old search URLs which didn't use Special:Search
182 // Do this above the read whitelist check for security...
183 $wgTitle = Title
::makeTitle( NS_SPECIAL
, 'Search' );
186 #global $wgTitle , $wgOut ;
187 # If the user is not logged in, the Namespace:title of the article must be in
188 # the Read array in order for the user to see it. (We have to check here to
189 # catch special pages etc. We check again in Article::view())
190 if ( !is_null( $wgTitle ) && !$wgTitle->userCanRead() ) {
191 $wgOut->loginToUse();
196 #global $wgTitle , $wgArticle , $wgRequest , $wgOut , $wgServer ;
197 #global $wgDisableInternalSearch , $wgUseCategoryMagic , $wgDisabledActions ;
198 #global $rdfrom , $url , $action , $ns , $rTitle , $search ;
199 wfProfileIn( 'main-action' );
201 if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
202 require_once( 'includes/SpecialSearch.php' );
203 $wgTitle = Title
::makeTitle( NS_SPECIAL
, 'Search' );
205 } else if( !$wgTitle or $wgTitle->getDBkey() == '' ) {
206 $wgTitle = Title
::newFromText( wfMsgForContent( 'badtitle' ) );
207 $wgOut->errorpage( 'badtitle', 'badtitletext' );
208 } else if ( $wgTitle->getInterwiki() != '' ) {
209 if( $rdfrom = $wgRequest->getVal( 'rdfrom' ) ) {
210 $url = $wgTitle->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
212 $url = $wgTitle->getFullURL();
214 # Check for a redirect loop
215 if ( !preg_match( '/^' . preg_quote( $wgServer, '/' ) . '/', $url ) && $wgTitle->isLocal() ) {
216 $wgOut->redirect( $url );
218 $wgTitle = Title
::newFromText( wfMsgForContent( 'badtitle' ) );
219 $wgOut->errorpage( 'badtitle', 'badtitletext' );
221 } else if ( ( $action == 'view' ) &&
222 (!isset( $_GET['title'] ) ||
$wgTitle->getPrefixedDBKey() != $_GET['title'] ) &&
223 !count( array_diff( array_keys( $_GET ), array( 'action', 'title' ) ) ) )
225 /* redirect to canonical url, make it a 301 to allow caching */
226 $wgOut->setSquidMaxage( 1200 );
227 $wgOut->redirect( $wgTitle->getFullURL(), '301');
228 } else if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
229 # actions that need to be made when we have a special pages
230 SpecialPage
::executePath( $wgTitle );
232 if ( NS_MEDIA
== $wgTitle->getNamespace() ) {
233 $wgTitle = Title
::makeTitle( NS_IMAGE
, $wgTitle->getDBkey() );
236 $ns = $wgTitle->getNamespace();
238 // Namespace might change when using redirects
239 if($action == 'view' && !$wgRequest->getVal( 'oldid' ) ) {
240 $wgArticle = new Article( $wgTitle );
241 $rTitle = Title
::newFromRedirect( $wgArticle->fetchContent() );
243 # Reload from the page pointed to later
244 $wgArticle->mContentLoaded
= false;
245 $ns = $rTitle->getNamespace();
249 // Categories and images are handled by a different class
250 if ( $ns == NS_IMAGE
) {
252 require_once( 'includes/ImagePage.php' );
253 $wgArticle = new ImagePage( $wgTitle );
254 } elseif ( $wgUseCategoryMagic && $ns == NS_CATEGORY
) {
256 require_once( 'includes/CategoryPage.php' );
257 $wgArticle = new CategoryPage( $wgTitle );
260 if ( in_array( $action, $wgDisabledActions ) ) {
261 $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
263 $act = 'act_' . $action ;
264 if ( method_exists ( $wgTheWiki , $act ) ) {
265 $wgTheWiki->$act ( $action ) ;
267 $wgTheWiki->action_unknown ( $action ) ;
272 wfProfileOut( 'main-action' );
276 # Deferred updates aren't really deferred anymore. It's important to report errors to the
277 # user, and that means doing this before OutputPage::output(). Note that for page saves,
278 # the client will wait until the script exits anyway before following the redirect.
279 wfProfileIn( 'main-updates' );
280 global $wgDeferredUpdateList ;
281 foreach ( $wgDeferredUpdateList as $up ) {
284 wfProfileOut( 'main-updates' );
287 #global $wgLoadBalancer , $wgOut , $wgPostCommitUpdateList ;
288 wfProfileIn( 'main-cleanup' );
289 $wgLoadBalancer->saveMasterPos();
291 # Now commit any transactions, so that unreported errors after output() don't roll back the whole thing
292 $wgLoadBalancer->commitAll();
296 foreach ( $wgPostCommitUpdateList as $up ) {
300 wfProfileOut( 'main-cleanup' );
303 $wgLoadBalancer->closeAll();
304 wfDebug( "Request ended normally\n" );