Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

index.php

Go to the documentation of this file.
00001 <?php 00002 # MediaWiki web-based config/installation 00003 # Copyright (C) 2004 Brion Vibber <brion@pobox.com> 00004 # http://www.mediawiki.org/ 00005 # 00006 # This program is free software; you can redistribute it and/or modify 00007 # it under the terms of the GNU General Public License as published by 00008 # the Free Software Foundation; either version 2 of the License, or 00009 # (at your option) any later version. 00010 # 00011 # This program is distributed in the hope that it will be useful, 00012 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 # GNU General Public License for more details. 00015 # 00016 # You should have received a copy of the GNU General Public License along 00017 # with this program; if not, write to the Free Software Foundation, Inc., 00018 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 # http://www.gnu.org/copyleft/gpl.html 00020 00021 error_reporting( E_ALL ); 00022 header( "Content-type: text/html; charset=utf-8" ); 00023 @ini_set( "display_errors", true ); 00024 00025 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 00026 "http://www.w3.org/TR/html4/loose.dtd"> 00027 <html> 00028 <head> 00029 <meta http-equiv="Content-type" content="text/html; charset=utf-8"> 00030 <meta name="robots" content="noindex,nofollow"> 00031 <title>MediaWiki installation</title> 00032 <style type="text/css"> 00033 #credit { 00034 float: right; 00035 width: 200px; 00036 font-size: 0.7em; 00037 background-color: #eee; 00038 color: black; 00039 border: solid 1px #444; 00040 padding: 8px; 00041 margin-left: 8px; 00042 } 00043 00044 dl.setup dd { 00045 margin-left: 0; 00046 } 00047 dl.setup dd label.column { 00048 clear: left; 00049 font-weight: bold; 00050 width: 12em; 00051 float: left; 00052 text-align: right; 00053 padding-right: 1em; 00054 } 00055 dl.setup dt { 00056 clear: left; 00057 font-size: 0.8em; 00058 margin-left: 10em; 00059 /* margin-right: 200px; */ 00060 margin-bottom: 2em; 00061 } 00062 .error { 00063 color: red; 00064 } 00065 ul.plain { 00066 list-style: none; 00067 clear: both; 00068 margin-left: 12em; 00069 } 00070 </style> 00071 </head> 00072 00073 <body> 00074 00075 <div id="credit"> 00076 <center> 00077 <a href="http://www.mediawiki.org/"><img 00078 src="../stylesheets/images/wiki.png" width="135" height="135" alt="" border="0" /></a> 00079 </center> 00080 00081 <b><a href="http://www.mediawiki.org/">MediaWiki</a></b> is 00082 Copyright (C) 2001-2004 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, 00083 Tim Starling, Erik M&ouml;ller, and others.</p> 00084 00085 <ul> 00086 <li><a href="../README">Readme</a></li> 00087 <li><a href="../RELEASE-NOTES">Release notes</a></li> 00088 <li><a href="../docs/">doc/</a></li> 00089 <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li> 00090 </ul> 00091 00092 <p>This program is free software; you can redistribute it and/or modify 00093 it under the terms of the GNU General Public License as published by 00094 the Free Software Foundation; either version 2 of the License, or 00095 (at your option) any later version.</p> 00096 00097 <p>This program is distributed in the hope that it will be useful, 00098 but WITHOUT ANY WARRANTY; without even the implied warranty of 00099 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00100 GNU General Public License for more details.</p> 00101 00102 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a> 00103 along with this program; if not, write to the Free Software 00104 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00105 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p> 00106 </div> 00107 00108 <?php 00109 00110 $IP = ".."; # Just to suppress notices, not for anything useful 00111 define( "MEDIAWIKI", true ); 00112 define( "MEDIAWIKI_INSTALL", true ); 00113 require( "../includes/DefaultSettings.php" ); 00114 require( "../includes/MagicWord.php" ); 00115 require( "../includes/Namespace.php" ); 00116 ?> 00117 00118 <h1>MediaWiki <?php print $wgVersion ?> installation</h1> 00119 00120 00121 <?php 00122 00123 /* Check for existing configurations and bug out! */ 00124 00125 if( file_exists( "../LocalSettings.php" ) || file_exists( "../AdminSettings.php" ) ) { 00126 dieout( "<h2>Wiki is configured.</h2> 00127 00128 <p>Already configured... <a href='../index.php'>return to the wiki</a>.</p> 00129 00130 <p>(You should probably remove this directory for added security.)</p>" ); 00131 } 00132 00133 if( file_exists( "./LocalSettings.php" ) || file_exists( "./AdminSettings.php" ) ) { 00134 dieout( "<h2>You're configured!</h2> 00135 00136 <p>Please move <tt>LocalSettings.php</tt> to the parent directory, then 00137 <a href='../index.php'>try out your wiki</a>. 00138 (You should remove this config directory for added security once you're done.)</p>" ); 00139 } 00140 00141 if( !is_writable( "." ) ) { 00142 dieout( "<h2>Can't write config file, aborting</h2> 00143 00144 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory 00145 writable by the web server. Once configuration is done you'll move the created 00146 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can 00147 then remove the <tt>config</tt> subdirectory entirely.</p> 00148 00149 <p>To make the directory writable on a Unix/Linux system:</p> 00150 00151 <pre> 00152 cd <i>/path/to/wiki</i> 00153 chmod a+w config 00154 </pre>" ); 00155 } 00156 00157 00158 require( "../install-utils.inc" ); 00159 require( "../maintenance/updaters.inc" ); 00160 require( "../maintenance/convertLinks.inc" ); 00161 require( "../maintenance/archives/moveCustomMessages.inc" ); 00162 00163 class ConfigData { 00164 function getEncoded( $data ) { 00165 # Hackish 00166 global $wgUseLatin1; 00167 if( $wgUseLatin1 ) { 00168 return utf8_decode( $data ); /* to latin1 wikis */ 00169 } else { 00170 return $data; 00171 } 00172 } 00173 function getSitename() { return $this->getEncoded( $this->Sitename ); } 00174 function getSysopName() { return $this->getEncoded( $this->SysopName ); } 00175 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); } 00176 } 00177 00178 ?> 00179 00180 <p><i>Please include all of the lines below when reporting installation problems.</i></p> 00181 00182 <h2>Checking environment...</h2> 00183 <ul> 00184 <?php 00185 $endl = " 00186 "; 00187 $conf = new ConfigData; 00188 00189 install_version_checks(); 00190 print "<li>PHP " . phpversion() . " ok</li>\n"; 00191 00192 $sapi = php_sapi_name(); 00193 $conf->prettyURLs = true; 00194 print "<li>PHP server API is $sapi; "; 00195 switch( $sapi ) { 00196 case "apache": 00197 case "apache2handler": 00198 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)"; 00199 break; 00200 case "cgi": 00201 case "cgi-fcgi": 00202 case "apache2filter": 00203 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)"; 00204 $conf->prettyURLs = false; 00205 break; 00206 default: 00207 print "unknown; using pretty URLs (<tt>index.php/Page_Title</tt>), if you have trouble change this in <tt>LocalSettings.php</tt>"; 00208 } 00209 print "</li>\n"; 00210 00211 $conf->xml = function_exists( "utf8_encode" ); 00212 if( $conf->xml ) { 00213 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n"; 00214 } else { 00215 print "<li><b>XML / Latin1-UTF-8 conversion is missing! Wiki will probably not work.</b></li>\n"; 00216 } 00217 00218 $memlimit = ini_get( "memory_limit" ); 00219 $conf->raiseMemory = false; 00220 if( empty( $memlimit ) ) { 00221 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n"; 00222 } else { 00223 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". <b>If this is too low, installation may fail!</b> "; 00224 $n = IntVal( $memlimit ); 00225 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) { 00226 $n = IntVal( $m[1] * (1024*1024) ); 00227 } 00228 if( $n < 20*1024*1024 ) { 00229 print "Attempting to raise limit to 20M... "; 00230 if( false === ini_set( "memory_limit", "20M" ) ) { 00231 print "failed."; 00232 } else { 00233 $conf->raiseMemory = true; 00234 print "ok."; 00235 } 00236 } 00237 print "</li>\n"; 00238 } 00239 00240 $conf->zlib = function_exists( "gzencode" ); 00241 if( $conf->zlib ) { 00242 print "<li>Have zlib support; enabling output compression.</li>\n"; 00243 } else { 00244 print "<li>No zlib support.</li>\n"; 00245 } 00246 00247 $conf->ImageMagick = false; 00248 00249 $conf->HaveGD = function_exists( "imagejpeg" ); 00250 if( $conf->HaveGD ) { 00251 print "<li>Found GD graphics library built-in, image thumbnailing will be enabled if you enable uploads.</li>\n"; 00252 } else { 00253 $imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin" ); 00254 foreach( $imcheck as $dir ) { 00255 $im = "$dir/convert"; 00256 if( file_exists( $im ) ) { 00257 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n"; 00258 $conf->ImageMagick = $im; 00259 break; 00260 } 00261 } 00262 if( !$conf->ImageMagick ) { 00263 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n"; 00264 } 00265 } 00266 00267 $conf->UseImageResize = $conf->HaveGD || $conf->ImageMagick; 00268 00269 # $conf->IP = "/Users/brion/Sites/inplace"; 00270 chdir( ".." ); 00271 $conf->IP = getcwd(); 00272 $conf->IP = preg_replace( "/\\\\/","\\\\\\\\",$conf->IP ); // For Windows, \ -> \\ 00273 chdir( "config" ); 00274 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n"; 00275 00276 # $conf->ScriptPath = "/~brion/inplace"; 00277 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["REQUEST_URI"] ); 00278 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n"; 00279 00280 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST"); 00281 00282 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) ); 00283 $conf->EmergencyContact = importPost( "EmergencyContact", $_SERVER["SERVER_ADMIN"] ); 00284 $conf->DBserver = importPost( "DBserver", "localhost" ); 00285 $conf->DBname = importPost( "DBname", "wikidb" ); 00286 $conf->DBuser = importPost( "DBuser", "wikiuser" ); 00287 $conf->DBpassword = importPost( "DBpassword" ); 00288 $conf->DBpassword2 = importPost( "DBpassword2" ); 00289 $conf->RootPW = importPost( "RootPW" ); 00290 $conf->LanguageCode = importPost( "LanguageCode", "en" ); 00291 $conf->SysopName = importPost( "SysopName", "WikiSysop" ); 00292 $conf->SysopPass = importPost( "SysopPass" ); 00293 $conf->SysopPass2 = importPost( "SysopPass2" ); 00294 00295 /* Check for validity */ 00296 $errs = array(); 00297 00298 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) { 00299 $errs["Sitename"] = "Must not be blank or \"MediaWiki\"."; 00300 } 00301 if( $conf->DBpassword == "" ) { 00302 $errs["DBpassword"] = "Must not be blank"; 00303 } 00304 if( $conf->DBpassword != $conf->DBpassword2 ) { 00305 $errs["DBpassword2"] = "Passwords don't match!"; 00306 } 00307 00308 if( $conf->SysopPass == "" ) { 00309 $errs["SysopPass"] = "Must not be blank"; 00310 } 00311 if( $conf->SysopPass != $conf->SysopPass2 ) { 00312 $errs["SysopPass2"] = "Passwords don't match!"; 00313 } 00314 00315 $conf->License = importPost( "License", "none" ); 00316 if( $conf->License == "gfdl" ) { 00317 $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html"; 00318 $conf->RightsText = "GNU Free Documentation License 1.2"; 00319 $conf->RightsCode = "gfdl"; 00320 $conf->RightsIcon = "{$conf->ScriptPath}/stylesheets/images/gnu-fdl.png"; 00321 } elseif( $conf->License == "none" ) { 00322 $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = ""; 00323 } else { 00324 $conf->RightsUrl = importPost( "RightsUrl", "" ); 00325 $conf->RightsText = importPost( "RightsText", "" ); 00326 $conf->RightsCode = importPost( "RightsCode", "" ); 00327 $conf->RightsIcon = importPost( "RightsIcon", "" ); 00328 } 00329 00330 if( $conf->posted && ( 0 == count( $errs ) ) ) { 00331 do { /* So we can 'continue' to end prematurely */ 00332 $conf->Root = ($conf->RootPW != ""); 00333 00334 /* Load up the settings and get installin' */ 00335 $local = writeLocalSettings( $conf ); 00336 $wgCommandLineMode = false; 00337 chdir( ".." ); 00338 eval($local); 00339 $wgDBadminuser = $wgDBuser; 00340 $wgDBadminpassword = $wgDBpassword; 00341 $wgCommandLineMode = true; 00342 $wgUseDatabaseMessages = false; /* FIXME: For database failure */ 00343 require_once( "includes/Setup.php" ); 00344 chdir( "config" ); 00345 00346 require_once( "../maintenance/InitialiseMessages.inc" ); 00347 00348 $wgTitle = Title::newFromText( "Installation script" ); 00349 $wgDatabase = Database::newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 ); 00350 $wgDatabase->mIgnoreErrors = true; 00351 00352 @$myver = mysql_get_server_info( $wgDatabase->mConn ); 00353 if( $myver ) { 00354 $conf->Root = true; 00355 print "<li>Connected as root (automatic)</li>\n"; 00356 } else { 00357 print "<li>MySQL error " . ($err = mysql_errno() ) . 00358 ": " . htmlspecialchars( mysql_error() ); 00359 $ok = false; 00360 switch( $err ) { 00361 case 1045: 00362 if( $conf->Root ) { 00363 $errs["RootPW"] = "Check password"; 00364 } else { 00365 print "<li>Trying regular user...\n"; 00366 /* Try the regular user... */ 00367 $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 ); 00368 $wgDatabase->isOpen(); 00369 $wgDatabase->mIgnoreErrors = true; 00370 @$myver = mysql_get_server_info( $wgDatabase->mConn ); 00371 if( !$myver ) { 00372 $errs["DBuser"] = "Check name/pass"; 00373 $errs["DBpassword"] = "or enter root"; 00374 $errs["DBpassword2"] = "password below"; 00375 $errs["RootPW"] = "Got root?"; 00376 print " need password.</li>\n"; 00377 } else { 00378 $conf->Root = false; 00379 $conf->RootPW = ""; 00380 print " ok.</li>\n"; 00381 # And keep going... 00382 $ok = true; 00383 } 00384 break; 00385 } 00386 case 2002: 00387 case 2003: 00388 $errs["DBserver"] = "Connection failed"; 00389 break; 00390 default: 00391 $errs["DBserver"] = "Couldn't connect to database"; 00392 break; 00393 } 00394 if( !$ok ) continue; 00395 } 00396 00397 if ( !$wgDatabase->isOpen() ) { 00398 $errs["DBserver"] = "Couldn't connect to database"; 00399 continue; 00400 } 00401 00402 print "<li>Connected to database... $myver"; 00403 if( version_compare( $myver, "4.0.0" ) >= 0 ) { 00404 print "; enabling MySQL 4 enhancements"; 00405 $conf->DBmysql4 = true; 00406 $local = writeLocalSettings( $conf ); 00407 } 00408 print "</li>\n"; 00409 00410 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn ); 00411 if( $sel ) { 00412 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n"; 00413 } else { 00414 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" ); 00415 if( !$res ) { 00416 print "<li>Couldn't create database <tt>" . 00417 htmlspecialchars( $wgDBname ) . 00418 "</tt>; try with root access or check your username/pass.</li>\n"; 00419 $errs["RootPW"] = "&lt;- Enter"; 00420 continue; 00421 } 00422 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n"; 00423 } 00424 00425 $wgDatabase->selectDB( $wgDBname ); 00426 00427 if( $wgDatabase->tableExists( "cur" ) ) { 00428 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n<pre>"; 00429 00430 chdir( ".." ); 00431 flush(); 00432 do_ipblocks_update(); flush(); 00433 do_interwiki_update(); flush(); 00434 do_index_update(); flush(); 00435 do_linkscc_update(); flush(); 00436 do_linkscc_1_3_update(); flush(); 00437 do_hitcounter_update(); flush(); 00438 do_recentchanges_update(); flush(); 00439 convertLinks(); flush(); 00440 do_user_real_name_update(); flush(); 00441 do_querycache_update(); flush(); 00442 do_objectcache_update(); flush(); 00443 do_categorylinks_update(); flush(); 00444 00445 if ( isTemplateInitialised() ) { 00446 print "Template namespace already initialised\n"; 00447 } else { 00448 moveCustomMessages( 1 ); flush(); 00449 moveCustomMessages( 2 ); flush(); 00450 moveCustomMessages( 3 ); flush(); 00451 } 00452 00453 initialiseMessages(); flush(); 00454 chdir( "config" ); 00455 00456 print "</pre>\n"; 00457 print "<li>Finished update checks.</li>\n"; 00458 } else { 00459 # FIXME: Check for errors 00460 print "<li>Creating tables..."; 00461 dbsource( "../maintenance/tables.sql", $wgDatabase ); 00462 dbsource( "../maintenance/interwiki.sql", $wgDatabase ); 00463 dbsource( "../maintenance/indexes.sql", $wgDatabase ); 00464 print " done.</li>\n"; 00465 00466 print "<li>Initializing data..."; 00467 $wgDatabase->query( "INSERT INTO site_stats (ss_row_id,ss_total_views," . 00468 "ss_total_edits,ss_good_articles) VALUES (1,0,0,0)" ); 00469 # setting up the db user 00470 if( $conf->Root ) { 00471 print "<li>Granting user permissions...</li>\n"; 00472 dbsource( "../maintenance/users.sql", $wgDatabase ); 00473 } 00474 00475 if( $conf->SysopName ) { 00476 $u = User::newFromName( $conf->getSysopName() ); 00477 if ( 0 == $u->idForName() ) { 00478 $u->addToDatabase(); 00479 $u->setPassword( $conf->getSysopPass() ); 00480 $u->addRight( "sysop" ); 00481 $u->addRight( "bureaucrat" ); 00482 $u->saveSettings(); 00483 print "<li>Created sysop account <tt>" . 00484 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n"; 00485 } else { 00486 print "<li>Could not create user - already exists!</li>\n"; 00487 } 00488 } else { 00489 print "<li>Skipped sysop account creation, no name given.</li>\n"; 00490 } 00491 00492 print "<li>Initialising log pages..."; 00493 $logs = array( 00494 "uploadlogpage" => "uploadlogpagetext", 00495 "dellogpage" => "dellogpagetext", 00496 "protectlogpage" => "protectlogtext", 00497 "blocklogpage" => "blocklogtext" 00498 ); 00499 $metaNamespace = Namespace::getWikipedia(); 00500 $now = wfTimestampNow(); 00501 $won = wfInvertTimestamp( $now ); 00502 foreach( $logs as $page => $text ) { 00503 $logTitle = wfStrencode( $wgLang->ucfirst( str_replace( " ", "_", wfMsgNoDB( $page ) ) ) ); 00504 $logText = wfStrencode( wfMsgNoDB( $text ) ); 00505 $wgDatabase->query( "INSERT INTO cur (cur_namespace,cur_title,cur_text," . 00506 "cur_restrictions,cur_timestamp,inverse_timestamp,cur_touched) " . 00507 "VALUES ($metaNamespace,'$logTitle','$logText','sysop','$now','$won','$now')" ); 00508 } 00509 print "</li>\n"; 00510 00511 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) ); 00512 $title = $titleobj->getDBkey(); 00513 $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text,cur_timestamp,inverse_timestamp,cur_touched) " . 00514 "VALUES (0,'$title','" . 00515 wfStrencode( wfMsg( "mainpagetext" ) . "\n\n" . wfMsg( "mainpagedocfooter" ) ) . "','$now','$won','$now')"; 00516 $wgDatabase->query( $sql, $fname ); 00517 00518 print "<li><pre>"; 00519 initialiseMessages(); 00520 print "</pre></li>\n"; 00521 } 00522 00523 /* Write out the config file now that all is well */ 00524 print "<p>Creating LocalSettings.php...</p>\n\n"; 00525 $localSettings = "<" . "?php$endl$local$endl?" . ">"; 00526 00527 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) { 00528 $xt = "xt"; # Refuse to overwrite an existing file 00529 } else { 00530 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah 00531 } 00532 $f = fopen( "LocalSettings.php", $xt ); 00533 00534 if( $f == false ) { 00535 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" . 00536 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" . 00537 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" ); 00538 } 00539 fwrite( $f, $localSettings ); 00540 fclose( $f ); 00541 00542 print "<p>Success! Move the LocalSettings.php file into the parent directory, then follow 00543 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n"; 00544 00545 } while( false ); 00546 } 00547 ?> 00548 </ul> 00549 00550 00551 <?php 00552 00553 if( count( $errs ) ) { 00554 /* Display options form */ 00555 00556 if( $conf->posted ) { 00557 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n"; 00558 } 00559 ?> 00560 00561 <form name="config" method="post"> 00562 00563 00564 <h2>Site config</h2> 00565 00566 <dl class="setup"> 00567 <dd> 00568 <?php 00569 aField( $conf, "Sitename", "Site name:" ); 00570 ?> 00571 </dd> 00572 <dt> 00573 Your site name should be a relatively short word. It'll appear as the namespace 00574 name for 'meta' pages as well as throughout the user interface. Good site names 00575 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and 00576 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation, 00577 which may cause problems. 00578 </dt> 00579 00580 <dd> 00581 <?php 00582 aField( $conf, "EmergencyContact", "Contact e-mail" ); 00583 ?> 00584 </dd> 00585 <dt> 00586 This will be used as the return address for password reminders and 00587 may be displayed in some error conditions so visitors can get in 00588 touch with you. 00589 </dt> 00590 00591 <dd> 00592 <label class='column' for="LanguageCode">Language</label> 00593 <select id="LanguageCode" name="LanguageCode"> 00594 <?php 00595 $list = getLanguageList(); 00596 foreach( $list as $code => $name ) { 00597 $sel = ($code == $conf->LanguageCode) ? "selected" : ""; 00598 echo "\t\t<option value=\"$code\" $sel>$name</option>\n"; 00599 } 00600 ?> 00601 </select> 00602 </dd> 00603 <dt> 00604 You may select the language for the user interface of the wiki... 00605 Some localizations are less complete than others. This also controls 00606 the character encoding; Unicode is more flexible, but Latin-1 may be 00607 more compatible with older browsers for some languages. Unicode will 00608 be used where not specified otherwise. 00609 </dt> 00610 00611 <dd> 00612 <label class='column'>Copyright/license metadata</label> 00613 <div>Select one:</div> 00614 00615 <ul class="plain"> 00616 <li><?php aField( $conf, "License", "no license metadata", "radio", "none" ); ?></li> 00617 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li> 00618 <li><?php 00619 aField( $conf, "License", "a Creative Commons license...", "radio", "cc" ); 00620 $partner = "MediaWiki"; 00621 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" ); 00622 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" ); 00623 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" ); 00624 print "<a href=\"$ccApp\">choose</a>"; 00625 ?></li> 00626 <li><?php aField( $conf, "RightsUrl", $conf->RightsUrl, "hidden" ); ?></li> 00627 <li><?php aField( $conf, "RightsText", $conf->RightsText, "hidden" ); ?></li> 00628 <li><?php aField( $conf, "RightsCode", $conf->RightsCode, "hidden" ); ?></li> 00629 <li><?php aField( $conf, "RightsIcon", $conf->RightsIcon, "hidden" ); ?></li> 00630 </ul> 00631 </dd> 00632 <dt> 00633 MediaWiki can include a basic license notice, icon, and machine-reable 00634 copyright metadata if your wiki's content is to be licensed under 00635 the GNU FDL or a Creative Commons license. If you're not sure, leave 00636 it at "none". 00637 </dt> 00638 00639 00640 <dd> 00641 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?> 00642 </dd> 00643 <dd> 00644 <?php aField( $conf, "SysopPass", "password:", "password" ) ?> 00645 </dd> 00646 <dd> 00647 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?> 00648 </dd> 00649 <dt> 00650 A sysop user account can lock or delete pages, block problematic IP 00651 addresses from editing, and other maintenance tasks. If creating a new 00652 wiki database, a sysop account will be created with the given name 00653 and password. 00654 </dt> 00655 </dl> 00656 00657 <h2>Database config</h2> 00658 00659 <dl class="setup"> 00660 <dd><?php 00661 aField( $conf, "DBserver", "MySQL server" ); 00662 ?></dd> 00663 <dt> 00664 If your database server isn't on your web server, enter the name 00665 or IP address here. 00666 </dt> 00667 00668 <dd><?php 00669 aField( $conf, "DBname", "Database name" ); 00670 ?></dd> 00671 <dd><?php 00672 aField( $conf, "DBuser", "DB username" ); 00673 ?></dd> 00674 <dd><?php 00675 aField( $conf, "DBpassword", "DB password", "password" ); 00676 ?></dd> 00677 <dd><?php 00678 aField( $conf, "DBpassword2", "again", "password" ); 00679 ?></dd> 00680 <dt> 00681 If you only have a single user account and database available, 00682 enter those here. If you have database root access (see below) 00683 you can specify new accounts/databases to be created. 00684 </dt> 00685 00686 00687 <dd> 00688 <?php 00689 aField( $conf, "RootPW", "DB root password", "password" ); 00690 ?> 00691 </dd> 00692 <dt> 00693 You will only need this if the database and/or user account 00694 above don't already exist. 00695 Do <em>not</em> type in your machine's root password! MySQL 00696 has its own "root" user with a separate password. (It might 00697 even be blank, depending on your configuration.) 00698 </dt> 00699 00700 <dd> 00701 <label class='column'>&nbsp;</label> 00702 <input type="submit" value="Install!" /> 00703 </dd> 00704 </dl> 00705 00706 00707 </form> 00708 00709 <?php 00710 } 00711 00712 /* -------------------------------------------------------------------------------------- */ 00713 00714 function writeAdminSettings( $conf ) { 00715 return " 00716 \$wgDBadminuser = \"{$conf->DBadminuser}\"; 00717 \$wgDBadminpassword = \"{$conf->DBadminpassword}\"; 00718 "; 00719 } 00720 00721 function writeLocalSettings( $conf ) { 00722 $conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false'; 00723 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false'; 00724 $conf->PasswordSender = $conf->EmergencyContact; 00725 if( preg_match( '/^([a-z]+)-latin1$/', $conf->LanguageCode, $m ) ) { 00726 $conf->LanguageCode = $m[1]; 00727 $conf->Latin1 = true; 00728 } else { 00729 $conf->Latin1 = false; 00730 } 00731 $zlib = ($conf->zlib ? "" : "# "); 00732 $magic = ($conf->ImageMagick ? "" : "# "); 00733 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" ); 00734 $pretty = ($conf->prettyURLs ? "" : "# "); 00735 $ugly = ($conf->prettyURLs ? "# " : ""); 00736 $rights = ($conf->RightsUrl) ? "" : "# "; 00737 00738 $file = @fopen( "/dev/random", "r" ); 00739 if ( $file ) { 00740 $proxyKey = bin2hex( fread( $file, 32 ) ); 00741 fclose( $file ); 00742 } else { 00743 $proxyKey = ""; 00744 for ( $i=0; $i<8; $i++ ) { 00745 $proxyKey .= dechex(mt_rand(0, 0x7fffffff)); 00746 } 00747 print "Warning: \$wgProxyKey is insecure\n"; 00748 } 00749 00750 # Add slashes to strings for double quoting 00751 $slconf = array_map( "addslashes", get_object_vars( $conf ) ); 00752 00753 00754 $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":"; 00755 return " 00756 # This file was automatically generated by the MediaWiki installer. 00757 # If you make manual changes, please keep track in case you need to 00758 # recreate them later. 00759 00760 \$IP = \"{$slconf['IP']}\"; 00761 ini_set( \"include_path\", \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" ); 00762 include_once( \"DefaultSettings.php\" ); 00763 00764 # If PHP's memory limit is very low, some operations may fail. 00765 " . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . " 00766 00767 if ( \$wgCommandLineMode ) { 00768 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) { 00769 die( \"This script must be run from the command line\\n\" ); 00770 } 00771 } else { 00772 ## Compress output if the browser supports it 00773 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) ob_start( 'ob_gzhandler' ); 00774 } 00775 00776 \$wgSitename = \"{$slconf['Sitename']}\"; 00777 00778 \$wgScriptPath = \"{$slconf['ScriptPath']}\"; 00779 \$wgScript = \"\$wgScriptPath/index.php\"; 00780 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\"; 00781 00782 ## If using PHP as a CGI module, use the ugly URLs 00783 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\"; 00784 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\"; 00785 00786 \$wgStylePath = \"\$wgScriptPath/stylesheets\"; 00787 \$wgStyleDirectory = \"\$IP/stylesheets\"; 00788 \$wgLogo = \"\$wgStylePath/images/wiki.png\"; 00789 00790 \$wgUploadPath = \"\$wgScriptPath/images\"; 00791 \$wgUploadDirectory = \"\$IP/images\"; 00792 00793 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\"; 00794 \$wgPasswordSender = \"{$slconf['PasswordSender']}\"; 00795 00796 \$wgDBserver = \"{$slconf['DBserver']}\"; 00797 \$wgDBname = \"{$slconf['DBname']}\"; 00798 \$wgDBuser = \"{$slconf['DBuser']}\"; 00799 \$wgDBpassword = \"{$slconf['DBpassword']}\"; 00800 00801 ## To allow SQL queries through the wiki's Special:Askaql page, 00802 ## uncomment the next lines. THIS IS VERY INSECURE. If you want 00803 ## to allow semipublic read-only SQL access for your sysops, 00804 ## you should define a MySQL user with limited privileges. 00805 ## See MySQL docs: http://www.mysql.com/doc/en/GRANT.html 00806 # 00807 # \$wgAllowSysopQueries = true; 00808 # \$wgDBsqluser = \"sqluser\"; 00809 # \$wgDBsqlpassword = \"sqlpass\"; 00810 00811 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4}; 00812 00813 ## To enable image uploads, make sure the 'images' directory 00814 ## is writable, then uncomment this: 00815 # \$wgDisableUploads = false; 00816 \$wgUseImageResize = {$conf->UseImageResize}; 00817 {$magic}\$wgUseImageMagick = true; 00818 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\"; 00819 00820 ## If you have the appropriate support software installed 00821 ## you can enable inline LaTeX equations: 00822 # \$wgUseTeX = true; 00823 \$wgMathPath = \"{\$wgUploadPath}/math\"; 00824 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\"; 00825 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\"; 00826 00827 \$wgLocalInterwiki = \$wgSitename; 00828 00829 \$wgLanguageCode = \"{$slconf['LanguageCode']}\"; 00830 \$wgUseLatin1 = " . ($conf->Latin1 ? 'true' : 'false') . ";\n 00831 00832 \$wgProxyKey = \"$proxyKey\"; 00833 00834 ## Default skin: you can change the default skin. Use the internal symbolic 00835 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook': 00836 # \$wgDefaultSkin = 'monobook'; 00837 00838 ## For attaching licensing metadata to pages, and displaying an 00839 ## appropriate copyright notice / icon. GNU Free Documentation 00840 ## License and Creative Commons licenses are supported so far. 00841 {$rights}\$wgEnableCreativeCommonsRdf = true; 00842 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright 00843 \$wgRightsUrl = \"{$conf->RightsUrl}\"; 00844 \$wgRightsText = \"{$conf->RightsText}\"; 00845 \$wgRightsIcon = \"{$conf->RightsIcon}\"; 00846 # \$wgRightsCode = \"{$conf->RightsCode}\"; # Not yet used 00847 "; 00848 } 00849 00850 function dieout( $text ) { 00851 die( $text . "\n\n</body>\n</html>" ); 00852 } 00853 00854 function importPost( $name, $default = "" ) { 00855 if( isset( $_POST[$name] ) ) { 00856 $retval = $_POST[$name]; 00857 if ( get_magic_quotes_gpc() ) { 00858 $retval = stripslashes( $retval ); 00859 } 00860 } else { 00861 $retval = $default; 00862 } 00863 return $retval; 00864 } 00865 00866 function aField( &$conf, $field, $text, $type = "", $value = "" ) { 00867 if( $type != "" ) { 00868 $xtype = "type=\"$type\""; 00869 } else { 00870 $xtype = ""; 00871 } 00872 00873 if(!(isset($id)) or ($id == "") ) $id = $field; 00874 $nolabel = ($type == "radio") || ($type == "hidden"); 00875 if( $nolabel ) { 00876 echo "\t\t<label>"; 00877 } else { 00878 echo "\t\t<label class='column' for=\"$id\">$text</label>\n"; 00879 } 00880 00881 if( $type == "radio" && $value == $conf->$field ) { 00882 $checked = "checked='checked'"; 00883 } else { 00884 $checked = ""; 00885 } 00886 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" $checked value=\""; 00887 if( $type == "radio" ) { 00888 echo htmlspecialchars( $value ); 00889 } else { 00890 echo htmlspecialchars( $conf->$field ); 00891 } 00892 echo "\" />\n"; 00893 if( $nolabel ) { 00894 echo " $text</label>\n"; 00895 } 00896 00897 global $errs; 00898 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n"; 00899 } 00900 00901 function getLanguageList() { 00902 global $wgLanguageNames; 00903 if( !isset( $wgLanguageNames ) ) { 00904 $wgLanguageCode = "xxx"; 00905 function wfLocalUrl( $x ) { return $x; } 00906 function wfLocalUrlE( $x ) { return $x; } 00907 require( "../languages/Names.php" ); 00908 } 00909 00910 $codes = array(); 00911 $latin1 = array( "da", "de", "en", "es", "fr", "nl", "sv" ); 00912 00913 $d = opendir( "../languages" ); 00914 while( false !== ($f = readdir( $d ) ) ) { 00915 if( preg_match( '/Language([A-Z][a-z]+)\.php$/', $f, $m ) ) { 00916 $code = strtolower( $m[1] ); 00917 if( in_array( $code, $latin1 ) ) { 00918 $codes[$code] = "$code - " . $wgLanguageNames[$code] . " - Unicode"; 00919 $codes[$code.'-latin1'] = "$code - " . $wgLanguageNames[$code] . " - Latin-1"; 00920 } else { 00921 $codes[$code] = "$code - " . $wgLanguageNames[$code]; 00922 } 00923 } 00924 } 00925 closedir( $d ); 00926 ksort( $codes ); 00927 return $codes; 00928 } 00929 00930 ?> 00931 00932 </body> 00933 </html>

Generated on Tue Jun 29 23:40:03 2004 for Mediawiki by doxygen 1.3.7