Separate MediaWiki logo for installer from the default $wgLogo
[lhc/web/wiklou.git] / config / index.php
index fe366ea..82bcdc9 100644 (file)
@@ -74,19 +74,20 @@ header( "Content-type: text/html; charset=utf-8" );
 
 <div id="credit">
  <center>
-  <a href="http://www.mediawiki.org/"><img
-    src="../skins/common/images/wiki.png" width="135" height="135" alt="" border="0" /></a>
+  <a href="http://www.mediawiki.org/">
+   <img src="../skins/common/images/mediawiki.png" width="135" height="135" alt="" border="0" />
+  </a>
  </center>
 
- <b><a href="http://www.mediawiki.org/">MediaWiki</a></b> is
- Copyright (C) 2001-2004 by Magnus Manske, Brion Vibber, Lee Daniel Crocker,
+ <strong><a href="http://www.mediawiki.org/">MediaWiki</a></strong> is
+ Copyright (C) 2001-<?=date('Y')?> by Magnus Manske, Brion Vibber, Lee Daniel Crocker,
  Tim Starling, Erik M&ouml;ller, Gabriel Wicke, Thomas Gries and others.</p>
 
  <ul>
- <li><a href="../README">Readme</a></li>
- <li><a href="../RELEASE-NOTES">Release notes</a></li>
- <li><a href="../docs/">doc/</a></li>
- <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li>
 <li><a href="../README">Readme</a></li>
 <li><a href="../RELEASE-NOTES">Release notes</a></li>
 <li><a href="../docs/">doc/</a></li>
 <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li>
  </ul>
 
  <p>This program is free software; you can redistribute it and/or modify
@@ -123,7 +124,7 @@ require_once( "../includes/Namespace.php" );
 
 /* Check for existing configurations and bug out! */
 
-if( file_exists( "../LocalSettings.php" ) || file_exists( "../AdminSettings.php" ) ) {
+if( file_exists( "../LocalSettings.php" ) ) {
        dieout( "<h2>Wiki is configured.</h2>
 
        <p>Already configured... <a href='../index.php'>return to the wiki</a>.</p>
@@ -131,7 +132,7 @@ if( file_exists( "../LocalSettings.php" ) || file_exists( "../AdminSettings.php"
        <p>(You should probably remove this directory for added security.)</p>" );
 }
 
-if( file_exists( "./LocalSettings.php" ) || file_exists( "./AdminSettings.php" ) ) {
+if( file_exists( "./LocalSettings.php" ) ) {
        dieout( "<h2>You're configured!</h2>
 
        <p>Please move <tt>LocalSettings.php</tt> to the parent directory, then
@@ -149,10 +150,10 @@ if( !is_writable( "." ) ) {
 
        <p>To make the directory writable on a Unix/Linux system:</p>
 
-       <pre>
-       cd <i>/path/to/wiki</i>
-       chmod a+w config
-       </pre>" );
+       <blockquote>
+       <tt>cd /path/to/wiki</tt><br>
+       <tt>chmod a+w config</tt>
+       </blockquote>" );
 }
 
 
@@ -163,13 +164,8 @@ require_once( "../maintenance/archives/moveCustomMessages.inc" );
 
 class ConfigData {
        function getEncoded( $data ) {
-               # Hackish
-               global $wgUseLatin1;
-               if( $wgUseLatin1 ) {
-                       return utf8_decode( $data ); /* to latin1 wikis */
-               } else {
-                       return $data;
-               }
+               # removing latin1 support, no need...
+               return $data;
        }
        function getSitename() { return $this->getEncoded( $this->Sitename ); }
        function getSysopName() { return $this->getEncoded( $this->SysopName ); }
@@ -178,7 +174,7 @@ class ConfigData {
 
 ?>
 
-<p><i>Please include all of the lines below when reporting installation problems.</i></p>
+<p><em>Please include all of the lines below when reporting installation problems.</em></p>
 
 <h2>Checking environment...</h2>
 <ul>
@@ -194,25 +190,45 @@ print "<li>PHP " . phpversion() . ": ok</li>\n";
 
 if( ini_get( "register_globals" ) ) {
        ?>
-       <li><b class='error'>Warning:</b> <b>PHP's
+       <li><b class='error'>Warning:</strong> <strong>PHP's
        <tt><a href="http://php.net/register_globals">register_globals</a></tt>
-       option is enabled.</b> MediaWiki will work correctly, but this setting
+       option is enabled.</strong> MediaWiki will work correctly, but this setting
        increases your exposure to potential security vulnerabilities in PHP-based
-       software running on your server. <b>You should disable it if you are able.</b></li>
+       software running on your server. <strong>You should disable it if you are able.</strong></li>
        <?php
 }
 
 if( ini_get( "safe_mode" ) ) {
        ?>
-       <li class='error'><b>Warning: PHP's
-       <a href='http://www.php.net/features.safe-mode'>safe mode</a> is active!</b>
-       You will likely have problems caused by this. You may need to make the
-       'images' subdirectory writable or specify a TMP environment variable pointing to
-       a writable temporary directory owned by you, since safe mode breaks the system
-       temporary directory.</li>
+       <li class='error'><strong>Warning: PHP's
+       <a href='http://www.php.net/features.safe-mode'>safe mode</a> is active!</strong>
+       You may have problems caused by this, particularly if using image uploads.
+       </li>
+       <?php
+}
+
+$fatal = false;
+
+if( ini_get( "magic_quotes_runtime" ) ) {
+       $fatal = true;
+       ?><li class='error'><strong>Fatal: <a href='http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-runtime'>magic_quotes_runtime</a> is active!</strong>
+       This option corrupts data input unpredictably; you cannot install or use
+       MediaWiki unless this option is disabled.
        <?php
 }
 
+if( ini_get( "magic_quotes_sybase" ) ) {
+       $fatal = true;
+       ?><li class='error'><strong>Fatal: <a href='http://www.php.net/manual/en/ref.sybase.php#ini.magic-quotes-sybase'>magic_quotes_sybase</a> is active!</strong>
+       This option corrupts data input unpredictably; you cannot install or use
+       MediaWiki unless this option is disabled.
+       <?php
+}
+
+if( $fatal ) {
+       dieout( "</ul><p>Cannot install wiki.</p>" );
+}
+
 $sapi = php_sapi_name();
 $conf->prettyURLs = true;
 print "<li>PHP server API is $sapi; ";
@@ -246,7 +262,7 @@ $conf->raiseMemory = false;
 if( empty( $memlimit ) ) {
        print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
 } else {
-       print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". <b>If this is too low, installation may fail!</b> ";
+       print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". <strong>If this is too low, installation may fail!</strong> ";
        $n = IntVal( $memlimit );
        if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
                $n = IntVal( $m[1] * (1024*1024) );
@@ -315,13 +331,16 @@ $conf->IP = dirname( dirname( __FILE__ ) );
 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
 
 # $conf->ScriptPath = "/~brion/inplace";
-$conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["REQUEST_URI"] );
+$conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["PHP_SELF"] ); # was SCRIPT_NAME
 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
 
        $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
 
        $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
-       $conf->EmergencyContact = importPost( "EmergencyContact", $_SERVER["SERVER_ADMIN"] );
+       $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
+               ? 'root@localhost'
+               : $_SERVER["SERVER_ADMIN"];
+       $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail );
        $conf->DBserver = importPost( "DBserver", "localhost" );
        $conf->DBname = importPost( "DBname", "wikidb" );
        $conf->DBuser = importPost( "DBuser", "wikiuser" );
@@ -570,28 +589,18 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                        }
 
                        $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
-                       $now = wfTimestampNow();
+                       $article = new Article( $titleobj );
+                       $newid = $article->insertOn( $wgDatabase );
+                       $revision = new Revision( array(
+                               'page'      => $newid,
+                               'text'      => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsg( 'mainpagedocfooter' ),
+                               'comment'   => '',
+                               'user'      => 0,
+                               'user_text' => 'MediaWiki default',
+                               ) );
+                       $revid = $revision->insertOn( $wgDatabase );
+                       $article->updateRevisionOn( $wgDatabase, $revision );
                        
-                       extract( $wgDatabase->tableNames( 'text', 'page', 'revision' ) );
-                       $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
-                       $title = $titleobj->getDBkey();
-                       $sql = "INSERT INTO $text (old_text, old_flags) VALUES ('" .
-                               wfStrencode( wfMsg( "mainpagetext" ) . "\n\n" . wfMsg( "mainpagedocfooter" ) ) .
-                               "', '')";
-                       $wgDatabase->query( $sql, $fname );
-                       $text_id = $wgDatabase->insertID();
-
-                       $sql = "INSERT INTO $page (page_namespace, page_title, page_restrictions, page_counter, page_is_redirect, 
-                               page_is_new, page_random, page_touched, page_latest) VALUES (
-                               0, '{$title}', '', 0, 0, 1, 0.5, '{$now}', {$text_id} )";
-                       $wgDatabase->query( $sql, $fname );
-                       $page_id = $wgDatabase->insertID();
-
-                       $sql = "INSERT INTO $revision (rev_id, rev_page, rev_comment, rev_user, rev_user_text,
-                                       rev_timestamp, rev_minor_edit)
-                               VALUES ({$text_id}, {$page_id}, '', 0, 'MediaWiki default', '{$now}', 0)";
-                       $wgDatabase->query( $sql, $fname );
-
                        print "<li><pre>";
                        initialiseMessages();
                        print "</pre></li>\n";
@@ -674,6 +683,7 @@ if( count( $errs ) ) {
        <dd>
                <label class='column' for="LanguageCode">Language</label>
                <select id="LanguageCode" name="LanguageCode">
+
                <?php
                        $list = getLanguageList();
                        foreach( $list as $code => $name ) {
@@ -685,10 +695,8 @@ if( count( $errs ) ) {
        </dd>
        <dt>
                You may select the language for the user interface of the wiki...
-               Some localizations are less complete than others. This also controls
-               the character encoding; Unicode is more flexible, but Latin-1 may be
-               more compatible with older browsers for some languages. Unicode will
-               be used where not specified otherwise.
+               Some localizations are less complete than others. Unicode (UTF-8 encoding)
+               is used for all localizations.
        </dt>
 
        <dd>
@@ -920,13 +928,6 @@ if( count( $errs ) ) {
 
 /* -------------------------------------------------------------------------------------- */
 
-function writeAdminSettings( $conf ) {
-       return "
-\$wgDBadminuser      = \"{$conf->DBadminuser}\";
-\$wgDBadminpassword  = \"{$conf->DBadminpassword}\";
-";
-}
-
 function escapePhpString( $string ) {
        return strtr( $string,
                array(
@@ -943,12 +944,6 @@ function writeLocalSettings( $conf ) {
        $conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false';
        $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
        $conf->PasswordSender = $conf->EmergencyContact;
-       if( preg_match( '/^([a-z]+)-latin1$/', $conf->LanguageCode, $m ) ) {
-               $conf->LanguageCode = $m[1];
-               $conf->Latin1 = true;
-       } else {
-               $conf->Latin1 = false;
-       }
        $zlib = ($conf->zlib ? "" : "# ");
        $magic = ($conf->ImageMagick ? "" : "# ");
        $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
@@ -1001,14 +996,14 @@ function writeLocalSettings( $conf ) {
 
        $file = @fopen( "/dev/urandom", "r" );
        if ( $file ) {
-               $proxyKey = bin2hex( fread( $file, 32 ) );
+               $secretKey = bin2hex( fread( $file, 32 ) );
                fclose( $file );
        } else {
-               $proxyKey = "";
+               $secretKey = "";
                for ( $i=0; $i<8; $i++ ) {
-                       $proxyKey .= dechex(mt_rand(0, 0x7fffffff));
+                       $secretKey .= dechex(mt_rand(0, 0x7fffffff));
                }
-               print "<li>Warning: \$wgProxyKey is insecure</li>\n";
+               print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
        }
 
        # Add slashes to strings for double quoting
@@ -1084,12 +1079,12 @@ if ( \$wgCommandLineMode ) {
 ## Shared memory settings
 \$wgUseMemCached = $memcached;
 \$wgMemCachedServers = $mcservers;
-{$turck}\$wgUseTurckShm = function_exists( 'mmcache_get' ) && php_sapi_name() == 'apache';
-{$turck}\$wgUseEAccelShm = function_exists( 'eaccelerator_get' ) && php_sapi_name() == 'apache';
+{$turck}\$wgUseTurckShm = function_exists( 'mmcache_get' ) && ( php_sapi_name() == 'apache' || php_sapi_name() == 'apache2handler' );
+{$turck}\$wgUseEAccelShm = function_exists( 'eaccelerator_get' ) && ( php_sapi_name() == 'apache' || php_sapi_name() == 'apache2handler' );
 
 ## To enable image uploads, make sure the 'images' directory
 ## is writable, then uncomment this:
-# \$wgDisableUploads           = false;
+# \$wgEnableUploads            = true;
 \$wgUseImageResize             = {$conf->UseImageResize};
 {$magic}\$wgUseImageMagick = true;
 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
@@ -1104,9 +1099,8 @@ if ( \$wgCommandLineMode ) {
 \$wgLocalInterwiki   = \$wgSitename;
 
 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
-\$wgUseLatin1 = " . ($conf->Latin1 ? 'true' : 'false') . ";\n
 
-\$wgProxyKey = \"$proxyKey\";
+\$wgProxyKey = \"$secretKey\";
 
 ## Default skin: you can change the default skin. Use the internal symbolic
 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
@@ -1193,7 +1187,6 @@ function getLanguageList() {
        }
 
        $codes = array();
-       $latin1 = array( "da", "de", "en", "es", "fr", "nl", "sv" );
 
        $d = opendir( "../languages" );
        while( false !== ($f = readdir( $d ) ) ) {
@@ -1204,12 +1197,7 @@ function getLanguageList() {
                        } else {
                                $name = $code;
                        }
-                       if( in_array( $code, $latin1 ) ) {
-                               $codes[$code] = $name . " - Unicode";
-                               $codes[$code.'-latin1'] = $name . " - Latin-1";
-                       } else {
-                               $codes[$code] = $name;
-                       }
+                       $codes[$code] = $name;
                }
        }
        closedir( $d );