fixed double-escaping of $conf->IP
[lhc/web/wiklou.git] / config / index.php
1 <?php
2 # MediaWiki web-based config/installation
3 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
4 # http://www.mediawiki.org/
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 # http://www.gnu.org/copyleft/gpl.html
20
21 error_reporting( E_ALL );
22 header( "Content-type: text/html; charset=utf-8" );
23 @ini_set( "display_errors", true );
24
25 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
26 "http://www.w3.org/TR/html4/loose.dtd">
27 <html>
28 <head>
29 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
30 <meta name="robots" content="noindex,nofollow">
31 <title>MediaWiki installation</title>
32 <style type="text/css">
33 #credit {
34 float: right;
35 width: 200px;
36 font-size: 0.7em;
37 background-color: #eee;
38 color: black;
39 border: solid 1px #444;
40 padding: 8px;
41 margin-left: 8px;
42 }
43
44 dl.setup dd {
45 margin-left: 0;
46 }
47 dl.setup dd label.column {
48 clear: left;
49 font-weight: bold;
50 width: 12em;
51 float: left;
52 text-align: right;
53 padding-right: 1em;
54 }
55 dl.setup dt {
56 clear: left;
57 font-size: 0.8em;
58 margin-left: 10em;
59 /* margin-right: 200px; */
60 margin-bottom: 2em;
61 }
62 .error {
63 color: red;
64 }
65 ul.plain {
66 list-style: none;
67 clear: both;
68 margin-left: 12em;
69 }
70 </style>
71 </head>
72
73 <body>
74
75 <div id="credit">
76 <center>
77 <a href="http://www.mediawiki.org/"><img
78 src="../stylesheets/images/wiki.png" width="135" height="135" alt="" border="0" /></a>
79 </center>
80
81 <b><a href="http://www.mediawiki.org/">MediaWiki</a></b> is
82 Copyright (C) 2001-2004 by Magnus Manske, Brion Vibber, Lee Daniel Crocker,
83 Tim Starling, Erik M&ouml;ller, Gabriel Wicke and others.</p>
84
85 <ul>
86 <li><a href="../README">Readme</a></li>
87 <li><a href="../RELEASE-NOTES">Release notes</a></li>
88 <li><a href="../docs/">doc/</a></li>
89 <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li>
90 </ul>
91
92 <p>This program is free software; you can redistribute it and/or modify
93 it under the terms of the GNU General Public License as published by
94 the Free Software Foundation; either version 2 of the License, or
95 (at your option) any later version.</p>
96
97 <p>This program is distributed in the hope that it will be useful,
98 but WITHOUT ANY WARRANTY; without even the implied warranty of
99 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
100 GNU General Public License for more details.</p>
101
102 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
103 along with this program; if not, write to the Free Software
104 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
105 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
106 </div>
107
108 <?php
109
110 $IP = ".."; # Just to suppress notices, not for anything useful
111 define( "MEDIAWIKI", true );
112 define( "MEDIAWIKI_INSTALL", true );
113 require_once( "../includes/DefaultSettings.php" );
114 require_once( "../includes/MagicWord.php" );
115 require_once( "../includes/Namespace.php" );
116 ?>
117
118 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
119
120
121 <?php
122
123 /* Check for existing configurations and bug out! */
124
125 if( file_exists( "../LocalSettings.php" ) || file_exists( "../AdminSettings.php" ) ) {
126 dieout( "<h2>Wiki is configured.</h2>
127
128 <p>Already configured... <a href='../index.php'>return to the wiki</a>.</p>
129
130 <p>(You should probably remove this directory for added security.)</p>" );
131 }
132
133 if( file_exists( "./LocalSettings.php" ) || file_exists( "./AdminSettings.php" ) ) {
134 dieout( "<h2>You're configured!</h2>
135
136 <p>Please move <tt>LocalSettings.php</tt> to the parent directory, then
137 <a href='../index.php'>try out your wiki</a>.
138 (You should remove this config directory for added security once you're done.)</p>" );
139 }
140
141 if( !is_writable( "." ) ) {
142 dieout( "<h2>Can't write config file, aborting</h2>
143
144 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
145 writable by the web server. Once configuration is done you'll move the created
146 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
147 then remove the <tt>config</tt> subdirectory entirely.</p>
148
149 <p>To make the directory writable on a Unix/Linux system:</p>
150
151 <pre>
152 cd <i>/path/to/wiki</i>
153 chmod a+w config
154 </pre>" );
155 }
156
157
158 require_once( "../install-utils.inc" );
159 require_once( "../maintenance/updaters.inc" );
160 require_once( "../maintenance/convertLinks.inc" );
161 require_once( "../maintenance/archives/moveCustomMessages.inc" );
162
163 class ConfigData {
164 function getEncoded( $data ) {
165 # Hackish
166 global $wgUseLatin1;
167 if( $wgUseLatin1 ) {
168 return utf8_decode( $data ); /* to latin1 wikis */
169 } else {
170 return $data;
171 }
172 }
173 function getSitename() { return $this->getEncoded( $this->Sitename ); }
174 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
175 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
176 }
177
178 ?>
179
180 <p><i>Please include all of the lines below when reporting installation problems.</i></p>
181
182 <h2>Checking environment...</h2>
183 <ul>
184 <?php
185 $endl = "
186 ";
187 $wgConfiguring = true;
188 $conf = new ConfigData;
189
190 install_version_checks();
191 print "<li>PHP " . phpversion() . " ok</li>\n";
192
193 $sapi = php_sapi_name();
194 $conf->prettyURLs = true;
195 print "<li>PHP server API is $sapi; ";
196 switch( $sapi ) {
197 case "apache":
198 case "apache2handler":
199 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
200 break;
201 case "cgi":
202 case "cgi-fcgi":
203 case "apache2filter":
204 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
205 $conf->prettyURLs = false;
206 break;
207 default:
208 print "unknown; using pretty URLs (<tt>index.php/Page_Title</tt>), if you have trouble change this in <tt>LocalSettings.php</tt>";
209 }
210 print "</li>\n";
211
212 $conf->xml = function_exists( "utf8_encode" );
213 if( $conf->xml ) {
214 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
215 } else {
216 print "<li><b>XML / Latin1-UTF-8 conversion is missing! Wiki will probably not work.</b></li>\n";
217 }
218
219 $memlimit = ini_get( "memory_limit" );
220 $conf->raiseMemory = false;
221 if( empty( $memlimit ) ) {
222 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
223 } else {
224 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". <b>If this is too low, installation may fail!</b> ";
225 $n = IntVal( $memlimit );
226 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
227 $n = IntVal( $m[1] * (1024*1024) );
228 }
229 if( $n < 20*1024*1024 ) {
230 print "Attempting to raise limit to 20M... ";
231 if( false === ini_set( "memory_limit", "20M" ) ) {
232 print "failed.";
233 } else {
234 $conf->raiseMemory = true;
235 print "ok.";
236 }
237 }
238 print "</li>\n";
239 }
240
241 $conf->zlib = function_exists( "gzencode" );
242 if( $conf->zlib ) {
243 print "<li>Have zlib support; enabling output compression.</li>\n";
244 } else {
245 print "<li>No zlib support.</li>\n";
246 }
247
248 $conf->ImageMagick = false;
249
250 $conf->HaveGD = function_exists( "imagejpeg" );
251 if( $conf->HaveGD ) {
252 print "<li>Found GD graphics library built-in, image thumbnailing will be enabled if you enable uploads.</li>\n";
253 } else {
254 $imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin" );
255 foreach( $imcheck as $dir ) {
256 $im = "$dir/convert";
257 if( file_exists( $im ) ) {
258 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
259 $conf->ImageMagick = $im;
260 break;
261 }
262 }
263 if( !$conf->ImageMagick ) {
264 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
265 }
266 }
267
268 $conf->UseImageResize = $conf->HaveGD || $conf->ImageMagick;
269
270 # $conf->IP = "/Users/brion/Sites/inplace";
271 chdir( ".." );
272 $conf->IP = getcwd();
273 chdir( "config" );
274 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
275
276 # $conf->ScriptPath = "/~brion/inplace";
277 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["REQUEST_URI"] );
278 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
279
280 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
281
282 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
283 $conf->EmergencyContact = importPost( "EmergencyContact", $_SERVER["SERVER_ADMIN"] );
284 $conf->DBserver = importPost( "DBserver", "localhost" );
285 $conf->DBname = importPost( "DBname", "wikidb" );
286 $conf->DBuser = importPost( "DBuser", "wikiuser" );
287 $conf->DBpassword = importPost( "DBpassword" );
288 $conf->DBpassword2 = importPost( "DBpassword2" );
289 $conf->RootPW = importPost( "RootPW" );
290 $conf->LanguageCode = importPost( "LanguageCode", "en" );
291 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
292 $conf->SysopPass = importPost( "SysopPass" );
293 $conf->SysopPass2 = importPost( "SysopPass2" );
294
295 /* Check for validity */
296 $errs = array();
297
298 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
299 $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
300 }
301 if( $conf->DBpassword == "" ) {
302 $errs["DBpassword"] = "Must not be blank";
303 }
304 if( $conf->DBpassword != $conf->DBpassword2 ) {
305 $errs["DBpassword2"] = "Passwords don't match!";
306 }
307
308 if( $conf->SysopPass == "" ) {
309 $errs["SysopPass"] = "Must not be blank";
310 }
311 if( $conf->SysopPass != $conf->SysopPass2 ) {
312 $errs["SysopPass2"] = "Passwords don't match!";
313 }
314
315 $conf->License = importPost( "License", "none" );
316 if( $conf->License == "gfdl" ) {
317 $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html";
318 $conf->RightsText = "GNU Free Documentation License 1.2";
319 $conf->RightsCode = "gfdl";
320 $conf->RightsIcon = '${wgStylePath}/images/gnu-fdl.png';
321 } elseif( $conf->License == "none" ) {
322 $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = "";
323 } else {
324 $conf->RightsUrl = importPost( "RightsUrl", "" );
325 $conf->RightsText = importPost( "RightsText", "" );
326 $conf->RightsCode = importPost( "RightsCode", "" );
327 $conf->RightsIcon = importPost( "RightsIcon", "" );
328 }
329
330 if( $conf->posted && ( 0 == count( $errs ) ) ) {
331 do { /* So we can 'continue' to end prematurely */
332 $conf->Root = ($conf->RootPW != "");
333
334 /* Load up the settings and get installin' */
335 $local = writeLocalSettings( $conf );
336 $wgCommandLineMode = false;
337 chdir( ".." );
338 eval($local);
339 $wgDBadminuser = $wgDBuser;
340 $wgDBadminpassword = $wgDBpassword;
341 $wgCommandLineMode = true;
342 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
343 require_once( "includes/Setup.php" );
344 chdir( "config" );
345
346 require_once( "../maintenance/InitialiseMessages.inc" );
347
348 $wgTitle = Title::newFromText( "Installation script" );
349 $wgDatabase = Database::newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 );
350 $wgDatabase->mIgnoreErrors = true;
351
352 @$myver = mysql_get_server_info( $wgDatabase->mConn );
353 if( $myver ) {
354 $conf->Root = true;
355 print "<li>Connected as root (automatic)</li>\n";
356 } else {
357 print "<li>MySQL error " . ($err = mysql_errno() ) .
358 ": " . htmlspecialchars( mysql_error() );
359 $ok = false;
360 switch( $err ) {
361 case 1045:
362 if( $conf->Root ) {
363 $errs["RootPW"] = "Check password";
364 } else {
365 print "<li>Trying regular user...\n";
366 /* Try the regular user... */
367 $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
368 $wgDatabase->isOpen();
369 $wgDatabase->mIgnoreErrors = true;
370 @$myver = mysql_get_server_info( $wgDatabase->mConn );
371 if( !$myver ) {
372 $errs["DBuser"] = "Check name/pass";
373 $errs["DBpassword"] = "or enter root";
374 $errs["DBpassword2"] = "password below";
375 $errs["RootPW"] = "Got root?";
376 print " need password.</li>\n";
377 } else {
378 $conf->Root = false;
379 $conf->RootPW = "";
380 print " ok.</li>\n";
381 # And keep going...
382 $ok = true;
383 }
384 break;
385 }
386 case 2002:
387 case 2003:
388 $errs["DBserver"] = "Connection failed";
389 break;
390 default:
391 $errs["DBserver"] = "Couldn't connect to database";
392 break;
393 }
394 if( !$ok ) continue;
395 }
396
397 if ( !$wgDatabase->isOpen() ) {
398 $errs["DBserver"] = "Couldn't connect to database";
399 continue;
400 }
401
402 print "<li>Connected to database... $myver";
403 if( version_compare( $myver, "4.0.0" ) >= 0 ) {
404 print "; enabling MySQL 4 enhancements";
405 $conf->DBmysql4 = true;
406 $local = writeLocalSettings( $conf );
407 }
408 print "</li>\n";
409
410 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn );
411 if( $sel ) {
412 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
413 } else {
414 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
415 if( !$res ) {
416 print "<li>Couldn't create database <tt>" .
417 htmlspecialchars( $wgDBname ) .
418 "</tt>; try with root access or check your username/pass.</li>\n";
419 $errs["RootPW"] = "&lt;- Enter";
420 continue;
421 }
422 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
423 }
424
425 $wgDatabase->selectDB( $wgDBname );
426
427 if( $wgDatabase->tableExists( "cur" ) ) {
428 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n<pre>";
429
430 chdir( ".." );
431 flush();
432 do_ipblocks_update(); flush();
433 do_interwiki_update(); flush();
434 do_index_update(); flush();
435 do_linkscc_update(); flush();
436 do_linkscc_1_3_update(); flush();
437 do_hitcounter_update(); flush();
438 do_recentchanges_update(); flush();
439 convertLinks(); flush();
440 do_user_real_name_update(); flush();
441 do_querycache_update(); flush();
442 do_objectcache_update(); flush();
443 do_categorylinks_update(); flush();
444 do_image_name_unique_update(); flush();
445
446 if ( isTemplateInitialised() ) {
447 print "Template namespace already initialised\n";
448 } else {
449 moveCustomMessages( 1 ); flush();
450 moveCustomMessages( 2 ); flush();
451 moveCustomMessages( 3 ); flush();
452 }
453
454 initialiseMessages(); flush();
455 chdir( "config" );
456
457 print "</pre>\n";
458 print "<li>Finished update checks.</li>\n";
459 } else {
460 # FIXME: Check for errors
461 print "<li>Creating tables...";
462 dbsource( "../maintenance/tables.sql", $wgDatabase );
463 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
464 dbsource( "../maintenance/indexes.sql", $wgDatabase );
465 print " done.</li>\n";
466
467 print "<li>Initializing data...";
468 $wgDatabase->query( "INSERT INTO site_stats (ss_row_id,ss_total_views," .
469 "ss_total_edits,ss_good_articles) VALUES (1,0,0,0)" );
470 # setting up the db user
471 if( $conf->Root ) {
472 print "<li>Granting user permissions...</li>\n";
473 dbsource( "../maintenance/users.sql", $wgDatabase );
474 }
475
476 if( $conf->SysopName ) {
477 $u = User::newFromName( $conf->getSysopName() );
478 if ( 0 == $u->idForName() ) {
479 $u->addToDatabase();
480 $u->setPassword( $conf->getSysopPass() );
481 $u->addRight( "sysop" );
482 $u->addRight( "bureaucrat" );
483 $u->saveSettings();
484 print "<li>Created sysop account <tt>" .
485 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
486 } else {
487 print "<li>Could not create user - already exists!</li>\n";
488 }
489 } else {
490 print "<li>Skipped sysop account creation, no name given.</li>\n";
491 }
492
493 print "<li>Initialising log pages...";
494 $logs = array(
495 "uploadlogpage" => "uploadlogpagetext",
496 "dellogpage" => "dellogpagetext",
497 "protectlogpage" => "protectlogtext",
498 "blocklogpage" => "blocklogtext"
499 );
500 $metaNamespace = Namespace::getWikipedia();
501 $now = wfTimestampNow();
502 $won = wfInvertTimestamp( $now );
503 foreach( $logs as $page => $text ) {
504 $logTitle = $wgDatabase->strencode( $wgLang->ucfirst( str_replace( " ", "_", wfMsgNoDB( $page ) ) ) );
505 $logText = $wgDatabase->strencode( wfMsgNoDB( $text ) );
506 $wgDatabase->query( "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
507 "cur_restrictions,cur_timestamp,inverse_timestamp,cur_touched) " .
508 "VALUES ($metaNamespace,'$logTitle','$logText','sysop','$now','$won','$now')" );
509 }
510 print "</li>\n";
511
512 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
513 $title = $titleobj->getDBkey();
514 $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text,cur_timestamp,inverse_timestamp,cur_touched) " .
515 "VALUES (0,'$title','" .
516 wfStrencode( wfMsg( "mainpagetext" ) . "\n\n" . wfMsg( "mainpagedocfooter" ) ) . "','$now','$won','$now')";
517 $wgDatabase->query( $sql, $fname );
518
519 print "<li><pre>";
520 initialiseMessages();
521 print "</pre></li>\n";
522 }
523
524 /* Write out the config file now that all is well */
525 print "<p>Creating LocalSettings.php...</p>\n\n";
526 $localSettings = "<" . "?php$endl$local$endl?" . ">";
527
528 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
529 $xt = "xt"; # Refuse to overwrite an existing file
530 } else {
531 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
532 }
533 $f = fopen( "LocalSettings.php", $xt );
534
535 if( $f == false ) {
536 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" .
537 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
538 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
539 }
540 fwrite( $f, $localSettings );
541 fclose( $f );
542
543 print "<p>Success! Move the config/LocalSettings.php file into the parent directory, then follow
544 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
545
546 } while( false );
547 }
548 ?>
549 </ul>
550
551
552 <?php
553
554 if( count( $errs ) ) {
555 /* Display options form */
556
557 if( $conf->posted ) {
558 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
559 }
560 ?>
561
562 <form name="config" method="post">
563
564
565 <h2>Site config</h2>
566
567 <dl class="setup">
568 <dd>
569 <?php
570 aField( $conf, "Sitename", "Site name:" );
571 ?>
572 </dd>
573 <dt>
574 Your site name should be a relatively short word. It'll appear as the namespace
575 name for 'meta' pages as well as throughout the user interface. Good site names
576 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
577 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
578 which may cause problems.
579 </dt>
580
581 <dd>
582 <?php
583 aField( $conf, "EmergencyContact", "Contact e-mail" );
584 ?>
585 </dd>
586 <dt>
587 This will be used as the return address for password reminders and
588 may be displayed in some error conditions so visitors can get in
589 touch with you.
590 </dt>
591
592 <dd>
593 <label class='column' for="LanguageCode">Language</label>
594 <select id="LanguageCode" name="LanguageCode">
595 <?php
596 $list = getLanguageList();
597 foreach( $list as $code => $name ) {
598 $sel = ($code == $conf->LanguageCode) ? "selected" : "";
599 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
600 }
601 ?>
602 </select>
603 </dd>
604 <dt>
605 You may select the language for the user interface of the wiki...
606 Some localizations are less complete than others. This also controls
607 the character encoding; Unicode is more flexible, but Latin-1 may be
608 more compatible with older browsers for some languages. Unicode will
609 be used where not specified otherwise.
610 </dt>
611
612 <dd>
613 <label class='column'>Copyright/license metadata</label>
614 <div>Select one:</div>
615
616 <ul class="plain">
617 <li><?php aField( $conf, "License", "no license metadata", "radio", "none" ); ?></li>
618 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li>
619 <li><?php
620 aField( $conf, "License", "a Creative Commons license...", "radio", "cc" );
621 $partner = "MediaWiki";
622 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
623 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
624 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
625 print "<a href=\"$ccApp\">choose</a>";
626 ?></li>
627 <li><?php aField( $conf, "RightsUrl", $conf->RightsUrl, "hidden" ); ?></li>
628 <li><?php aField( $conf, "RightsText", $conf->RightsText, "hidden" ); ?></li>
629 <li><?php aField( $conf, "RightsCode", $conf->RightsCode, "hidden" ); ?></li>
630 <li><?php aField( $conf, "RightsIcon", $conf->RightsIcon, "hidden" ); ?></li>
631 </ul>
632 </dd>
633 <dt>
634 MediaWiki can include a basic license notice, icon, and machine-reable
635 copyright metadata if your wiki's content is to be licensed under
636 the GNU FDL or a Creative Commons license. If you're not sure, leave
637 it at "none".
638 </dt>
639
640
641 <dd>
642 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
643 </dd>
644 <dd>
645 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
646 </dd>
647 <dd>
648 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
649 </dd>
650 <dt>
651 A sysop user account can lock or delete pages, block problematic IP
652 addresses from editing, and other maintenance tasks. If creating a new
653 wiki database, a sysop account will be created with the given name
654 and password.
655 </dt>
656 </dl>
657
658 <h2>Database config</h2>
659
660 <dl class="setup">
661 <dd><?php
662 aField( $conf, "DBserver", "MySQL server" );
663 ?></dd>
664 <dt>
665 If your database server isn't on your web server, enter the name
666 or IP address here.
667 </dt>
668
669 <dd><?php
670 aField( $conf, "DBname", "Database name" );
671 ?></dd>
672 <dd><?php
673 aField( $conf, "DBuser", "DB username" );
674 ?></dd>
675 <dd><?php
676 aField( $conf, "DBpassword", "DB password", "password" );
677 ?></dd>
678 <dd><?php
679 aField( $conf, "DBpassword2", "again", "password" );
680 ?></dd>
681 <dt>
682 If you only have a single user account and database available,
683 enter those here. If you have database root access (see below)
684 you can specify new accounts/databases to be created.
685 </dt>
686
687
688 <dd>
689 <?php
690 aField( $conf, "RootPW", "DB root password", "password" );
691 ?>
692 </dd>
693 <dt>
694 You will only need this if the database and/or user account
695 above don't already exist.
696 Do <em>not</em> type in your machine's root password! MySQL
697 has its own "root" user with a separate password. (It might
698 even be blank, depending on your configuration.)
699 </dt>
700
701 <dd>
702 <label class='column'>&nbsp;</label>
703 <input type="submit" value="Install!" />
704 </dd>
705 </dl>
706
707
708 </form>
709
710 <?php
711 }
712
713 /* -------------------------------------------------------------------------------------- */
714
715 function writeAdminSettings( $conf ) {
716 return "
717 \$wgDBadminuser = \"{$conf->DBadminuser}\";
718 \$wgDBadminpassword = \"{$conf->DBadminpassword}\";
719 ";
720 }
721
722 function writeLocalSettings( $conf ) {
723 $conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false';
724 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
725 $conf->PasswordSender = $conf->EmergencyContact;
726 if( preg_match( '/^([a-z]+)-latin1$/', $conf->LanguageCode, $m ) ) {
727 $conf->LanguageCode = $m[1];
728 $conf->Latin1 = true;
729 } else {
730 $conf->Latin1 = false;
731 }
732 $zlib = ($conf->zlib ? "" : "# ");
733 $magic = ($conf->ImageMagick ? "" : "# ");
734 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
735 $pretty = ($conf->prettyURLs ? "" : "# ");
736 $ugly = ($conf->prettyURLs ? "# " : "");
737 $rights = ($conf->RightsUrl) ? "" : "# ";
738
739 $file = @fopen( "/dev/random", "r" );
740 if ( $file ) {
741 $proxyKey = bin2hex( fread( $file, 32 ) );
742 fclose( $file );
743 } else {
744 $proxyKey = "";
745 for ( $i=0; $i<8; $i++ ) {
746 $proxyKey .= dechex(mt_rand(0, 0x7fffffff));
747 }
748 print "<li>Warning: \$wgProxyKey is insecure</li>\n";
749 }
750
751 # Add slashes to strings for double quoting
752 $slconf = array_map( "addslashes", get_object_vars( $conf ) );
753
754
755 $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
756 return "
757 # This file was automatically generated by the MediaWiki installer.
758 # If you make manual changes, please keep track in case you need to
759 # recreate them later.
760
761 \$IP = \"{$slconf['IP']}\";
762 ini_set( \"include_path\", \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" );
763 include_once( \"DefaultSettings.php\" );
764
765 # If PHP's memory limit is very low, some operations may fail.
766 " . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
767
768 if ( \$wgCommandLineMode ) {
769 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
770 die( \"This script must be run from the command line\\n\" );
771 }
772 } elseif ( empty( \$wgConfiguring ) ) {
773 ## Compress output if the browser supports it
774 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) ob_start( 'ob_gzhandler' );
775 }
776
777 \$wgSitename = \"{$slconf['Sitename']}\";
778
779 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
780 \$wgScript = \"\$wgScriptPath/index.php\";
781 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
782
783 ## If using PHP as a CGI module, use the ugly URLs
784 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
785 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
786
787 \$wgStylePath = \"\$wgScriptPath/stylesheets\";
788 \$wgStyleDirectory = \"\$IP/stylesheets\";
789 \$wgLogo = \"\$wgStylePath/images/wiki.png\";
790
791 \$wgUploadPath = \"\$wgScriptPath/images\";
792 \$wgUploadDirectory = \"\$IP/images\";
793
794 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
795 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
796
797 \$wgDBserver = \"{$slconf['DBserver']}\";
798 \$wgDBname = \"{$slconf['DBname']}\";
799 \$wgDBuser = \"{$slconf['DBuser']}\";
800 \$wgDBpassword = \"{$slconf['DBpassword']}\";
801
802 ## To allow SQL queries through the wiki's Special:Askaql page,
803 ## uncomment the next lines. THIS IS VERY INSECURE. If you want
804 ## to allow semipublic read-only SQL access for your sysops,
805 ## you should define a MySQL user with limited privileges.
806 ## See MySQL docs: http://www.mysql.com/doc/en/GRANT.html
807 #
808 # \$wgAllowSysopQueries = true;
809 # \$wgDBsqluser = \"sqluser\";
810 # \$wgDBsqlpassword = \"sqlpass\";
811
812 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
813
814 ## To enable image uploads, make sure the 'images' directory
815 ## is writable, then uncomment this:
816 # \$wgDisableUploads = false;
817 \$wgUseImageResize = {$conf->UseImageResize};
818 {$magic}\$wgUseImageMagick = true;
819 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
820
821 ## If you have the appropriate support software installed
822 ## you can enable inline LaTeX equations:
823 # \$wgUseTeX = true;
824 \$wgMathPath = \"{\$wgUploadPath}/math\";
825 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
826 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
827
828 \$wgLocalInterwiki = \$wgSitename;
829
830 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
831 \$wgUseLatin1 = " . ($conf->Latin1 ? 'true' : 'false') . ";\n
832
833 \$wgProxyKey = \"$proxyKey\";
834
835 ## Default skin: you can change the default skin. Use the internal symbolic
836 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
837 # \$wgDefaultSkin = 'monobook';
838
839 ## For attaching licensing metadata to pages, and displaying an
840 ## appropriate copyright notice / icon. GNU Free Documentation
841 ## License and Creative Commons licenses are supported so far.
842 {$rights}\$wgEnableCreativeCommonsRdf = true;
843 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
844 \$wgRightsUrl = \"{$conf->RightsUrl}\";
845 \$wgRightsText = \"{$conf->RightsText}\";
846 \$wgRightsIcon = \"{$conf->RightsIcon}\";
847 # \$wgRightsCode = \"{$conf->RightsCode}\"; # Not yet used
848 ";
849 }
850
851 function dieout( $text ) {
852 die( $text . "\n\n</body>\n</html>" );
853 }
854
855 function importPost( $name, $default = "" ) {
856 if( isset( $_POST[$name] ) ) {
857 $retval = $_POST[$name];
858 if ( get_magic_quotes_gpc() ) {
859 $retval = stripslashes( $retval );
860 }
861 } else {
862 $retval = $default;
863 }
864 return $retval;
865 }
866
867 function aField( &$conf, $field, $text, $type = "", $value = "" ) {
868 if( $type != "" ) {
869 $xtype = "type=\"$type\"";
870 } else {
871 $xtype = "";
872 }
873
874 if(!(isset($id)) or ($id == "") ) $id = $field;
875 $nolabel = ($type == "radio") || ($type == "hidden");
876 if( $nolabel ) {
877 echo "\t\t<label>";
878 } else {
879 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
880 }
881
882 if( $type == "radio" && $value == $conf->$field ) {
883 $checked = "checked='checked'";
884 } else {
885 $checked = "";
886 }
887 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" $checked value=\"";
888 if( $type == "radio" ) {
889 echo htmlspecialchars( $value );
890 } else {
891 echo htmlspecialchars( $conf->$field );
892 }
893 echo "\" />\n";
894 if( $nolabel ) {
895 echo " $text</label>\n";
896 }
897
898 global $errs;
899 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
900 }
901
902 function getLanguageList() {
903 global $wgLanguageNames;
904 if( !isset( $wgLanguageNames ) ) {
905 $wgLanguageCode = "xxx";
906 function wfLocalUrl( $x ) { return $x; }
907 function wfLocalUrlE( $x ) { return $x; }
908 require_once( "../languages/Names.php" );
909 }
910
911 $codes = array();
912 $latin1 = array( "da", "de", "en", "es", "fr", "nl", "sv" );
913
914 $d = opendir( "../languages" );
915 while( false !== ($f = readdir( $d ) ) ) {
916 if( preg_match( '/Language([A-Z][a-z]+)\.php$/', $f, $m ) ) {
917 $code = strtolower( $m[1] );
918 if( in_array( $code, $latin1 ) ) {
919 $codes[$code] = "$code - " . $wgLanguageNames[$code] . " - Unicode";
920 $codes[$code.'-latin1'] = "$code - " . $wgLanguageNames[$code] . " - Latin-1";
921 } else {
922 $codes[$code] = "$code - " . $wgLanguageNames[$code];
923 }
924 }
925 }
926 closedir( $d );
927 ksort( $codes );
928 return $codes;
929 }
930
931 ?>
932
933 </body>
934 </html>