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 $title = $_REQUEST['title'];
34 # Placeholders in case of DB error
35 $wgTitle = Title
::newFromText( wfMsg( "badtitle" ) );
36 $wgArticle = new Article($wgTitle);
38 $action = strtolower( trim( $action ) );
39 if ( "" == $action ) { $action = "view"; }
40 if ( "yes" == $_REQUEST['printable'] ) { $wgOut->setPrintable(); }
42 if ( "" == $title && "delete" != $action ) {
43 $wgTitle = Title
::newFromText( wfMsg( "mainpage" ) );
44 } elseif ( $_REQUEST['curid'] ) {
45 # URLs like this are generated by RC, because rc_title isn't always accurate
46 $wgTitle = Title
::newFromID( $_REQUEST['curid'] );
48 $wgTitle = Title
::newFromURL( $title );
50 wfProfileOut( "main-misc-setup" );
52 # If the user is not logged in, the Namespace:title of the article must be in the Read array in
53 # order for the user to see it.
54 if ( !$wgUser->getID() && is_array( $wgWhitelistRead ) && $wgTitle) {
55 if ( !in_array( $wgLang->getNsText( $wgTitle->getNamespace() ) . ":" . $wgTitle->getDBkey(), $wgWhitelistRead ) ) {
62 if ( "" != $_REQUEST['search'] ) {
63 if( isset($_REQUEST['fulltext']) ) {
64 wfSearch( $_REQUEST['search'] );
66 wfGo( $_REQUEST['search'] );
68 } else if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
69 $wgTitle = Title
::newFromText( wfMsg( "badtitle" ) );
70 $wgOut->errorpage( "badtitle", "badtitletext" );
71 } else if ( ( $action == "view" ) && $wgTitle->getPrefixedDBKey() != $title ) {
72 /* redirect to canonical url, make it a 301 to allow caching */
73 $wgOut->redirect( wfLocalUrl( $wgTitle->getPrefixedURL() ), '301');
74 } else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
77 if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
78 $wgTitle = Title
::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
81 switch( $wgTitle->getNamespace() ) {
83 include_once( "ImagePage.php" );
84 $wgArticle = new ImagePage( $wgTitle );
87 $wgArticle = new Article( $wgTitle );
90 wfQuery("BEGIN", DB_WRITE
);
100 $wgArticle->$action();
107 if( !$wgCommandLineMode && !isset( $_COOKIE[ini_get("session.name")] ) ) {
108 User
::SetupSession();
110 include_once( "EditPage.php" );
111 $editor = new EditPage( $wgArticle );
115 include_once( "PageHistory.php" );
116 $history = new PageHistory( $wgArticle );
120 $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
122 wfQuery("COMMIT", DB_WRITE
);
126 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
128 wfDebug( "Request ended normally\n" );