# MediaWiki web-based config/installation
# Copyright (C) 2004 Brion Vibber <brion@pobox.com>
# http://www.mediawiki.org/
-#
+#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
-#
+#
# 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.
-#
+#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
padding: 8px;
margin-left: 8px;
}
-
+
dl.setup dd {
margin-left: 0;
}
<a href="http://www.mediawiki.org/"><img
src="../stylesheets/images/wiki.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,
- Tim Starling, Erik Möller, and others.</p>
-
+ Tim Starling, Erik Möller, Gabriel Wicke 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>
</ul>
-
+
<p>This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.</p>
-
+
<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>
-
+
<p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
$IP = ".."; # Just to suppress notices, not for anything useful
define( "MEDIAWIKI", true );
define( "MEDIAWIKI_INSTALL", true );
+require_once( "../includes/Defines.php" );
require_once( "../includes/DefaultSettings.php" );
require_once( "../includes/MagicWord.php" );
require_once( "../includes/Namespace.php" );
if( file_exists( "../LocalSettings.php" ) || file_exists( "../AdminSettings.php" ) ) {
dieout( "<h2>Wiki is configured.</h2>
-
+
<p>Already configured... <a href='../index.php'>return to the wiki</a>.</p>
-
+
<p>(You should probably remove this directory for added security.)</p>" );
}
if( file_exists( "./LocalSettings.php" ) || file_exists( "./AdminSettings.php" ) ) {
dieout( "<h2>You're configured!</h2>
-
+
<p>Please move <tt>LocalSettings.php</tt> to the parent directory, then
<a href='../index.php'>try out your wiki</a>.
(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
<?php
$endl = "
";
+$wgConfiguring = true;
$conf = new ConfigData;
install_version_checks();
-print "<li>PHP " . phpversion() . " ok</li>\n";
+
+print "<li>PHP " . phpversion() . ": ";
+if( version_compare( phpversion(), "5.0", "lt" ) ) {
+ print "ok";
+} else {
+ print " <b>the MonoBook skin will be disabled due to an incompatibility
+ between the PHPTAL template library and PHP 5</b>. The wiki should
+ function normally, but with the older look and feel.";
+}
+print "</li>\n";
+
+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>
+ <?php
+}
$sapi = php_sapi_name();
$conf->prettyURLs = true;
# $conf->IP = "/Users/brion/Sites/inplace";
chdir( ".." );
$conf->IP = getcwd();
-$conf->IP = preg_replace( "/\\\\/","\\\\\\\\",$conf->IP ); // For Windows, \ -> \\
chdir( "config" );
print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
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"] );
$conf->DBserver = importPost( "DBserver", "localhost" );
$conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html";
$conf->RightsText = "GNU Free Documentation License 1.2";
$conf->RightsCode = "gfdl";
- $conf->RightsIcon = "{$conf->ScriptPath}/stylesheets/images/gnu-fdl.png";
+ $conf->RightsIcon = '${wgStylePath}/images/gnu-fdl.png';
} elseif( $conf->License == "none" ) {
$conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = "";
} else {
if( $conf->posted && ( 0 == count( $errs ) ) ) {
do { /* So we can 'continue' to end prematurely */
$conf->Root = ($conf->RootPW != "");
-
+
/* Load up the settings and get installin' */
$local = writeLocalSettings( $conf );
$wgCommandLineMode = false;
$wgTitle = Title::newFromText( "Installation script" );
$wgDatabase = Database::newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 );
$wgDatabase->mIgnoreErrors = true;
-
+
@$myver = mysql_get_server_info( $wgDatabase->mConn );
if( $myver ) {
$conf->Root = true;
}
if( !$ok ) continue;
}
-
+
if ( !$wgDatabase->isOpen() ) {
$errs["DBserver"] = "Couldn't connect to database";
continue;
$local = writeLocalSettings( $conf );
}
print "</li>\n";
-
+
@$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn );
if( $sel ) {
print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
}
print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
}
-
+
$wgDatabase->selectDB( $wgDBname );
-
+
if( $wgDatabase->tableExists( "cur" ) ) {
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_querycache_update(); flush();
do_objectcache_update(); flush();
do_categorylinks_update(); flush();
-
+ do_image_name_unique_update(); flush();
+
if ( isTemplateInitialised() ) {
print "Template namespace already initialised\n";
} else {
initialiseMessages(); flush();
chdir( "config" );
-
+
print "</pre>\n";
print "<li>Finished update checks.</li>\n";
} else {
dbsource( "../maintenance/interwiki.sql", $wgDatabase );
dbsource( "../maintenance/indexes.sql", $wgDatabase );
print " done.</li>\n";
-
+
print "<li>Initializing data...";
$wgDatabase->query( "INSERT INTO site_stats (ss_row_id,ss_total_views," .
"ss_total_edits,ss_good_articles) VALUES (1,0,0,0)" );
- # setting up the db user
+ # setting up the db user
if( $conf->Root ) {
print "<li>Granting user permissions...</li>\n";
dbsource( "../maintenance/users.sql", $wgDatabase );
}
-
+
if( $conf->SysopName ) {
$u = User::newFromName( $conf->getSysopName() );
if ( 0 == $u->idForName() ) {
} else {
print "<li>Skipped sysop account creation, no name given.</li>\n";
}
-
+
print "<li>Initialising log pages...";
$logs = array(
"uploadlogpage" => "uploadlogpagetext",
$now = wfTimestampNow();
$won = wfInvertTimestamp( $now );
foreach( $logs as $page => $text ) {
- $logTitle = wfStrencode( $wgLang->ucfirst( str_replace( " ", "_", wfMsgNoDB( $page ) ) ) );
- $logText = wfStrencode( wfMsgNoDB( $text ) );
+ $logTitle = $wgDatabase->strencode( $wgLang->ucfirst( str_replace( " ", "_", wfMsgNoDB( $page ) ) ) );
+ $logText = $wgDatabase->strencode( 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" ) . "\n\n" . wfMsg( "mainpagedocfooter" ) ) . "','$now','$won','$now')";
$wgDatabase->query( $sql, $fname );
-
+
print "<li><pre>";
initialiseMessages();
print "</pre></li>\n";
/* Write out the config file now that all is well */
print "<p>Creating LocalSettings.php...</p>\n\n";
$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( "<p>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" .
}
fwrite( $f, $localSettings );
fclose( $f );
-
- print "<p>Success! Move the LocalSettings.php file into the parent directory, then follow
+
+ print "<p>Success! Move the config/LocalSettings.php file into the parent directory, then follow
<a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
-
+
} while( false );
}
?>
if( count( $errs ) ) {
/* Display options form */
-
+
if( $conf->posted ) {
echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
}
more compatible with older browsers for some languages. Unicode will
be used where not specified otherwise.
</dt>
-
+
<dd>
<label class='column'>Copyright/license metadata</label>
<div>Select one:</div>
<li><?php aField( $conf, "License", "no license metadata", "radio", "none" ); ?></li>
<li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li>
<li><?php
- aField( $conf, "License", "a Creative Commons license...", "radio", "cc" );
+ aField( $conf, "License", "a Creative Commons license...", "radio", "cc" );
$partner = "MediaWiki";
$exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
$icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
the GNU FDL or a Creative Commons license. If you're not sure, leave
it at "none".
</dt>
-
-
+
+
<dd>
<?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
</dd>
";
}
+function escapePhpString( $string ) {
+ return strtr( $string,
+ array(
+ "\n" => "\\n",
+ "\r" => "\\r",
+ "\t" => "\\t",
+ "\\" => "\\\\",
+ "\$" => "\\\$",
+ "\"" => "\\\""
+ ));
+}
+
function writeLocalSettings( $conf ) {
$conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false';
$conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
$pretty = ($conf->prettyURLs ? "" : "# ");
$ugly = ($conf->prettyURLs ? "# " : "");
$rights = ($conf->RightsUrl) ? "" : "# ";
-
+
$file = @fopen( "/dev/random", "r" );
if ( $file ) {
$proxyKey = bin2hex( fread( $file, 32 ) );
for ( $i=0; $i<8; $i++ ) {
$proxyKey .= dechex(mt_rand(0, 0x7fffffff));
}
- print "Warning: \$wgProxyKey is insecure\n";
+ print "<li>Warning: \$wgProxyKey is insecure</li>\n";
}
# Add slashes to strings for double quoting
- $slconf = array_map( "addslashes", get_object_vars( $conf ) );
+ $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
+
-
$sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
return "
# This file was automatically generated by the MediaWiki installer.
if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
die( \"This script must be run from the command line\\n\" );
}
-} else {
+} elseif ( empty( \$wgConfiguring ) ) {
## Compress output if the browser supports it
{$zlib}if( !ini_get( 'zlib.output_compression' ) ) ob_start( 'ob_gzhandler' );
}
} else {
$xtype = "";
}
-
+
if(!(isset($id)) or ($id == "") ) $id = $field;
$nolabel = ($type == "radio") || ($type == "hidden");
if( $nolabel ) {
} else {
echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
}
-
+
if( $type == "radio" && $value == $conf->$field ) {
$checked = "checked='checked'";
} else {
if( $nolabel ) {
echo " $text</label>\n";
}
-
+
global $errs;
if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
}
function wfLocalUrlE( $x ) { return $x; }
require_once( "../languages/Names.php" );
}
-
+
$codes = array();
$latin1 = array( "da", "de", "en", "es", "fr", "nl", "sv" );
-
+
$d = opendir( "../languages" );
while( false !== ($f = readdir( $d ) ) ) {
if( preg_match( '/Language([A-Z][a-z]+)\.php$/', $f, $m ) ) {