Fix non-root install bug
[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 program 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
103 $IP = ".."; # Just to suppress notices, not for anything useful
104 include( "../includes/DefaultSettings.php" );
105 ?>
106
107 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
108
109
110 <?php
111
112 /* Check for existing configurations and bug out! */
113
114 if( file_exists( "../LocalSettings.php" ) || file_exists( "../AdminSettings.php" ) ) {
115 dieout( "<h2>Wiki is configured.</h2>
116
117 <p>Already configured... <a href='../index.php'>return to the wiki</a>.</p>
118
119 <p>(You should probably remove this directory for added security.)</p>" );
120 }
121
122 if( file_exists( "./LocalSettings.php" ) || file_exists( "./AdminSettings.php" ) ) {
123 dieout( "<h2>You're configured!</h2>
124
125 <p>Please move <tt>LocalSettings.php</tt> to the parent directory, then
126 <a href='../index.php'>try out your wiki</a>.
127 (You should remove this config directory for added security once you're done.)</p>" );
128 }
129
130 if( !is_writable( "." ) ) {
131 dieout( "<h2>Can't write config file, aborting</h2>
132
133 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
134 writable by the web server. Once configuration is done you'll move the created
135 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
136 then remove the <tt>config</tt> subdirectory entirely.</p>
137
138 <p>To make the directory writable on a Unix/Linux system:</p>
139
140 <pre>
141 cd <i>/path/to/wiki</i>
142 chmod a+w config
143 </pre>" );
144 }
145
146
147 include( "../install-utils.inc" );
148 include( "../maintenance/updaters.inc" );
149 class ConfigData {
150 function getEncoded( $data ) {
151 # Hackish
152 global $wgInputEncoding;
153 if( strcasecmp( $wgInputEncoding, "utf-8" ) == 0 ) {
154 return $data;
155 } else {
156 return utf8_decode( $data ); /* to latin1 wikis */
157 }
158 }
159 function getSitename() { return $this->getEncoded( $this->Sitename ); }
160 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
161 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
162 }
163
164 ?>
165
166
167 <h2>Checking environment...</h2>
168 <ul>
169 <?php
170 $endl = "
171 ";
172 $conf = new ConfigData;
173
174 install_version_checks();
175 print "<li>PHP " . phpversion() . " ok</li>\n";
176
177 $sapi = php_sapi_name();
178 $conf->prettyURLs = true;
179 print "<li>PHP server API is $sapi; ";
180 switch( $sapi ) {
181 case "apache":
182 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
183 break;
184 case "cgi":
185 case "cgi-fcgi":
186 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
187 $conf->prettyURLs = false;
188 break;
189 default:
190 print "unknown; using pretty URLs (<tt>index.php/Page_Title</tt>), if you have trouble change this in <tt>LocalSettings.php</tt>";
191 }
192 print "</li>\n";
193
194 $conf->zlib = function_exists( "gzencode" );
195 if( $conf->zlib ) {
196 print "<li>Have zlib support; enabling output compression.</li>\n";
197 } else {
198 print "<li>No zlib support.</li>\n";
199 }
200
201 $conf->ImageMagick = false;
202
203 $conf->HaveGD = function_exists( "imagejpeg" );
204 if( $conf->HaveGD ) {
205 print "<li>Found GD graphics library built-in, image thumbnailing will be enabled if you enable uploads.</li>\n";
206 } else {
207 $imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin" );
208 foreach( $imcheck as $dir ) {
209 $im = "$dir/convert";
210 if( file_exists( $im ) ) {
211 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
212 $conf->ImageMagick = $im;
213 break;
214 }
215 }
216 if( !$conf->ImageMagick ) {
217 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
218 }
219 }
220
221 $conf->UseImageResize = $conf->HaveGD || $conf->ImageMagick;
222
223 # $conf->IP = "/Users/brion/Sites/inplace";
224 chdir( ".." );
225 $conf->IP = getcwd();
226 chdir( "config" );
227 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
228
229 # $conf->ScriptPath = "/~brion/inplace";
230 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["REQUEST_URI"] );
231 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
232
233 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
234
235 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
236 $conf->EmergencyContact = importPost( "EmergencyContact", $_SERVER["SERVER_ADMIN"] );
237 $conf->DBserver = importPost( "DBserver", "localhost" );
238 $conf->DBname = importPost( "DBname", "wikidb" );
239 $conf->DBuser = importPost( "DBuser", "wikiuser" );
240 $conf->DBpassword = importPost( "DBpassword" );
241 $conf->DBpassword2 = importPost( "DBpassword2" );
242 $conf->RootPW = importPost( "RootPW" );
243 $conf->LanguageCode = importPost( "LanguageCode", "en-utf8" );
244 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
245 $conf->SysopPass = importPost( "SysopPass" );
246 $conf->SysopPass2 = importPost( "SysopPass2" );
247
248 /* Check for validity */
249 $errs = array();
250
251 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
252 $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
253 }
254 if( $conf->DBpassword == "" ) {
255 $errs["DBpassword"] = "Must not be blank";
256 }
257 if( $conf->DBpassword != $conf->DBpassword2 ) {
258 $errs["DBpassword2"] = "Passwords don't match!";
259 }
260
261 if( $conf->SysopPass == "" ) {
262 $errs["SysopPass"] = "Must not be blank";
263 }
264 if( $conf->SysopPass != $conf->SysopPass2 ) {
265 $errs["SysopPass2"] = "Passwords don't match!";
266 }
267
268 if( $conf->posted && ( 0 == count( $errs ) ) ) {
269 do { /* So we can 'continue' to end prematurely */
270 $conf->Root = ($conf->RootPW != "");
271
272 /* Load up the settings and get installin' */
273 $local = writeLocalSettings( $conf );
274 $wgCommandLineMode = false;
275 eval($local);
276
277 $wgDBadminuser = $wgDBuser;
278 $wgDBadminpassword = $wgDBpassword;
279 $wgCommandLineMode = true;
280 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
281 include_once( "Setup.php" );
282 include_once( "../maintenance/InitialiseMessages.inc" );
283
284 $wgTitle = Title::newFromText( "Installation script" );
285 $wgDatabase = Database::newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 );
286 $wgDatabase->mIgnoreErrors = true;
287
288 @$myver = mysql_get_server_info( $wgDatabase->mConn );
289 if( !$myver ) {
290 print "<li>MySQL error " . ($err = mysql_errno() ) .
291 ": " . htmlspecialchars( mysql_error() );
292 $ok = false;
293 switch( $err ) {
294 case 1045:
295 if( $conf->Root ) {
296 $errs["RootPW"] = "Check password";
297 } else {
298 print "<li>Trying regular user...\n";
299 /* Try the regular user... */
300 $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
301 $wgDatabase->isOpen();
302 $wgDatabase->mIgnoreErrors = true;
303 @$myver = mysql_get_server_info( $wgDatabase->mConn );
304 if( !$myver ) {
305 $errs["DBuser"] = "Check name/pass";
306 $errs["DBpassword"] = "or enter root";
307 $errs["DBpassword2"] = "password below";
308 $errs["RootPW"] = "Got root?";
309 print " need password.</li>\n";
310 } else {
311 $conf->Root = false;
312 $conf->RootPW = "";
313 print " ok.</li>\n";
314 # And keep going...
315 $ok = true;
316 }
317 break;
318 }
319 case 2002:
320 case 2003:
321 $errs["DBserver"] = "Connection failed";
322 break;
323 default:
324 $errs["DBserver"] = "Couldn't connect to database";
325 break;
326 }
327 if( !$ok ) continue;
328 }
329
330 if ( !$wgDatabase->isOpen() ) {
331 $errs["DBserver"] = "Couldn't connect to database";
332 continue;
333 }
334
335 print "<li>Connected to database... $myver";
336 if( version_compare( $myver, "4.0.0" ) >= 0 ) {
337 print "; enabling MySQL 4 enhancements";
338 $conf->DBmysql4 = true;
339 $local = writeLocalSettings( $conf );
340 }
341 print "</li>\n";
342
343 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn );
344 if( $sel ) {
345 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
346 } else {
347 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
348 if( !$res ) {
349 print "<li>Couldn't create database <tt>" .
350 htmlspecialchars( $wgDBname ) .
351 "</tt>; try with root access or check your username/pass.</li>\n";
352 $errs["RootPW"] = "&lt;- Enter";
353 continue;
354 }
355 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
356 }
357
358 $wgDatabase->selectDB( $wgDBname );
359
360 if( $wgDatabase->tableExists( "cur" ) ) {
361 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n<pre>";
362
363 chdir( ".." );
364 flush();
365 do_ipblocks_update(); flush();
366 do_interwiki_update(); flush();
367 do_index_update(); flush();
368 do_linkscc_update(); flush();
369 do_hitcounter_update(); flush();
370 do_recentchanges_update(); flush();
371 initialiseMessages(); flush();
372 chdir( "config" );
373
374 print "</pre>\n";
375 print "<li>Finished update checks.</li>\n";
376 } else {
377 # FIXME: Check for errors
378 print "<li>Creating tables...";
379 dbsource( "../maintenance/tables.sql", $wgDatabase );
380 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
381 dbsource( "../maintenance/indexes.sql", $wgDatabase );
382 print " done.</li>\n";
383
384 print "<li>Initializing data...";
385 $wgDatabase->query( "INSERT INTO site_stats (ss_row_id,ss_total_views," .
386 "ss_total_edits,ss_good_articles) VALUES (1,0,0,0)" );
387
388 if( $conf->SysopName ) {
389 $u = User::newFromName( $conf->getSysopName() );
390 if ( 0 == $u->idForName() ) {
391 $u->addToDatabase();
392 $u->setPassword( $conf->getSysopPass() );
393 $u->addRight( "sysop" );
394 $u->addRight( "bureaucrat" );
395 $u->saveSettings();
396 print "<li>Created sysop account <tt>" .
397 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
398 } else {
399 print "<li>Could not create user - already exists!</li>\n";
400 }
401 } else {
402 print "<li>Skipped sysop account creation, no name given.</li>\n";
403 }
404
405 print "<li>Initialising log pages...";
406 $logs = array(
407 "uploadlogpage" => "uploadlogpagetext",
408 "dellogpage" => "dellogpagetext",
409 "protectlogpage" => "protectlogtext",
410 "blocklogpage" => "blocklogtext"
411 );
412 $metaNamespace = Namespace::getWikipedia();
413 $now = wfTimestampNow();
414 $won = wfInvertTimestamp( $now );
415 foreach( $logs as $page => $text ) {
416 $logTitle = wfStrencode( $wgLang->ucfirst( str_replace( " ", "_", wfMsgNoDB( $page ) ) ) );
417 $logText = wfStrencode( wfMsgNoDB( $text ) );
418 $wgDatabase->query( "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
419 "cur_restrictions,cur_timestamp,inverse_timestamp,cur_touched) " .
420 "VALUES ($metaNamespace,'$logTitle','$logText','sysop','$now','$won','$now')" );
421 }
422 print "</li>\n";
423
424 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
425 $title = $titleobj->getDBkey();
426 $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text,cur_timestamp,inverse_timestamp,cur_touched) " .
427 "VALUES (0,'$title','" .
428 wfStrencode( wfMsg( "mainpagetext" ) ) . "','$now','$won','$now')";
429 $wgDatabase->query( $sql, $fname );
430
431 print "<li><pre>";
432 initialiseMessages();
433 print "</pre></li>\n";
434
435 if( $conf->Root ) {
436 # Grant user permissions
437 dbsource( "../maintenance/users.sql", $wgDatabase );
438 }
439 }
440
441 /* Write out the config file now that all is well */
442 print "<p>Creating LocalSettings.php...</p>\n\n";
443 $localSettings = "<" . "?php$endl$local$endl?" . ">";
444
445 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
446 $xt = "xt"; # Refuse to overwrite an existing file
447 } else {
448 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
449 }
450 $f = fopen( "LocalSettings.php", $xt );
451
452 if( $f == false ) {
453 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" .
454 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
455 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
456 }
457 fwrite( $f, $localSettings );
458 fclose( $f );
459
460 print "<p>Success! Move the LocalSettings.php file into the parent directory, then follow
461 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
462
463 } while( false );
464 }
465 ?>
466 </ul>
467
468
469 <?php
470
471 if( count( $errs ) ) {
472 /* Display options form */
473
474 if( $conf->posted ) {
475 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
476 }
477 ?>
478
479 <form name="config" method="post">
480
481
482 <h2>Site config</h2>
483
484 <dl class="setup">
485 <dd>
486 <?php
487 aField( $conf, "Sitename", "Site name:" );
488 ?>
489 </dd>
490 <dt>
491 Your site name should be a relatively short word. It'll appear as the namespace
492 name for 'meta' pages as well as throughout the user interface. Good site names
493 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
494 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
495 which may cause problems.
496 </dt>
497
498 <dd>
499 <?php
500 aField( $conf, "EmergencyContact", "Contact e-mail" );
501 ?>
502 </dd>
503 <dt>
504 This will be used as the return address for password reminders and
505 may be displayed in some error conditions so visitors can get in
506 touch with you.
507 </dt>
508
509 <dd>
510 <label for="LanguageCode">Language</label>
511 <select id="LanguageCode" name="LanguageCode">
512 <?php
513 $list = getLanguageList();
514 foreach( $list as $code => $name ) {
515 $sel = ($code == $conf->LanguageCode) ? "selected" : "";
516 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
517 }
518 ?>
519 </select>
520 </dd>
521 <dt>
522 You may select the language for the user interface of the wiki...
523 Some localizations are less complete than others. This also controls
524 the character encoding; Unicode is more flexible, but Latin-1 may be
525 more compatible with older browsers for some languages. Unicode will
526 be used where not specified otherwise.
527 </dt>
528
529 <dd>
530 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
531 </dd>
532 <dd>
533 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
534 </dd>
535 <dd>
536 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
537 </dd>
538 <dt>
539 A sysop user account can lock or delete pages, block problematic IP
540 addresses from editing, and other maintenance tasks. If creating a new
541 wiki database, a sysop account will be created with the given name
542 and password.
543 </dt>
544 </dl>
545
546 <h2>Database config</h2>
547
548 <dl class="setup">
549 <dd><?php
550 aField( $conf, "DBserver", "MySQL server" );
551 ?></dd>
552 <dt>
553 If your database server isn't on your web server, enter the name
554 or IP address here.
555 </dt>
556
557 <dd><?php
558 aField( $conf, "DBname", "Database name" );
559 ?></dd>
560 <dd><?php
561 aField( $conf, "DBuser", "DB username" );
562 ?></dd>
563 <dd><?php
564 aField( $conf, "DBpassword", "DB password", "password" );
565 ?></dd>
566 <dd><?php
567 aField( $conf, "DBpassword2", "again", "password" );
568 ?></dd>
569 <dt>
570 If you only have a single user account and database available,
571 enter those here. If you have database root access (see below)
572 you can specify new accounts/databases to be created.
573 </dt>
574
575
576 <dd>
577 <?php
578 aField( $conf, "RootPW", "DB root password", "password" );
579 ?>
580 </dd>
581 <dt>
582 You will only need this if the database and/or user account
583 above don't already exist.
584 Do <em>not</em> type in your machine's root password! MySQL
585 has its own "root" user with a separate password. (It might
586 even be blank, depending on your configuration.)
587 </dt>
588
589 <dd>
590 <label>&nbsp;</label>
591 <input type="submit" value="Install!" />
592 </dd>
593 </dl>
594
595
596 </form>
597
598 <?php
599 }
600
601 /* -------------------------------------------------------------------------------------- */
602
603 function writeAdminSettings( $conf ) {
604 return "
605 \$wgDBadminuser = \"{$conf->DBadminuser}\";
606 \$wgDBadminpassword = \"{$conf->DBadminpassword}\";
607 ";
608 }
609
610 function writeLocalSettings( $conf ) {
611 $conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false';
612 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
613 $conf->PasswordSender = $conf->EmergencyContact;
614 if( $conf->LanguageCode == "en-utf8" ) {
615 $conf->LanguageCode = "en";
616 $conf->Encoding = "UTF-8";
617 }
618 $zlib = ($conf->zlib ? "" : "# ");
619 $magic = ($conf->ImageMagick ? "" : "# ");
620 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
621 $pretty = ($conf->prettyURLs ? "" : "# ");
622 $ugly = ($conf->prettyURLs ? "# " : "");
623
624 $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
625 return "
626 # This file was automatically generated by the MediaWiki installer.
627 # If you make manual changes, please keep track in case you need to
628 # recreate them later.
629
630 \$IP = \"{$conf->IP}\";
631 ini_set( \"include_path\", \"\$IP/includes$sep\$IP/languages$sep\" . ini_get(\"include_path\") );
632 include_once( \"DefaultSettings.php\" );
633
634 if( \$wgCommandLineMode ) {
635 die( \"Can't use command-line utils with in-place install yet, sorry.\" );
636 } else {
637 ## Compress output if the browser supports it
638 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) ob_start( 'ob_gzhandler' );
639 }
640
641 \$wgSitename = \"{$conf->Sitename}\";
642
643 \$wgScriptPath = \"{$conf->ScriptPath}\";
644 \$wgScript = \"\$wgScriptPath/index.php\";
645 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
646
647 ## If using PHP as a CGI module, use the ugly URLs
648 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
649 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
650
651 \$wgStyleSheetPath = \"\$wgScriptPath/stylesheets\";
652 \$wgStyleSheetDirectory = \"\$IP/stylesheets\";
653
654 \$wgUploadPath = \"\$wgScriptPath/images\";
655 \$wgUploadDirectory = \"\$IP/images\";
656 \$wgLogo = \"\$wgUploadPath/wiki.png\";
657
658 \$wgEmergencyContact = \"{$conf->EmergencyContact}\";
659 \$wgPasswordSender = \"{$conf->PasswordSender}\";
660
661 \$wgDBserver = \"{$conf->DBserver}\";
662 \$wgDBname = \"{$conf->DBname}\";
663 \$wgDBuser = \"{$conf->DBuser}\";
664 \$wgDBpassword = \"{$conf->DBpassword}\";
665
666 ## To allow SQL queries through the wiki's Special:Askaql page,
667 ## uncomment the next lines. THIS IS VERY INSECURE. If you want
668 ## to allow semipublic read-only SQL access for your sysops,
669 ## you should define a MySQL user with limited privileges.
670 ## See MySQL docs: http://www.mysql.com/doc/en/GRANT.html
671 #
672 # \$wgAllowSysopQueries = true;
673 # \$wgDBsqluser = \"sqluser\";
674 # \$wgDBsqlpassword = \"sqlpass\";
675
676 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
677
678 ## To enable image uploads, make sure the 'images' directory
679 ## is writable, then uncomment this:
680 # \$wgDisableUploads = false;
681 \$wgUseImageResize = {$conf->UseImageResize};
682 {$magic}\$wgUseImageMagick = true;
683 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
684
685 ## If you have the appropriate support software installed
686 ## you can enable inline LaTeX equations:
687 # \$wgUseTeX = true;
688 \$wgMathPath = \"{\$wgUploadPath}/math\";
689 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
690 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
691
692 ## Experimental layout template subsystems
693 \$wgUsePHPTal = false;
694 \$wgUseSmarty = false;
695 if ( \$wgUsePHPTal ) {
696 ini_set( \"include_path\", \"\$IP/PHPTAL-NP-0.7.0/libs$sep\" . ini_get(\"include_path\") );
697 }
698 if ( \$wgUseSmarty ) {
699 ini_set( \"include_path\", \"\$IP/Smarty-2.6.2/libs$sep\" . ini_get(\"include_path\") );
700 }
701
702 \$wgLocalInterwiki = \$wgSitename;
703
704 \$wgLanguageCode = \"{$conf->LanguageCode}\";
705 " . ($conf->Encoding ? "\$wgInputEncoding = \$wgOutputEncoding = \"{$conf->Encoding}\";" : "" ) . "
706
707 ";
708 }
709
710 function dieout( $text ) {
711 die( $text . "\n\n</body>\n</html>" );
712 }
713
714 function importPost( $name, $default = "" ) {
715 if( isset( $_POST[$name] ) ) {
716 return $_POST[$name];
717 } else {
718 return $default;
719 }
720 }
721
722 function aField( &$conf, $field, $text, $type = "" ) {
723 if( $type != "" ) $type = "type=\"$type\"";
724 echo "\t\t<label for=\"$field\">$text</label>\n";
725 echo "\t\t<input $type name=\"$field\" id=\"$field\" value=\"";
726 echo htmlspecialchars( $conf->$field );
727 echo "\" />\n";
728
729 global $errs;
730 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
731 }
732
733 function getLanguageList() {
734 global $wgLanguageNames;
735 if( !isset( $wgLanguageNames ) ) {
736 $wgLanguageCode = "xxx";
737 function wfLocalUrl( $x ) { return $x; }
738 function wfLocalUrlE( $x ) { return $x; }
739 include( "../languages/Language.php" );
740 }
741
742 $codes = array();
743 $latin1 = array( "da", "de", "en", "es", "nl", "sv" );
744
745 $d = opendir( "../languages" );
746 while( false !== ($f = readdir( $d ) ) ) {
747 if( preg_match( '/Language([A-Z][a-z]+)\.php$/', $f, $m ) ) {
748 $code = strtolower( $m[1] );
749 $codes[$code] = "$code - " . $wgLanguageNames[$code];
750 if( in_array( $code, $latin1 ) ) {
751 $codes[$code] .= " - Latin-1";
752 }
753 }
754 }
755 $codes["en-utf8"] = "en - English - Unicode";
756 closedir( $d );
757 ksort( $codes );
758 return $codes;
759 }
760
761 ?>
762
763 </body>
764 </html>