2 # Main wiki script; see design.doc
4 $wgRequestTime = microtime();
7 ini_set( "allow_url_fopen", 0 ); # For security...
8 if(!file_exists("LocalSettings.php")) {
9 die( "You'll have to <a href='config/index.php'>set the wiki up</a> first!" );
11 include_once( "./LocalSettings.php" );
13 if( $wgSitename == "MediaWiki" ) {
14 die( "You must set the site name in \$wgSitename before installation.\n\n" );
17 # PATH_SEPARATOR avaialble only from 4.3.0
18 $sep = (DIRECTORY_SEPARATOR
== "\\") ?
";" : ":";
19 ini_set( "include_path", $IP . $sep . ini_get( "include_path" ) );
21 include_once( "Setup.php" );
23 wfProfileIn( "main-misc-setup" );
24 OutputPage
::setEncodings(); # Not really used yet
27 $action = $wgRequest->getVal( "action", "view" );
29 if( isset( $_SERVER['PATH_INFO'] ) ) {
30 $title = substr( $_SERVER['PATH_INFO'], 1 );
32 $title = $wgRequest->getVal( "title" );
35 # Placeholders in case of DB error
36 $wgTitle = Title
::newFromText( wfMsg( "badtitle" ) );
37 $wgArticle = new Article($wgTitle);
39 $action = strtolower( trim( $action ) );
40 if ( "" == $action ) { $action = "view"; }
41 if ($wgRequest->getVal( "printable" ) == "yes") {
42 $wgOut->setPrintable();
45 if ( "" == $title && "delete" != $action ) {
46 $wgTitle = Title
::newFromText( wfMsg( "mainpage" ) );
47 } elseif ( $curid = $wgRequest->getInt( 'curid' ) ) {
48 # URLs like this are generated by RC, because rc_title isn't always accurate
49 $wgTitle = Title
::newFromID( $curid );
51 $wgTitle = Title
::newFromURL( $title );
53 wfProfileOut( "main-misc-setup" );
55 # If the user is not logged in, the Namespace:title of the article must be in the Read array in
56 # order for the user to see it.
57 if ( !$wgUser->getID() && is_array( $wgWhitelistRead ) && $wgTitle) {
58 if ( !in_array( $wgLang->getNsText( $wgTitle->getNamespace() ) . ":" . $wgTitle->getDBkey(), $wgWhitelistRead ) ) {
65 if ( $search = $wgRequest->getText( 'search' ) ) {
66 if( $wgRequest->getVal( 'fulltext' ) ) {
71 } else if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
72 $wgTitle = Title
::newFromText( wfMsg( "badtitle" ) );
73 $wgOut->errorpage( "badtitle", "badtitletext" );
74 } else if ( ( $action == "view" ) && $wgTitle->getPrefixedDBKey() != $title ) {
75 /* redirect to canonical url, make it a 301 to allow caching */
76 $wgOut->redirect( $wgTitle->getFullURL(), '301');
77 } else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
80 if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
81 $wgTitle = Title
::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
84 switch( $wgTitle->getNamespace() ) {
86 include_once( "ImagePage.php" );
87 $wgArticle = new ImagePage( $wgTitle );
90 $wgArticle = new Article( $wgTitle );
93 wfQuery("BEGIN", DB_WRITE
);
103 $wgArticle->$action();
110 if( !$wgCommandLineMode && !$wgRequest->checkSessionCookie() ) {
111 User
::SetupSession();
113 include_once( "EditPage.php" );
114 $editor = new EditPage( $wgArticle );
118 include_once( "PageHistory.php" );
119 $history = new PageHistory( $wgArticle );
123 $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
125 wfQuery("COMMIT", DB_WRITE
);
129 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
131 wfDebug( "Request ended normally\n" );