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