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>
</div>
<?php
+$IP = ".."; # Just to suppress notices, not for anything useful
include( "../includes/DefaultSettings.php" );
?>
(You should remove this config directory for added security once you're done.)</p>" );
}
+if( !is_writable( "." ) ) {
+ dieout( "<h2>Can't write config file, aborting</h2>
+
+ <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
+ writable by the web server. Once configuration is done you'll move the created
+ <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
+ then remove the <tt>config</tt> subdirectory entirely.</p>
+
+ <p>To make the directory writable on a Unix/Linux system:</p>
+
+ <pre>
+ cd <i>/path/to/wiki</i>
+ chmod a+w config
+ </pre>" );
+}
+
include( "../install-utils.inc" );
+include( "../maintenance/updaters.inc" );
class ConfigData {
function getEncoded( $data ) {
# Hackish
<h2>Checking environment...</h2>
<ul>
<?php
-
+$endl = "
+";
$conf = new ConfigData;
install_version_checks();
print "<li>PHP " . phpversion() . " ok</li>\n";
-/*
-$conf->zlib = function_exists( "gzencode" );
-$z = $conf->zlib ? "Have" : "No";
-print "<li>$z zlib support</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->gd = function_exists( "imagejpeg" );
-if( $conf->gd ) {
- print "<li>Found GD graphics library built-in</li>\n";
+$conf->zlib = function_exists( "gzencode" );
+if( $conf->zlib ) {
+ print "<li>Have zlib support; enabling output compression.</li>\n";
} else {
- print "<li>No built-in GD library</li>\n";
+ print "<li>No zlib support.</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";
+$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 {
- $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->ImageMagick;
# $conf->IP = "/Users/brion/Sites/inplace";
chdir( ".." );
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() ) .
": " . htmlspecialchars( mysql_error() );
+ $ok = false;
switch( $err ) {
case 1045:
if( $conf->Root ) {
$errs["RootPW"] = "Check password";
} else {
- $errs["DBuser"] = "Check name/pass";
- $errs["DBpassword"] = "or enter root";
- $errs["DBpassword2"] = "password below";
- $errs["RootPW"] = "Got root?";
+ 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 );
+ if( !$myver ) {
+ $errs["DBuser"] = "Check name/pass";
+ $errs["DBpassword"] = "or enter root";
+ $errs["DBpassword2"] = "password below";
+ $errs["RootPW"] = "Got root?";
+ print " need password.</li>\n";
+ } else {
+ $conf->Root = true;
+ $conf->RootPW = "";
+ print " ok.</li>\n";
+ # And keep going...
+ $ok = true;
+ }
+ break;
}
- break;
case 2002:
case 2003:
$errs["DBserver"] = "Connection failed";
break;
default:
$errs["DBserver"] = "Couldn't connect to database";
+ break;
}
+ 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";
$wgDatabase->selectDB( $wgDBname );
if( $wgDatabase->tableExists( "cur" ) ) {
- print "<li>There are already MediaWiki tables in this database. Skipping rest of database setup...</li>\n";
+ print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n<pre>";
+
+ chdir( ".." );
+ flush();
+ do_ipblocks_update(); flush();
+ do_interwiki_update(); flush();
+ do_index_update(); flush();
+ do_linkscc_update(); flush();
+ do_hitcounter_update(); flush();
+ do_recentchanges_update(); flush();
+ initialiseMessages(); flush();
+ chdir( "config" );
+
+ print "</pre>\n";
+ print "<li>Finished update checks.</li>\n";
} else {
# FIXME: Check for errors
print "<li>Creating tables...";
$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";
print "<li>Skipped sysop account creation, no name given.</li>\n";
}
- # FIXME: Main page, logs
- # FIXME: Initialize messages
- print "<li>(NYI: pages)</li>\n";
+ print "<li>Initialising log pages...";
+ $logs = array(
+ "uploadlogpage" => "uploadlogpagetext",
+ "dellogpage" => "dellogpagetext",
+ "protectlogpage" => "protectlogtext",
+ "blocklogpage" => "blocklogtext"
+ );
+ $metaNamespace = Namespace::getWikipedia();
+ $now = wfTimestampNow();
+ $won = wfInvertTimestamp( $now );
+ foreach( $logs as $page => $text ) {
+ $logTitle = wfStrencode( $wgLang->ucfirst( str_replace( " ", "_", wfMsgNoDB( $page ) ) ) );
+ $logText = wfStrencode( wfMsgNoDB( $text ) );
+ $wgDatabase->query( "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
+ "cur_restrictions,cur_timestamp,inverse_timestamp,cur_touched) " .
+ "VALUES ($metaNamespace,'$logTitle','$logText','sysop','$now','$won','$now')" );
+ }
+ print "</li>\n";
+
+ $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
+ $title = $titleobj->getDBkey();
+ $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text,cur_timestamp,inverse_timestamp,cur_touched) " .
+ "VALUES (0,'$title','" .
+ 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
/* Write out the config file now that all is well */
print "<p>Creating LocalSettings.php...</p>\n\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 fiel of that name here." );
+ 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" .
+ "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
}
- fwrite( $f, "<" . "?php\n$local\n?" . ">" );
+ fwrite( $f, $localSettings );
fclose( $f );
print "<p>Success! Move the LocalSettings.php file into the parent directory, then follow
}
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:\$IP/languages:\" . ini_get(\"include_path\") );
+ini_set( \"include_path\", \"\$IP/includes$sep\$IP/languages$sep\" . ini_get(\"include_path\") );
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}\";
\$wgScript = \"\$wgScriptPath/index.php\";
\$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
-\$wgArticlePath = \"\$wgScript?title=\$1\";
-# \$wgArticlePath = \"\$wgScript/\$1\"; # Prettier if you're setup for it
+## 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\";
\$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};
+## To enable image uploads, make sure the 'images' directory
+## 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;
}
$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 ) ) ) {
?>
</body>
-</html>
\ No newline at end of file
+</html>