(bug 619) be intelligent about finding the "diff3" executable. firstly, make sure
[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 error_reporting( E_ALL );
22 header( "Content-type: text/html; charset=utf-8" );
23 @ini_set( "display_errors", true );
24
25 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
26 "http://www.w3.org/TR/html4/loose.dtd">
27 <html>
28 <head>
29 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
30 <meta name="robots" content="noindex,nofollow">
31 <title>MediaWiki installation</title>
32 <style type="text/css">
33 #credit {
34 float: right;
35 width: 200px;
36 font-size: 0.7em;
37 background-color: #eee;
38 color: black;
39 border: solid 1px #444;
40 padding: 8px;
41 margin-left: 8px;
42 }
43
44 dl.setup dd {
45 margin-left: 0;
46 }
47 dl.setup dd label.column {
48 clear: left;
49 font-weight: bold;
50 width: 12em;
51 float: left;
52 text-align: right;
53 padding-right: 1em;
54 }
55 dl.setup dt {
56 clear: left;
57 font-size: 0.8em;
58 margin-left: 10em;
59 /* margin-right: 200px; */
60 margin-bottom: 2em;
61 }
62 .error {
63 color: red;
64 }
65 ul.plain {
66 list-style: none;
67 clear: both;
68 margin-left: 12em;
69 }
70 </style>
71 </head>
72
73 <body>
74
75 <div id="credit">
76 <center>
77 <a href="http://www.mediawiki.org/">
78 <img src="../skins/common/images/mediawiki.png" width="135" height="135" alt="" border="0" />
79 </a>
80 </center>
81
82 <p><strong><a href="http://www.mediawiki.org/">MediaWiki</a></strong> is
83 Copyright (C) 2001-2005 by Magnus Manske, Brion Vibber, Lee Daniel Crocker,
84 Tim Starling, Erik M&ouml;ller, Gabriel Wicke and others.</p>
85
86 <ul>
87 <li><a href="../README">Readme</a></li>
88 <li><a href="../RELEASE-NOTES">Release notes</a></li>
89 <li><a href="../docs/">doc/</a></li>
90 <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li>
91 </ul>
92
93 <p>This program is free software; you can redistribute it and/or modify
94 it under the terms of the GNU General Public License as published by
95 the Free Software Foundation; either version 2 of the License, or
96 (at your option) any later version.</p>
97
98 <p>This program is distributed in the hope that it will be useful,
99 but WITHOUT ANY WARRANTY; without even the implied warranty of
100 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
101 GNU General Public License for more details.</p>
102
103 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
104 along with this program; if not, write to the Free Software
105 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
106 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
107 </div>
108
109 <?php
110
111 # Relative includes seem to break if a parent directory is not readable;
112 # this is common for public_html subdirs under user home directories.
113 #
114 # As a dirty hack, we'll try to set up the include path first.
115 #
116 $IP = dirname( dirname( __FILE__ ) );
117 $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
118 ini_set( "include_path", ".$sep$IP$sep$IP/includes$sep$IP/languages" );
119
120 define( "MEDIAWIKI", true );
121 define( "MEDIAWIKI_INSTALL", true );
122 require_once( "includes/Defines.php" );
123 require_once( "includes/DefaultSettings.php" );
124 require_once( "includes/MagicWord.php" );
125 require_once( "includes/Namespace.php" );
126 ?>
127
128 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
129
130
131 <?php
132
133 /* Check for existing configurations and bug out! */
134
135 if( file_exists( "../LocalSettings.php" ) ) {
136 dieout( "<h2>Wiki is configured.</h2>
137
138 <p>Already configured... <a href='../index.php'>return to the wiki</a>.</p>
139
140 <p>(You should probably remove this directory for added security.)</p>" );
141 }
142
143 if( file_exists( "./LocalSettings.php" ) ) {
144 writeSuccessMessage();
145
146 dieout( '' );
147 }
148
149 if( !is_writable( "." ) ) {
150 dieout( "<h2>Can't write config file, aborting</h2>
151
152 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
153 writable by the web server. Once configuration is done you'll move the created
154 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
155 then remove the <tt>config</tt> subdirectory entirely.</p>
156
157 <p>To make the directory writable on a Unix/Linux system:</p>
158
159 <pre>
160 cd <i>/path/to/wiki</i>
161 chmod a+w config
162 </pre>" );
163 }
164
165
166 require_once( "install-utils.inc" );
167 require_once( "maintenance/updaters.inc" );
168
169 class ConfigData {
170 function getEncoded( $data ) {
171 # removing latin1 support, no need...
172 return $data;
173 }
174 function getSitename() { return $this->getEncoded( $this->Sitename ); }
175 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
176 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
177 }
178
179 ?>
180
181 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
182
183 <h2>Checking environment...</h2>
184 <ul>
185 <?php
186 $endl = "
187 ";
188 $wgNoOutputBuffer = true;
189 $conf = new ConfigData;
190
191 install_version_checks();
192
193 print "<li>PHP " . phpversion() . ": ok</li>\n";
194
195 if( ini_get( "register_globals" ) ) {
196 ?>
197 <li><b class='error'>Warning:</b> <strong>PHP's
198 <tt><a href="http://php.net/register_globals">register_globals</a></tt>
199 option is enabled.</strong> MediaWiki will work correctly, but this setting
200 increases your exposure to potential security vulnerabilities in PHP-based
201 software running on your server. <strong>You should disable it if you are able.</strong></li>
202 <?php
203 }
204
205 $fatal = false;
206
207 if( ini_get( "magic_quotes_runtime" ) ) {
208 $fatal = true;
209 ?><li class='error'><strong>Fatal: <a href='http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-runtime'>magic_quotes_runtime</a> is active!</strong>
210 This option corrupts data input unpredictably; you cannot install or use
211 MediaWiki unless this option is disabled.
212 <?php
213 }
214
215 if( ini_get( "magic_quotes_sybase" ) ) {
216 $fatal = true;
217 ?><li class='error'><strong>Fatal: <a href='http://www.php.net/manual/en/ref.sybase.php#ini.magic-quotes-sybase'>magic_quotes_sybase</a> is active!</strong>
218 This option corrupts data input unpredictably; you cannot install or use
219 MediaWiki unless this option is disabled.
220 <?php
221 }
222
223 if( $fatal ) {
224 dieout( "</ul><p>Cannot install wiki.</p>" );
225 }
226
227 if( ini_get( "safe_mode" ) ) {
228 $conf->safeMode = true;
229 ?>
230 <li><b class='error'>Warning:</b> <strong>PHP's
231 <a href='http://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
232 You may have problems caused by this, particularly if using image uploads.
233 </li>
234 <?php
235 } else {
236 $conf->safeMode = false;
237 }
238
239
240 $sapi = php_sapi_name();
241 $conf->prettyURLs = true;
242 print "<li>PHP server API is $sapi; ";
243 switch( $sapi ) {
244 case "apache":
245 case "apache2handler":
246 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
247 break;
248 case "cgi":
249 case "cgi-fcgi":
250 case "apache2filter":
251 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
252 $conf->prettyURLs = false;
253 break;
254 default:
255 print "unknown; using pretty URLs (<tt>index.php/Page_Title</tt>), if you have trouble change this in <tt>LocalSettings.php</tt>";
256 }
257 print "</li>\n";
258
259 $conf->xml = function_exists( "utf8_encode" );
260 if( $conf->xml ) {
261 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
262 } else {
263 dieout( "PHP's XML module is missing; the wiki requires functions in
264 this module and won't work in this configuration.
265 If you're running Mandrake, install the php-xml package." );
266 }
267
268 $memlimit = ini_get( "memory_limit" );
269 $conf->raiseMemory = false;
270 if( empty( $memlimit ) || $memlimit == -1 ) {
271 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
272 } else {
273 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". <strong>If this is too low, installation may fail!</strong> ";
274 $n = IntVal( $memlimit );
275 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
276 $n = IntVal( $m[1] * (1024*1024) );
277 }
278 if( $n < 20*1024*1024 ) {
279 print "Attempting to raise limit to 20M... ";
280 if( false === ini_set( "memory_limit", "20M" ) ) {
281 print "failed.";
282 } else {
283 $conf->raiseMemory = true;
284 print "ok.";
285 }
286 }
287 print "</li>\n";
288 }
289
290 $conf->zlib = function_exists( "gzencode" );
291 if( $conf->zlib ) {
292 print "<li>Have zlib support; enabling output compression.</li>\n";
293 } else {
294 print "<li>No zlib support.</li>\n";
295 }
296
297 $conf->turck = function_exists( 'mmcache_get' );
298 if ( $conf->turck ) {
299 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
300 }
301 $conf->eaccel = function_exists( 'eaccelerator_get' );
302 if ( $conf->eaccel ) {
303 $conf->turck = 'eaccelerator';
304 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
305 }
306 if (!$conf->turck && !$conf->eaccel) {
307 print "<li>Neither <a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> nor <a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> are installed, " .
308 "can't use object caching functions</li>\n";
309 }
310
311 $conf->diff3 = false;
312 $diff3locations = array("/usr/bin", "/opt/csw/bin", "/usr/gnu/bin", "/usr/sfw/bin") + explode(":", getenv("PATH"));
313 $diff3names = array("gdiff3", "diff3");
314
315 function check_location($loc) {
316 global $diff3names;
317
318 foreach ($diff3names as $name) {
319 if (file_exists("$loc/$name") && (strstr(`$loc/$name --version 2>&1`, "diff3 (GNU diffutils)") !== false))
320 return "$loc/$name";
321 }
322 return false;
323 }
324
325 foreach ($diff3locations as $loc) {
326 if (($ok = check_location($loc)) !== false) {
327 $conf->diff3 = $ok;
328 break;
329 }
330 }
331
332 if ($conf->diff3)
333 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
334 else
335 print "<li>GNU diff3 not found.</li>";
336
337 $conf->ImageMagick = false;
338 $imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
339 foreach( $imcheck as $dir ) {
340 $im = "$dir/convert";
341 if( file_exists( $im ) ) {
342 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
343 $conf->ImageMagick = $im;
344 break;
345 }
346 }
347
348 $conf->HaveGD = function_exists( "imagejpeg" );
349 if( $conf->HaveGD ) {
350 print "<li>Found GD graphics library built-in";
351 if( !$conf->ImageMagick ) {
352 print ", image thumbnailing will be enabled if you enable uploads";
353 }
354 print ".</li>\n";
355 } else {
356 if( !$conf->ImageMagick ) {
357 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
358 }
359 }
360
361 $conf->UseImageResize = $conf->HaveGD || $conf->ImageMagick;
362
363 # $conf->IP = "/Users/brion/Sites/inplace";
364 $conf->IP = dirname( dirname( __FILE__ ) );
365 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
366
367 # $conf->ScriptPath = "/~brion/inplace";
368 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["PHP_SELF"] ); # was SCRIPT_NAME
369 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
370
371 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
372
373 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
374 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
375 ? 'root@localhost'
376 : $_SERVER["SERVER_ADMIN"];
377 $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail );
378 $conf->DBserver = importPost( "DBserver", "localhost" );
379 $conf->DBname = importPost( "DBname", "wikidb" );
380 $conf->DBuser = importPost( "DBuser", "wikiuser" );
381 $conf->DBpassword = importPost( "DBpassword" );
382 $conf->DBpassword2 = importPost( "DBpassword2" );
383 $conf->DBprefix = importPost( "DBprefix" );
384 $conf->RootPW = importPost( "RootPW" );
385 $conf->LanguageCode = importPost( "LanguageCode", "en" );
386 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
387 $conf->SysopPass = importPost( "SysopPass" );
388 $conf->SysopPass2 = importPost( "SysopPass2" );
389
390 /* Check for validity */
391 $errs = array();
392
393 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
394 $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
395 }
396 if( $conf->DBuser == "" ) {
397 $errs["DBuser"] = "Must not be blank";
398 }
399 if( $conf->DBpassword == "" ) {
400 $errs["DBpassword"] = "Must not be blank";
401 }
402 if( $conf->DBpassword != $conf->DBpassword2 ) {
403 $errs["DBpassword2"] = "Passwords don't match!";
404 }
405 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) {
406 $errs["DBprefix"] = "Invalid table prefix";
407 }
408
409 if( $conf->SysopPass == "" ) {
410 $errs["SysopPass"] = "Must not be blank";
411 }
412 if( $conf->SysopPass != $conf->SysopPass2 ) {
413 $errs["SysopPass2"] = "Passwords don't match!";
414 }
415
416 $conf->License = importRequest( "License", "none" );
417 if( $conf->License == "gfdl" ) {
418 $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html";
419 $conf->RightsText = "GNU Free Documentation License 1.2";
420 $conf->RightsCode = "gfdl";
421 $conf->RightsIcon = '${wgStylePath}/common/images/gnu-fdl.png';
422 } elseif( $conf->License == "none" ) {
423 $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = "";
424 } else {
425 $conf->RightsUrl = importRequest( "RightsUrl", "" );
426 $conf->RightsText = importRequest( "RightsText", "" );
427 $conf->RightsCode = importRequest( "RightsCode", "" );
428 $conf->RightsIcon = importRequest( "RightsIcon", "" );
429 }
430
431 $conf->Shm = importRequest( "Shm", "none" );
432 $conf->MCServers = importRequest( "MCServers" );
433
434 /* Test memcached servers */
435
436 if ( $conf->Shm == 'memcached' && $conf->MCServers ) {
437 $conf->MCServerArray = array_map( 'trim', explode( ',', $conf->MCServers ) );
438 foreach ( $conf->MCServerArray as $server ) {
439 $error = testMemcachedServer( $server );
440 if ( $error ) {
441 $errs["MCServers"] = $error;
442 break;
443 }
444 }
445 } else if ( $conf->Shm == 'memcached' ) {
446 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
447 }
448
449 /* default values for installation */
450 $conf->Email =importRequest("Email", "email_enabled");
451 $conf->Emailuser=importRequest("Emailuser", "emailuser_enabled");
452 $conf->Enotif =importRequest("Enotif", "enotif_allpages");
453 $conf->Eauthent =importRequest("Eauthent", "eauthent_enabled");
454
455 if( $conf->posted && ( 0 == count( $errs ) ) ) {
456 do { /* So we can 'continue' to end prematurely */
457 $conf->Root = ($conf->RootPW != "");
458
459 /* Load up the settings and get installin' */
460 $local = writeLocalSettings( $conf );
461 $wgCommandLineMode = false;
462 chdir( ".." );
463 eval($local);
464 $wgDBadminuser = "root";
465 $wgDBadminpassword = $conf->RootPW;
466 $wgDBprefix = $conf->DBprefix;
467 $wgCommandLineMode = true;
468 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
469 require_once( "includes/Setup.php" );
470 chdir( "config" );
471
472 require_once( "maintenance/InitialiseMessages.inc" );
473
474 $wgTitle = Title::newFromText( "Installation script" );
475 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
476 if( $mysqlOldClient ) {
477 print "<li><b>PHP is linked with old MySQL client libraries. If you are
478 using a MySQL 4.1 server and have problems connecting to the database,
479 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
480 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
481 }
482 print "<li>Trying to connect to MySQL on $wgDBserver as root...\n";
483 $wgDatabase = Database::newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 );
484
485 if( $wgDatabase->isOpen() ) {
486 $myver = mysql_get_server_info( $wgDatabase->mConn );
487 $wgDatabase->ignoreErrors(true);
488 $conf->Root = true;
489 print "<ul><li>Connected as root (automatic)</li></ul></li>\n";
490 } else {
491 print "<ul><li>MySQL error " . ($err = mysql_errno() ) .
492 ": " . htmlspecialchars( mysql_error() ) . "</li></ul></li>";
493 $ok = false;
494 switch( $err ) {
495 case 1045:
496 case 2000:
497 if( $conf->Root ) {
498 $errs["RootPW"] = "Check password";
499 } else {
500 print "<li>Trying regular user...\n";
501 /* Try the regular user... */
502 $wgDBadminuser = $wgDBuser;
503 $wgDBadminpassword = $wgDBpassword;
504 /* Wait one second for connection rate limiting, present on some systems */
505 sleep(1);
506 $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
507 if( !$wgDatabase->isOpen() ) {
508 print "<ul><li>MySQL error " . ($err = mysql_errno() ) .
509 ": " . htmlspecialchars( mysql_error() ) . "</li></ul></li>";
510 $errs["DBuser"] = "Check name/pass";
511 $errs["DBpassword"] = "or enter root";
512 $errs["DBpassword2"] = "password below";
513 $errs["RootPW"] = "Got root?";
514 } else {
515 $myver = mysql_get_server_info( $wgDatabase->mConn );
516 $wgDatabase->ignoreErrors(true);
517 $conf->Root = false;
518 $conf->RootPW = "";
519 print " ok.</li>\n";
520 # And keep going...
521 $ok = true;
522 }
523 break;
524 }
525 case 2002:
526 case 2003:
527 $errs["DBserver"] = "Connection failed";
528 break;
529 default:
530 $errs["DBserver"] = "Couldn't connect to database";
531 break;
532 }
533 if( !$ok ) continue;
534 }
535
536 if ( !$wgDatabase->isOpen() ) {
537 $errs["DBserver"] = "Couldn't connect to database";
538 continue;
539 }
540
541 print "<li>Connected to $myver";
542 if( version_compare( $myver, "4.0.0" ) >= 0 ) {
543 print "; enabling MySQL 4 enhancements";
544 $conf->DBmysql4 = true;
545 $local = writeLocalSettings( $conf );
546 }
547 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
548 if( $mysqlNewAuth && $mysqlOldClient ) {
549 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
550 to old client libraries; if you have trouble with authentication, see
551 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
552 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
553 }
554 print "</li>\n";
555
556 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn );
557 if( $sel ) {
558 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
559 } else {
560 $err = mysql_errno();
561 if ( $err != 1049 ) {
562 print "<ul><li>Error selecting database $wgDBname: $err " . htmlspecialchars( mysql_error() ) .
563 "</li></ul>";
564 continue;
565 }
566 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
567 if( !$res ) {
568 print "<li>Couldn't create database <tt>" .
569 htmlspecialchars( $wgDBname ) .
570 "</tt>; try with root access or check your username/pass.</li>\n";
571 $errs["RootPW"] = "&lt;- Enter";
572 continue;
573 }
574 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
575 }
576
577 $wgDatabase->selectDB( $wgDBname );
578
579 if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) {
580 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
581
582 # Create user if required
583 if ( $conf->Root ) {
584 $conn = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
585 if ( $conn->isOpen() ) {
586 print "<li>DB user account ok</li>\n";
587 $conn->close();
588 } else {
589 print "<li>Granting user permissions...";
590 if( $mysqlOldClient && $mysqlNewAuth ) {
591 print " <b class='error'>If the next step fails, see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'>http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
592 }
593 print "</li>\n";
594 dbsource( "../maintenance/users.sql", $wgDatabase );
595 }
596 }
597 print "<pre>\n";
598 chdir( ".." );
599 flush();
600 do_all_updates();
601 chdir( "config" );
602
603 print "</pre>\n";
604 print "<li>Finished update checks.</li>\n";
605 } else {
606 # FIXME: Check for errors
607 print "<li>Creating tables...";
608 dbsource( "../maintenance/tables.sql", $wgDatabase );
609 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
610 print " done.</li>\n";
611
612 print "<li>Initializing data...";
613 $wgDatabase->insert( 'site_stats',
614 array( 'ss_row_id' => 1,
615 'ss_total_views' => 0,
616 'ss_total_edits' => 0,
617 'ss_good_articles' => 0 ) );
618 # setting up the db user
619 if( $conf->Root ) {
620 print "<li>Granting user permissions...</li>\n";
621 dbsource( "../maintenance/users.sql", $wgDatabase );
622 }
623
624 if( $conf->SysopName ) {
625 $u = User::newFromName( $conf->getSysopName() );
626 if ( 0 == $u->idForName() ) {
627 $u->addToDatabase();
628 $u->setPassword( $conf->getSysopPass() );
629 $u->saveSettings();
630
631 $u->addGroup( "sysop" );
632 $u->addGroup( "bureaucrat" );
633
634 print "<li>Created sysop account <tt>" .
635 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
636 } else {
637 print "<li>Could not create user - already exists!</li>\n";
638 }
639 } else {
640 print "<li>Skipped sysop account creation, no name given.</li>\n";
641 }
642
643 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
644 $article = new Article( $titleobj );
645 $newid = $article->insertOn( $wgDatabase );
646 $revision = new Revision( array(
647 'page' => $newid,
648 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsg( 'mainpagedocfooter' ),
649 'comment' => '',
650 'user' => 0,
651 'user_text' => 'MediaWiki default',
652 ) );
653 $revid = $revision->insertOn( $wgDatabase );
654 $article->updateRevisionOn( $wgDatabase, $revision );
655
656 print "<li><pre>";
657 initialiseMessages();
658 print "</pre></li>\n";
659 }
660
661 /* Write out the config file now that all is well */
662 print "<p>Creating LocalSettings.php...</p>\n\n";
663 $localSettings = "<" . "?php$endl$local$endl?" . ">";
664 // Fix up a common line-ending problem (due to CVS on Windows)
665 $localSettings = str_replace( "\r\n", "\n", $localSettings );
666
667 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
668 $xt = "xt"; # Refuse to overwrite an existing file
669 } else {
670 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
671 }
672 $f = fopen( "LocalSettings.php", $xt );
673
674 if( $f == false ) {
675 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" .
676 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
677 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
678 }
679 if(fwrite( $f, $localSettings ) ) {
680 fclose( $f );
681 writeSuccessMessage();
682 } else {
683 fclose( $f );
684 die("<p class='error'>An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.</p>\n");
685
686 }
687
688 } while( false );
689 }
690 ?>
691 </ul>
692
693
694 <?php
695
696 if( count( $errs ) ) {
697 /* Display options form */
698
699 if( $conf->posted ) {
700 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
701 }
702 ?>
703
704 <form action="index.php" name="config" method="post">
705
706
707 <h2>Site config</h2>
708
709 <dl class="setup">
710 <dd>
711 <?php
712 aField( $conf, "Sitename", "Site name:" );
713 ?>
714 </dd>
715 <dt>
716 Your site name should be a relatively short word. It'll appear as the namespace
717 name for 'meta' pages as well as throughout the user interface. Good site names
718 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
719 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
720 which may cause problems.
721 </dt>
722
723 <dd>
724 <?php
725 aField( $conf, "EmergencyContact", "Contact e-mail" );
726 ?>
727 </dd>
728 <dt>
729 This will be used as the return address for password reminders and
730 may be displayed in some error conditions so visitors can get in
731 touch with you. It is also be used as the default sender address of e-mail
732 notifications (enotifs).
733 </dt>
734
735 <dd>
736 <label class='column' for="LanguageCode">Language</label>
737 <select id="LanguageCode" name="LanguageCode">
738
739 <?php
740 $list = getLanguageList();
741 foreach( $list as $code => $name ) {
742 $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : '';
743 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
744 }
745 ?>
746 </select>
747 </dd>
748 <dt>
749 You may select the language for the user interface of the wiki...
750 Some localizations are less complete than others. Unicode (UTF-8 encoding)
751 is used for all localizations.
752 </dt>
753
754 <dd>
755 <label class='column'>Copyright/license metadata</label>
756 <div>Select one:</div>
757
758 <ul class="plain">
759 <li><?php aField( $conf, "License", "no license metadata", "radio", "none" ); ?></li>
760 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li>
761 <li><?php
762 aField( $conf, "License", "a Creative Commons license...", "radio", "cc" );
763 $partner = "MediaWiki";
764 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
765 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
766 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
767 print "<a href=\"$ccApp\">choose</a>";
768 ?> (link will wipe out any other data in this form!)
769 <?php if( $conf->License == "cc" ) { ?>
770 <ul>
771 <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='icon' />", "hidden" ); ?></li>
772 <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li>
773 <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li>
774 <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li>
775 </ul>
776 <?php } ?>
777 </li>
778 </ul>
779 </dd>
780 <dt>
781 MediaWiki can include a basic license notice, icon, and machine-readable
782 copyright metadata if your wiki's content is to be licensed under
783 the GNU FDL or a Creative Commons license. If you're not sure, leave
784 it at "none".
785 </dt>
786
787
788 <dd>
789 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
790 </dd>
791 <dd>
792 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
793 </dd>
794 <dd>
795 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
796 </dd>
797 <dt>
798 A sysop user account can lock or delete pages, block problematic IP
799 addresses from editing, and other maintenance tasks. If creating a new
800 wiki database, a sysop account will be created with the given name
801 and password.
802 </dt>
803
804 <dd>
805 <label class='column'>Shared memory caching</label>
806 <div>Select one:</div>
807
808 <ul class="plain">
809 <li><?php aField( $conf, "Shm", "no caching", "radio", "none" ); ?></li>
810 <?php
811 if ( $conf->turck ) {
812 echo "<li>";
813 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
814 echo "</li>";
815 }
816 ?>
817 <?php
818 if ( $conf->eaccel ) {
819 echo "<li>";
820 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
821 echo "</li>";
822 }
823 ?>
824 <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li>
825 <li><?php aField( $conf, "MCServers", "Memcached servers", "" ) ?></li>
826 </ul>
827 </dd>
828 <dt>
829 Using a shared memory system such as Turck MMCache, eAccelerator, or Memcached will speed
830 up MediaWiki significantly. Memcached is the best solution but needs to be
831 installed. Specify the server addresses and ports in a comma-separted list. Only
832 use Turck shared memory if the wiki will be running on a single Apache server.
833 </dl>
834
835 <h2>E-mail, e-mail notification and authentification setup</h2>
836
837 <dl class="setup">
838 <dd>
839 <label class='column'>E-mail (general)</label>
840 <div>Select one:</div>
841
842 <ul class="plain">
843 <li><?php aField( $conf, "Email", "enabled", "radio", "email_enabled" ); ?></li>
844 <li><?php aField( $conf, "Email", "disabled", "radio", "email_disabled" ); ?></li>
845 </ul>
846 </dd>
847 <dt>
848 Use this to disable all e-mail functions (send a password reminder, user-to-user e-mail and e-mail notification),
849 if sending e-mails on your server doesn't work.
850 </dt>
851 <dd>
852 <label class='column'>User-to-user e-mail</label>
853 <div>Select one:</div>
854
855 <ul class="plain">
856 <li><?php aField( $conf, "Emailuser", "enabled", "radio", "emailuser_enabled" ); ?></li>
857 <li><?php aField( $conf, "Emailuser", "disabled", "radio", "emailuser_disabled" ); ?></li>
858 </ul>
859 </dd>
860 <dt>
861 Use this to disable only the user-to-user e-mail function (EmailUser).
862 </dt>
863 <dd>
864 <label class='column'>E-mail notification</label>
865 <div>Select one:</div>
866
867 <ul class="plain">
868 <li><?php aField( $conf, "Enotif", "disabled", "radio", "enotif_disabled" ); ?></li>
869 <li><?php aField( $conf, "Enotif", "enabled for changes of watch-listed and user_talk pages (recommended for small wikis; perhaps not suited for large wikis)", "radio", "enotif_allpages" ); ?></li>
870 <li><?php aField( $conf, "Enotif", "enabled for changes of user_talk pages only (suited for small and large wikis)", "radio", "enotif_usertalk" ); ?></li>
871 </ul>
872 </dd>
873 <dt>
874 <p>
875 E-mail notification sends a notification e-mail to a user, when the user_talk page is changed
876 and/or when watch-listed pages are changed, depending on the above settings.
877 When testing this feature, be reminded, that obviously an e-mail address must be present in your preferences
878 and that your own changes never trigger notifications to be sent to yourself.</p>
879
880 <p>Users get corresponding options to select or deselect in their users' preferences.
881 The user options are not shown on the preference page, if e-mail notification is disabled.</p>
882
883 <p>There are additional options for fine tuning in /includes/DefaultSettings.php .</p>
884 </dt>
885
886 <dd>
887 <label class='column'>E-mail address authentication</label>
888 <div>Select one:</div>
889
890 <ul class="plain">
891 <li><?php aField( $conf, "Eauthent", "disabled", "radio", "eauthent_disabled" ); ?></li>
892 <li><?php aField( $conf, "Eauthent", "enabled", "radio", "eauthent_enabled" ); ?></li>
893 </ul>
894 </dd>
895 <dt>
896 <p>
897 E-mail address authentication uses a scheme to authenticate e-mail addresses of the users. The user who initially enters or who changes his/her stored e-mail address
898 gets a one-time temporary password mailed to that address. The user can use the original password as long as wanted, however, the stored e-mail address
899 is only authenticated at the moment when the user logs in with the one-time temporary password.<p>
900
901 <p>The e-mail address stays authenticated as long as the user does not change it; the time of authentication is indicated
902 on the user preference page.</p>
903
904 <p>If the option is enabled, only authenticated e-mail addresses can receive EmailUser mails and/or
905 e-mail notification mails.</p>
906 </dt>
907
908 </dl>
909
910 <h2>Database config</h2>
911
912 <dl class="setup">
913 <dd><?php
914 aField( $conf, "DBserver", "MySQL server" );
915 ?></dd>
916 <dt>
917 If your database server isn't on your web server, enter the name
918 or IP address here.
919 </dt>
920
921 <dd><?php
922 aField( $conf, "DBname", "Database name" );
923 ?></dd>
924 <dd><?php
925 aField( $conf, "DBuser", "DB username" );
926 ?></dd>
927 <dd><?php
928 aField( $conf, "DBpassword", "DB password", "password" );
929 ?></dd>
930 <dd><?php
931 aField( $conf, "DBpassword2", "again", "password" );
932 ?></dd>
933 <dt>
934 If you only have a single user account and database available,
935 enter those here. If you have database root access (see below)
936 you can specify new accounts/databases to be created.
937 </dt>
938
939 <dd><?php
940 aField( $conf, "DBprefix", "Database table prefix" );
941 ?></dd>
942 <dt>
943 <p>If you need to share one database between multiple wikis, or
944 MediaWiki and another web application, you may choose to
945 add a prefix to all the table names to avoid conflicts.</p>
946
947 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
948 </dt>
949
950 <dd>
951 <?php
952 aField( $conf, "RootPW", "DB root password", "password" );
953 ?>
954 </dd>
955 <dt>
956 You will only need this if the database and/or user account
957 above don't already exist.
958 Do <em>not</em> type in your machine's root password! MySQL
959 has its own "root" user with a separate password. (It might
960 even be blank, depending on your configuration.)
961 </dt>
962
963 <dd>
964 <label class='column'>&nbsp;</label>
965 <input type="submit" value="Install!" />
966 </dd>
967 </dl>
968
969
970 </form>
971
972 <?php
973 }
974
975 /* -------------------------------------------------------------------------------------- */
976 function writeSuccessMessage() {
977 global $conf;
978 if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
979 echo <<<EOT
980 <p>Installation successful!</p>
981 <p>To complete the installation, please do the following:
982 <ol>
983 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
984 <li>Upload it to the parent directory</li>
985 <li>Delete config/LocalSettings.php</li>
986 <li>Start using <a href='../index.php'>your wiki</a>!
987 </ol>
988 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
989 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
990 which means that anyone on the same server can read your database password! Downloading
991 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
992 EOT;
993 } else {
994 echo "<p>Installation successful! Move the config/LocalSettings.php file into the parent directory, then follow
995 <a href='../index.php'>this link</a> to your wiki.</p>\n";
996 }
997 }
998
999
1000 function escapePhpString( $string ) {
1001 return strtr( $string,
1002 array(
1003 "\n" => "\\n",
1004 "\r" => "\\r",
1005 "\t" => "\\t",
1006 "\\" => "\\\\",
1007 "\$" => "\\\$",
1008 "\"" => "\\\""
1009 ));
1010 }
1011
1012 function writeLocalSettings( $conf ) {
1013 $conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false';
1014 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
1015 $conf->PasswordSender = $conf->EmergencyContact;
1016 $zlib = ($conf->zlib ? "" : "# ");
1017 $magic = ($conf->ImageMagick ? "" : "# ");
1018 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
1019 $pretty = ($conf->prettyURLs ? "" : "# ");
1020 $ugly = ($conf->prettyURLs ? "# " : "");
1021 $rights = ($conf->RightsUrl) ? "" : "# ";
1022 $hashedUploads = $conf->safeMode ? '' : '# ';
1023
1024 switch ( $conf->Shm ) {
1025 case 'memcached':
1026 $cacheType = 'CACHE_MEMCACHED';
1027 $mcservers = var_export( $conf->MCServerArray, true );
1028 break;
1029 case 'turck':
1030 case 'eaccel':
1031 $cacheType = 'CACHE_ACCEL';
1032 $mcservers = 'array()';
1033 break;
1034 default:
1035 $cacheType = 'CACHE_NONE';
1036 $mcservers = 'array()';
1037 }
1038
1039 if ( $conf->Email == 'email_enabled' ) {
1040 $enableemail = 'true';
1041 $enableuseremail = ( $conf->Emailuser == 'emailuser_enabled' ) ? 'true' : 'false' ;
1042 $eauthent = ( $conf->Eauthent == 'eauthent_enabled' ) ? 'true' : 'false' ;
1043 switch ( $conf->Enotif ) {
1044 case 'enotif_usertalk':
1045 $enotifusertalk = 'true';
1046 $enotifwatchlist = 'false';
1047 break;
1048 case 'enotif_allpages':
1049 $enotifusertalk = 'true';
1050 $enotifwatchlist = 'true';
1051 break;
1052 default:
1053 $enotifusertalk = 'false';
1054 $enotifwatchlist = 'false';
1055 }
1056 } else {
1057 $enableuseremail = 'false';
1058 $enableemail = 'false';
1059 $eauthent = 'false';
1060 $enotifusertalk = 'false';
1061 $enotifwatchlist = 'false';
1062 }
1063
1064 $file = @fopen( "/dev/urandom", "r" );
1065 if ( $file ) {
1066 $secretKey = bin2hex( fread( $file, 32 ) );
1067 fclose( $file );
1068 } else {
1069 $secretKey = "";
1070 for ( $i=0; $i<8; $i++ ) {
1071 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1072 }
1073 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1074 }
1075
1076 # Add slashes to strings for double quoting
1077 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1078 if( $conf->License == 'gfdl' ) {
1079 # Needs literal string interpolation for the current style path
1080 $slconf['RightsIcon'] = $conf->RightsIcon;
1081 }
1082
1083 $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
1084 $localsettings = "
1085 # This file was automatically generated by the MediaWiki installer.
1086 # If you make manual changes, please keep track in case you need to
1087 # recreate them later.
1088
1089 \$IP = \"{$slconf['IP']}\";
1090 ini_set( \"include_path\", \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" );
1091 require_once( \"includes/DefaultSettings.php\" );
1092
1093 # If PHP's memory limit is very low, some operations may fail.
1094 " . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1095
1096 if ( \$wgCommandLineMode ) {
1097 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1098 die( \"This script must be run from the command line\\n\" );
1099 }
1100 } elseif ( empty( \$wgNoOutputBuffer ) ) {
1101 ## Compress output if the browser supports it
1102 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) @ob_start( 'ob_gzhandler' );
1103 }
1104
1105 \$wgSitename = \"{$slconf['Sitename']}\";
1106
1107 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1108 \$wgScript = \"\$wgScriptPath/index.php\";
1109 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
1110
1111 ## If using PHP as a CGI module, use the ugly URLs
1112 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
1113 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
1114
1115 \$wgStylePath = \"\$wgScriptPath/skins\";
1116 \$wgStyleDirectory = \"\$IP/skins\";
1117 \$wgLogo = \"\$wgStylePath/common/images/wiki.png\";
1118
1119 \$wgUploadPath = \"\$wgScriptPath/images\";
1120 \$wgUploadDirectory = \"\$IP/images\";
1121
1122 \$wgEnableEmail = $enableemail;
1123 \$wgEnableUserEmail = $enableuseremail;
1124
1125 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1126 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1127
1128 ## For a detailed description of the following switches see
1129 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1130 ## There are many more options for fine tuning available see
1131 ## /includes/DefaultSettings.php
1132 ## UPO means: this is also a user preference option
1133 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1134 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1135 \$wgEmailAuthentication = $eauthent;
1136
1137 \$wgDBserver = \"{$slconf['DBserver']}\";
1138 \$wgDBname = \"{$slconf['DBname']}\";
1139 \$wgDBuser = \"{$slconf['DBuser']}\";
1140 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1141 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1142
1143 # If you're on MySQL 3.x, this next line must be FALSE:
1144 \$wgDBmysql4 = {$conf->DBmysql4};
1145
1146 ## Shared memory settings
1147 \$wgMainCacheType = $cacheType;
1148 \$wgMemCachedServers = $mcservers;
1149
1150 ## To enable image uploads, make sure the 'images' directory
1151 ## is writable, then uncomment this:
1152 # \$wgEnableUploads = true;
1153 \$wgUseImageResize = {$conf->UseImageResize};
1154 {$magic}\$wgUseImageMagick = true;
1155 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1156
1157 ## If you want to use image uploads under safe mode,
1158 ## create the directories images/archive, images/thumb and
1159 ## images/temp, and make them all writable. Then uncomment
1160 ## this, if it's not already uncommented:
1161 {$hashedUploads}\$wgHashedUploadDirectory = false;
1162
1163 ## If you have the appropriate support software installed
1164 ## you can enable inline LaTeX equations:
1165 # \$wgUseTeX = true;
1166 \$wgMathPath = \"{\$wgUploadPath}/math\";
1167 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
1168 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
1169
1170 \$wgLocalInterwiki = \$wgSitename;
1171
1172 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1173
1174 \$wgProxyKey = \"$secretKey\";
1175
1176 ## Default skin: you can change the default skin. Use the internal symbolic
1177 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1178 # \$wgDefaultSkin = 'monobook';
1179
1180 ## For attaching licensing metadata to pages, and displaying an
1181 ## appropriate copyright notice / icon. GNU Free Documentation
1182 ## License and Creative Commons licenses are supported so far.
1183 {$rights}\$wgEnableCreativeCommonsRdf = true;
1184 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1185 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1186 \$wgRightsText = \"{$slconf['RightsText']}\";
1187 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1188 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1189
1190 \$wgDiff3 = \"{$slconf['diff3']}\";
1191 ";
1192 // Keep things in Unix line endings internally;
1193 // the system will write out as local text type.
1194 return str_replace( "\r\n", "\n", $localsettings );
1195 }
1196
1197 function dieout( $text ) {
1198 die( $text . "\n\n</body>\n</html>" );
1199 }
1200
1201 function importVar( &$var, $name, $default = "" ) {
1202 if( isset( $var[$name] ) ) {
1203 $retval = $var[$name];
1204 if ( get_magic_quotes_gpc() ) {
1205 $retval = stripslashes( $retval );
1206 }
1207 } else {
1208 $retval = $default;
1209 }
1210 return $retval;
1211 }
1212
1213 function importPost( $name, $default = "" ) {
1214 return importVar( $_POST, $name, $default );
1215 }
1216
1217 function importRequest( $name, $default = "" ) {
1218 return importVar( $_REQUEST, $name, $default );
1219 }
1220
1221 function aField( &$conf, $field, $text, $type = "", $value = "" ) {
1222 if( $type != "" ) {
1223 $xtype = "type=\"$type\"";
1224 } else {
1225 $xtype = "";
1226 }
1227
1228 if(!(isset($id)) or ($id == "") ) $id = $field;
1229 $nolabel = ($type == "radio") || ($type == "hidden");
1230 if( $nolabel ) {
1231 echo "\t\t<label>";
1232 } else {
1233 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1234 }
1235
1236 if( $type == "radio" && $value == $conf->$field ) {
1237 $checked = "checked='checked'";
1238 } else {
1239 $checked = "";
1240 }
1241 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" $checked value=\"";
1242 if( $type == "radio" ) {
1243 echo htmlspecialchars( $value );
1244 } else {
1245 echo htmlspecialchars( $conf->$field );
1246 }
1247 echo "\" />\n";
1248 if( $nolabel ) {
1249 echo " $text</label>\n";
1250 }
1251
1252 global $errs;
1253 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1254 }
1255
1256 function getLanguageList() {
1257 global $wgLanguageNames;
1258 if( !isset( $wgLanguageNames ) ) {
1259 $wgContLanguageCode = "xxx";
1260 function wfLocalUrl( $x ) { return $x; }
1261 function wfLocalUrlE( $x ) { return $x; }
1262 require_once( "languages/Names.php" );
1263 }
1264
1265 $codes = array();
1266
1267 $d = opendir( "../languages" );
1268 while( false !== ($f = readdir( $d ) ) ) {
1269 if( preg_match( '/Language([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1270 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1271 if( isset( $wgLanguageNames[$code] ) ) {
1272 $name = $code . ' - ' . $wgLanguageNames[$code];
1273 } else {
1274 $name = $code;
1275 }
1276 $codes[$code] = $name;
1277 }
1278 }
1279 closedir( $d );
1280 ksort( $codes );
1281 return $codes;
1282 }
1283
1284 # Test a memcached server
1285 function testMemcachedServer( $server ) {
1286 $hostport = explode(":", $server);
1287 $errstr = false;
1288 $fp = false;
1289 if ( !function_exists( 'fsockopen' ) ) {
1290 $errstr = "Can't connect to memcached, fsockopen() not present";
1291 }
1292 if ( !$errstr && count( $hostport ) != 2 ) {
1293 $errstr = 'Please specify host and port';
1294 var_dump( $hostport );
1295 }
1296 if ( !$errstr ) {
1297 list( $host, $port ) = $hostport;
1298 $errno = 0;
1299 $fsockerr = '';
1300
1301 $fp = @fsockopen( $host, $port, $errno, $fsockerr, 1.0 );
1302 if ( $fp === false ) {
1303 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1304 }
1305 }
1306 if ( !$errstr ) {
1307 $command = "version\r\n";
1308 $bytes = fwrite( $fp, $command );
1309 if ( $bytes != strlen( $command ) ) {
1310 $errstr = "Cannot write to memcached socket on $host:$port";
1311 }
1312 }
1313 if ( !$errstr ) {
1314 $expected = "VERSION ";
1315 $response = fread( $fp, strlen( $expected ) );
1316 if ( $response != $expected ) {
1317 $errstr = "Didn't get correct memcached response from $host:$port";
1318 }
1319 }
1320 if ( $fp ) {
1321 fclose( $fp );
1322 }
1323 if ( !$errstr ) {
1324 echo "<li>Connected to memcached on $host:$port successfully";
1325 }
1326 return $errstr;
1327 }
1328 ?>
1329
1330 </body>
1331 </html>