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