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