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