MediaWiki: namespace update bug fix
[lhc/web/wiklou.git] / wiki.phtml
index 98895a2..d30db09 100644 (file)
@@ -3,19 +3,28 @@
 #
 $wgRequestTime = microtime();
 
-session_cache_limiter( "private, must-revalidate" );
-session_start();
-session_register( "wsUserID" );
-session_register( "wsUserName" );
-session_register( "wsUserPassword" );
-
-global $IP;
+unset( $IP );
+ini_set( "allow_url_fopen", 0 ); # For security...
 include_once( "./LocalSettings.php" );
-include_once( "$IP/Setup.php" );
+
+# Windows requires ';' as separator, ':' for Unix
+$sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
+ini_set( "include_path", "$IP$sep$include_path" );
+
+include_once( "Setup.php" );
 
 wfProfileIn( "main-misc-setup" );
 OutputPage::setEncodings(); # Not really used yet
 
+# Useful debug output
+wfDebug( "\nStart request\n" );
+wfDebug( "$REQUEST_METHOD $REQUEST_URI\n" );
+$headers = getallheaders();
+foreach ($headers as $name => $value) {
+       wfDebug( "$name: $value\n" );
+}
+wfDebug( "\n" );
+
 # Query string fields
 #
 global $action, $title, $search, $go, $target, $printable;
@@ -30,28 +39,36 @@ if ( "" == $title && "delete" != $action ) {
 } else {
        $wgTitle = Title::newFromURL( $title );
 #      if( $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" or strncmp($wgTitle->getDBkey(),"_",1) == 0 ) {
-       if( $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
+       if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
+               $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
                $wgOut->errorpage( "badtitle", "badtitletext" );
                $wgOut->output();
                exit;
        }
 }
-wfProfileOut();
-if ( -1 == $wgTitle->getNamespace() ) {
+wfProfileOut( "main-misc-setup" );
+
+if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
        wfSpecialPage();
 } else if ( "" != $search ) {
        if($go) {
-       
-               wfGo ($search);
-       
+               wfGo( $search );
        } else {
-       
                wfSearch( $search );
-               
        }
-               
 } else {
-       $wgArticle = new Article();
+       if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
+               $wgTitle = Title::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
+       }       
+       
+       switch( $wgTitle->getNamespace() ) {
+       case 6:
+               include_once( "ImagePage.php" );
+               $wgArticle = new ImagePage( $wgTitle );
+               break;
+       default:
+               $wgArticle = new Article( $wgTitle );
+       }
 
        switch( $action ) {
                case "view":
@@ -70,7 +87,7 @@ if ( -1 == $wgTitle->getNamespace() ) {
                        break;
                case "edit":
                case "submit":
-                       include_once( "$IP/EditPage.php" );
+                       include_once( "EditPage.php" );
                        $editor = new EditPage( $wgArticle );
                        $editor->$action();
                        break;