From: Brion Vibber Date: Mon, 1 Mar 2004 12:59:45 +0000 (+0000) Subject: Experimental in-place installer. X-Git-Tag: 1.3.0beta1~890 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=d11bdf29ca7bc32200cc439b88ccbbacf89630f3;p=lhc%2Fweb%2Fwiklou.git Experimental in-place installer. Doesn't yet do any database setup, but does produce a LocalSettings.php that can successfully operate the wiki in the distribution directory structure. Note that the maintenance scripts may not all be fully armored against web access, and aren't set up to be run from the web by an actual administrator either. --- diff --git a/config/index.php b/config/index.php new file mode 100644 index 0000000000..99a18c73d9 --- /dev/null +++ b/config/index.php @@ -0,0 +1,426 @@ + + + + + + MediaWiki installation + + + + + +
+
+ +
+ + MediaWiki is + Copyright (C) 2001-2004 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, + Tim Starling, Erik Möller, and others.

+ + + +

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.

+ +

This progarm 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. + or read it online

+
+ + + +

MediaWiki installation

+ + +Wiki is configured. + +

Already configured... return to the wiki.

+ +

(You should probably remove this directory for added security.)

" ); +} + +if( file_exists( "./LocalSettings.php" ) || file_exists( "./AdminSettings.php" ) ) { + dieout( "

You're configured!

+ +

Please move LocalSettings.php to the parent directory, then + try out your wiki. + (You should remove this config directory for added security once you're done.)

" ); +} + + +include( "../install-utils.inc" ); +class ConfigData {} + +?> + + +

Checking environment...

+ + + +Sitename = ucfirst( importPost( "Sitename", "" ) ); + $conf->EmergencyContact = importPost( "EmergencyContact", $_SERVER["SERVER_ADMIN"] ); + $conf->DBserver = importPost( "DBserver", "localhost" ); + $conf->DBname = importPost( "DBname", "wikidb" ); + $conf->DBuser = importPost( "DBuser", "wikiuser" ); + $conf->DBpassword = importPost( "DBpassword" ); + $conf->DBpassword2 = importPost( "DBpassword2" ); + $conf->RootPW = importPost( "RootPW" ); + $conf->LanguageCode = importPost( "LanguageCode", "en-utf8" ); + +/* Check for validity */ +$errs = array(); + +if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) { + $errs["Sitename"] = "Must not be blank or \"MediaWiki\"."; +} +if( $conf->DBpassword == "" ) { + $errs["DBpassword"] = "Must not be blank"; +} +if( $conf->DBpassword != $conf->DBpassword2 ) { + $errs["DBpassword2"] = "Passwords don't match!"; +} + +if( count( $errs ) ) { + /* Display options form */ +?> +

Database config

+ +
+ +
+
+
+ If your database server isn't on your web server, enter the name + or IP address here. +
+ +
+
+
+
+
+ If you only have a single user account and database available, + enter those here. If you have database root access (see below) + you can specify new accounts/databases to be created. +
+ + +
+ +
+
+ You will only need this if the database and/or user account + above don't already exist. + Do not type in your machine's root password! MySQL + has its own "root" user with a separate password. (It might + even be blank, depending on your configuration.) +
+
+ +

Site config

+ +
+
+ +
+
+ Your site name should be a relatively short word. It'll appear as the namespace + name for 'meta' pages as well as throughout the user interface. Good site names + are things like "Wikipedia" and + "OpenFacts"; avoid punctuation, + which may cause problems. +
+ +
+ +
+
+ If the wiki breaks terribly, it may display this contact address. +
+ +
+ + +
+
+ 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. The default + for most languages is Unicode. +
+ +
+ + +
+
+ +
+ +Creating LocalSettings.php...

\n\n"; + + $local = writeLocalSettings( $conf ); + $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." ); + } + fwrite( $f, $local ); + fclose( $f ); + + print "

Success! Move the LocalSettings.php file into the parent directory, then follow + this link to your wiki.

\n"; +} + +/* -------------------------------------------------------------------------------------- */ + +function writeAdminSettings( $conf ) { + return "<" . "?php +\$wgDBadminuser = \"{$conf->DBadminuser}\"; +\$wgDBadminpassword = \"{$conf->DBadminpassword}\"; +?" . ">"; +} + +function writeLocalSettings( $conf ) { + $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"; + } + return "<" . "?php +# This file was automatically generated. Don't touch unless you +# know what you're doing; see LocalSettings.sample for an edit- +# friendly file. + +\$IP = \"{$conf->IP}\"; +ini_set( \"include_path\", ini_get(\"include_path\") . \":\$IP/includes:\$IP/languages\" ); +include_once( \"includes/DefaultSettings.php\" ); + +if( \$wgCommandLineMode ) { + die( \"Can't use command-line utils with in-place install yet, sorry.\" ); +} + +\$wgSitename = \"{$conf->Sitename}\"; + +\$wgScriptPath = \"{$conf->ScriptPath}\"; +\$wgScript = \"\$wgScriptPath/index.php\"; +\$wgRedirectScript = \"\$wgScriptPath/redirect.php\"; + +\$wgArticlePath = \"\$wgScript?title=\$1\"; +# \$wgArticlePath = \"\$wgScript/\$1\"; # Prettier if you're setup for it + +\$wgStyleSheetPath = \"\$wgScriptPath/stylesheets\"; +\$wgStyleSheetDirectory = \"\$IP/stylesheets\"; + +\$wgUploadPath = \"\$wgScriptPath/images\"; +\$wgUploadDirectory = \"\$IP/images\"; +\$wgLogo = \"\$wgUploadPath/wiki.png\"; + +\$wgEmergencyContact = \"{$conf->EmergencyContact}\"; +\$wgPasswordSender = \"{$conf->PasswordSender}\"; + +\$wgDBserver = \"{$conf->DBserver}\"; +\$wgDBname = \"{$conf->DBname}\"; +\$wgDBuser = \"{$conf->DBuser}\"; +\$wgDBpassword = \"{$conf->DBpassword}\"; +\$wgDBsqluser = \"{$conf->DBsqluser}\"; +\$wgDBsqlpassword = \"{$conf->DBsqlpassword}\"; + +\$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4}; + +\$wgUseImageResize = {$conf->UseImageResize}; + +## 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\"; + +\$wgLocalInterwiki = \$wgSitename; + +\$wgLanguageCode = \"{$conf->LanguageCode}\"; +" . ($conf->Encoding ? "\$wgInputEncoding = \$wgOutputEncoding = \"{$conf->Encoding}\";" : "" ) . " + +?" . ">"; +} + +function dieout( $text ) { + die( $text . "\n\n\n" ); +} + +function importPost( $name, $default = "" ) { + if( isset( $_POST[$name] ) ) { + return $_POST[$name]; + } else { + return $default; + } +} + +function aField( &$conf, $field, $text, $type = "" ) { + if( $type != "" ) $type = "type=\"$type\""; + echo "\t\t\n"; + echo "\t\t$field ); + echo "\" />\n"; + + global $errs; + if(isset($errs[$field])) echo "" . $errs[$field] . "\n"; +} + +function getLanguageList() { + $wgLanguageCode = "xxx"; + function wfLocalUrl( $x ) { return $x; } + function wfLocalUrlE( $x ) { return $x; } + include( "../languages/Language.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 ) ) { + $code = strtolower( $m[1] ); + $codes[$code] = "$code - " . $wgLanguageNames[$code]; + if( in_array( $code, $latin1 ) ) { + $codes[$code] .= " - Latin-1"; + } + } + } + $codes["en-utf8"] = "en - English - Unicode"; + closedir( $d ); + ksort( $codes ); + return $codes; +} + +?> + \ No newline at end of file diff --git a/index.php b/index.php index 1c2a53109b..a8b400954e 100644 --- a/index.php +++ b/index.php @@ -5,6 +5,9 @@ $wgRequestTime = microtime(); unset( $IP ); ini_set( "allow_url_fopen", 0 ); # For security... +if(!file_exists("LocalSettings.php")) { + die( "You'll have to set the wiki up first!" ); +} include_once( "./LocalSettings.php" ); if( $wgSitename == "MediaWiki" ) {