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