typo
[lhc/web/wiklou.git] / config / index.php
index cc22169..9eab263 100644 (file)
@@ -87,7 +87,7 @@ header( "Content-type: text/html; charset=utf-8" );
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.</p>
  
- <p>This progarm is distributed in the hope that it will be useful,
+ <p>This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.</p>
@@ -99,6 +99,7 @@ header( "Content-type: text/html; charset=utf-8" );
 </div>
 
 <?php
+$IP = ".."; # Just to suppress notices, not for anything useful
 include( "../includes/DefaultSettings.php" );
 ?>
 
@@ -165,39 +166,58 @@ class ConfigData {
 <h2>Checking environment...</h2>
 <ul>
 <?php
-
+$endl = "
+";
 $conf = new ConfigData;
 
 install_version_checks();
 print "<li>PHP " . phpversion() . " ok</li>\n";
 
-/*
+$sapi = php_sapi_name();
+$conf->prettyURLs = true;
+print "<li>PHP server API is $sapi; ";
+switch( $sapi ) {
+case "apache":
+       print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
+       break;
+case "cgi":
+case "cgi-fcgi":
+       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";
+
 $conf->zlib = function_exists( "gzencode" );
-$z = $conf->zlib ? "Have" : "No";
-print "<li>$z zlib support</li>\n";
-*/
+if( $conf->zlib ) {
+       print "<li>Have zlib support; enabling output compression.</li>\n";
+} else {
+       print "<li>No zlib support.</li>\n";
+}
+
+$conf->ImageMagick = false;
 
 $conf->HaveGD = function_exists( "imagejpeg" );
 if( $conf->HaveGD ) {
        print "<li>Found GD graphics library built-in, image thumbnailing will be enabled if you enable uploads.</li>\n";
 } else {
-       print "<li>No built-in GD library, image thumbnailing disabled.</li>\n";
-}
-
-/*
-if( file_exists( "/usr/bin/convert" ) ) {
-       $conf->ImageMagick = "/usr/bin/convert";
-       print "<li>Found ImageMagick: /usr/bin/convert</li>\n";
-} elseif( file_exists( "/usr/local/bin/convert" ) ) {
-       $conf->ImageMagick = "/usr/local/bin/convert";
-       print "<li>Found ImageMagick: /usr/local/bin/convert</li>\n";
-} else {
-       $conf->ImageMagick = false;
-       print "<li>No ImageMagick.</li>\n";
+       $imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin" );
+       foreach( $imcheck as $dir ) {
+               $im = "$dir/convert";
+               if( file_exists( $im ) ) {
+                       print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
+                       $conf->ImageMagick = $im;
+                       break;
+               }
+       }
+       if( !$conf->ImageMagick ) {
+               print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
+       }
 }
-*/
 
-$conf->UseImageResize = $conf->HaveGD;
+$conf->UseImageResize = $conf->HaveGD || $conf->ImageMagick;
 
 # $conf->IP = "/Users/brion/Sites/inplace";
 chdir( ".." );
@@ -261,19 +281,9 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                include_once( "../maintenance/InitialiseMessages.inc" );
 
                $wgTitle = Title::newFromText( "Installation script" );
-               
-               if( $conf->Root ) {
-                       $wgDatabase = Database::newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 );
-               } else {
-                       $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
-               }
+               $wgDatabase = Database::newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 );
                $wgDatabase->mIgnoreErrors = true;
                
-               if ( !$wgDatabase->isOpen() ) {
-                       $errs["DBserver"] = "Couldn't connect to database";
-                       continue;
-               }
-
                @$myver = mysql_get_server_info( $wgDatabase->mConn );
                if( !$myver ) {
                        print "<li>MySQL error " . ($err = mysql_errno() ) .
@@ -284,9 +294,9 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                                if( $conf->Root ) {
                                        $errs["RootPW"] = "Check password";
                                } else {
-                                       print "<li>Trying root...\n";
-                                       /* Try a blank root password... */
-                                       $wgDatabase = Database::newFromParams( $wgDBserver, "root", "", "", 1 );
+                                       print "<li>Trying regular user...\n";
+                                       /* Try the regular user... */
+                                       $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
                                        $wgDatabase->isOpen();
                                        $wgDatabase->mIgnoreErrors = true;
                                        @$myver = mysql_get_server_info( $wgDatabase->mConn );
@@ -315,6 +325,12 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                        }
                        if( !$ok ) continue;
                }
+               
+               if ( !$wgDatabase->isOpen() ) {
+                       $errs["DBserver"] = "Couldn't connect to database";
+                       continue;
+               }
+
                print "<li>Connected to database... $myver";
                if( version_compare( $myver, "4.0.0" ) >= 0 ) {
                        print "; enabling MySQL 4 enhancements";
@@ -374,7 +390,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                                        $u->addToDatabase();
                                        $u->setPassword( $conf->getSysopPass() );
                                        $u->addRight( "sysop" );
-                                       $u->addRight( "developer" ); /* ?? */
+                                       $u->addRight( "bureaucrat" );
                                        $u->saveSettings();
                                        print "<li>Created sysop account <tt>" .
                                                htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
@@ -390,7 +406,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                                "uploadlogpage" => "uploadlogpagetext",
                                "dellogpage" => "dellogpagetext",
                                "protectlogpage" => "protectlogtext",
-                               "blocklogpage" => "bloglogtext"
+                               "blocklogpage" => "blocklogtext"
                        );
                        $metaNamespace = Namespace::getWikipedia();
                        $now = wfTimestampNow();
@@ -411,9 +427,9 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                          wfStrencode( wfMsg( "mainpagetext" ) ) . "','$now','$won','$now')";
                        $wgDatabase->query( $sql, $fname );
                        
-                       print "<li>";
+                       print "<li><pre>";
                        initialiseMessages();
-                       print "</li>\n";
+                       print "</pre></li>\n";
                        
                        if( $conf->Root ) {
                                # Grant user permissions
@@ -423,8 +439,15 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
 
                /* Write out the config file now that all is well */
                print "<p>Creating LocalSettings.php...</p>\n\n";
-               $localSettings =  "<" . "?php\n$local\n?" . ">";
-               $f = fopen( "LocalSettings.php", "xt" );
+               $localSettings =  "<" . "?php$endl$local$endl?" . ">";
+               
+               if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
+                       $xt = "xt"; # Refuse to overwrite an existing file
+               } else {
+                       $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
+               }
+               $f = fopen( "LocalSettings.php", $xt );
+               
                if( $f == false ) {
                        dieout( "Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a file of that name here...</p>\n" .
                        "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
@@ -584,20 +607,24 @@ function writeAdminSettings( $conf ) {
 }
 
 function writeLocalSettings( $conf ) {
-       $conf->DBmysql4 = $conf->DBmysql4 ? 'true' : 'false';
+       $conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false';
        $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
-       $conf->DBsqluser = $conf->DBuser;
-       $conf->DBsqlpassword = $conf->DBpassword;
        $conf->PasswordSender = $conf->EmergencyContact;
        if( $conf->LanguageCode == "en-utf8" ) {
                $conf->LanguageCode = "en";
                $conf->Encoding = "UTF-8";
        }
+       $zlib = ($conf->zlib ? "" : "# ");
+       $magic = ($conf->ImageMagick ? "" : "# ");
+       $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
+       $pretty = ($conf->prettyURLs ? "" : "# ");
+       $ugly = ($conf->prettyURLs ? "# " : "");
+       
        $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
        return "
-# This file was automatically generated. Don't touch unless you
-# know what you're doing; see LocalSettings.sample for an edit-
-# friendly file.
+# This file was automatically generated by the MediaWiki installer.
+# If you make manual changes, please keep track in case you need to
+# recreate them later.
 
 \$IP = \"{$conf->IP}\";
 ini_set( \"include_path\", \"\$IP/includes$sep\$IP/languages$sep\" . ini_get(\"include_path\") );
@@ -605,6 +632,9 @@ include_once( \"DefaultSettings.php\" );
 
 if( \$wgCommandLineMode ) {
        die( \"Can't use command-line utils with in-place install yet, sorry.\" );
+} else {
+       ## Compress output if the browser supports it
+       {$zlib}if( !ini_get( 'zlib.output_compression' ) ) ob_start( 'ob_gzhandler' );
 }
 
 \$wgSitename         = \"{$conf->Sitename}\";
@@ -613,7 +643,9 @@ if( \$wgCommandLineMode ) {
 \$wgScript           = \"\$wgScriptPath/index.php\";
 \$wgRedirectScript   = \"\$wgScriptPath/redirect.php\";
 
-\$wgArticlePath      = \"\$wgScript/\$1\";
+## If using PHP as a CGI module, use the ugly URLs
+{$pretty}\$wgArticlePath      = \"\$wgScript/\$1\";
+{$ugly}\$wgArticlePath      = \"\$wgScript?title=\$1\";
 
 \$wgStyleSheetPath   = \"\$wgScriptPath/stylesheets\";
 \$wgStyleSheetDirectory = \"\$IP/stylesheets\";
@@ -629,8 +661,16 @@ if( \$wgCommandLineMode ) {
 \$wgDBname           = \"{$conf->DBname}\";
 \$wgDBuser           = \"{$conf->DBuser}\";
 \$wgDBpassword       = \"{$conf->DBpassword}\";
-\$wgDBsqluser        = \"{$conf->DBsqluser}\";
-\$wgDBsqlpassword      = \"{$conf->DBsqlpassword}\";
+
+## To allow SQL queries through the wiki's Special:Askaql page,
+## uncomment the next lines. THIS IS VERY INSECURE. If you want
+## to allow semipublic read-only SQL access for your sysops,
+## you should define a MySQL user with limited privileges.
+## See MySQL docs: http://www.mysql.com/doc/en/GRANT.html
+#
+# \$wgAllowSysopQueries = true;
+# \$wgDBsqluser        = \"sqluser\";
+# \$wgDBsqlpassword    = \"sqlpass\";
 
 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
 
@@ -638,13 +678,25 @@ if( \$wgCommandLineMode ) {
 ## is writable, then uncomment this:
 # \$wgDisableUploads           = false;
 \$wgUseImageResize             = {$conf->UseImageResize};
+{$magic}\$wgUseImageMagick = true;
+{$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
 
 ## If you have the appropriate support software installed
 ## you can enable inline LaTeX equations:
 # \$wgUseTeX                   = true;
-# \$wgMathPath         = \"{\$wgUploadPath}/math\";
-# \$wgMathDirectory    = \"{\$wgUploadDirectory}/math\";
-# \$wgTmpDirectory     = \"{\$wgUploadDirectory}/tmp\";
+\$wgMathPath         = \"{\$wgUploadPath}/math\";
+\$wgMathDirectory    = \"{\$wgUploadDirectory}/math\";
+\$wgTmpDirectory     = \"{\$wgUploadDirectory}/tmp\";
+
+## Experimental layout template subsystems
+\$wgUsePHPTal = false;
+\$wgUseSmarty = false;
+if ( \$wgUsePHPTal ) {
+      ini_set( \"include_path\", \"\$IP/PHPTAL-NP-0.7.0/libs$sep\" . ini_get(\"include_path\") );
+}
+if ( \$wgUseSmarty ) {
+      ini_set( \"include_path\", \"\$IP/Smarty-2.6.2/libs$sep\" . ini_get(\"include_path\") );
+}
 
 \$wgLocalInterwiki   = \$wgSitename;
 
@@ -687,7 +739,7 @@ function getLanguageList() {
        }
        
        $codes = array();
-       $latin1 = array( "da", "de", "en", "es", "fr", "nl", "sv" );
+       $latin1 = array( "da", "de", "en", "es", "nl", "sv" );
        
        $d = opendir( "../languages" );
        while( false !== ($f = readdir( $d ) ) ) {
@@ -708,4 +760,4 @@ function getLanguageList() {
 ?>
 
 </body>
-</html>
\ No newline at end of file
+</html>