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
20 if ( function_exists( "getallheaders" ) ) {
21 wfDebug( "\nStart request\n" );
22 wfDebug( "$REQUEST_METHOD $REQUEST_URI\n" );
23 $headers = getallheaders();
24 foreach ($headers as $name => $value) {
25 wfDebug( "$name: $value\n" );
29 wfDebug( "$REQUEST_METHOD $REQUEST_URI\n" );
34 global $action, $title, $search, $go, $target, $printable;
35 global $returnto, $diff, $oldid, $curid;
37 # Placeholders in case of DB error
38 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
39 $wgArticle = new Article($wgTitle);
41 $action = strtolower( trim( $action ) );
42 if ( "" == $action ) { $action = "view"; }
43 if ( "yes" == $printable ) { $wgOut->setPrintable(); }
45 if ( "" == $title && "delete" != $action ) {
46 $wgTitle = Title::newFromText( wfMsg( "mainpage" ) );
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( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
56 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
57 $wgOut->errorpage( "badtitle", "badtitletext" );
58 } else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
60 } else if ( "" != $search ) {
67 if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
68 $wgTitle = Title::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
71 switch( $wgTitle->getNamespace() ) {
73 include_once( "ImagePage.php" );
74 $wgArticle = new ImagePage( $wgTitle );
77 $wgArticle = new Article( $wgTitle );
89 $wgArticle->$action();
96 include_once( "EditPage.php" );
97 $editor = new EditPage( $wgArticle );
101 include_once( "PageHistory.php" );
102 $history = new PageHistory( $wgArticle );
106 $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
111 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
113 wfDebug( "Request ended normally\n" );