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