Add an objectcache table for limited caching when memcached isn't
[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 do_objectcache_update(); flush();
402 initialiseMessages(); flush();
403 chdir( "config" );
404
405 print "</pre>\n";
406 print "<li>Finished update checks.</li>\n";
407 } else {
408 # FIXME: Check for errors
409 print "<li>Creating tables...";
410 dbsource( "../maintenance/tables.sql", $wgDatabase );
411 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
412 dbsource( "../maintenance/indexes.sql", $wgDatabase );
413 print " done.</li>\n";
414
415 print "<li>Initializing data...";
416 $wgDatabase->query( "INSERT INTO site_stats (ss_row_id,ss_total_views," .
417 "ss_total_edits,ss_good_articles) VALUES (1,0,0,0)" );
418
419 if( $conf->SysopName ) {
420 $u = User::newFromName( $conf->getSysopName() );
421 if ( 0 == $u->idForName() ) {
422 $u->addToDatabase();
423 $u->setPassword( $conf->getSysopPass() );
424 $u->addRight( "sysop" );
425 $u->addRight( "bureaucrat" );
426 $u->saveSettings();
427 print "<li>Created sysop account <tt>" .
428 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
429 } else {
430 print "<li>Could not create user - already exists!</li>\n";
431 }
432 } else {
433 print "<li>Skipped sysop account creation, no name given.</li>\n";
434 }
435
436 print "<li>Initialising log pages...";
437 $logs = array(
438 "uploadlogpage" => "uploadlogpagetext",
439 "dellogpage" => "dellogpagetext",
440 "protectlogpage" => "protectlogtext",
441 "blocklogpage" => "blocklogtext"
442 );
443 $metaNamespace = Namespace::getWikipedia();
444 $now = wfTimestampNow();
445 $won = wfInvertTimestamp( $now );
446 foreach( $logs as $page => $text ) {
447 $logTitle = wfStrencode( $wgLang->ucfirst( str_replace( " ", "_", wfMsgNoDB( $page ) ) ) );
448 $logText = wfStrencode( wfMsgNoDB( $text ) );
449 $wgDatabase->query( "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
450 "cur_restrictions,cur_timestamp,inverse_timestamp,cur_touched) " .
451 "VALUES ($metaNamespace,'$logTitle','$logText','sysop','$now','$won','$now')" );
452 }
453 print "</li>\n";
454
455 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
456 $title = $titleobj->getDBkey();
457 $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text,cur_timestamp,inverse_timestamp,cur_touched) " .
458 "VALUES (0,'$title','" .
459 wfStrencode( wfMsg( "mainpagetext" ) . "\n\n" . wfMsg( "mainpagedocfooter" ) ) . "','$now','$won','$now')";
460 $wgDatabase->query( $sql, $fname );
461
462 print "<li><pre>";
463 initialiseMessages();
464 print "</pre></li>\n";
465
466 if( $conf->Root ) {
467 print "<li>Granting user permissions...</li>\n";
468 dbsource( "../maintenance/users.sql", $wgDatabase );
469 }
470 }
471
472 /* Write out the config file now that all is well */
473 print "<p>Creating LocalSettings.php...</p>\n\n";
474 $localSettings = "<" . "?php$endl$local$endl?" . ">";
475
476 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
477 $xt = "xt"; # Refuse to overwrite an existing file
478 } else {
479 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
480 }
481 $f = fopen( "LocalSettings.php", $xt );
482
483 if( $f == false ) {
484 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" .
485 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
486 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
487 }
488 fwrite( $f, $localSettings );
489 fclose( $f );
490
491 print "<p>Success! Move the LocalSettings.php file into the parent directory, then follow
492 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
493
494 } while( false );
495 }
496 ?>
497 </ul>
498
499
500 <?php
501
502 if( count( $errs ) ) {
503 /* Display options form */
504
505 if( $conf->posted ) {
506 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
507 }
508 ?>
509
510 <form name="config" method="post">
511
512
513 <h2>Site config</h2>
514
515 <dl class="setup">
516 <dd>
517 <?php
518 aField( $conf, "Sitename", "Site name:" );
519 ?>
520 </dd>
521 <dt>
522 Your site name should be a relatively short word. It'll appear as the namespace
523 name for 'meta' pages as well as throughout the user interface. Good site names
524 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
525 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
526 which may cause problems.
527 </dt>
528
529 <dd>
530 <?php
531 aField( $conf, "EmergencyContact", "Contact e-mail" );
532 ?>
533 </dd>
534 <dt>
535 This will be used as the return address for password reminders and
536 may be displayed in some error conditions so visitors can get in
537 touch with you.
538 </dt>
539
540 <dd>
541 <label class='column' for="LanguageCode">Language</label>
542 <select id="LanguageCode" name="LanguageCode">
543 <?php
544 $list = getLanguageList();
545 foreach( $list as $code => $name ) {
546 $sel = ($code == $conf->LanguageCode) ? "selected" : "";
547 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
548 }
549 ?>
550 </select>
551 </dd>
552 <dt>
553 You may select the language for the user interface of the wiki...
554 Some localizations are less complete than others. This also controls
555 the character encoding; Unicode is more flexible, but Latin-1 may be
556 more compatible with older browsers for some languages. Unicode will
557 be used where not specified otherwise.
558 </dt>
559
560 <dd>
561 <label class='column'>Copyright/license metadata</label>
562 <div>Select one:</div>
563
564 <ul class="plain">
565 <li><?php aField( $conf, "License", "no license metadata", "radio", "none" ); ?></li>
566 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li>
567 <li><?php
568 aField( $conf, "License", "a Creative Commons license...", "radio", "cc" );
569 $partner = "MediaWiki";
570 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
571 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
572 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
573 print "<a href=\"$ccApp\">choose</a>";
574 ?></li>
575 <li><?php aField( $conf, "RightsUrl", $conf->RightsUrl, "hidden" ); ?></li>
576 <li><?php aField( $conf, "RightsText", $conf->RightsText, "hidden" ); ?></li>
577 <li><?php aField( $conf, "RightsCode", $conf->RightsCode, "hidden" ); ?></li>
578 <li><?php aField( $conf, "RightsIcon", $conf->RightsIcon, "hidden" ); ?></li>
579 </ul>
580 </dd>
581 <dt>
582 MediaWiki can include a basic license notice, icon, and machine-reable
583 copyright metadata if your wiki's content is to be licensed under
584 the GNU FDL or a Creative Commons license. If you're not sure, leave
585 it at "none".
586 </dt>
587
588
589 <dd>
590 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
591 </dd>
592 <dd>
593 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
594 </dd>
595 <dd>
596 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
597 </dd>
598 <dt>
599 A sysop user account can lock or delete pages, block problematic IP
600 addresses from editing, and other maintenance tasks. If creating a new
601 wiki database, a sysop account will be created with the given name
602 and password.
603 </dt>
604 </dl>
605
606 <h2>Database config</h2>
607
608 <dl class="setup">
609 <dd><?php
610 aField( $conf, "DBserver", "MySQL server" );
611 ?></dd>
612 <dt>
613 If your database server isn't on your web server, enter the name
614 or IP address here.
615 </dt>
616
617 <dd><?php
618 aField( $conf, "DBname", "Database name" );
619 ?></dd>
620 <dd><?php
621 aField( $conf, "DBuser", "DB username" );
622 ?></dd>
623 <dd><?php
624 aField( $conf, "DBpassword", "DB password", "password" );
625 ?></dd>
626 <dd><?php
627 aField( $conf, "DBpassword2", "again", "password" );
628 ?></dd>
629 <dt>
630 If you only have a single user account and database available,
631 enter those here. If you have database root access (see below)
632 you can specify new accounts/databases to be created.
633 </dt>
634
635
636 <dd>
637 <?php
638 aField( $conf, "RootPW", "DB root password", "password" );
639 ?>
640 </dd>
641 <dt>
642 You will only need this if the database and/or user account
643 above don't already exist.
644 Do <em>not</em> type in your machine's root password! MySQL
645 has its own "root" user with a separate password. (It might
646 even be blank, depending on your configuration.)
647 </dt>
648
649 <dd>
650 <label class='column'>&nbsp;</label>
651 <input type="submit" value="Install!" />
652 </dd>
653 </dl>
654
655
656 </form>
657
658 <?php
659 }
660
661 /* -------------------------------------------------------------------------------------- */
662
663 function writeAdminSettings( $conf ) {
664 return "
665 \$wgDBadminuser = \"{$conf->DBadminuser}\";
666 \$wgDBadminpassword = \"{$conf->DBadminpassword}\";
667 ";
668 }
669
670 function writeLocalSettings( $conf ) {
671 $conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false';
672 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
673 $conf->PasswordSender = $conf->EmergencyContact;
674 if( $conf->LanguageCode == "en-utf8" ) {
675 $conf->LanguageCode = "en";
676 $conf->Encoding = "UTF-8";
677 }
678 $zlib = ($conf->zlib ? "" : "# ");
679 $magic = ($conf->ImageMagick ? "" : "# ");
680 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
681 $pretty = ($conf->prettyURLs ? "" : "# ");
682 $ugly = ($conf->prettyURLs ? "# " : "");
683 $rights = ($conf->RightsUrl) ? "" : "# ";
684
685 # $proxyKey = Parser::getRandomString() . Parser::getRandomString();
686
687 $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
688 return "
689 # This file was automatically generated by the MediaWiki installer.
690 # If you make manual changes, please keep track in case you need to
691 # recreate them later.
692
693 \$IP = \"{$conf->IP}\";
694 ini_set( \"include_path\", \"\$IP/includes$sep\$IP/languages$sep\" . ini_get(\"include_path\") );
695 require_once( \"DefaultSettings.php\" );
696
697 if ( \$wgCommandLineMode ) {
698 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
699 die( \"This script must be run from the command line\\n\" );
700 }
701 } else {
702 ## Compress output if the browser supports it
703 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) ob_start( 'ob_gzhandler' );
704 }
705
706 \$wgSitename = \"{$conf->Sitename}\";
707
708 \$wgScriptPath = \"{$conf->ScriptPath}\";
709 \$wgScript = \"\$wgScriptPath/index.php\";
710 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
711
712 ## If using PHP as a CGI module, use the ugly URLs
713 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
714 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
715
716 \$wgStylePath = \"\$wgScriptPath/stylesheets\";
717 \$wgStyleDirectory = \"\$IP/stylesheets\";
718 \$wgLogo = \"\$wgStylePath/images/wiki.png\";
719
720 \$wgUploadPath = \"\$wgScriptPath/images\";
721 \$wgUploadDirectory = \"\$IP/images\";
722
723 \$wgEmergencyContact = \"{$conf->EmergencyContact}\";
724 \$wgPasswordSender = \"{$conf->PasswordSender}\";
725
726 \$wgDBserver = \"{$conf->DBserver}\";
727 \$wgDBname = \"{$conf->DBname}\";
728 \$wgDBuser = \"{$conf->DBuser}\";
729 \$wgDBpassword = \"{$conf->DBpassword}\";
730
731 ## To allow SQL queries through the wiki's Special:Askaql page,
732 ## uncomment the next lines. THIS IS VERY INSECURE. If you want
733 ## to allow semipublic read-only SQL access for your sysops,
734 ## you should define a MySQL user with limited privileges.
735 ## See MySQL docs: http://www.mysql.com/doc/en/GRANT.html
736 #
737 # \$wgAllowSysopQueries = true;
738 # \$wgDBsqluser = \"sqluser\";
739 # \$wgDBsqlpassword = \"sqlpass\";
740
741 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
742
743 ## To enable image uploads, make sure the 'images' directory
744 ## is writable, then uncomment this:
745 # \$wgDisableUploads = false;
746 \$wgUseImageResize = {$conf->UseImageResize};
747 {$magic}\$wgUseImageMagick = true;
748 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
749
750 ## If you have the appropriate support software installed
751 ## you can enable inline LaTeX equations:
752 # \$wgUseTeX = true;
753 \$wgMathPath = \"{\$wgUploadPath}/math\";
754 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
755 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
756
757 \$wgUsePHPTal = true;
758 if ( \$wgUsePHPTal ) {
759 ini_set( \"include_path\", \"\$IP/PHPTAL-NP-0.7.0/libs$sep\" . ini_get(\"include_path\") );
760 }
761
762 \$wgLocalInterwiki = \$wgSitename;
763
764 \$wgLanguageCode = \"{$conf->LanguageCode}\";
765 " . ($conf->Encoding ? "\$wgInputEncoding = \$wgOutputEncoding = \"{$conf->Encoding}\";" : "" ) . "
766
767 ## Default skin: you can change the default skin. Use the internal symbolic
768 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
769 # \$wgDefaultSkin = 'monobook';
770
771 ## This is incomplete, ignore it:
772 #\$wgProxyKey = $proxyKey;
773
774 ## For attaching licensing metadata to pages, and displaying an
775 ## appropriate copyright notice / icon. GNU Free Documentation
776 ## License and Creative Commons licenses are supported so far.
777 {$rights}\$wgEnableCreativeCommonsRdf = true;
778 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
779 \$wgRightsUrl = \"{$conf->RightsUrl}\";
780 \$wgRightsText = \"{$conf->RightsText}\";
781 \$wgRightsIcon = \"{$conf->RightsIcon}\";
782 # \$wgRightsCode = \"{$conf->RightsCode}\"; # Not yet used
783 ";
784 }
785
786 function dieout( $text ) {
787 die( $text . "\n\n</body>\n</html>" );
788 }
789
790 function importPost( $name, $default = "" ) {
791 if( isset( $_REQUEST[$name] ) ) {
792 return $_REQUEST[$name];
793 } else {
794 return $default;
795 }
796 }
797
798 function aField( &$conf, $field, $text, $type = "", $value = "" ) {
799 if( $type != "" ) {
800 $xtype = "type=\"$type\"";
801 } else {
802 $xtype = "";
803 }
804
805 if(!(isset($id)) or ($id == "") ) $id = $field;
806 $nolabel = ($type == "radio") || ($type == "hidden");
807 if( $nolabel ) {
808 echo "\t\t<label>";
809 } else {
810 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
811 }
812
813 if( $type == "radio" && $value == $conf->$field ) {
814 $checked = "checked='checked'";
815 } else {
816 $checked = "";
817 }
818 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" $checked value=\"";
819 if( $type == "radio" ) {
820 echo htmlspecialchars( $value );
821 } else {
822 echo htmlspecialchars( $conf->$field );
823 }
824 echo "\" />\n";
825 if( $nolabel ) {
826 echo " $text</label>\n";
827 }
828
829 global $errs;
830 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
831 }
832
833 function getLanguageList() {
834 global $wgLanguageNames;
835 if( !isset( $wgLanguageNames ) ) {
836 $wgLanguageCode = "xxx";
837 function wfLocalUrl( $x ) { return $x; }
838 function wfLocalUrlE( $x ) { return $x; }
839 include( "../languages/Language.php" );
840 }
841
842 $codes = array();
843 $latin1 = array( "da", "de", "en", "es", "nl", "sv" );
844
845 $d = opendir( "../languages" );
846 while( false !== ($f = readdir( $d ) ) ) {
847 if( preg_match( '/Language([A-Z][a-z]+)\.php$/', $f, $m ) ) {
848 $code = strtolower( $m[1] );
849 $codes[$code] = "$code - " . $wgLanguageNames[$code];
850 if( in_array( $code, $latin1 ) ) {
851 $codes[$code] .= " - Latin-1";
852 }
853 }
854 }
855 $codes["en-utf8"] = "en - English - Unicode";
856 closedir( $d );
857 ksort( $codes );
858 return $codes;
859 }
860
861 ?>
862
863 </body>
864 </html>