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