Further cleanup of index.php
[lhc/web/wiklou.git] / config / index.php
index 7893bb7..12c38ba 100644 (file)
@@ -30,7 +30,7 @@ header( "Content-type: text/html; charset=utf-8" );
        <title>MediaWiki installation</title>
        <style type="text/css">
 
-               @import "../skins/monobook/main.css"; 
+               @import "../skins/monobook/main.css";
 
                .env-check {
                        font-size: 90%;
@@ -123,8 +123,11 @@ header( "Content-type: text/html; charset=utf-8" );
 # As a dirty hack, we'll try to set up the include path first.
 #
 $IP = dirname( dirname( __FILE__ ) );
-$sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
-ini_set( "include_path", ".$sep$IP$sep$IP/includes$sep$IP/languages" );
+$sep = PATH_SEPARATOR;
+if( !ini_set( "include_path", ".$sep$IP$sep$IP/includes$sep$IP/languages" ) ) {
+       set_include_path( ".$sep$IP$sep$IP/includes$sep$IP/languages" );
+}
+
 
 define( "MEDIAWIKI", true );
 define( "MEDIAWIKI_INSTALL", true );
@@ -141,11 +144,9 @@ require_once( "includes/Namespace.php" );
 /* Check for existing configurations and bug out! */
 
 if( file_exists( "../LocalSettings.php" ) ) {
-       dieout( "<h2>Already configured</h2>
+       dieout( "       <p><strong>Setup has completed, <a href='../index.php'>your wiki</a> is configured.</strong></p>
 
-       <p><strong>Setup has completed, <a href='../index.php'>your wiki</a> is configured.</strong></p>
-
-       <p>Please delete the /config directory for extra security.</p>" );
+       <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
 }
 
 if( file_exists( "./LocalSettings.php" ) ) {
@@ -197,15 +198,17 @@ $conf = new ConfigData;
 
 install_version_checks();
 
-print "<li>PHP " . phpversion() . ": ok</li>\n";
+print "<li>PHP " . phpversion() . " installed</li>\n";
 
 if( ini_get( "register_globals" ) ) {
        ?>
-       <li><b class='error'>Warning:</b> <strong>PHP's
-       <tt><a href="http://php.net/register_globals">register_globals</a></tt>
-       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. <strong>You should disable it if you are able.</strong></li>
+       <li>
+               <div style="font-size:110%">
+               <strong class="error">Warning:</strong>
+               <strong>PHP's   <tt><a href="http://php.net/register_globals">register_globals</a></tt> option is enabled. Disable it if you can.</strong>
+               </div>
+               MediaWiki will work, but your server is more exposed to PHP-based security vulnerabilities.
+       </li>
        <?php
 }
 
@@ -227,6 +230,14 @@ if( ini_get( "magic_quotes_sybase" ) ) {
        <?php
 }
 
+if( ini_get( "mbstring.func_overload" ) ) {
+       $fatal = true;
+       ?><li class='error'><strong>Fatal: <a href='http://www.php.net/manual/en/ref.mbstring.php#mbstring.overload'>mbstring.func_overload</a> is active!</strong>
+       This option causes errors and may corrupt data unpredictably;
+       you cannot install or use MediaWiki unless this option is disabled.
+       <?php
+}
+
 if( $fatal ) {
        dieout( "</ul><p>Cannot install Mediawiki.</p>" );
 }
@@ -252,14 +263,15 @@ case "apache":
 case "apache2handler":
        print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
        break;
+default:
+       print "unknown; ";
 case "cgi":
 case "cgi-fcgi":
 case "apache2filter":
+case "isapi":
        print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
        $conf->prettyURLs = false;
        break;
-default:
-       print "unknown; using pretty URLs (<tt>index.php/Page_Title</tt>), if you have trouble change this in <tt>LocalSettings.php</tt>";
 }
 print "</li>\n";
 
@@ -316,8 +328,8 @@ if (!$conf->turck && !$conf->eaccel) {
 }
 
 $conf->diff3 = false;
-$diff3locations = array("/usr/bin", "/opt/csw/bin", "/usr/gnu/bin", "/usr/sfw/bin") + explode(":", getenv("PATH"));
-$diff3names = array("gdiff3", "diff3");
+$diff3locations = array("/usr/bin", "/opt/csw/bin", "/usr/gnu/bin", "/usr/sfw/bin") + explode($sep, getenv("PATH"));
+$diff3names = array("gdiff3", "diff3", "diff3.exe");
 
 $diff3versioninfo = array('$1 --version 2>&1', 'diff3 (GNU diffutils)');
 foreach ($diff3locations as $loc) {
@@ -367,7 +379,7 @@ print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt
 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["PHP_SELF"] ); # was SCRIPT_NAME
 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
 
-print "<li style='font-weight:bold;color:green'>Environment checked. You can install MediaWiki.</li>\n";
+print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
        $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
 
        $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
@@ -382,9 +394,10 @@ print "<li style='font-weight:bold;color:green'>Environment checked. You can ins
        $conf->DBpassword = importPost( "DBpassword" );
        $conf->DBpassword2 = importPost( "DBpassword2" );
        $conf->DBprefix = importPost( "DBprefix" );
+       $conf->DBmysql5 = (importPost( "DBmysql5" ) == "true") ? "true" : "false";
        $conf->RootPW = importPost( "RootPW" );
        $conf->LanguageCode = importPost( "LanguageCode", "en" );
-       $conf->SysopName = importPost( "SysopName", "WikiAdmin" );
+       $conf->SysopName = importPost( "SysopName", "WikiSysop" );
        $conf->SysopPass = importPost( "SysopPass" );
        $conf->SysopPass2 = importPost( "SysopPass2" );
 
@@ -392,7 +405,7 @@ print "<li style='font-weight:bold;color:green'>Environment checked. You can ins
 $errs = array();
 
 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
-       $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
+       $errs["Sitename"] = "Must not be blank or \"MediaWiki\"";
 }
 if( $conf->DBuser == "" ) {
        $errs["DBuser"] = "Must not be blank";
@@ -570,6 +583,14 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                                <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
                                >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
                }
+               if( $wgDBmysql5 ) {
+                       if( $mysqlNewAuth ) {
+                               print "; enabling MySQL 4.1/5.0 charset mode";
+                       } else {
+                               print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
+                                       but older version detected; will likely fail.</b>";
+                       }
+               }
                print "</li>\n";
 
                if ($conf->DBtype == 'mysql') {
@@ -627,7 +648,13 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                        # FIXME: Check for errors
                        print "<li>Creating tables...";
                        if ($conf->DBtype == 'mysql') {
-                               dbsource( "../maintenance/tables.sql", $wgDatabase );
+                               if( $wgDBmysql5 ) {
+                                       print " using MySQL 5 table defs...";
+                                       dbsource( "../maintenance/mysql5/tables.sql", $wgDatabase );
+                               } else {
+                                       print " using MySQL 4 table defs...";
+                                       dbsource( "../maintenance/tables.sql", $wgDatabase );
+                               }
                                dbsource( "../maintenance/interwiki.sql", $wgDatabase );
                        } else {
                                dbsource( "../maintenance/oracle/tables.sql", $wgDatabase );
@@ -740,7 +767,8 @@ if( count( $errs ) ) {
                ?>
        </div>
        <p class="config-desc">
-               Preferably a short word without punctuation, i.e. "Wikipedia". Will appear as the namespace name for "meta" pages, and throughout the interface.
+               Preferably a short word without punctuation, i.e. "Wikipedia".<br>
+               Will appear as the namespace name for "meta" pages, and throughout the interface.
        </p>
 
        <div class="config-input">
@@ -809,10 +837,8 @@ if( count( $errs ) ) {
                <?php aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?>
        </div>
        <p class="config-desc">
-               An admin user account can lock or delete pages, block problematic IP
-               addresses from editing, and other maintenance tasks. If creating a new
-               wiki database, an admin account will be created with the given name
-               and password.
+               An admin can lock/delete pages, block users from editing, and other maintenance tasks.<br>
+               A new account will be added only when creating a new wiki database.
        </p>
 
        <div class="config-input">
@@ -874,8 +900,8 @@ if( count( $errs ) ) {
                <label class='column'>E-mail notification:</label>
                <ul class="plain">
                <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
-               <li><?php aField( $conf, "Enotif", "Enabled for changes of watch-listed and user_talk pages (recommended for small wikis; perhaps not suited for large wikis)", "radio", "enotif_allpages" ); ?></li>
-               <li><?php aField( $conf, "Enotif", "Enabled for changes of user_talk pages only (suited for small and large wikis)", "radio", "enotif_usertalk" ); ?></li>
+               <li><?php aField( $conf, "Enotif", "Enabled for user_talk changes only", "radio", "enotif_usertalk" ); ?></li>
+               <li><?php aField( $conf, "Enotif", "Enabled for user_talk and watch list changes (not recommended for large wikis)", "radio", "enotif_allpages" ); ?></li>
                </ul>
        </div>
        <div class="config-desc">
@@ -962,6 +988,20 @@ if( count( $errs ) ) {
                <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
        </div>
 
+       <div class="config-input"><label class="column">Database charset</label>
+               <div>Select one:</div>
+               <ul class="plain">
+               <li><?php aField( $conf, "DBmysql5", "Backwards-compatible UTF-8", "radio", "false" ); ?></li>
+               <li><?php aField( $conf, "DBmysql5", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "true" ); ?></li>
+               </ul>
+       </div>
+       <p class="config-desc">
+               <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support
+               for MySQL 4.1 and 5.0 servers. This is not well tested and may
+               cause things to break. <b>If upgrading an older installation, leave
+               in backwards-compatible mode.</b>
+       </p>
+
        <div class="config-input">
                <?php
                aField( $conf, "RootPW", "DB root password:", "password" );
@@ -989,7 +1029,6 @@ if( count( $errs ) ) {
 
 /* -------------------------------------------------------------------------------------- */
 function writeSuccessMessage() {
-       global $conf;
        if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
                echo <<<EOT
 <p>Installation successful!</p>
@@ -1094,7 +1133,7 @@ function writeLocalSettings( $conf ) {
                $slconf['RightsIcon'] = $conf->RightsIcon;
        }
 
-       $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
+       $sep = PATH_SEPARATOR;
        $localsettings = "
 # This file was automatically generated by the MediaWiki installer.
 # If you make manual changes, please keep track in case you need to
@@ -1105,7 +1144,9 @@ function writeLocalSettings( $conf ) {
 # file, not there.
 
 \$IP = \"{$slconf['IP']}\";
-ini_set( \"include_path\", \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" );
+if( !ini_set( \"include_path\", \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" ) ) {
+       set_include_path( \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" );
+}
 require_once( \"includes/DefaultSettings.php\" );
 
 # If PHP's memory limit is very low, some operations may fail.
@@ -1159,6 +1200,9 @@ if ( \$wgCommandLineMode ) {
 \$wgDBprefix         = \"{$slconf['DBprefix']}\";
 \$wgDBtype           = \"{$slconf['DBtype']}\";
 
+# Experimental charset support for MySQL 4.1/5.0.
+\$wgDBmysql5 = {$conf->DBmysql5};
+
 ## Shared memory settings
 \$wgMainCacheType = $cacheType;
 \$wgMemCachedServers = $mcservers;
@@ -1237,7 +1281,7 @@ function importRequest( $name, $default = "" ) {
 $radioCount = 0;
 
 function aField( &$conf, $field, $text, $type = "text", $value = "" ) {
-       global $radioCount; 
+       global $radioCount;
        if( $type != "" ) {
                $xtype = "type=\"$type\"";
        } else {
@@ -1246,10 +1290,10 @@ function aField( &$conf, $field, $text, $type = "text", $value = "" ) {
 
        if(!(isset($id)) or ($id == "") ) $id = $field;
        $nolabel = ($type == "radio") || ($type == "hidden");
-       
+
        if ($type == 'radio')
                $id .= $radioCount++;
-       
+
        if( $nolabel ) {
                echo "\t\t<label>";
        } else {
@@ -1289,6 +1333,7 @@ function getLanguageList() {
 
        $d = opendir( "../languages" );
        while( false !== ($f = readdir( $d ) ) ) {
+               $m = array();
                if( preg_match( '/Language([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
                        $code = str_replace( '_', '-', strtolower( $m[1] ) );
                        if( isset( $wgLanguageNames[$code] ) ) {
@@ -1313,13 +1358,14 @@ function locate_executable($loc, $names, $versioninfo = false) {
                $names = array($names);
 
        foreach ($names as $name) {
-               if (file_exists("$loc/$name")) {
+               $command = "$loc".DIRECTORY_SEPARATOR."$name";
+               if (file_exists($command)) {
                        if (!$versioninfo)
-                               return "$loc/$name";
+                               return $command;
 
-                       $file = str_replace('$1', "$loc/$name", $versioninfo[0]);
+                       $file = str_replace('$1', $command, $versioninfo[0]);
                        if (strstr(`$file`, $versioninfo[1]) !== false)
-                               return "$loc/$name";
+                               return $command;
                }
        }
        return false;
@@ -1403,18 +1449,20 @@ function testMemcachedServer( $server ) {
 <div id="column-one">
        <div class="portlet" id="p-logo">
          <a style="background-image: url(../skins/common/images/mediawiki.png);"
-           href="/phase3/index.php/Main_Page"
+           href="http://www.mediawiki.org/"
            title="Main Page"></a>
        </div>
        <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
        <div class='portlet'><div class='pBody'>
-               <p style="font-size:90%"><strong><a href="http://www.mediawiki.org/">MediaWiki</a></strong> is Copyright (C) 2001-2005 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, Tim Starling, Erik M&ouml;ller, Gabriel Wicke and others.</p>
                <ul>
+                       <li><strong><a href="http://www.mediawiki.org/">MediaWiki home</a></strong></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="../docs/">Documentation</a></li>
                        <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li>
+                       <li><a href="http://meta.wikimedia.org/wiki/MediaWiki_FAQ">FAQ</a></li>
                </ul>
+               <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright &copy; 2001-2006 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, Tim Starling, Erik M&ouml;ller, Gabriel Wicke and others.</p>
        </div></div>
 </div>