getVal( 'action', 'view' ); $title = $wgRequest->getVal( 'title' ); $action = strtolower( $action ); if ($wgRequest->getVal( 'printable' ) == 'yes') { $wgOut->setPrintable(); } if ( wfHomePageInternalTitle() == $title && 'delete' != $action ) { $wgTitle = Title::newFromText( wfHomePageInternalTitle() ); } elseif ( $curid = $wgRequest->getInt( 'curid' ) ) { # URLs like this are generated by RC, because rc_title isn't always accurate $wgTitle = Title::newFromID( $curid ); } else { if ($contextID = $wgRequest->getInt( 'contextid' )) $wgTitle = Title::newFromURL( $title, Title::newFromID( $contextID ) ); else $wgTitle = Title::newFromURL( $title ); } /*** * MT RoyK: Special sitemap handling for search engines * The sitemap xml file is required to be at the root of the domain, so the API url won't work. Instead, we need to load the contents and output. * So here, we catch the special case and call the API and return the document, gzipped. * Using mod_rewrite isn't as easy (would need another PHP entry point, need to modify sites-available, and restart, etc.) */ $lpt = strtolower($wgTitle->getPrefixedText()); if ('sitemap.gz' == $lpt || 'sitemap.xml' == $lpt) { //create a new plug instead of using $wgDekiPlug cause we have to suppress the dream.out.format=php $Plug = new Plug($wgDreamServer, 'xml'); $r = $Plug->At($wgDekiApi, 'pages')->With('format', 'sitemap')->Get(); if ($lpt == 'sitemap.gz') { ob_start ("ob_gzhandler"); header("Cache-Control: must-revalidate"); header("Expires: " . gmdate("D, d M Y H:i:s", time() + (3600)) . " GMT"); } header('Content-type: '.$r['type']); echo($r['body']); exit(); } wfProfileOut( 'main-misc-setup' ); wfProfileIn( 'main-action' ); $search = $wgRequest->getText( 'search' ); if ( !is_null( $search ) && $search !== '' ) { $wgTitle = Title::makeTitle( NS_SPECIAL, 'Search' ); } if ( !$wgTitle ) { $wgTitle = Title::newFromText( wfMsgForContent('Article.Error.input-bad-title') ); $wgOut->errorpage('badtitle', 'Article.Error.page-title-is-invalid'); } else if ( $wgTitle->getInterwiki() != '' ) { $url = $wgTitle->getFullURL(); # Check for a redirect loop if ( !preg_match( '/^' . preg_quote( $wgServer, '/' ) . '/', $url ) ) { $wgOut->redirect( $url ); } else { $wgTitle = Title::newFromText( wfMsgForContent('Article.Error.input-bad-title') ); $wgOut->errorpage('badtitle', 'Article.Error.page-title-is-invalid'); } } else if ( ( $action == 'view' ) && (!isset( $_GET['title'] ) || strcasecmp(rawurldecode($wgTitle->getPrefixedDBKey()), $_GET['title']) != 0 ) && !count( array_diff( array_keys( $_GET ), array( 'action', 'title' ) ) ) ) { $wgOut->redirect( $wgTitle->getFullURL(), '301'); } else { if (!empty($wgPreloadPages)) { $articleId = $wgTitle->getArticleId(); foreach ($wgPreloadPages as $page) { $at = new Article(Title::newFromText($page)); $at->mTargetArticleId = $articleId; $at->loadContent(); } } if ( NS_ADMIN == $wgTitle->getNamespace() ) { require_once( 'includes/SpecialPage.php' ); AdminPage::executePath( $wgTitle ); } else if ( NS_SPECIAL == $wgTitle->getNamespace() ) { # actions that need to be made when we have a special pages require_once( 'includes/SpecialPage.php' ); SpecialPage::executePath( $wgTitle ); } else { switch( $wgTitle->getNamespace() ) { case NS_ATTACHMENT: if (AttachFile::execute( $wgTitle, $action )) return; break; default: $wgArticle = new Article( $wgTitle ); } # MT ursm: edit a new article by default if ($action == 'view' && $wgArticle->getID() <= 0 && $wgTitle->isEditable() && $wgArticle->userCanCreate()) { $action = 'edit'; } if ($action == 'edit' && $wgArticle->getId() > 0 && !$wgArticle->userCanEdit()) { $action = 'view'; } switch( $action ) { case 'noaction': break; case 'view': $wgArticle->view(); break; case 'comment': $editor = new CommentPage( $wgArticle->mTitle ); $editor->submit(); break; case 'watch': case 'unwatch': // case 'delete': case 'revert': case 'rollback': case 'addsubpage': $wgArticle->$action(); break; case 'export': $wgOut->mExport = true; $wgOut->mExportType = strtolower($wgRequest->getVal('type')); $wgArticle->view(); if ($wgRequest->getVal('type') == 'pdf') { $wgOut->mExportType == 'pdf'; } break; case 'print': $wgArticle->view(); break; case 'submit': if( !$wgCommandLineMode && !$wgRequest->checkSessionCookie() ) { User::SetupSession(); } # Continue... case 'edit': require_once( 'includes/EditPage.php' ); $editor = new EditPage( $wgArticle ); $editor->submit(); break; case 'history': require_once( 'includes/PageHistory.php' ); $history = new PageHistory( $wgArticle ); $history->history(); break; default: if (wfRunHooks('UnknownAction', $action, $wgArticle)) { $wgOut->errorpage('nosuchaction', 'Article.Error.unknown-action-specified'); } } } } wfProfileOut( 'main-action' ); wfProfileIn( 'main-cleanup' ); $wgOut->output(); wfProfileOut( 'main-cleanup' ); logProfilingData(); $wgDatabase->close(); ?>