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