99a18c73d948f6ef69d8ce161a5f4474ed06d432
[lhc/web/wiklou.git] / config / index.php
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6 <meta name="robots" content="noindex,nofollow">
7 <title>MediaWiki installation</title>
8 <style type="text/css">
9 #credit {
10 float: right;
11 width: 200px;
12 font-size: 0.7em;
13 background-color: #eee;
14 color: black;
15 border: solid 1px #444;
16 padding: 8px;
17 margin-left: 8px;
18 }
19
20 dl.setup dd {
21 }
22 dl.setup dt {
23 font-size: 0.8em;
24 margin-left: 10em;
25 margin-right: 200px;
26 margin-bottom: 2em;
27 }
28 dl.setup dd label {
29 font-weight: bold;
30 width: 10em;
31 float: left;
32 text-align: right;
33 padding-right: 1em;
34 }
35 .error {
36 color: red;
37 }
38 </style>
39 </head>
40
41 <body>
42
43 <div id="credit">
44 <center>
45 <a href="http://www.mediawiki.org/"><img
46 src="../images/wiki.png" width="135" height="135" alt="" border="0" /></a>
47 </center>
48
49 <b><a href="http://www.mediawiki.org/">MediaWiki</a></b> is
50 Copyright (C) 2001-2004 by Magnus Manske, Brion Vibber, Lee Daniel Crocker,
51 Tim Starling, Erik M&ouml;ller, and others.</p>
52
53 <ul>
54 <li><a href="../README">Readme</a></li>
55 <li><a href="../RELEASE-NOTES">Release notes</a></li>
56 <li><a href="../docs/">doc/</a></li>
57 <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li>
58 </ul>
59
60 <p>This program is free software; you can redistribute it and/or modify
61 it under the terms of the GNU General Public License as published by
62 the Free Software Foundation; either version 2 of the License, or
63 (at your option) any later version.</p>
64
65 <p>This progarm is distributed in the hope that it will be useful,
66 but WITHOUT ANY WARRANTY; without even the implied warranty of
67 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
68 GNU General Public License for more details.</p>
69
70 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
71 along with this program; if not, write to the Free Software
72 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
73 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
74 </div>
75
76 <?php
77 include( "../includes/DefaultSettings.php" );
78 ?>
79
80 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
81
82
83 <?php
84
85 /* Check for existing configurations and bug out! */
86
87 if( file_exists( "../LocalSettings.php" ) || file_exists( "../AdminSettings.php" ) ) {
88 dieout( "<h2>Wiki is configured.</h2>
89
90 <p>Already configured... <a href='../index.php'>return to the wiki</a>.</p>
91
92 <p>(You should probably remove this directory for added security.)</p>" );
93 }
94
95 if( file_exists( "./LocalSettings.php" ) || file_exists( "./AdminSettings.php" ) ) {
96 dieout( "<h2>You're configured!</h2>
97
98 <p>Please move <tt>LocalSettings.php</tt> to the parent directory, then
99 <a href='../index.php'>try out your wiki</a>.
100 (You should remove this config directory for added security once you're done.)</p>" );
101 }
102
103
104 include( "../install-utils.inc" );
105 class ConfigData {}
106
107 ?>
108
109
110 <h2>Checking environment...</h2>
111 <ul>
112 <?php
113
114 $conf = new ConfigData;
115
116 install_version_checks();
117 print "<li>PHP " . phpversion() . " ok</li>\n";
118
119 /*
120 $conf->zlib = function_exists( "gzencode" );
121 $z = $conf->zlib ? "Have" : "No";
122 print "<li>$z zlib support</li>\n";
123
124 $conf->gd = function_exists( "imagejpeg" );
125 if( $conf->gd ) {
126 print "<li>Found GD graphics library built-in</li>\n";
127 } else {
128 print "<li>No built-in GD library</li>\n";
129 }
130
131 if( file_exists( "/usr/bin/convert" ) ) {
132 $conf->ImageMagick = "/usr/bin/convert";
133 print "<li>Found ImageMagick: /usr/bin/convert</li>\n";
134 } elseif( file_exists( "/usr/local/bin/convert" ) ) {
135 $conf->ImageMagick = "/usr/local/bin/convert";
136 print "<li>Found ImageMagick: /usr/local/bin/convert</li>\n";
137 } else {
138 $conf->ImageMagick = false;
139 print "<li>No ImageMagick.</li>\n";
140 }
141 */
142
143 # $conf->IP = "/Users/brion/Sites/inplace";
144 chdir( ".." );
145 $conf->IP = getcwd();
146 chdir( "config" );
147 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
148
149 # $conf->ScriptPath = "/~brion/inplace";
150 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["REQUEST_URI"] );
151 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
152
153 ?>
154 </ul>
155
156
157 <?php
158 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
159 $conf->EmergencyContact = importPost( "EmergencyContact", $_SERVER["SERVER_ADMIN"] );
160 $conf->DBserver = importPost( "DBserver", "localhost" );
161 $conf->DBname = importPost( "DBname", "wikidb" );
162 $conf->DBuser = importPost( "DBuser", "wikiuser" );
163 $conf->DBpassword = importPost( "DBpassword" );
164 $conf->DBpassword2 = importPost( "DBpassword2" );
165 $conf->RootPW = importPost( "RootPW" );
166 $conf->LanguageCode = importPost( "LanguageCode", "en-utf8" );
167
168 /* Check for validity */
169 $errs = array();
170
171 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
172 $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
173 }
174 if( $conf->DBpassword == "" ) {
175 $errs["DBpassword"] = "Must not be blank";
176 }
177 if( $conf->DBpassword != $conf->DBpassword2 ) {
178 $errs["DBpassword2"] = "Passwords don't match!";
179 }
180
181 if( count( $errs ) ) {
182 /* Display options form */
183 ?>
184 <h2>Database config</h2>
185
186 <form name="config" method="post">
187
188 <dl class="setup">
189 <dd><?php
190 aField( $conf, "DBserver", "MySQL server" );
191 ?></dd>
192 <dt>
193 If your database server isn't on your web server, enter the name
194 or IP address here.
195 </dt>
196
197 <dd><?php
198 aField( $conf, "DBname", "Database name" );
199 ?></dd>
200 <dd><?php
201 aField( $conf, "DBuser", "DB username" );
202 ?></dd>
203 <dd><?php
204 aField( $conf, "DBpassword", "DB password", "password" );
205 ?></dd>
206 <dd><?php
207 aField( $conf, "DBpassword2", "again", "password" );
208 ?></dd>
209 <dt>
210 If you only have a single user account and database available,
211 enter those here. If you have database root access (see below)
212 you can specify new accounts/databases to be created.
213 </dt>
214
215
216 <dd>
217 <?php
218 aField( $conf, "RootPW", "DB root password", "password" );
219 ?>
220 </dd>
221 <dt>
222 You will only need this if the database and/or user account
223 above don't already exist.
224 Do <em>not</em> type in your machine's root password! MySQL
225 has its own "root" user with a separate password. (It might
226 even be blank, depending on your configuration.)
227 </dt>
228 </dl>
229
230 <h2>Site config</h2>
231
232 <dl class="setup">
233 <dd>
234 <?php
235 aField( $conf, "Sitename", "Site name:" );
236 ?>
237 </dd>
238 <dt>
239 Your site name should be a relatively short word. It'll appear as the namespace
240 name for 'meta' pages as well as throughout the user interface. Good site names
241 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
242 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
243 which may cause problems.
244 </dt>
245
246 <dd>
247 <?php
248 aField( $conf, "EmergencyContact", "Contact e-mail" );
249 ?>
250 </dd>
251 <dt>
252 If the wiki breaks terribly, it may display this contact address.
253 </dt>
254
255 <dd>
256 <label for="LanguageCode">Language</label>
257 <select id="LanguageCode" name="LanguageCode">
258 <?php
259 $list = getLanguageList();
260 foreach( $list as $code => $name ) {
261 $sel = ($code == $conf->LanguageCode) ? "selected" : "";
262 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
263 }
264 ?>
265 </select>
266 </dd>
267 <dt>
268 You may select the language for the user interface of the wiki...
269 Some localizations are less complete than others. This also controls
270 the character encoding; Unicode is more flexible, but Latin-1 may be
271 more compatible with older browsers for some languages. The default
272 for most languages is Unicode.
273 </dt>
274
275 <dd>
276 <label>&nbsp;</label>
277 <input type="submit" value="Install!" />
278 </dd>
279 </dl>
280
281 </form>
282
283 <?php
284 } else {
285 /* Go for it! */
286 print "<p>Creating LocalSettings.php...</p>\n\n";
287
288 $local = writeLocalSettings( $conf );
289 $f = fopen( "LocalSettings.php", "xt" );
290 if( $f == false ) {
291 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." );
292 }
293 fwrite( $f, $local );
294 fclose( $f );
295
296 print "<p>Success! Move the LocalSettings.php file into the parent directory, then follow
297 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
298 }
299
300 /* -------------------------------------------------------------------------------------- */
301
302 function writeAdminSettings( $conf ) {
303 return "<" . "?php
304 \$wgDBadminuser = \"{$conf->DBadminuser}\";
305 \$wgDBadminpassword = \"{$conf->DBadminpassword}\";
306 ?" . ">";
307 }
308
309 function writeLocalSettings( $conf ) {
310 $conf->DBmysql4 = $conf->DBmysql4 ? 'true' : 'false';
311 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
312 $conf->DBsqluser = $conf->DBuser;
313 $conf->DBsqlpassword = $conf->DBpassword;
314 $conf->PasswordSender = $conf->EmergencyContact;
315 if( $conf->LanguageCode == "en-utf8" ) {
316 $conf->LanguageCode = "en";
317 $conf->Encoding = "UTF-8";
318 }
319 return "<" . "?php
320 # This file was automatically generated. Don't touch unless you
321 # know what you're doing; see LocalSettings.sample for an edit-
322 # friendly file.
323
324 \$IP = \"{$conf->IP}\";
325 ini_set( \"include_path\", ini_get(\"include_path\") . \":\$IP/includes:\$IP/languages\" );
326 include_once( \"includes/DefaultSettings.php\" );
327
328 if( \$wgCommandLineMode ) {
329 die( \"Can't use command-line utils with in-place install yet, sorry.\" );
330 }
331
332 \$wgSitename = \"{$conf->Sitename}\";
333
334 \$wgScriptPath = \"{$conf->ScriptPath}\";
335 \$wgScript = \"\$wgScriptPath/index.php\";
336 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
337
338 \$wgArticlePath = \"\$wgScript?title=\$1\";
339 # \$wgArticlePath = \"\$wgScript/\$1\"; # Prettier if you're setup for it
340
341 \$wgStyleSheetPath = \"\$wgScriptPath/stylesheets\";
342 \$wgStyleSheetDirectory = \"\$IP/stylesheets\";
343
344 \$wgUploadPath = \"\$wgScriptPath/images\";
345 \$wgUploadDirectory = \"\$IP/images\";
346 \$wgLogo = \"\$wgUploadPath/wiki.png\";
347
348 \$wgEmergencyContact = \"{$conf->EmergencyContact}\";
349 \$wgPasswordSender = \"{$conf->PasswordSender}\";
350
351 \$wgDBserver = \"{$conf->DBserver}\";
352 \$wgDBname = \"{$conf->DBname}\";
353 \$wgDBuser = \"{$conf->DBuser}\";
354 \$wgDBpassword = \"{$conf->DBpassword}\";
355 \$wgDBsqluser = \"{$conf->DBsqluser}\";
356 \$wgDBsqlpassword = \"{$conf->DBsqlpassword}\";
357
358 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
359
360 \$wgUseImageResize = {$conf->UseImageResize};
361
362 ## If you have the appropriate support software installed
363 ## you can enable inline LaTeX equations:
364 # \$wgUseTeX = true;
365 # \$wgMathPath = \"{$wgUploadPath}/math\";
366 # \$wgMathDirectory = \"{$wgUploadDirectory}/math\";
367 # \$wgTmpDirectory = \"{$wgUploadDirectory}/tmp\";
368
369 \$wgLocalInterwiki = \$wgSitename;
370
371 \$wgLanguageCode = \"{$conf->LanguageCode}\";
372 " . ($conf->Encoding ? "\$wgInputEncoding = \$wgOutputEncoding = \"{$conf->Encoding}\";" : "" ) . "
373
374 ?" . ">";
375 }
376
377 function dieout( $text ) {
378 die( $text . "\n\n</body>\n</html>" );
379 }
380
381 function importPost( $name, $default = "" ) {
382 if( isset( $_POST[$name] ) ) {
383 return $_POST[$name];
384 } else {
385 return $default;
386 }
387 }
388
389 function aField( &$conf, $field, $text, $type = "" ) {
390 if( $type != "" ) $type = "type=\"$type\"";
391 echo "\t\t<label for=\"$field\">$text</label>\n";
392 echo "\t\t<input $type name=\"$field\" id=\"$field\" value=\"";
393 echo htmlspecialchars( $conf->$field );
394 echo "\" />\n";
395
396 global $errs;
397 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
398 }
399
400 function getLanguageList() {
401 $wgLanguageCode = "xxx";
402 function wfLocalUrl( $x ) { return $x; }
403 function wfLocalUrlE( $x ) { return $x; }
404 include( "../languages/Language.php" );
405
406 $codes = array();
407 $latin1 = array( "da", "de", "en", "es", "fr", "nl", "sv" );
408
409 $d = opendir( "../languages" );
410 while( false !== ($f = readdir( $d ) ) ) {
411 if( preg_match( '/Language([A-Z][a-z]+)\.php$/', $f, $m ) ) {
412 $code = strtolower( $m[1] );
413 $codes[$code] = "$code - " . $wgLanguageNames[$code];
414 if( in_array( $code, $latin1 ) ) {
415 $codes[$code] .= " - Latin-1";
416 }
417 }
418 }
419 $codes["en-utf8"] = "en - English - Unicode";
420 closedir( $d );
421 ksort( $codes );
422 return $codes;
423 }
424
425 ?>
426 </html>