Use PATH_INFO for prettier default URLs: index.php/Foo instead of index.php?title=Foo
[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 {
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 </style>
64 </head>
65
66 <body>
67
68 <div id="credit">
69 <center>
70 <a href="http://www.mediawiki.org/"><img
71 src="../images/wiki.png" width="135" height="135" alt="" border="0" /></a>
72 </center>
73
74 <b><a href="http://www.mediawiki.org/">MediaWiki</a></b> is
75 Copyright (C) 2001-2004 by Magnus Manske, Brion Vibber, Lee Daniel Crocker,
76 Tim Starling, Erik M&ouml;ller, and others.</p>
77
78 <ul>
79 <li><a href="../README">Readme</a></li>
80 <li><a href="../RELEASE-NOTES">Release notes</a></li>
81 <li><a href="../docs/">doc/</a></li>
82 <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li>
83 </ul>
84
85 <p>This program is free software; you can redistribute it and/or modify
86 it under the terms of the GNU General Public License as published by
87 the Free Software Foundation; either version 2 of the License, or
88 (at your option) any later version.</p>
89
90 <p>This progarm is distributed in the hope that it will be useful,
91 but WITHOUT ANY WARRANTY; without even the implied warranty of
92 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93 GNU General Public License for more details.</p>
94
95 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
96 along with this program; if not, write to the Free Software
97 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
98 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
99 </div>
100
101 <?php
102 include( "../includes/DefaultSettings.php" );
103 ?>
104
105 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
106
107
108 <?php
109
110 /* Check for existing configurations and bug out! */
111
112 if( file_exists( "../LocalSettings.php" ) || file_exists( "../AdminSettings.php" ) ) {
113 dieout( "<h2>Wiki is configured.</h2>
114
115 <p>Already configured... <a href='../index.php'>return to the wiki</a>.</p>
116
117 <p>(You should probably remove this directory for added security.)</p>" );
118 }
119
120 if( file_exists( "./LocalSettings.php" ) || file_exists( "./AdminSettings.php" ) ) {
121 dieout( "<h2>You're configured!</h2>
122
123 <p>Please move <tt>LocalSettings.php</tt> to the parent directory, then
124 <a href='../index.php'>try out your wiki</a>.
125 (You should remove this config directory for added security once you're done.)</p>" );
126 }
127
128 if( !is_writable( "." ) ) {
129 dieout( "<h2>Can't write config file, aborting</h2>
130
131 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
132 writable by the web server. Once configuration is done you'll move the created
133 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
134 then remove the <tt>config</tt> subdirectory entirely.</p>
135
136 <p>To make the directory writable on a Unix/Linux system:</p>
137
138 <pre>
139 cd <i>/path/to/wiki</i>
140 chmod a+w config
141 </pre>" );
142 }
143
144
145 include( "../install-utils.inc" );
146 include( "../maintenance/updaters.inc" );
147 class ConfigData {
148 function getEncoded( $data ) {
149 # Hackish
150 global $wgInputEncoding;
151 if( strcasecmp( $wgInputEncoding, "utf-8" ) == 0 ) {
152 return $data;
153 } else {
154 return utf8_decode( $data ); /* to latin1 wikis */
155 }
156 }
157 function getSitename() { return $this->getEncoded( $this->Sitename ); }
158 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
159 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
160 }
161
162 ?>
163
164
165 <h2>Checking environment...</h2>
166 <ul>
167 <?php
168
169 $conf = new ConfigData;
170
171 install_version_checks();
172 print "<li>PHP " . phpversion() . " ok</li>\n";
173
174 /*
175 $conf->zlib = function_exists( "gzencode" );
176 $z = $conf->zlib ? "Have" : "No";
177 print "<li>$z zlib support</li>\n";
178
179 $conf->gd = function_exists( "imagejpeg" );
180 if( $conf->gd ) {
181 print "<li>Found GD graphics library built-in</li>\n";
182 } else {
183 print "<li>No built-in GD library</li>\n";
184 }
185
186 if( file_exists( "/usr/bin/convert" ) ) {
187 $conf->ImageMagick = "/usr/bin/convert";
188 print "<li>Found ImageMagick: /usr/bin/convert</li>\n";
189 } elseif( file_exists( "/usr/local/bin/convert" ) ) {
190 $conf->ImageMagick = "/usr/local/bin/convert";
191 print "<li>Found ImageMagick: /usr/local/bin/convert</li>\n";
192 } else {
193 $conf->ImageMagick = false;
194 print "<li>No ImageMagick.</li>\n";
195 }
196 */
197
198 # $conf->IP = "/Users/brion/Sites/inplace";
199 chdir( ".." );
200 $conf->IP = getcwd();
201 chdir( "config" );
202 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
203
204 # $conf->ScriptPath = "/~brion/inplace";
205 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["REQUEST_URI"] );
206 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
207
208 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
209
210 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
211 $conf->EmergencyContact = importPost( "EmergencyContact", $_SERVER["SERVER_ADMIN"] );
212 $conf->DBserver = importPost( "DBserver", "localhost" );
213 $conf->DBname = importPost( "DBname", "wikidb" );
214 $conf->DBuser = importPost( "DBuser", "wikiuser" );
215 $conf->DBpassword = importPost( "DBpassword" );
216 $conf->DBpassword2 = importPost( "DBpassword2" );
217 $conf->RootPW = importPost( "RootPW" );
218 $conf->LanguageCode = importPost( "LanguageCode", "en-utf8" );
219 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
220 $conf->SysopPass = importPost( "SysopPass" );
221 $conf->SysopPass2 = importPost( "SysopPass2" );
222
223 /* Check for validity */
224 $errs = array();
225
226 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
227 $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
228 }
229 if( $conf->DBpassword == "" ) {
230 $errs["DBpassword"] = "Must not be blank";
231 }
232 if( $conf->DBpassword != $conf->DBpassword2 ) {
233 $errs["DBpassword2"] = "Passwords don't match!";
234 }
235
236 if( $conf->SysopPass == "" ) {
237 $errs["SysopPass"] = "Must not be blank";
238 }
239 if( $conf->SysopPass != $conf->SysopPass2 ) {
240 $errs["SysopPass2"] = "Passwords don't match!";
241 }
242
243 if( $conf->posted && ( 0 == count( $errs ) ) ) {
244 do { /* So we can 'continue' to end prematurely */
245 $conf->Root = ($conf->RootPW != "");
246
247 /* Load up the settings and get installin' */
248 $local = writeLocalSettings( $conf );
249 $wgCommandLineMode = false;
250 eval($local);
251
252 $wgDBadminuser = $wgDBuser;
253 $wgDBadminpassword = $wgDBpassword;
254 $wgCommandLineMode = true;
255 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
256 include_once( "Setup.php" );
257 include_once( "../maintenance/InitialiseMessages.inc" );
258
259 $wgTitle = Title::newFromText( "Installation script" );
260
261 if( $conf->Root ) {
262 $wgDatabase = Database::newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 );
263 } else {
264 $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
265 }
266 $wgDatabase->mIgnoreErrors = true;
267
268 if ( !$wgDatabase->isOpen() ) {
269 $errs["DBserver"] = "Couldn't connect to database";
270 continue;
271 }
272
273 @$myver = mysql_get_server_info( $wgDatabase->mConn );
274 if( !$myver ) {
275 print "<li>MySQL error " . ($err = mysql_errno() ) .
276 ": " . htmlspecialchars( mysql_error() );
277 switch( $err ) {
278 case 1045:
279 if( $conf->Root ) {
280 $errs["RootPW"] = "Check password";
281 } else {
282 $errs["DBuser"] = "Check name/pass";
283 $errs["DBpassword"] = "or enter root";
284 $errs["DBpassword2"] = "password below";
285 $errs["RootPW"] = "Got root?";
286 }
287 break;
288 case 2002:
289 case 2003:
290 $errs["DBserver"] = "Connection failed";
291 break;
292 default:
293 $errs["DBserver"] = "Couldn't connect to database";
294 }
295 continue;
296 }
297 print "<li>Connected to database... $myver";
298 if( version_compare( $myver, "4.0.0" ) >= 0 ) {
299 print "; enabling MySQL 4 enhancements";
300 $conf->DBmysql4 = true;
301 $local = writeLocalSettings( $conf );
302 }
303 print "</li>\n";
304
305 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn );
306 if( $sel ) {
307 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
308 } else {
309 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
310 if( !$res ) {
311 print "<li>Couldn't create database <tt>" .
312 htmlspecialchars( $wgDBname ) .
313 "</tt>; try with root access or check your username/pass.</li>\n";
314 $errs["RootPW"] = "&lt;- Enter";
315 continue;
316 }
317 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
318 }
319
320 $wgDatabase->selectDB( $wgDBname );
321
322 if( $wgDatabase->tableExists( "cur" ) ) {
323 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n<pre>";
324
325 chdir( ".." );
326 flush();
327 do_ipblocks_update(); flush();
328 do_interwiki_update(); flush();
329 do_index_update(); flush();
330 do_linkscc_update(); flush();
331 do_hitcounter_update(); flush();
332 do_recentchanges_update(); flush();
333 initialiseMessages(); flush();
334 chdir( "config" );
335
336 print "</pre>\n";
337 print "<li>Finished update checks.</li>\n";
338 } else {
339 # FIXME: Check for errors
340 print "<li>Creating tables...";
341 dbsource( "../maintenance/tables.sql", $wgDatabase );
342 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
343 dbsource( "../maintenance/indexes.sql", $wgDatabase );
344 print " done.</li>\n";
345
346 print "<li>Initializing data...";
347 $wgDatabase->query( "INSERT INTO site_stats (ss_row_id,ss_total_views," .
348 "ss_total_edits,ss_good_articles) VALUES (1,0,0,0)" );
349
350 if( $conf->SysopName ) {
351 $u = User::newFromName( $conf->getSysopName() );
352 if ( 0 == $u->idForName() ) {
353 $u->addToDatabase();
354 $u->setPassword( $conf->getSysopPass() );
355 $u->addRight( "sysop" );
356 $u->addRight( "developer" ); /* ?? */
357 $u->saveSettings();
358 print "<li>Created sysop account <tt>" .
359 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
360 } else {
361 print "<li>Could not create user - already exists!</li>\n";
362 }
363 } else {
364 print "<li>Skipped sysop account creation, no name given.</li>\n";
365 }
366
367 print "<li>Initialising log pages...";
368 $logs = array(
369 "uploadlogpage" => "uploadlogpagetext",
370 "dellogpage" => "dellogpagetext",
371 "protectlogpage" => "protectlogtext",
372 "blocklogpage" => "bloglogtext"
373 );
374 $metaNamespace = Namespace::getWikipedia();
375 $now = wfTimestampNow();
376 $won = wfInvertTimestamp( $now );
377 foreach( $logs as $page => $text ) {
378 $logTitle = wfStrencode( $wgLang->ucfirst( str_replace( " ", "_", wfMsgNoDB( $page ) ) ) );
379 $logText = wfStrencode( wfMsgNoDB( $text ) );
380 $wgDatabase->query( "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
381 "cur_restrictions,cur_timestamp,inverse_timestamp,cur_touched) " .
382 "VALUES ($metaNamespace,'$logTitle','$logText','sysop','$now','$won','$now')" );
383 }
384 print "</li>\n";
385
386 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
387 $title = $titleobj->getDBkey();
388 $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text,cur_timestamp,inverse_timestamp,cur_touched) " .
389 "VALUES (0,'$title','" .
390 wfStrencode( wfMsg( "mainpagetext" ) ) . "','$now','$won','$now')";
391 $wgDatabase->query( $sql, $fname );
392
393 print "<li>";
394 initialiseMessages();
395 print "</li>\n";
396
397 if( $conf->Root ) {
398 # Grant user permissions
399 dbsource( "../maintenance/users.sql", $wgDatabase );
400 }
401 }
402
403 /* Write out the config file now that all is well */
404 print "<p>Creating LocalSettings.php...</p>\n\n";
405 $localSettings = "<" . "?php\n$local\n?" . ">";
406 $f = fopen( "LocalSettings.php", "xt" );
407 if( $f == false ) {
408 dieout( "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" .
409 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
410 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
411 }
412 fwrite( $f, $localSettings );
413 fclose( $f );
414
415 print "<p>Success! Move the LocalSettings.php file into the parent directory, then follow
416 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
417
418 } while( false );
419 }
420 ?>
421 </ul>
422
423
424 <?php
425
426 if( count( $errs ) ) {
427 /* Display options form */
428
429 if( $conf->posted ) {
430 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
431 }
432 ?>
433
434 <form name="config" method="post">
435
436
437 <h2>Site config</h2>
438
439 <dl class="setup">
440 <dd>
441 <?php
442 aField( $conf, "Sitename", "Site name:" );
443 ?>
444 </dd>
445 <dt>
446 Your site name should be a relatively short word. It'll appear as the namespace
447 name for 'meta' pages as well as throughout the user interface. Good site names
448 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
449 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
450 which may cause problems.
451 </dt>
452
453 <dd>
454 <?php
455 aField( $conf, "EmergencyContact", "Contact e-mail" );
456 ?>
457 </dd>
458 <dt>
459 This will be used as the return address for password reminders and
460 may be displayed in some error conditions so visitors can get in
461 touch with you.
462 </dt>
463
464 <dd>
465 <label for="LanguageCode">Language</label>
466 <select id="LanguageCode" name="LanguageCode">
467 <?php
468 $list = getLanguageList();
469 foreach( $list as $code => $name ) {
470 $sel = ($code == $conf->LanguageCode) ? "selected" : "";
471 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
472 }
473 ?>
474 </select>
475 </dd>
476 <dt>
477 You may select the language for the user interface of the wiki...
478 Some localizations are less complete than others. This also controls
479 the character encoding; Unicode is more flexible, but Latin-1 may be
480 more compatible with older browsers for some languages. Unicode will
481 be used where not specified otherwise.
482 </dt>
483
484 <dd>
485 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
486 </dd>
487 <dd>
488 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
489 </dd>
490 <dd>
491 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
492 </dd>
493 <dt>
494 A sysop user account can lock or delete pages, block problematic IP
495 addresses from editing, and other maintenance tasks. If creating a new
496 wiki database, a sysop account will be created with the given name
497 and password.
498 </dt>
499 </dl>
500
501 <h2>Database config</h2>
502
503 <dl class="setup">
504 <dd><?php
505 aField( $conf, "DBserver", "MySQL server" );
506 ?></dd>
507 <dt>
508 If your database server isn't on your web server, enter the name
509 or IP address here.
510 </dt>
511
512 <dd><?php
513 aField( $conf, "DBname", "Database name" );
514 ?></dd>
515 <dd><?php
516 aField( $conf, "DBuser", "DB username" );
517 ?></dd>
518 <dd><?php
519 aField( $conf, "DBpassword", "DB password", "password" );
520 ?></dd>
521 <dd><?php
522 aField( $conf, "DBpassword2", "again", "password" );
523 ?></dd>
524 <dt>
525 If you only have a single user account and database available,
526 enter those here. If you have database root access (see below)
527 you can specify new accounts/databases to be created.
528 </dt>
529
530
531 <dd>
532 <?php
533 aField( $conf, "RootPW", "DB root password", "password" );
534 ?>
535 </dd>
536 <dt>
537 You will only need this if the database and/or user account
538 above don't already exist.
539 Do <em>not</em> type in your machine's root password! MySQL
540 has its own "root" user with a separate password. (It might
541 even be blank, depending on your configuration.)
542 </dt>
543
544 <dd>
545 <label>&nbsp;</label>
546 <input type="submit" value="Install!" />
547 </dd>
548 </dl>
549
550
551 </form>
552
553 <?php
554 }
555
556 /* -------------------------------------------------------------------------------------- */
557
558 function writeAdminSettings( $conf ) {
559 return "
560 \$wgDBadminuser = \"{$conf->DBadminuser}\";
561 \$wgDBadminpassword = \"{$conf->DBadminpassword}\";
562 ";
563 }
564
565 function writeLocalSettings( $conf ) {
566 $conf->DBmysql4 = $conf->DBmysql4 ? 'true' : 'false';
567 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
568 $conf->DBsqluser = $conf->DBuser;
569 $conf->DBsqlpassword = $conf->DBpassword;
570 $conf->PasswordSender = $conf->EmergencyContact;
571 if( $conf->LanguageCode == "en-utf8" ) {
572 $conf->LanguageCode = "en";
573 $conf->Encoding = "UTF-8";
574 }
575 $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
576 return "
577 # This file was automatically generated. Don't touch unless you
578 # know what you're doing; see LocalSettings.sample for an edit-
579 # friendly file.
580
581 \$IP = \"{$conf->IP}\";
582 ini_set( \"include_path\", \"\$IP/includes$sep\$IP/languages$sep\" . ini_get(\"include_path\") );
583 include_once( \"DefaultSettings.php\" );
584
585 if( \$wgCommandLineMode ) {
586 die( \"Can't use command-line utils with in-place install yet, sorry.\" );
587 }
588
589 \$wgSitename = \"{$conf->Sitename}\";
590
591 \$wgScriptPath = \"{$conf->ScriptPath}\";
592 \$wgScript = \"\$wgScriptPath/index.php\";
593 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
594
595 \$wgArticlePath = \"\$wgScript/\$1\";
596
597 \$wgStyleSheetPath = \"\$wgScriptPath/stylesheets\";
598 \$wgStyleSheetDirectory = \"\$IP/stylesheets\";
599
600 \$wgUploadPath = \"\$wgScriptPath/images\";
601 \$wgUploadDirectory = \"\$IP/images\";
602 \$wgLogo = \"\$wgUploadPath/wiki.png\";
603
604 \$wgEmergencyContact = \"{$conf->EmergencyContact}\";
605 \$wgPasswordSender = \"{$conf->PasswordSender}\";
606
607 \$wgDBserver = \"{$conf->DBserver}\";
608 \$wgDBname = \"{$conf->DBname}\";
609 \$wgDBuser = \"{$conf->DBuser}\";
610 \$wgDBpassword = \"{$conf->DBpassword}\";
611 \$wgDBsqluser = \"{$conf->DBsqluser}\";
612 \$wgDBsqlpassword = \"{$conf->DBsqlpassword}\";
613
614 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
615
616 \$wgUseImageResize = {$conf->UseImageResize};
617
618 ## If you have the appropriate support software installed
619 ## you can enable inline LaTeX equations:
620 # \$wgUseTeX = true;
621 # \$wgMathPath = \"{$wgUploadPath}/math\";
622 # \$wgMathDirectory = \"{$wgUploadDirectory}/math\";
623 # \$wgTmpDirectory = \"{$wgUploadDirectory}/tmp\";
624
625 \$wgLocalInterwiki = \$wgSitename;
626
627 \$wgLanguageCode = \"{$conf->LanguageCode}\";
628 " . ($conf->Encoding ? "\$wgInputEncoding = \$wgOutputEncoding = \"{$conf->Encoding}\";" : "" ) . "
629
630 ";
631 }
632
633 function dieout( $text ) {
634 die( $text . "\n\n</body>\n</html>" );
635 }
636
637 function importPost( $name, $default = "" ) {
638 if( isset( $_POST[$name] ) ) {
639 return $_POST[$name];
640 } else {
641 return $default;
642 }
643 }
644
645 function aField( &$conf, $field, $text, $type = "" ) {
646 if( $type != "" ) $type = "type=\"$type\"";
647 echo "\t\t<label for=\"$field\">$text</label>\n";
648 echo "\t\t<input $type name=\"$field\" id=\"$field\" value=\"";
649 echo htmlspecialchars( $conf->$field );
650 echo "\" />\n";
651
652 global $errs;
653 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
654 }
655
656 function getLanguageList() {
657 global $wgLanguageNames;
658 if( !isset( $wgLanguageNames ) ) {
659 $wgLanguageCode = "xxx";
660 function wfLocalUrl( $x ) { return $x; }
661 function wfLocalUrlE( $x ) { return $x; }
662 include( "../languages/Language.php" );
663 }
664
665 $codes = array();
666 $latin1 = array( "da", "de", "en", "es", "fr", "nl", "sv" );
667
668 $d = opendir( "../languages" );
669 while( false !== ($f = readdir( $d ) ) ) {
670 if( preg_match( '/Language([A-Z][a-z]+)\.php$/', $f, $m ) ) {
671 $code = strtolower( $m[1] );
672 $codes[$code] = "$code - " . $wgLanguageNames[$code];
673 if( in_array( $code, $latin1 ) ) {
674 $codes[$code] .= " - Latin-1";
675 }
676 }
677 }
678 $codes["en-utf8"] = "en - English - Unicode";
679 closedir( $d );
680 ksort( $codes );
681 return $codes;
682 }
683
684 ?>
685
686 </body>
687 </html>