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 $action = $_REQUEST['action'];
32 if( isset( $_SERVER['PATH_INFO'] ) ) {
33 $title = substr( $_SERVER['PATH_INFO'], 1 );
35 $title = $_REQUEST['title'];
38 # Placeholders in case of DB error
39 $wgTitle = Title
::newFromText( wfMsg( "badtitle" ) );
40 $wgArticle = new Article($wgTitle);
42 $action = strtolower( trim( $action ) );
43 if ( "" == $action ) { $action = "view"; }
44 if ( "yes" == $_REQUEST['printable'] ) { $wgOut->setPrintable(); }
46 if ( "" == $title && "delete" != $action ) {
47 $wgTitle = Title
::newFromText( wfMsg( "mainpage" ) );
48 } elseif ( $_REQUEST['curid'] ) {
49 # URLs like this are generated by RC, because rc_title isn't always accurate
50 $wgTitle = Title
::newFromID( $_REQUEST['curid'] );
52 $wgTitle = Title
::newFromURL( $title );
54 wfProfileOut( "main-misc-setup" );
56 # If the user is not logged in, the Namespace:title of the article must be in the Read array in
57 # order for the user to see it.
58 if ( !$wgUser->getID() && is_array( $wgWhitelistRead ) && $wgTitle) {
59 if ( !in_array( $wgLang->getNsText( $wgTitle->getNamespace() ) . ":" . $wgTitle->getDBkey(), $wgWhitelistRead ) ) {
66 if ( "" != $_REQUEST['search'] ) {
67 if( isset($_REQUEST['fulltext']) ) {
68 wfSearch( $_REQUEST['search'] );
70 wfGo( $_REQUEST['search'] );
72 } else if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
73 $wgTitle = Title
::newFromText( wfMsg( "badtitle" ) );
74 $wgOut->errorpage( "badtitle", "badtitletext" );
75 } else if ( ( $action == "view" ) && $wgTitle->getPrefixedDBKey() != $title ) {
76 /* redirect to canonical url, make it a 301 to allow caching */
77 $wgOut->redirect( wfLocalUrl( $wgTitle->getPrefixedURL() ), '301');
78 } else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
81 if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
82 $wgTitle = Title
::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
85 switch( $wgTitle->getNamespace() ) {
87 include_once( "ImagePage.php" );
88 $wgArticle = new ImagePage( $wgTitle );
91 $wgArticle = new Article( $wgTitle );
94 wfQuery("BEGIN", DB_WRITE
);
104 $wgArticle->$action();
111 if( !$wgCommandLineMode && !isset( $_COOKIE[ini_get("session.name")] ) ) {
112 User
::SetupSession();
114 include_once( "EditPage.php" );
115 $editor = new EditPage( $wgArticle );
119 include_once( "PageHistory.php" );
120 $history = new PageHistory( $wgArticle );
124 $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
126 wfQuery("COMMIT", DB_WRITE
);
130 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
132 wfDebug( "Request ended normally\n" );