Usability improvements + IE fix
[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() . ": ok</li>\n";
201
202 if( ini_get( "register_globals" ) ) {
203 ?>
204 <li><b class='error'>Warning:</b> <strong>PHP's
205 <tt><a href="http://php.net/register_globals">register_globals</a></tt>
206 option is enabled.</strong> MediaWiki will work correctly, but this setting
207 increases your exposure to potential security vulnerabilities in PHP-based
208 software running on your server. <strong>You should disable it if you are able.</strong></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'>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". Will appear as the namespace name for "meta" pages, and throughout the interface.
744 </p>
745
746 <div class="config-input">
747 <?php
748 aField( $conf, "EmergencyContact", "Contact e-mail:" );
749 ?>
750 </div>
751 <p class="config-desc">
752 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.
753 </p>
754
755 <div class="config-input">
756 <label class='column' for="LanguageCode">Language:</label>
757 <select id="LanguageCode" name="LanguageCode">
758
759 <?php
760 $list = getLanguageList();
761 foreach( $list as $code => $name ) {
762 $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : '';
763 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
764 }
765 ?>
766 </select>
767 </div>
768 <p class="config-desc">
769 Select the language for your wiki's interface. Some localizations aren't fully complete. Unicode (UTF-8) used for all localizations.
770 </p>
771
772 <div class="config-input">
773 <label class='column'>Copyright/license:</label>
774
775 <ul class="plain">
776 <li><?php aField( $conf, "License", "No license metadata", "radio", "none" ); ?></li>
777 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li>
778 <li><?php
779 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
780 $partner = "MediaWiki";
781 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
782 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
783 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
784 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
785 ?>
786 <?php if( $conf->License == "cc" ) { ?>
787 <ul>
788 <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='icon' />", "hidden" ); ?></li>
789 <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li>
790 <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li>
791 <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li>
792 </ul>
793 <?php } ?>
794 </li>
795 </ul>
796 </div>
797 <p class="config-desc">
798 A notice, icon, and machine-readable copyright metadata will be displayed for the license you pick.
799 </p>
800
801
802 <div class="config-input">
803 <?php aField( $conf, "SysopName", "Admin username:" ) ?>
804 </div>
805 <div class="config-input">
806 <?php aField( $conf, "SysopPass", "Password:", "password" ) ?>
807 </div>
808 <div class="config-input">
809 <?php aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?>
810 </div>
811 <p class="config-desc">
812 An admin user account can lock or delete pages, block problematic IP
813 addresses from editing, and other maintenance tasks. If creating a new
814 wiki database, an admin account will be created with the given name
815 and password.
816 </p>
817
818 <div class="config-input">
819 <label class='column'>Shared memory caching:</label>
820
821 <ul class="plain">
822 <li><?php aField( $conf, "Shm", "No caching", "radio", "none" ); ?></li>
823 <?php
824 if ( $conf->turck ) {
825 echo "<li>";
826 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
827 echo "</li>";
828 }
829 ?>
830 <?php
831 if ( $conf->eaccel ) {
832 echo "<li>";
833 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
834 echo "</li>";
835 }
836 ?>
837 <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li>
838 </ul>
839 <div style="clear:left"><?php aField( $conf, "MCServers", "Memcached servers:", "text" ) ?></div>
840 </div>
841 <p class="config-desc">
842 Using a shared memory system such as Turck MMCache, eAccelerator, or Memcached will speed
843 up MediaWiki significantly. Memcached is the best solution but needs to be
844 installed. Specify the server addresses and ports in a comma-separted list. Only
845 use Turck shared memory if the wiki will be running on a single Apache server.
846 </p>
847 </div>
848
849 <h2>E-mail, e-mail notification and authentication setup</h2>
850
851 <div class="config-section">
852 <div class="config-input">
853 <label class='column'>E-mail (general):</label>
854 <ul class="plain">
855 <li><?php aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?></li>
856 <li><?php aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?></li>
857 </ul>
858 </div>
859 <p class="config-desc">
860 Use this to disable all e-mail functions (send a password reminder, user-to-user e-mail and e-mail notification),
861 if sending e-mails on your server doesn't work.
862 </p>
863 <div class="config-input">
864 <label class='column'>User-to-user e-mail:</label>
865 <ul class="plain">
866 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
867 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
868 </ul>
869 </div>
870 <p class="config-desc">
871 Use this to disable only the user-to-user e-mail function (EmailUser).
872 </p>
873 <div class="config-input">
874 <label class='column'>E-mail notification:</label>
875 <ul class="plain">
876 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
877 <li><?php aField( $conf, "Enotif", "Enabled for changes of watch-listed and user_talk pages (recommended for small wikis; perhaps not suited for large wikis)", "radio", "enotif_allpages" ); ?></li>
878 <li><?php aField( $conf, "Enotif", "Enabled for changes of user_talk pages only (suited for small and large wikis)", "radio", "enotif_usertalk" ); ?></li>
879 </ul>
880 </div>
881 <div class="config-desc">
882 <p>
883 E-mail notification sends a notification e-mail to a user, when the user_talk page is changed
884 and/or when watch-listed pages are changed, depending on the above settings.
885 When testing this feature, be reminded, that obviously an e-mail address must be present in your preferences
886 and that your own changes never trigger notifications to be sent to yourself.</p>
887
888 <p>Users get corresponding options to select or deselect in their users' preferences.
889 The user options are not shown on the preference page, if e-mail notification is disabled.</p>
890
891 <p>There are additional options for fine tuning in /includes/DefaultSettings.php .</p>
892 </div>
893
894 <div class="config-input">
895 <label class='column'>E-mail authentication:</label>
896 <ul class="plain">
897 <li><?php aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?></li>
898 <li><?php aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?></li>
899 </ul>
900 </div>
901 <div class="config-desc">
902 <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
903 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>
904
905 <p>The e-mail address stays authenticated as long as the user does not change it; the time of authentication is indicated
906 on the user preference page.</p>
907
908 <p>If the option is enabled, only authenticated e-mail addresses can receive EmailUser mails and/or
909 e-mail notification mails.</p>
910 </div>
911
912 </div>
913
914 <h2>Database config</h2>
915
916 <div class="config-section">
917 <div class="config-input">
918 <label class='column'>Database type:</label>
919 <ul class='plain'>
920 <li><?php aField( $conf, "DBtype", "MySQL", "radio", "mysql"); ?></li>
921 <li><?php aField( $conf, "DBtype", "Oracle", "radio", "oracle" ); ?></li>
922 </ul>
923 </div>
924
925 <div class="config-input" style="clear:left"><?php
926 aField( $conf, "DBserver", "SQL server host:" );
927 ?></div>
928 <p class="config-desc">
929 If your database server isn't on your web server, enter the name
930 or IP address here. MySQL only.
931 </p>
932
933 <div class="config-input"><?php
934 aField( $conf, "DBname", "Database name:" );
935 ?></div>
936 <div class="config-desc">
937 If using Oracle, set this to your connection identifier.
938 </div>
939 <div class="config-input"><?php
940 aField( $conf, "DBuser", "DB username:" );
941 ?></div>
942 <div class="config-input"><?php
943 aField( $conf, "DBpassword", "DB password:", "password" );
944 ?></div>
945 <div class="config-input"><?php
946 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
947 ?></div>
948 <p class="config-desc">
949 If you only have a single user account and database available,
950 enter those here. If you have database root access (see below)
951 you can specify new accounts/databases to be created.
952 </p>
953
954 <div class="config-input"><?php
955 aField( $conf, "DBprefix", "Database table prefix:" );
956 ?></div>
957 <div class="config-desc">
958 <p>If you need to share one database between multiple wikis, or
959 MediaWiki and another web application, you may choose to
960 add a prefix to all the table names to avoid conflicts.</p>
961
962 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
963 </div>
964
965 <div class="config-input">
966 <?php
967 aField( $conf, "RootPW", "DB root password:", "password" );
968 ?>
969 </div>
970 <p class="config-desc">
971 You will only need this if the database and/or user account
972 above don't already exist.
973 Do <em>not</em> type in your machine's root password! MySQL
974 has its own "root" user with a separate password. (It might
975 even be blank, depending on your configuration.)
976 </p>
977
978 <div class="config-input" style="padding:2em 0 3em">
979 <label class='column'>&nbsp;</label>
980 <input type="submit" value="Install MediaWiki!" class="btn-install" />
981 </div>
982
983 </div>
984
985 </form>
986
987 <?php
988 }
989
990 /* -------------------------------------------------------------------------------------- */
991 function writeSuccessMessage() {
992 global $conf;
993 if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
994 echo <<<EOT
995 <p>Installation successful!</p>
996 <p>To complete the installation, please do the following:
997 <ol>
998 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
999 <li>Upload it to the parent directory</li>
1000 <li>Delete config/LocalSettings.php</li>
1001 <li>Start using <a href='../index.php'>your wiki</a>!
1002 </ol>
1003 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1004 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1005 which means that anyone on the same server can read your database password! Downloading
1006 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1007 EOT;
1008 } else {
1009 echo "<p>Installation successful! Move the config/LocalSettings.php file into the parent directory, then follow
1010 <a href='../index.php'>this link</a> to your wiki.</p>\n";
1011 }
1012 }
1013
1014
1015 function escapePhpString( $string ) {
1016 return strtr( $string,
1017 array(
1018 "\n" => "\\n",
1019 "\r" => "\\r",
1020 "\t" => "\\t",
1021 "\\" => "\\\\",
1022 "\$" => "\\\$",
1023 "\"" => "\\\""
1024 ));
1025 }
1026
1027 function writeLocalSettings( $conf ) {
1028 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
1029 $conf->PasswordSender = $conf->EmergencyContact;
1030 $zlib = ($conf->zlib ? "" : "# ");
1031 $magic = ($conf->ImageMagick ? "" : "# ");
1032 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
1033 $pretty = ($conf->prettyURLs ? "" : "# ");
1034 $ugly = ($conf->prettyURLs ? "# " : "");
1035 $rights = ($conf->RightsUrl) ? "" : "# ";
1036 $hashedUploads = $conf->safeMode ? '' : '# ';
1037
1038 switch ( $conf->Shm ) {
1039 case 'memcached':
1040 $cacheType = 'CACHE_MEMCACHED';
1041 $mcservers = var_export( $conf->MCServerArray, true );
1042 break;
1043 case 'turck':
1044 case 'eaccel':
1045 $cacheType = 'CACHE_ACCEL';
1046 $mcservers = 'array()';
1047 break;
1048 default:
1049 $cacheType = 'CACHE_NONE';
1050 $mcservers = 'array()';
1051 }
1052
1053 if ( $conf->Email == 'email_enabled' ) {
1054 $enableemail = 'true';
1055 $enableuseremail = ( $conf->Emailuser == 'emailuser_enabled' ) ? 'true' : 'false' ;
1056 $eauthent = ( $conf->Eauthent == 'eauthent_enabled' ) ? 'true' : 'false' ;
1057 switch ( $conf->Enotif ) {
1058 case 'enotif_usertalk':
1059 $enotifusertalk = 'true';
1060 $enotifwatchlist = 'false';
1061 break;
1062 case 'enotif_allpages':
1063 $enotifusertalk = 'true';
1064 $enotifwatchlist = 'true';
1065 break;
1066 default:
1067 $enotifusertalk = 'false';
1068 $enotifwatchlist = 'false';
1069 }
1070 } else {
1071 $enableuseremail = 'false';
1072 $enableemail = 'false';
1073 $eauthent = 'false';
1074 $enotifusertalk = 'false';
1075 $enotifwatchlist = 'false';
1076 }
1077
1078 $file = @fopen( "/dev/urandom", "r" );
1079 if ( $file ) {
1080 $secretKey = bin2hex( fread( $file, 32 ) );
1081 fclose( $file );
1082 } else {
1083 $secretKey = "";
1084 for ( $i=0; $i<8; $i++ ) {
1085 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1086 }
1087 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1088 }
1089
1090 # Add slashes to strings for double quoting
1091 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1092 if( $conf->License == 'gfdl' ) {
1093 # Needs literal string interpolation for the current style path
1094 $slconf['RightsIcon'] = $conf->RightsIcon;
1095 }
1096
1097 $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
1098 $localsettings = "
1099 # This file was automatically generated by the MediaWiki installer.
1100 # If you make manual changes, please keep track in case you need to
1101 # recreate them later.
1102 #
1103 # See includes/DefaultSettings.php for all configurable settings
1104 # and their default values, but don't forget to make changes in _this_
1105 # file, not there.
1106
1107 \$IP = \"{$slconf['IP']}\";
1108 ini_set( \"include_path\", \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" );
1109 require_once( \"includes/DefaultSettings.php\" );
1110
1111 # If PHP's memory limit is very low, some operations may fail.
1112 " . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1113
1114 if ( \$wgCommandLineMode ) {
1115 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1116 die( \"This script must be run from the command line\\n\" );
1117 }
1118 } elseif ( empty( \$wgNoOutputBuffer ) ) {
1119 ## Compress output if the browser supports it
1120 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) @ob_start( 'ob_gzhandler' );
1121 }
1122
1123 \$wgSitename = \"{$slconf['Sitename']}\";
1124
1125 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1126 \$wgScript = \"\$wgScriptPath/index.php\";
1127 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
1128
1129 ## If using PHP as a CGI module, use the ugly URLs
1130 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
1131 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
1132
1133 \$wgStylePath = \"\$wgScriptPath/skins\";
1134 \$wgStyleDirectory = \"\$IP/skins\";
1135 \$wgLogo = \"\$wgStylePath/common/images/wiki.png\";
1136
1137 \$wgUploadPath = \"\$wgScriptPath/images\";
1138 \$wgUploadDirectory = \"\$IP/images\";
1139
1140 \$wgEnableEmail = $enableemail;
1141 \$wgEnableUserEmail = $enableuseremail;
1142
1143 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1144 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1145
1146 ## For a detailed description of the following switches see
1147 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1148 ## There are many more options for fine tuning available see
1149 ## /includes/DefaultSettings.php
1150 ## UPO means: this is also a user preference option
1151 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1152 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1153 \$wgEmailAuthentication = $eauthent;
1154
1155 \$wgDBserver = \"{$slconf['DBserver']}\";
1156 \$wgDBname = \"{$slconf['DBname']}\";
1157 \$wgDBuser = \"{$slconf['DBuser']}\";
1158 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1159 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1160 \$wgDBtype = \"{$slconf['DBtype']}\";
1161
1162 ## Shared memory settings
1163 \$wgMainCacheType = $cacheType;
1164 \$wgMemCachedServers = $mcservers;
1165
1166 ## To enable image uploads, make sure the 'images' directory
1167 ## is writable, then uncomment this:
1168 # \$wgEnableUploads = true;
1169 \$wgUseImageResize = {$conf->UseImageResize};
1170 {$magic}\$wgUseImageMagick = true;
1171 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1172
1173 ## If you want to use image uploads under safe mode,
1174 ## create the directories images/archive, images/thumb and
1175 ## images/temp, and make them all writable. Then uncomment
1176 ## this, if it's not already uncommented:
1177 {$hashedUploads}\$wgHashedUploadDirectory = false;
1178
1179 ## If you have the appropriate support software installed
1180 ## you can enable inline LaTeX equations:
1181 # \$wgUseTeX = true;
1182 \$wgMathPath = \"{\$wgUploadPath}/math\";
1183 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
1184 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
1185
1186 \$wgLocalInterwiki = \$wgSitename;
1187
1188 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1189
1190 \$wgProxyKey = \"$secretKey\";
1191
1192 ## Default skin: you can change the default skin. Use the internal symbolic
1193 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1194 # \$wgDefaultSkin = 'monobook';
1195
1196 ## For attaching licensing metadata to pages, and displaying an
1197 ## appropriate copyright notice / icon. GNU Free Documentation
1198 ## License and Creative Commons licenses are supported so far.
1199 {$rights}\$wgEnableCreativeCommonsRdf = true;
1200 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1201 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1202 \$wgRightsText = \"{$slconf['RightsText']}\";
1203 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1204 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1205
1206 \$wgDiff3 = \"{$slconf['diff3']}\";
1207 ";
1208 // Keep things in Unix line endings internally;
1209 // the system will write out as local text type.
1210 return str_replace( "\r\n", "\n", $localsettings );
1211 }
1212
1213 function dieout( $text ) {
1214 die( $text . "\n\n</body>\n</html>" );
1215 }
1216
1217 function importVar( &$var, $name, $default = "" ) {
1218 if( isset( $var[$name] ) ) {
1219 $retval = $var[$name];
1220 if ( get_magic_quotes_gpc() ) {
1221 $retval = stripslashes( $retval );
1222 }
1223 } else {
1224 $retval = $default;
1225 }
1226 return $retval;
1227 }
1228
1229 function importPost( $name, $default = "" ) {
1230 return importVar( $_POST, $name, $default );
1231 }
1232
1233 function importRequest( $name, $default = "" ) {
1234 return importVar( $_REQUEST, $name, $default );
1235 }
1236
1237 $radioCount = 0;
1238
1239 function aField( &$conf, $field, $text, $type = "text", $value = "" ) {
1240 global $radioCount;
1241 if( $type != "" ) {
1242 $xtype = "type=\"$type\"";
1243 } else {
1244 $xtype = "";
1245 }
1246
1247 if(!(isset($id)) or ($id == "") ) $id = $field;
1248 $nolabel = ($type == "radio") || ($type == "hidden");
1249
1250 if ($type == 'radio')
1251 $id .= $radioCount++;
1252
1253 if( $nolabel ) {
1254 echo "\t\t<label>";
1255 } else {
1256 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1257 }
1258
1259 if( $type == "radio" && $value == $conf->$field ) {
1260 $checked = "checked='checked'";
1261 } else {
1262 $checked = "";
1263 }
1264 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked value=\"";
1265 if( $type == "radio" ) {
1266 echo htmlspecialchars( $value );
1267 } else {
1268 echo htmlspecialchars( $conf->$field );
1269 }
1270 echo "\" />\n";
1271 if( $nolabel ) {
1272 echo " $text</label>\n";
1273 }
1274
1275 global $errs;
1276 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1277 }
1278
1279 function getLanguageList() {
1280 global $wgLanguageNames;
1281 if( !isset( $wgLanguageNames ) ) {
1282 $wgContLanguageCode = "xxx";
1283 function wfLocalUrl( $x ) { return $x; }
1284 function wfLocalUrlE( $x ) { return $x; }
1285 require_once( "languages/Names.php" );
1286 }
1287
1288 $codes = array();
1289
1290 $d = opendir( "../languages" );
1291 while( false !== ($f = readdir( $d ) ) ) {
1292 if( preg_match( '/Language([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1293 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1294 if( isset( $wgLanguageNames[$code] ) ) {
1295 $name = $code . ' - ' . $wgLanguageNames[$code];
1296 } else {
1297 $name = $code;
1298 }
1299 $codes[$code] = $name;
1300 }
1301 }
1302 closedir( $d );
1303 ksort( $codes );
1304 return $codes;
1305 }
1306
1307 #Check for location of an executable
1308 # @param string $loc single location to check
1309 # @param array $names filenames to check for.
1310 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1311 function locate_executable($loc, $names, $versioninfo = false) {
1312 if (!is_array($names))
1313 $names = array($names);
1314
1315 foreach ($names as $name) {
1316 if (file_exists("$loc/$name")) {
1317 if (!$versioninfo)
1318 return "$loc/$name";
1319
1320 $file = str_replace('$1', "$loc/$name", $versioninfo[0]);
1321 if (strstr(`$file`, $versioninfo[1]) !== false)
1322 return "$loc/$name";
1323 }
1324 }
1325 return false;
1326 }
1327
1328 function get_db_version() {
1329 global $wgDatabase, $conf;
1330 if ($conf->DBtype == 'mysql')
1331 return mysql_get_server_info( $wgDatabase->mConn );
1332 else if ($conf->DBtype == 'oracle')
1333 return oci_server_version($wgDatabase->mConn);
1334 }
1335
1336 # Test a memcached server
1337 function testMemcachedServer( $server ) {
1338 $hostport = explode(":", $server);
1339 $errstr = false;
1340 $fp = false;
1341 if ( !function_exists( 'fsockopen' ) ) {
1342 $errstr = "Can't connect to memcached, fsockopen() not present";
1343 }
1344 if ( !$errstr && count( $hostport ) != 2 ) {
1345 $errstr = 'Please specify host and port';
1346 var_dump( $hostport );
1347 }
1348 if ( !$errstr ) {
1349 list( $host, $port ) = $hostport;
1350 $errno = 0;
1351 $fsockerr = '';
1352
1353 $fp = @fsockopen( $host, $port, $errno, $fsockerr, 1.0 );
1354 if ( $fp === false ) {
1355 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1356 }
1357 }
1358 if ( !$errstr ) {
1359 $command = "version\r\n";
1360 $bytes = fwrite( $fp, $command );
1361 if ( $bytes != strlen( $command ) ) {
1362 $errstr = "Cannot write to memcached socket on $host:$port";
1363 }
1364 }
1365 if ( !$errstr ) {
1366 $expected = "VERSION ";
1367 $response = fread( $fp, strlen( $expected ) );
1368 if ( $response != $expected ) {
1369 $errstr = "Didn't get correct memcached response from $host:$port";
1370 }
1371 }
1372 if ( $fp ) {
1373 fclose( $fp );
1374 }
1375 if ( !$errstr ) {
1376 echo "<li>Connected to memcached on $host:$port successfully";
1377 }
1378 return $errstr;
1379 }
1380 ?>
1381
1382 <div class="license">
1383 <hr>
1384 <p>This program is free software; you can redistribute it and/or modify
1385 it under the terms of the GNU General Public License as published by
1386 the Free Software Foundation; either version 2 of the License, or
1387 (at your option) any later version.</p>
1388
1389 <p>This program is distributed in the hope that it will be useful,
1390 but WITHOUT ANY WARRANTY; without even the implied warranty of
1391 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1392 GNU General Public License for more details.</p>
1393
1394 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
1395 along with this program; if not, write to the Free Software
1396 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1397 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
1398 </div>
1399
1400 </div></div></div>
1401
1402
1403 <div id="column-one">
1404 <div class="portlet" id="p-logo">
1405 <a style="background-image: url(../skins/common/images/mediawiki.png);"
1406 href="/phase3/index.php/Main_Page"
1407 title="Main Page"></a>
1408 </div>
1409 <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
1410 <div class='portlet'><div class='pBody'>
1411 <p style="font-size:90%"><strong><a href="http://www.mediawiki.org/">MediaWiki</a></strong> is Copyright (C) 2001-2005 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, Tim Starling, Erik M&ouml;ller, Gabriel Wicke and others.</p>
1412 <ul>
1413 <li><a href="../README">Readme</a></li>
1414 <li><a href="../RELEASE-NOTES">Release notes</a></li>
1415 <li><a href="../docs/">doc/</a></li>
1416 <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li>
1417 </ul>
1418 </div></div>
1419 </div>
1420
1421 </div>
1422
1423 </body>
1424 </html>