2004-02-28 03:04:02 +00:00
|
|
|
<?php
|
2004-08-14 12:10:43 +00:00
|
|
|
#apd_set_pprof_trace();
|
2004-02-28 03:04:02 +00:00
|
|
|
# Main wiki script; see design.doc
|
|
|
|
|
#
|
|
|
|
|
$wgRequestTime = microtime();
|
|
|
|
|
|
|
|
|
|
unset( $IP );
|
2004-09-26 10:41:48 +00:00
|
|
|
@ini_set( 'allow_url_fopen', 0 ); # For security...
|
|
|
|
|
if( !file_exists( 'LocalSettings.php' ) ) {
|
|
|
|
|
if ( file_exists( 'config/LocalSettings.php' ) ) {
|
|
|
|
|
die( "To complete the installation, move <tt>config/LocalSettings.php</tt> to the parent directory.\n" );
|
|
|
|
|
} else {
|
|
|
|
|
die( "You'll have to <a href='config/index.php'>set the wiki up</a> first!" );
|
|
|
|
|
}
|
2004-03-01 12:59:45 +00:00
|
|
|
}
|
2004-02-29 08:06:49 +00:00
|
|
|
|
2004-08-14 20:33:01 +00:00
|
|
|
# Valid web server entry point, enable includes.
|
|
|
|
|
# Please don't move this line to includes/Defines.php. This line essentially defines
|
|
|
|
|
# a valid entry point. If you put it in includes/Defines.php, then any script that includes
|
|
|
|
|
# it becomes an entry point, thereby defeating its purpose.
|
2004-08-14 12:20:39 +00:00
|
|
|
define( "MEDIAWIKI", true );
|
|
|
|
|
|
2004-07-24 07:24:04 +00:00
|
|
|
require_once( "./includes/Defines.php" );
|
2004-05-09 10:37:00 +00:00
|
|
|
require_once( "./LocalSettings.php" );
|
|
|
|
|
require_once( "includes/Setup.php" );
|
2004-02-28 03:04:02 +00:00
|
|
|
|
|
|
|
|
wfProfileIn( "main-misc-setup" );
|
|
|
|
|
OutputPage::setEncodings(); # Not really used yet
|
|
|
|
|
|
|
|
|
|
# Query string fields
|
2004-03-08 09:09:35 +00:00
|
|
|
$action = $wgRequest->getVal( "action", "view" );
|
2004-09-03 06:12:57 +00:00
|
|
|
$title = $wgRequest->getVal( "title" );
|
2004-02-28 03:04:02 +00:00
|
|
|
|
|
|
|
|
$action = strtolower( trim( $action ) );
|
2004-03-08 09:09:35 +00:00
|
|
|
if ($wgRequest->getVal( "printable" ) == "yes") {
|
2004-03-08 01:51:32 +00:00
|
|
|
$wgOut->setPrintable();
|
|
|
|
|
}
|
2004-02-28 03:04:02 +00:00
|
|
|
|
|
|
|
|
if ( "" == $title && "delete" != $action ) {
|
2004-09-22 04:09:31 +00:00
|
|
|
$wgTitle = Title::newFromText( wfMsgForContent( "mainpage" ) );
|
2004-03-08 09:09:35 +00:00
|
|
|
} elseif ( $curid = $wgRequest->getInt( 'curid' ) ) {
|
2004-02-28 03:04:02 +00:00
|
|
|
# URLs like this are generated by RC, because rc_title isn't always accurate
|
2004-03-08 09:09:35 +00:00
|
|
|
$wgTitle = Title::newFromID( $curid );
|
2004-02-28 03:04:02 +00:00
|
|
|
} else {
|
|
|
|
|
$wgTitle = Title::newFromURL( $title );
|
|
|
|
|
}
|
|
|
|
|
wfProfileOut( "main-misc-setup" );
|
|
|
|
|
|
2004-10-24 19:14:48 +00:00
|
|
|
# Debug statement for user levels
|
|
|
|
|
// print_r($wgUser);
|
|
|
|
|
|
2004-05-11 09:47:41 +00:00
|
|
|
# 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())
|
2004-05-30 06:44:47 +00:00
|
|
|
if ( !is_null( $wgTitle ) && !$wgTitle->userCanRead() ) {
|
2004-05-11 09:47:41 +00:00
|
|
|
$wgOut->loginToUse();
|
|
|
|
|
$wgOut->output();
|
|
|
|
|
exit;
|
2004-03-05 13:19:19 +00:00
|
|
|
}
|
|
|
|
|
|
2004-08-22 09:07:31 +00:00
|
|
|
wfProfileIn( "main-action" );
|
2004-12-21 09:28:57 +00:00
|
|
|
|
2004-08-31 02:26:55 +00:00
|
|
|
$search = $wgRequest->getText( 'search' );
|
2004-12-21 09:28:57 +00:00
|
|
|
if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
|
2004-10-20 09:56:34 +00:00
|
|
|
require_once( 'includes/SpecialSearch.php' );
|
2004-04-24 06:39:59 +00:00
|
|
|
$wgTitle = Title::makeTitle( NS_SPECIAL, "Search" );
|
2004-10-20 09:56:34 +00:00
|
|
|
wfSpecialSearch();
|
2004-05-04 12:37:29 +00:00
|
|
|
} else if( !$wgTitle or $wgTitle->getDBkey() == "" ) {
|
2004-09-22 04:09:31 +00:00
|
|
|
$wgTitle = Title::newFromText( wfMsgForContent( "badtitle" ) );
|
2004-02-28 03:04:02 +00:00
|
|
|
$wgOut->errorpage( "badtitle", "badtitletext" );
|
2004-05-04 12:37:29 +00:00
|
|
|
} else if ( $wgTitle->getInterwiki() != "" ) {
|
|
|
|
|
$url = $wgTitle->getFullURL();
|
|
|
|
|
# Check for a redirect loop
|
2004-05-29 01:24:33 +00:00
|
|
|
if ( !preg_match( "/^" . preg_quote( $wgServer, "/" ) . "/", $url ) && $wgTitle->isLocal() ) {
|
2004-05-04 12:37:29 +00:00
|
|
|
$wgOut->redirect( $url );
|
|
|
|
|
} else {
|
2004-09-22 04:09:31 +00:00
|
|
|
$wgTitle = Title::newFromText( wfMsgForContent( "badtitle" ) );
|
2004-05-04 12:37:29 +00:00
|
|
|
$wgOut->errorpage( "badtitle", "badtitletext" );
|
|
|
|
|
}
|
2004-09-06 03:17:21 +00:00
|
|
|
} else if ( ( $action == "view" ) &&
|
|
|
|
|
(!isset( $_GET['title'] ) || $wgTitle->getPrefixedDBKey() != $_GET['title'] ) &&
|
|
|
|
|
!count( array_diff( array_keys( $_GET ), array( 'action', 'title' ) ) ) )
|
2004-07-25 11:49:05 +00:00
|
|
|
{
|
2004-03-01 22:16:39 +00:00
|
|
|
/* redirect to canonical url, make it a 301 to allow caching */
|
2004-03-08 09:09:35 +00:00
|
|
|
$wgOut->redirect( $wgTitle->getFullURL(), '301');
|
2004-02-28 03:04:02 +00:00
|
|
|
} else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
|
2004-06-12 01:31:00 +00:00
|
|
|
# actions that need to be made when we have a special pages
|
|
|
|
|
require_once( 'includes/SpecialPage.php' );
|
|
|
|
|
if ( !$wgAllowSysopQueries ) {SpecialPage::removePage( 'Asksql' ); }
|
2004-05-15 03:36:39 +00:00
|
|
|
SpecialPage::executePath( $wgTitle );
|
2004-02-28 03:04:02 +00:00
|
|
|
} else {
|
|
|
|
|
if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
|
2004-08-22 23:55:36 +00:00
|
|
|
$wgTitle = Title::makeTitle( NS_IMAGE, $wgTitle->getDBkey() );
|
2004-03-08 09:09:35 +00:00
|
|
|
}
|
2004-04-09 10:29:54 +00:00
|
|
|
|
2004-02-28 03:04:02 +00:00
|
|
|
switch( $wgTitle->getNamespace() ) {
|
2004-03-08 09:09:35 +00:00
|
|
|
case NS_IMAGE:
|
2004-05-09 10:37:00 +00:00
|
|
|
require_once( "includes/ImagePage.php" );
|
2004-02-28 03:04:02 +00:00
|
|
|
$wgArticle = new ImagePage( $wgTitle );
|
|
|
|
|
break;
|
2004-08-22 09:42:12 +00:00
|
|
|
case NS_CATEGORY:
|
|
|
|
|
if ( $wgUseCategoryMagic ) {
|
|
|
|
|
require_once( "includes/CategoryPage.php" );
|
|
|
|
|
$wgArticle = new CategoryPage( $wgTitle );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
# NO break if wgUseCategoryMagic is false, drop through to next (default).
|
|
|
|
|
# Don't insert other cases between NS_CATEGORY and default.
|
2004-02-28 03:04:02 +00:00
|
|
|
default:
|
|
|
|
|
$wgArticle = new Article( $wgTitle );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch( $action ) {
|
|
|
|
|
case "view":
|
2004-03-13 13:43:22 +00:00
|
|
|
$wgOut->setSquidMaxage( $wgSquidMaxage );
|
2004-04-09 10:29:54 +00:00
|
|
|
$wgArticle->view();
|
2004-03-13 13:43:22 +00:00
|
|
|
break;
|
2004-02-28 03:04:02 +00:00
|
|
|
case "watch":
|
|
|
|
|
case "unwatch":
|
|
|
|
|
case "delete":
|
|
|
|
|
case "revert":
|
|
|
|
|
case "rollback":
|
|
|
|
|
case "protect":
|
|
|
|
|
case "unprotect":
|
2004-07-20 20:48:19 +00:00
|
|
|
case "validate":
|
2004-07-08 15:41:45 +00:00
|
|
|
case "info":
|
2004-08-09 08:21:34 +00:00
|
|
|
case "markpatrolled":
|
2004-04-09 10:46:28 +00:00
|
|
|
$wgArticle->$action();
|
2004-02-28 03:04:02 +00:00
|
|
|
break;
|
|
|
|
|
case "print":
|
|
|
|
|
$wgArticle->view();
|
|
|
|
|
break;
|
2004-04-04 22:33:11 +00:00
|
|
|
case "dublincore":
|
|
|
|
|
if( !$wgEnableDublinCoreRdf ) {
|
|
|
|
|
wfHttpError( 403, "Forbidden", wfMsg( "nodublincore" ) );
|
|
|
|
|
} else {
|
2004-05-09 10:37:00 +00:00
|
|
|
require_once( "includes/Metadata.php" );
|
2004-04-04 22:33:11 +00:00
|
|
|
wfDublinCoreRdf( $wgArticle );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "creativecommons":
|
|
|
|
|
if( !$wgEnableCreativeCommonsRdf ) {
|
|
|
|
|
wfHttpError( 403, "Forbidden", wfMsg("nocreativecommons") );
|
|
|
|
|
} else {
|
2004-05-09 10:37:00 +00:00
|
|
|
require_once( "includes/Metadata.php" );
|
2004-04-04 22:33:11 +00:00
|
|
|
wfCreativeCommonsRdf( $wgArticle );
|
|
|
|
|
}
|
|
|
|
|
break;
|
2004-10-14 02:13:12 +00:00
|
|
|
case "credits":
|
|
|
|
|
require_once( "includes/Credits.php" );
|
2004-06-28 17:46:54 +00:00
|
|
|
showCreditsPage( $wgArticle );
|
2004-10-14 02:13:12 +00:00
|
|
|
break;
|
2004-02-28 03:04:02 +00:00
|
|
|
case "edit":
|
|
|
|
|
case "submit":
|
2004-03-08 09:09:35 +00:00
|
|
|
if( !$wgCommandLineMode && !$wgRequest->checkSessionCookie() ) {
|
2004-02-28 03:04:02 +00:00
|
|
|
User::SetupSession();
|
|
|
|
|
}
|
2004-05-09 10:37:00 +00:00
|
|
|
require_once( "includes/EditPage.php" );
|
2004-02-28 03:04:02 +00:00
|
|
|
$editor = new EditPage( $wgArticle );
|
2004-08-09 08:21:34 +00:00
|
|
|
$editor->submit();
|
2004-02-28 03:04:02 +00:00
|
|
|
break;
|
|
|
|
|
case "history":
|
2004-03-13 13:43:22 +00:00
|
|
|
if ($_SERVER["REQUEST_URI"] == $wgTitle->getInternalURL('action=history')) {
|
|
|
|
|
$wgOut->setSquidMaxage( $wgSquidMaxage );
|
|
|
|
|
}
|
2004-05-09 10:37:00 +00:00
|
|
|
require_once( "includes/PageHistory.php" );
|
2004-02-28 03:04:02 +00:00
|
|
|
$history = new PageHistory( $wgArticle );
|
|
|
|
|
$history->history();
|
|
|
|
|
break;
|
2004-04-28 17:38:48 +00:00
|
|
|
case "raw":
|
2004-05-09 10:37:00 +00:00
|
|
|
require_once( "includes/RawPage.php" );
|
2004-04-28 17:38:48 +00:00
|
|
|
$raw = new RawPage( $wgArticle );
|
|
|
|
|
$raw->view();
|
|
|
|
|
break;
|
2004-03-13 16:09:00 +00:00
|
|
|
case "purge":
|
|
|
|
|
wfPurgeSquidServers(array($wgTitle->getInternalURL()));
|
|
|
|
|
$wgOut->setSquidMaxage( $wgSquidMaxage );
|
2004-06-06 14:05:51 +00:00
|
|
|
$wgTitle->invalidateCache();
|
2004-03-13 16:09:00 +00:00
|
|
|
$wgArticle->view();
|
|
|
|
|
break;
|
2004-02-28 03:04:02 +00:00
|
|
|
default:
|
2004-11-28 07:06:25 +00:00
|
|
|
if (wfRunHooks('UnknownAction', $action, $wgArticle)) {
|
|
|
|
|
$wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
|
|
|
|
|
}
|
2004-02-28 03:04:02 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-08-22 09:07:31 +00:00
|
|
|
wfProfileOut( "main-action" );
|
2004-02-28 03:04:02 +00:00
|
|
|
|
2004-07-24 07:24:04 +00:00
|
|
|
# Deferred updates aren't really deferred anymore. It's important to report errors to the
|
2004-08-09 08:21:34 +00:00
|
|
|
# user, and that means doing this before OutputPage::output(). Note that for page saves,
|
2004-07-24 07:24:04 +00:00
|
|
|
# the client will wait until the script exits anyway before following the redirect.
|
2004-08-22 09:07:31 +00:00
|
|
|
wfProfileIn( "main-updates" );
|
2004-07-09 17:37:03 +00:00
|
|
|
foreach ( $wgDeferredUpdateList as $up ) {
|
|
|
|
|
$up->doUpdate();
|
|
|
|
|
}
|
2004-08-22 09:07:31 +00:00
|
|
|
wfProfileOut( "main-updates" );
|
2004-07-24 07:24:04 +00:00
|
|
|
|
2004-08-22 09:07:31 +00:00
|
|
|
wfProfileIn( "main-cleanup" );
|
2004-07-24 07:24:04 +00:00
|
|
|
$wgLoadBalancer->saveMasterPos();
|
|
|
|
|
|
|
|
|
|
# Now commit any transactions, so that unreported errors after output() don't roll back the whole thing
|
|
|
|
|
$wgLoadBalancer->commitAll();
|
|
|
|
|
|
|
|
|
|
$wgOut->output();
|
2004-08-22 09:07:31 +00:00
|
|
|
wfProfileOut( "main-cleanup" );
|
2004-07-24 07:24:04 +00:00
|
|
|
|
2004-02-28 03:04:02 +00:00
|
|
|
logProfilingData();
|
2004-07-24 07:24:04 +00:00
|
|
|
$wgLoadBalancer->closeAll();
|
2004-02-28 03:04:02 +00:00
|
|
|
wfDebug( "Request ended normally\n" );
|
|
|
|
|
?>
|