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