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