2 # Main wiki script; see design.doc
4 $wgRequestTime = microtime();
7 ini_set( "allow_url_fopen", 0 ); # For security...
8 include_once( "./LocalSettings.php" );
10 # Windows requires ';' as separator, ':' for Unix
11 $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
12 ini_set( "include_path", "$IP$sep$include_path" );
14 include_once( "Setup.php" );
16 wfProfileIn( "main-misc-setup" );
17 OutputPage::setEncodings(); # Not really used yet
21 global $action, $title, $search, $go, $target, $printable;
22 global $returnto, $diff, $oldid, $curid;
24 # Placeholders in case of DB error
25 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
26 $wgArticle = new Article($wgTitle);
28 $action = strtolower( trim( $action ) );
29 if ( "" == $action ) { $action = "view"; }
30 if ( "yes" == $printable ) { $wgOut->setPrintable(); }
32 if ( "" == $title && "delete" != $action ) {
33 $wgTitle = Title::newFromText( wfMsg( "mainpage" ) );
35 # URLs like this are generated by RC, because rc_title isn't always accurate
36 $wgTitle = Title::newFromID( $curid );
38 $wgTitle = Title::newFromURL( $title );
40 wfProfileOut( "main-misc-setup" );
42 if ( "" != $search ) {
43 if( isset($_REQUEST['fulltext']) ) {
48 } else if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
49 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
50 $wgOut->errorpage( "badtitle", "badtitletext" );
51 } else if ( ( $action == "view" ) && $wgTitle->getPrefixedDBKey() != $title ) {
52 /* redirect to canonical url */
53 $wgOut->redirect( wfLocalUrl( $wgTitle->getPrefixedURL() ) );
54 } else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
57 if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
58 $wgTitle = Title::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
61 switch( $wgTitle->getNamespace() ) {
63 include_once( "ImagePage.php" );
64 $wgArticle = new ImagePage( $wgTitle );
67 $wgArticle = new Article( $wgTitle );
79 $wgArticle->$action();
86 if( !$wgCommandLineMode && !isset( $_COOKIE[ini_get("session.name")] ) ) {
89 include_once( "EditPage.php" );
90 $editor = new EditPage( $wgArticle );
94 include_once( "PageHistory.php" );
95 $history = new PageHistory( $wgArticle );
99 $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
104 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
106 wfDebug( "Request ended normally\n" );