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