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