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