3 # MediaWiki web-based config/installation
4 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>, 2006 Rob Church <robchur@gmail.com>
5 # http://www.mediawiki.org/
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 # http://www.gnu.org/copyleft/gpl.html
22 error_reporting( E_ALL
);
23 header( "Content-type: text/html; charset=utf-8" );
24 @ini_set
( "display_errors", true );
26 # Attempt to set up the include path, to fix problems with relative includes
27 $IP = dirname( dirname( __FILE__
) );
28 $sep = PATH_SEPARATOR
;
29 if( !ini_set( "include_path", ".$sep$IP$sep$IP/includes$sep$IP/languages" ) ) {
30 set_include_path( ".$sep$IP$sep$IP/includes$sep$IP/languages" );
33 # Define an entry point and include some files
34 define( "MEDIAWIKI", true );
35 define( "MEDIAWIKI_INSTALL", true );
36 require_once( "includes/Defines.php" );
37 require_once( "includes/DefaultSettings.php" );
38 require_once( "includes/MagicWord.php" );
39 require_once( "includes/Namespace.php" );
42 <!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
45 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8">
46 <title
>MediaWiki
<?php
echo( $wgVersion ); ?
> Installation
</title
>
47 <style type
="text/css">
49 @import
"../skins/monobook/main.css";
53 margin
: 1em
0 1em
2.5em
;
60 .config
-section label
.column
{
72 zoom
: 100%
; /* IE hack */
75 .config
-section
.config
-desc
{
82 .iput
-text
, .iput
-password
{
89 background
-color
: #fff;
97 background
-color
: #FFF0F0;
98 border
: 2px solid red
;
106 list-style
-type
: none
;
107 list-style
-image
: none
;
128 <div id
="globalWrapper">
129 <div id
="column-content">
131 <div id
="bodyContent">
133 <h1
>MediaWiki
<?php
print $wgVersion ?
> Installation
</h1
>
137 /* Check for existing configurations and bug out! */
139 if( file_exists( "../LocalSettings.php" ) ) {
140 dieout( " <p><strong>Setup has completed, <a href='../index.php'>your wiki</a> is configured.</strong></p>
142 <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
145 if( file_exists( "./LocalSettings.php" ) ) {
146 writeSuccessMessage();
151 if( !is_writable( "." ) ) {
152 dieout( "<h2>Can't write config file, aborting</h2>
154 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
155 writable by the web server. Once configuration is done you'll move the created
156 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
157 then remove the <tt>config</tt> subdirectory entirely.</p>
159 <p>To make the directory writable on a Unix/Linux system:</p>
162 cd <i>/path/to/wiki</i>
168 require_once( "install-utils.inc" );
169 require_once( "maintenance/updaters.inc" );
172 function getEncoded( $data ) {
173 # removing latin1 support, no need...
176 function getSitename() { return $this->getEncoded( $this->Sitename
); }
177 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
178 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
183 <h2
>Checking environment
...</h2
>
184 <p
><em
>Please
include all of the lines below when reporting installation problems
.</em
></p
>
185 <ul
class="env-check">
189 $wgNoOutputBuffer = true;
190 $conf = new ConfigData
;
192 install_version_checks();
194 print "<li>PHP " . phpversion() . " installed</li>\n";
196 if( ini_get( "register_globals" ) ) {
199 <div style
="font-size:110%">
200 <strong
class="error">Warning
:</strong
>
201 <strong
>PHP
's <tt><a href="http://php.net/register_globals">register_globals</a></tt> option is enabled. Disable it if you can.</strong>
203 MediaWiki will work, but your server is more exposed to PHP-based security vulnerabilities.
210 if( ini_get( "magic_quotes_runtime" ) ) {
212 ?><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>
213 This option corrupts data input unpredictably
; you cannot install
or use
214 MediaWiki unless this option is disabled
.
218 if( ini_get( "magic_quotes_sybase" ) ) {
220 ?
><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
>
221 This option corrupts data input unpredictably
; you cannot install
or use
222 MediaWiki unless this option is disabled
.
226 if( ini_get( "mbstring.func_overload" ) ) {
228 ?
><li
class='error'><strong
>Fatal
: <a href
='http://www.php.net/manual/en/ref.mbstring.php#mbstring.overload'>mbstring
.func_overload
</a
> is active
!</strong
>
229 This option causes errors
and may corrupt data unpredictably
;
230 you cannot install
or use MediaWiki unless this option is disabled
.
235 dieout( "</ul><p>Cannot install MediaWiki.</p>" );
238 if( ini_get( "safe_mode" ) ) {
239 $conf->safeMode
= true;
241 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
242 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
243 You may have problems caused by this
, particularly
if using image uploads
.
247 $conf->safeMode
= false;
250 $sapi = php_sapi_name();
251 $conf->prettyURLs
= true;
252 print "<li>PHP server API is $sapi; ";
255 case "apache2handler":
256 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
262 case "apache2filter":
264 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
265 $conf->prettyURLs
= false;
270 $conf->xml
= function_exists( "utf8_encode" );
272 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
274 dieout( "PHP's XML module is missing; the wiki requires functions in
275 this module and won't work in this configuration.
276 If you're running Mandrake, install the php-xml package." );
279 $memlimit = ini_get( "memory_limit" );
280 $conf->raiseMemory
= false;
281 if( empty( $memlimit ) ||
$memlimit == -1 ) {
282 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
284 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". <strong>If this is too low, installation may fail!</strong> ";
285 $n = intval( $memlimit );
286 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
287 $n = intval( $m[1] * (1024*1024) );
289 if( $n < 20*1024*1024 ) {
290 print "Attempting to raise limit to 20M... ";
291 if( false === ini_set( "memory_limit", "20M" ) ) {
294 $conf->raiseMemory
= true;
301 $conf->zlib
= function_exists( "gzencode" );
303 print "<li>Have zlib support; enabling output compression.</li>\n";
305 print "<li>No zlib support.</li>\n";
308 $conf->turck
= function_exists( 'mmcache_get' );
309 if ( $conf->turck
) {
310 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
312 $conf->eaccel
= function_exists( 'eaccelerator_get' );
313 if ( $conf->eaccel
) {
314 $conf->turck
= 'eaccelerator';
315 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
317 if (!$conf->turck
&& !$conf->eaccel
) {
318 print "<li>Neither <a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> nor <a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> are installed, " .
319 "can't use object caching functions</li>\n";
322 $conf->diff3
= false;
323 $diff3locations = array("/usr/bin", "/opt/csw/bin", "/usr/gnu/bin", "/usr/sfw/bin") +
explode($sep, getenv("PATH"));
324 $diff3names = array("gdiff3", "diff3", "diff3.exe");
326 $diff3versioninfo = array('$1 --version 2>&1', 'diff3 (GNU diffutils)');
327 foreach ($diff3locations as $loc) {
328 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
329 if ($exe !== false) {
336 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
338 print "<li>GNU diff3 not found.</li>";
340 $conf->ImageMagick
= false;
341 $imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
342 foreach( $imcheck as $dir ) {
343 $im = "$dir/convert";
344 if( file_exists( $im ) ) {
345 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
346 $conf->ImageMagick
= $im;
351 $conf->HaveGD
= function_exists( "imagejpeg" );
352 if( $conf->HaveGD
) {
353 print "<li>Found GD graphics library built-in";
354 if( !$conf->ImageMagick
) {
355 print ", image thumbnailing will be enabled if you enable uploads";
359 if( !$conf->ImageMagick
) {
360 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
364 $conf->UseImageResize
= $conf->HaveGD ||
$conf->ImageMagick
;
366 $conf->IP
= dirname( dirname( __FILE__
) );
367 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
369 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["PHP_SELF"] ); # was SCRIPT_NAME
370 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
372 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
373 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
375 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
376 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
378 : $_SERVER["SERVER_ADMIN"];
379 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
380 $conf->DBtype
= importPost( "DBtype", "mysql" );
381 $conf->DBserver
= importPost( "DBserver", "localhost" );
382 $conf->DBname
= importPost( "DBname", "wikidb" );
383 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
384 $conf->DBpassword
= importPost( "DBpassword" );
385 $conf->DBpassword2
= importPost( "DBpassword2" );
386 $conf->DBprefix
= importPost( "DBprefix" );
387 $conf->DBmysql5
= (importPost( "DBmysql5" ) == "true") ?
"true" : "false";
388 $conf->RootUser
= importPost( "RootUser", "root" );
389 $conf->RootPW
= importPost( "RootPW", "-" );
390 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
391 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
392 $conf->SysopPass
= importPost( "SysopPass" );
393 $conf->SysopPass2
= importPost( "SysopPass2" );
395 /* Check for validity */
398 if( $conf->Sitename
== "" ||
$conf->Sitename
== "MediaWiki" ||
$conf->Sitename
== "Mediawiki" ) {
399 $errs["Sitename"] = "Must not be blank or \"MediaWiki\"";
401 if( $conf->DBuser
== "" ) {
402 $errs["DBuser"] = "Must not be blank";
404 if( $conf->DBpassword
== "" ) {
405 $errs["DBpassword"] = "Must not be blank";
407 if( $conf->DBpassword
!= $conf->DBpassword2
) {
408 $errs["DBpassword2"] = "Passwords don't match!";
410 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
411 $errs["DBprefix"] = "Invalid table prefix";
414 if( $conf->SysopPass
== "" ) {
415 $errs["SysopPass"] = "Must not be blank";
417 if( $conf->SysopPass
!= $conf->SysopPass2
) {
418 $errs["SysopPass2"] = "Passwords don't match!";
421 $conf->License
= importRequest( "License", "none" );
422 if( $conf->License
== "gfdl" ) {
423 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
424 $conf->RightsText
= "GNU Free Documentation License 1.2";
425 $conf->RightsCode
= "gfdl";
426 $conf->RightsIcon
= '${wgStylePath}/common/images/gnu-fdl.png';
427 } elseif( $conf->License
== "none" ) {
428 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
430 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
431 $conf->RightsText
= importRequest( "RightsText", "" );
432 $conf->RightsCode
= importRequest( "RightsCode", "" );
433 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
436 $conf->Shm
= importRequest( "Shm", "none" );
437 $conf->MCServers
= importRequest( "MCServers" );
439 /* Test memcached servers */
441 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
442 $conf->MCServerArray
= array_map( 'trim', explode( ',', $conf->MCServers
) );
443 foreach ( $conf->MCServerArray
as $server ) {
444 $error = testMemcachedServer( $server );
446 $errs["MCServers"] = $error;
450 } else if ( $conf->Shm
== 'memcached' ) {
451 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
454 /* default values for installation */
455 $conf->Email
=importRequest("Email", "email_enabled");
456 $conf->Emailuser
=importRequest("Emailuser", "emailuser_enabled");
457 $conf->Enotif
=importRequest("Enotif", "enotif_allpages");
458 $conf->Eauthent
=importRequest("Eauthent", "eauthent_enabled");
460 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
461 do { /* So we can 'continue' to end prematurely */
462 $conf->Root
= ($conf->RootPW
!= "");
464 /* Load up the settings and get installin' */
465 $local = writeLocalSettings( $conf );
466 $wgCommandLineMode = false;
469 if (!in_array($conf->DBtype
, array("mysql", "oracle"))) {
470 $errs["DBtype"] = "Unknown database type.";
473 print "<li>Database type: {$conf->DBtype}</li>\n";
474 $dbclass = 'Database'.ucfirst($conf->DBtype
);
475 require_once("$dbclass.php");
476 $wgDBtype = $conf->DBtype
;
477 $wgDBadminuser = "root";
478 $wgDBadminpassword = $conf->RootPW
;
479 $wgDBprefix = $conf->DBprefix
;
480 $wgCommandLineMode = true;
481 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
482 require_once( "includes/Setup.php" );
485 require_once( "maintenance/InitialiseMessages.inc" );
487 $wgTitle = Title
::newFromText( "Installation script" );
488 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
489 if( $mysqlOldClient ) {
490 print "<li><b>PHP is linked with old MySQL client libraries. If you are
491 using a MySQL 4.1 server and have problems connecting to the database,
492 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
493 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
497 if( $conf->DBtype
== 'mysql' ) {
498 $ok = true; # Let's be optimistic
500 # Decide if we're going to use the superuser or the regular database user
501 if( $conf->RootPW
== '-' ) {
504 $db_user = $wgDBuser;
505 $db_pass = $wgDBpassword;
509 $db_user = $conf->RootUser
;
510 $db_pass = $conf->RootPW
;
514 echo( "<li>Attempting to connect to database server as $db_user..." );
515 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
517 # Check the connection and respond to errors
518 if( $wgDatabase->isOpen() ) {
521 $wgDBadminuser = $db_user;
522 $wgDBadminpassword = $wgDBpassword;
523 echo( "success.</li>\n" );
524 $wgDatabase->ignoreErrors( true );
525 $myver = mysql_get_server_info( $wgDatabase->mConn
);
527 # There were errors, report them and back out
529 $errno = mysql_errno();
530 $errtx = htmlspecialchars( mysql_error() );
534 echo( "failed due to authentication errors. Check passwords.</li>" );
536 # The superuser details are wrong
537 $errs["RootUser"] = "Check username";
538 $errs["RootPW"] = "and password";
540 # The regular user details are wrong
541 $errs["DBuser"] = "Check username";
542 $errs["DBpassword"] = "and password";
548 # General connection problem
549 echo( "failed with error [$errno] $errtx.</li>\n" );
550 $errs["DBserver"] = "Connection failed";
555 if( !$ok ) { continue; }
557 } else /* not mysql */ {
558 print "<li>Connecting to SQL server...";
559 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
560 if (!$wgDatabase->isOpen()) {
561 print " error: " . $wgDatabase->lastError() . "</li>\n";
563 $wgDatabase->ignoreErrors(true);
564 $myver = get_db_version();
568 if ( !$wgDatabase->isOpen() ) {
569 $errs["DBserver"] = "Couldn't connect to database";
573 print "<li>Connected to $myver";
574 if( version_compare( $myver, "4.0.0" ) < 0 ) {
575 die( " -- mysql 4.0 or later required. Aborting." );
577 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
578 if( $mysqlNewAuth && $mysqlOldClient ) {
579 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
580 to old client libraries; if you have trouble with authentication, see
581 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
582 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
585 if( $mysqlNewAuth ) {
586 print "; enabling MySQL 4.1/5.0 charset mode";
588 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
589 but older version detected; will likely fail.</b>";
594 if ($conf->DBtype
== 'mysql') {
595 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn
);
597 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
599 $err = mysql_errno();
600 if ( $err != 1049 ) {
601 print "<ul><li>Error selecting database $wgDBname: $err " .
602 htmlspecialchars( mysql_error() ) . "</li></ul>";
605 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
607 print "<li>Couldn't create database <tt>" .
608 htmlspecialchars( $wgDBname ) .
609 "</tt>; try with root access or check your username/pass.</li>\n";
610 $errs["RootPW"] = "<- Enter";
613 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
615 $wgDatabase->selectDB( $wgDBname );
618 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
619 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
621 # Create user if required
623 $conn = Database
::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
624 if ( $conn->isOpen() ) {
625 print "<li>DB user account ok</li>\n";
628 print "<li>Granting user permissions...";
629 if( $mysqlOldClient && $mysqlNewAuth ) {
630 print " <b class='error'>If the next step fails, see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'>http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
633 dbsource( "../maintenance/users.sql", $wgDatabase );
643 print "<li>Finished update checks.</li>\n";
645 # FIXME: Check for errors
646 print "<li>Creating tables...";
647 if ($conf->DBtype
== 'mysql') {
649 print " using MySQL 5 table defs...";
650 dbsource( "../maintenance/mysql5/tables.sql", $wgDatabase );
652 print " using MySQL 4 table defs...";
653 dbsource( "../maintenance/tables.sql", $wgDatabase );
655 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
657 dbsource( "../maintenance/oracle/tables.sql", $wgDatabase );
658 dbsource( "../maintenance/oracle/interwiki.sql", $wgDatabase );
661 print " done.</li>\n";
663 print "<li>Initializing data...";
664 $wgDatabase->insert( 'site_stats',
665 array( 'ss_row_id' => 1,
666 'ss_total_views' => 0,
667 'ss_total_edits' => 0,
668 'ss_good_articles' => 0 ) );
670 # Set up the "regular user" account *if we can, and if we need to*
673 $wgDatabase2 = Database
::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, '', 1 );
674 if( $wgDatabase2->isOpen() ) {
675 # Nope, just close the test connection and continue
676 $wgDatabase2->close();
677 echo( "<li>User $wgDBuser exists. Skipping grants.</li>" );
679 # Yes, so run the grants
680 echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
681 dbsource( "../maintenance/users.sql", $wgDatabase );
682 echo( "success.</li>" );
686 if( $conf->SysopName
) {
687 $u = User
::newFromName( $conf->getSysopName() );
688 if ( 0 == $u->idForName() ) {
690 $u->setPassword( $conf->getSysopPass() );
693 $u->addGroup( "sysop" );
694 $u->addGroup( "bureaucrat" );
696 print "<li>Created sysop account <tt>" .
697 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
699 print "<li>Could not create user - already exists!</li>\n";
702 print "<li>Skipped sysop account creation, no name given.</li>\n";
705 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
706 $article = new Article( $titleobj );
707 $newid = $article->insertOn( $wgDatabase );
708 $revision = new Revision( array(
710 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsg( 'mainpagedocfooter' ),
713 'user_text' => 'MediaWiki default',
715 $revid = $revision->insertOn( $wgDatabase );
716 $article->updateRevisionOn( $wgDatabase, $revision );
719 initialiseMessages();
720 print "</pre></li>\n";
723 /* Write out the config file now that all is well */
724 print "<p>Creating LocalSettings.php...</p>\n\n";
725 $localSettings = "<" . "?php$endl$local$endl?" . ">";
726 // Fix up a common line-ending problem (due to CVS on Windows)
727 $localSettings = str_replace( "\r\n", "\n", $localSettings );
729 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
730 $xt = "xt"; # Refuse to overwrite an existing file
732 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
734 $f = fopen( "LocalSettings.php", $xt );
737 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" .
738 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
739 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
741 if(fwrite( $f, $localSettings ) ) {
743 writeSuccessMessage();
746 die("<p class='error'>An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.</p>\n");
758 if( count( $errs ) ) {
759 /* Display options form */
761 if( $conf->posted
) {
762 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
766 <form action
="index.php" name
="config" method
="post">
771 <div
class="config-section">
772 <div
class="config-input">
774 aField( $conf, "Sitename", "Wiki name:" );
777 <p
class="config-desc">
778 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
>
779 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
782 <div
class="config-input">
784 aField( $conf, "EmergencyContact", "Contact e-mail:" );
787 <p
class="config-desc">
788 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
.
791 <div
class="config-input">
792 <label
class='column' for="LanguageCode">Language
:</label
>
793 <select id
="LanguageCode" name
="LanguageCode">
796 $list = getLanguageList();
797 foreach( $list as $code => $name ) {
798 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
799 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
804 <p
class="config-desc">
805 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) used
for all localizations
.
808 <div
class="config-input">
809 <label
class='column'>Copyright
/license
:</label
>
812 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
813 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?
></li
>
815 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
816 $partner = "MediaWiki";
817 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
818 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
819 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
820 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
822 <?php
if( $conf->License
== "cc" ) { ?
>
824 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='icon' />", "hidden" ); ?
></li
>
825 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
826 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
827 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
833 <p
class="config-desc">
834 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
838 <div
class="config-input">
839 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
841 <div
class="config-input">
842 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
844 <div
class="config-input">
845 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
847 <p
class="config-desc">
848 An admin can lock
/delete pages
, block users from editing
, and other maintenance tasks
.<br
>
849 A
new account will be added only when creating a
new wiki database
.
852 <div
class="config-input">
853 <label
class='column'>Shared memory caching
:</label
>
856 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
858 if ( $conf->turck
) {
860 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
865 if ( $conf->eaccel
) {
867 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
871 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
873 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
875 <p
class="config-desc">
876 Using a shared memory system such
as Turck MMCache
, eAccelerator
, or Memcached will speed
877 up MediaWiki significantly
. Memcached is the best solution but needs to be
878 installed
. Specify the server addresses
and ports in a comma
-separted
list. Only
879 use Turck shared memory
if the wiki will be running on a single Apache server
.
883 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
885 <div
class="config-section">
886 <div
class="config-input">
887 <label
class='column'>E
-mail (general
):</label
>
889 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
890 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
893 <p
class="config-desc">
894 Use this to disable all e
-mail
functions (send a password reminder
, user
-to
-user e
-mail
and e
-mail notification
),
895 if sending e
-mails on your server doesn
't work.
897 <div class="config-input">
898 <label class='column
'>User-to-user e-mail:</label>
900 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
901 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
904 <p class="config-desc">
905 Use this to disable only the user-to-user e-mail function (EmailUser).
907 <div class="config-input">
908 <label class='column
'>E-mail notification:</label>
910 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
911 <li><?php aField( $conf, "Enotif", "Enabled for user_talk changes only", "radio", "enotif_usertalk" ); ?></li>
912 <li><?php aField( $conf, "Enotif", "Enabled for user_talk and watch list changes (not recommended for large wikis)", "radio", "enotif_allpages" ); ?></li>
915 <div class="config-desc">
917 E-mail notification sends a notification e-mail to a user, when the user_talk page is changed
918 and/or when watch-listed pages are changed, depending on the above settings.
919 When testing this feature, be reminded, that obviously an e-mail address must be present in your preferences
920 and that your own changes never trigger notifications to be sent to yourself.</p>
922 <p>Users get corresponding options to select or deselect in their users' preferences
.
923 The user options are not shown on the preference page
, if e
-mail notification is disabled
.</p
>
925 <p
>There are additional options
for fine tuning in
/includes
/DefaultSettings
.php
.</p
>
928 <div
class="config-input">
929 <label
class='column'>E
-mail authentication
:</label
>
931 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
932 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
935 <div
class="config-desc">
936 <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
937 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
>
939 <p
>The e
-mail address stays authenticated
as long
as the user does not change it
; the time of authentication is indicated
940 on the user preference page
.</p
>
942 <p
>If the option is enabled
, only authenticated e
-mail addresses can receive EmailUser mails
and/or
943 e
-mail notification mails
.</p
>
948 <h2
>Database config
</h2
>
950 <div
class="config-section">
951 <div
class="config-input">
952 <label
class='column'>Database type
:</label
>
954 <li
><?php
aField( $conf, "DBtype", "MySQL", "radio", "mysql"); ?
></li
>
955 <li
><?php
aField( $conf, "DBtype", "Oracle", "radio", "oracle" ); ?
></li
>
959 <div
class="config-input" style
="clear:left"><?php
960 aField( $conf, "DBserver", "SQL server host:" );
962 <p
class="config-desc">
963 If your database server isn
't on your web server, enter the name
964 or IP address here. MySQL only.
967 <div class="config-input"><?php
968 aField( $conf, "DBname", "Database name:" );
970 <div class="config-desc">
971 If using Oracle, set this to your connection identifier.
973 <div class="config-input"><?php
974 aField( $conf, "DBuser", "DB username:" );
976 <div class="config-input"><?php
977 aField( $conf, "DBpassword", "DB password:", "password" );
979 <div class="config-input"><?php
980 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
982 <p class="config-desc">
983 If you only have a single user account and database available,
984 enter those here. If you have database root access (see below)
985 you can specify new accounts/databases to be created.
988 This account will not be created if it pre-exists. If this is the case, ensure that it
989 has SELECT, INSERT, UPDATE and DELETE permissions on the MediaWiki database.
992 <div class="config-input"><?php
993 aField( $conf, "DBprefix", "Database table prefix:" );
995 <div class="config-desc">
996 <p>If you need to share one database between multiple wikis, or
997 MediaWiki and another web application, you may choose to
998 add a prefix to all the table names to avoid conflicts.</p>
1000 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1003 <div class="config-input"><label class="column">Database charset</label>
1004 <div>Select one:</div>
1006 <li><?php aField( $conf, "DBmysql5", "Backwards-compatible UTF-8", "radio", "false" ); ?></li>
1007 <li><?php aField( $conf, "DBmysql5", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "true" ); ?></li>
1010 <p class="config-desc">
1011 <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support
1012 for MySQL 4.1 and 5.0 servers. This is not well tested and may
1013 cause things to break. <b>If upgrading an older installation, leave
1014 in backwards-compatible mode.</b>
1017 <div class="config-input">
1019 aField( $conf, "RootUser", "Superuser account:", "superuser" );
1022 <div class="config-input">
1024 aField( $conf, "RootPW", "Superuser password:", "password" );
1028 <p class="config-desc">
1029 If the database user specified above does not exist, or does not have access to create
1030 the database (if needed) or tables within it, please provide details of a superuser account,
1031 such as <strong>root</strong>, which does. Leave the password set to <strong>-</strong> if this is not needed.
1034 <div class="config-input" style="padding:2em 0 3em">
1035 <label class='column
'> </label>
1036 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1046 /* -------------------------------------------------------------------------------------- */
1047 function writeSuccessMessage() {
1048 if ( ini_get( 'safe_mode
' ) && !ini_get( 'open_basedir
' ) ) {
1050 <p>Installation successful!</p>
1051 <p>To complete the installation, please do the following:
1053 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1054 <li>Upload it to the parent directory</li>
1055 <li>Delete config/LocalSettings.php</li>
1056 <li>Start using <a href='../index
.php
'>your wiki</a>!
1058 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1059 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1060 which means that anyone on the same server can read your database password! Downloading
1061 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1064 echo "<p>Installation successful! Move the config/LocalSettings.php file into the parent directory, then follow
1065 <a href='../index
.php
'>this link</a> to your wiki.</p>\n";
1070 function escapePhpString( $string ) {
1071 return strtr( $string,
1082 function writeLocalSettings( $conf ) {
1083 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
1084 $conf->PasswordSender = $conf->EmergencyContact;
1085 $zlib = ($conf->zlib ? "" : "# ");
1086 $magic = ($conf->ImageMagick ? "" : "# ");
1087 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
1088 $pretty = ($conf->prettyURLs ? "" : "# ");
1089 $ugly = ($conf->prettyURLs ? "# " : "");
1090 $rights = ($conf->RightsUrl) ? "" : "# ";
1091 $hashedUploads = $conf->safeMode ? '' : '# ';
1093 switch ( $conf->Shm
) {
1095 $cacheType = 'CACHE_MEMCACHED';
1096 $mcservers = var_export( $conf->MCServerArray
, true );
1100 $cacheType = 'CACHE_ACCEL';
1101 $mcservers = 'array()';
1104 $cacheType = 'CACHE_NONE';
1105 $mcservers = 'array()';
1108 if ( $conf->Email
== 'email_enabled' ) {
1109 $enableemail = 'true';
1110 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1111 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1112 switch ( $conf->Enotif
) {
1113 case 'enotif_usertalk':
1114 $enotifusertalk = 'true';
1115 $enotifwatchlist = 'false';
1117 case 'enotif_allpages':
1118 $enotifusertalk = 'true';
1119 $enotifwatchlist = 'true';
1122 $enotifusertalk = 'false';
1123 $enotifwatchlist = 'false';
1126 $enableuseremail = 'false';
1127 $enableemail = 'false';
1128 $eauthent = 'false';
1129 $enotifusertalk = 'false';
1130 $enotifwatchlist = 'false';
1133 $file = @fopen
( "/dev/urandom", "r" );
1135 $secretKey = bin2hex( fread( $file, 32 ) );
1139 for ( $i=0; $i<8; $i++
) {
1140 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1142 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1145 # Add slashes to strings for double quoting
1146 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1147 if( $conf->License
== 'gfdl' ) {
1148 # Needs literal string interpolation for the current style path
1149 $slconf['RightsIcon'] = $conf->RightsIcon
;
1152 $sep = PATH_SEPARATOR
;
1154 # This file was automatically generated by the MediaWiki installer.
1155 # If you make manual changes, please keep track in case you need to
1156 # recreate them later.
1158 # See includes/DefaultSettings.php for all configurable settings
1159 # and their default values, but don't forget to make changes in _this_
1162 \$IP = \"{$slconf['IP']}\";
1163 if( !ini_set( \"include_path\", \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" ) ) {
1164 set_include_path( \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" );
1166 require_once( \"includes/DefaultSettings.php\" );
1168 # If PHP's memory limit is very low, some operations may fail.
1169 " . ($conf->raiseMemory ?
'' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1171 if ( \$wgCommandLineMode ) {
1172 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1173 die( \"This script must be run from the command line\\n\" );
1175 } elseif ( empty( \$wgNoOutputBuffer ) ) {
1176 ## Compress output if the browser supports it
1177 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) @ob_start( 'ob_gzhandler' );
1180 \$wgSitename = \"{$slconf['Sitename']}\";
1182 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1183 \$wgScript = \"\$wgScriptPath/index.php\";
1184 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
1186 ## If using PHP as a CGI module, use the ugly URLs
1187 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
1188 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
1190 \$wgStylePath = \"\$wgScriptPath/skins\";
1191 \$wgStyleDirectory = \"\$IP/skins\";
1192 \$wgLogo = \"\$wgStylePath/common/images/wiki.png\";
1194 \$wgUploadPath = \"\$wgScriptPath/images\";
1195 \$wgUploadDirectory = \"\$IP/images\";
1197 \$wgEnableEmail = $enableemail;
1198 \$wgEnableUserEmail = $enableuseremail;
1200 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1201 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1203 ## For a detailed description of the following switches see
1204 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1205 ## There are many more options for fine tuning available see
1206 ## /includes/DefaultSettings.php
1207 ## UPO means: this is also a user preference option
1208 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1209 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1210 \$wgEmailAuthentication = $eauthent;
1212 \$wgDBserver = \"{$slconf['DBserver']}\";
1213 \$wgDBname = \"{$slconf['DBname']}\";
1214 \$wgDBuser = \"{$slconf['DBuser']}\";
1215 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1216 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1217 \$wgDBtype = \"{$slconf['DBtype']}\";
1219 # Experimental charset support for MySQL 4.1/5.0.
1220 \$wgDBmysql5 = {$conf->DBmysql5};
1222 ## Shared memory settings
1223 \$wgMainCacheType = $cacheType;
1224 \$wgMemCachedServers = $mcservers;
1226 ## To enable image uploads, make sure the 'images' directory
1227 ## is writable, then uncomment this:
1228 # \$wgEnableUploads = true;
1229 \$wgUseImageResize = {$conf->UseImageResize};
1230 {$magic}\$wgUseImageMagick = true;
1231 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1233 ## If you want to use image uploads under safe mode,
1234 ## create the directories images/archive, images/thumb and
1235 ## images/temp, and make them all writable. Then uncomment
1236 ## this, if it's not already uncommented:
1237 {$hashedUploads}\$wgHashedUploadDirectory = false;
1239 ## If you have the appropriate support software installed
1240 ## you can enable inline LaTeX equations:
1241 # \$wgUseTeX = true;
1242 \$wgMathPath = \"{\$wgUploadPath}/math\";
1243 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
1244 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
1246 \$wgLocalInterwiki = \$wgSitename;
1248 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1250 \$wgProxyKey = \"$secretKey\";
1252 ## Default skin: you can change the default skin. Use the internal symbolic
1253 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1254 # \$wgDefaultSkin = 'monobook';
1256 ## For attaching licensing metadata to pages, and displaying an
1257 ## appropriate copyright notice / icon. GNU Free Documentation
1258 ## License and Creative Commons licenses are supported so far.
1259 {$rights}\$wgEnableCreativeCommonsRdf = true;
1260 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1261 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1262 \$wgRightsText = \"{$slconf['RightsText']}\";
1263 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1264 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1266 \$wgDiff3 = \"{$slconf['diff3']}\";
1268 // Keep things in Unix line endings internally;
1269 // the system will write out as local text type.
1270 return str_replace( "\r\n", "\n", $localsettings );
1273 function dieout( $text ) {
1274 die( $text . "\n\n</body>\n</html>" );
1277 function importVar( &$var, $name, $default = "" ) {
1278 if( isset( $var[$name] ) ) {
1279 $retval = $var[$name];
1280 if ( get_magic_quotes_gpc() ) {
1281 $retval = stripslashes( $retval );
1289 function importPost( $name, $default = "" ) {
1290 return importVar( $_POST, $name, $default );
1293 function importRequest( $name, $default = "" ) {
1294 return importVar( $_REQUEST, $name, $default );
1299 function aField( &$conf, $field, $text, $type = "text", $value = "" ) {
1302 $xtype = "type=\"$type\"";
1307 if(!(isset($id)) or ($id == "") ) $id = $field;
1308 $nolabel = ($type == "radio") ||
($type == "hidden");
1310 if ($type == 'radio')
1311 $id .= $radioCount++
;
1316 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1319 if( $type == "radio" && $value == $conf->$field ) {
1320 $checked = "checked='checked'";
1324 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked value=\"";
1325 if( $type == "radio" ) {
1326 echo htmlspecialchars( $value );
1328 echo htmlspecialchars( $conf->$field );
1332 echo " $text</label>\n";
1336 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1339 function getLanguageList() {
1340 global $wgLanguageNames;
1341 if( !isset( $wgLanguageNames ) ) {
1342 $wgContLanguageCode = "xxx";
1343 function wfLocalUrl( $x ) { return $x; }
1344 function wfLocalUrlE( $x ) { return $x; }
1345 require_once( "languages/Names.php" );
1350 $d = opendir( "../languages" );
1351 while( false !== ($f = readdir( $d ) ) ) {
1353 if( preg_match( '/Language([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1354 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1355 if( isset( $wgLanguageNames[$code] ) ) {
1356 $name = $code . ' - ' . $wgLanguageNames[$code];
1360 $codes[$code] = $name;
1368 #Check for location of an executable
1369 # @param string $loc single location to check
1370 # @param array $names filenames to check for.
1371 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1372 function locate_executable($loc, $names, $versioninfo = false) {
1373 if (!is_array($names))
1374 $names = array($names);
1376 foreach ($names as $name) {
1377 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
1378 if (file_exists($command)) {
1382 $file = str_replace('$1', $command, $versioninfo[0]);
1383 if (strstr(`
$file`
, $versioninfo[1]) !== false)
1390 function get_db_version() {
1391 global $wgDatabase, $conf;
1392 if ($conf->DBtype
== 'mysql')
1393 return mysql_get_server_info( $wgDatabase->mConn
);
1394 else if ($conf->DBtype
== 'oracle')
1395 return oci_server_version($wgDatabase->mConn
);
1398 # Test a memcached server
1399 function testMemcachedServer( $server ) {
1400 $hostport = explode(":", $server);
1403 if ( !function_exists( 'fsockopen' ) ) {
1404 $errstr = "Can't connect to memcached, fsockopen() not present";
1406 if ( !$errstr && count( $hostport ) != 2 ) {
1407 $errstr = 'Please specify host and port';
1408 var_dump( $hostport );
1411 list( $host, $port ) = $hostport;
1415 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
1416 if ( $fp === false ) {
1417 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1421 $command = "version\r\n";
1422 $bytes = fwrite( $fp, $command );
1423 if ( $bytes != strlen( $command ) ) {
1424 $errstr = "Cannot write to memcached socket on $host:$port";
1428 $expected = "VERSION ";
1429 $response = fread( $fp, strlen( $expected ) );
1430 if ( $response != $expected ) {
1431 $errstr = "Didn't get correct memcached response from $host:$port";
1438 echo "<li>Connected to memcached on $host:$port successfully";
1444 <div
class="license">
1446 <p
>This program is free software
; you can redistribute it
and/or modify
1447 it under the terms of the GNU General
Public License
as published by
1448 the Free Software Foundation
; either version
2 of the License
, or
1449 (at your option
) any later version
.</p
>
1451 <p
>This program is distributed in the hope that it will be useful
,
1452 but WITHOUT ANY WARRANTY
; without even the implied warranty of
1453 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
1454 GNU General
Public License
for more details
.</p
>
1456 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
1457 along with this program
; if not
, write to the Free Software
1458 Foundation
, Inc
., 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA
.
1459 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
1465 <div id
="column-one">
1466 <div
class="portlet" id
="p-logo">
1467 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
1468 href
="http://www.mediawiki.org/"
1469 title
="Main Page"></a
>
1471 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
1472 <div
class='portlet'><div
class='pBody'>
1474 <li
><strong
><a href
="http://www.mediawiki.org/">MediaWiki home
</a
></strong
></li
>
1475 <li
><a href
="../README">Readme
</a
></li
>
1476 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
1477 <li
><a href
="../docs/">Documentation
</a
></li
>
1478 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
1479 <li><a href="http://meta.wikimedia.org/wiki/MediaWiki_FAQ">FAQ</a></li>
1481 <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2006 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke and others.</p>