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