X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=index.php;h=85403d9d54b8e1052f1a12a097fc04aba6716a00;hb=7abb98667681945d3386fb8852032d771377f783;hp=34580967802e17c26b2b61eb662c4b09970fb58f;hpb=1dea93f758375b209c402d01543a10f75d597f30;p=lhc%2Fweb%2Fwiklou.git diff --git a/index.php b/index.php index 3458096780..85403d9d54 100644 --- a/index.php +++ b/index.php @@ -1,37 +1,44 @@ set the wiki up first!" ); +} -include_once( "Setup.php" ); +define( "MEDIAWIKI", true ); +require_once( "./includes/Defines.php" ); +require_once( "./LocalSettings.php" ); +require_once( "includes/Setup.php" ); wfProfileIn( "main-misc-setup" ); OutputPage::setEncodings(); # Not really used yet # Query string fields -# -global $action, $title, $search, $go, $target, $printable; -global $returnto, $diff, $oldid, $curid; +$action = $wgRequest->getVal( "action", "view" ); + +if( isset( $_SERVER['PATH_INFO'] ) && $wgUsePathInfo ) { + $title = substr( $_SERVER['PATH_INFO'], 1 ); +} else { + $title = $wgRequest->getVal( "title" ); +} # Placeholders in case of DB error $wgTitle = Title::newFromText( wfMsg( "badtitle" ) ); $wgArticle = new Article($wgTitle); $action = strtolower( trim( $action ) ); -if ( "" == $action ) { $action = "view"; } -if ( "yes" == $printable ) { $wgOut->setPrintable(); } +if ($wgRequest->getVal( "printable" ) == "yes") { + $wgOut->setPrintable(); +} if ( "" == $title && "delete" != $action ) { $wgTitle = Title::newFromText( wfMsg( "mainpage" ) ); -} elseif ( $curid ) { +} elseif ( $curid = $wgRequest->getInt( 'curid' ) ) { # URLs like this are generated by RC, because rc_title isn't always accurate $wgTitle = Title::newFromID( $curid ); } else { @@ -39,37 +46,61 @@ if ( "" == $title && "delete" != $action ) { } wfProfileOut( "main-misc-setup" ); -if ( "" != $search ) { - if( isset($_REQUEST['fulltext']) ) { +# If the user is not logged in, the Namespace:title of the article must be in +# the Read array in order for the user to see it. (We have to check here to +# catch special pages etc. We check again in Article::view()) +if ( !is_null( $wgTitle ) && !$wgTitle->userCanRead() ) { + $wgOut->loginToUse(); + $wgOut->output(); + exit; +} + +if ( $search = $wgRequest->getText( 'search' ) ) { + $wgTitle = Title::makeTitle( NS_SPECIAL, "Search" ); + if( $wgRequest->getVal( 'fulltext' ) || !is_null( $wgRequest->getVal( 'offset' ) ) ) { wfSearch( $search ); } else { wfGo( $search ); } -} else if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) { +} else if( !$wgTitle or $wgTitle->getDBkey() == "" ) { $wgTitle = Title::newFromText( wfMsg( "badtitle" ) ); $wgOut->errorpage( "badtitle", "badtitletext" ); +} else if ( $wgTitle->getInterwiki() != "" ) { + $url = $wgTitle->getFullURL(); + # Check for a redirect loop + if ( !preg_match( "/^" . preg_quote( $wgServer, "/" ) . "/", $url ) && $wgTitle->isLocal() ) { + $wgOut->redirect( $url ); + } else { + $wgTitle = Title::newFromText( wfMsg( "badtitle" ) ); + $wgOut->errorpage( "badtitle", "badtitletext" ); + } } else if ( ( $action == "view" ) && $wgTitle->getPrefixedDBKey() != $title ) { - /* redirect to canonical url */ - $wgOut->redirect( wfLocalUrl( $wgTitle->getPrefixedURL() ) ); + /* redirect to canonical url, make it a 301 to allow caching */ + $wgOut->redirect( $wgTitle->getFullURL(), '301'); } else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) { - wfSpecialPage(); + # actions that need to be made when we have a special pages + require_once( 'includes/SpecialPage.php' ); + if ( !$wgAllowSysopQueries ) {SpecialPage::removePage( 'Asksql' ); } + SpecialPage::executePath( $wgTitle ); } else { if ( Namespace::getMedia() == $wgTitle->getNamespace() ) { $wgTitle = Title::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() ); - } - + } + switch( $wgTitle->getNamespace() ) { - case 6: - include_once( "ImagePage.php" ); + case NS_IMAGE: + require_once( "includes/ImagePage.php" ); $wgArticle = new ImagePage( $wgTitle ); break; default: $wgArticle = new Article( $wgTitle ); } - wfQuery("BEGIN", DB_WRITE); switch( $action ) { case "view": + $wgOut->setSquidMaxage( $wgSquidMaxage ); + $wgArticle->view(); + break; case "watch": case "unwatch": case "delete": @@ -77,33 +108,81 @@ if ( "" != $search ) { case "rollback": case "protect": case "unprotect": + case "validate": + case "info": $wgArticle->$action(); break; case "print": $wgArticle->view(); break; + case "dublincore": + if( !$wgEnableDublinCoreRdf ) { + wfHttpError( 403, "Forbidden", wfMsg( "nodublincore" ) ); + } else { + require_once( "includes/Metadata.php" ); + wfDublinCoreRdf( $wgArticle ); + } + break; + case "creativecommons": + if( !$wgEnableCreativeCommonsRdf ) { + wfHttpError( 403, "Forbidden", wfMsg("nocreativecommons") ); + } else { + require_once( "includes/Metadata.php" ); + wfCreativeCommonsRdf( $wgArticle ); + } + break; + case "credits": + require_once( "includes/Credits.php" ); + showCreditsPage( $wgArticle ); + break; case "edit": case "submit": - if( !$wgCommandLineMode && !isset( $_COOKIE[ini_get("session.name")] ) ) { + if( !$wgCommandLineMode && !$wgRequest->checkSessionCookie() ) { User::SetupSession(); } - include_once( "EditPage.php" ); + require_once( "includes/EditPage.php" ); $editor = new EditPage( $wgArticle ); $editor->$action(); break; case "history": - include_once( "PageHistory.php" ); + if ($_SERVER["REQUEST_URI"] == $wgTitle->getInternalURL('action=history')) { + $wgOut->setSquidMaxage( $wgSquidMaxage ); + } + require_once( "includes/PageHistory.php" ); $history = new PageHistory( $wgArticle ); $history->history(); break; + case "raw": + require_once( "includes/RawPage.php" ); + $raw = new RawPage( $wgArticle ); + $raw->view(); + break; + case "purge": + wfPurgeSquidServers(array($wgTitle->getInternalURL())); + $wgOut->setSquidMaxage( $wgSquidMaxage ); + $wgTitle->invalidateCache(); + $wgArticle->view(); + break; default: $wgOut->errorpage( "nosuchaction", "nosuchactiontext" ); } - wfQuery("COMMIT", DB_WRITE); } +# Deferred updates aren't really deferred anymore. It's important to report errors to the +# user, and that means doing this before OutputPage::output(). Note that for page saves, +# the client will wait until the script exits anyway before following the redirect. +foreach ( $wgDeferredUpdateList as $up ) { + $up->doUpdate(); +} + +$wgLoadBalancer->saveMasterPos(); + +# Now commit any transactions, so that unreported errors after output() don't roll back the whole thing +$wgLoadBalancer->commitAll(); + $wgOut->output(); -foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); } + logProfilingData(); +$wgLoadBalancer->closeAll(); wfDebug( "Request ended normally\n" ); ?>