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