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 # Windows requires ';' as separator, ':' for Unix
18 $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ?
";" : ":";
19 ini_set( "include_path", "$IP$sep$include_path" );
21 include_once( "Setup.php" );
23 wfProfileIn( "main-misc-setup" );
24 OutputPage
::setEncodings(); # Not really used yet
28 global $action, $title, $search, $go, $target, $printable;
29 global $returnto, $diff, $oldid, $curid;
31 # Placeholders in case of DB error
32 $wgTitle = Title
::newFromText( wfMsg( "badtitle" ) );
33 $wgArticle = new Article($wgTitle);
35 $action = strtolower( trim( $action ) );
36 if ( "" == $action ) { $action = "view"; }
37 if ( "yes" == $printable ) { $wgOut->setPrintable(); }
39 if ( "" == $title && "delete" != $action ) {
40 $wgTitle = Title
::newFromText( wfMsg( "mainpage" ) );
42 # URLs like this are generated by RC, because rc_title isn't always accurate
43 $wgTitle = Title
::newFromID( $curid );
45 $wgTitle = Title
::newFromURL( $title );
47 wfProfileOut( "main-misc-setup" );
49 # If the user is not logged in, the Namespace:title of the article must be in the Read array in
50 # order for the user to see it.
51 if ( !$wgUser->getID() && is_array( $wgWhitelistRead ) && $wgTitle) {
52 if ( !in_array( $wgLang->getNsText( $wgTitle->getNamespace() ) . ":" . $wgTitle->getDBkey(), $wgWhitelistRead ) ) {
59 if ( "" != $search ) {
60 if( isset($_REQUEST['fulltext']) ) {
65 } else if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
66 $wgTitle = Title
::newFromText( wfMsg( "badtitle" ) );
67 $wgOut->errorpage( "badtitle", "badtitletext" );
68 } else if ( ( $action == "view" ) && $wgTitle->getPrefixedDBKey() != $title ) {
69 /* redirect to canonical url, make it a 301 to allow caching */
70 $wgOut->redirect( wfLocalUrl( $wgTitle->getPrefixedURL() ), '301');
71 } else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
74 if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
75 $wgTitle = Title
::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
78 switch( $wgTitle->getNamespace() ) {
80 include_once( "ImagePage.php" );
81 $wgArticle = new ImagePage( $wgTitle );
84 $wgArticle = new Article( $wgTitle );
87 wfQuery("BEGIN", DB_WRITE
);
97 $wgArticle->$action();
104 if( !$wgCommandLineMode && !isset( $_COOKIE[ini_get("session.name")] ) ) {
105 User
::SetupSession();
107 include_once( "EditPage.php" );
108 $editor = new EditPage( $wgArticle );
112 include_once( "PageHistory.php" );
113 $history = new PageHistory( $wgArticle );
117 $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
119 wfQuery("COMMIT", DB_WRITE
);
123 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
125 wfDebug( "Request ended normally\n" );