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