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