index.php 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211
  1. <?php
  2. # MediaWiki web-based config/installation
  3. # Copyright (C) 2004 Brion Vibber <brion@pobox.com>, 2006 Rob Church <robchur@gmail.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. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. # http://www.gnu.org/copyleft/gpl.html
  20. error_reporting( E_ALL );
  21. header( "Content-type: text/html; charset=utf-8" );
  22. @ini_set( "display_errors", true );
  23. # In case of errors, let output be clean.
  24. $wgRequestTime = microtime( true );
  25. # Attempt to set up the include path, to fix problems with relative includes
  26. $IP = dirname( dirname( __FILE__ ) );
  27. define( 'MW_INSTALL_PATH', $IP );
  28. # Define an entry point and include some files
  29. define( "MEDIAWIKI", true );
  30. define( "MEDIAWIKI_INSTALL", true );
  31. // Run version checks before including other files
  32. // so people don't see a scary parse error.
  33. require_once( "$IP/install-utils.inc" );
  34. install_version_checks();
  35. require_once( "$IP/includes/Defines.php" );
  36. require_once( "$IP/includes/DefaultSettings.php" );
  37. require_once( "$IP/includes/AutoLoader.php" );
  38. require_once( "$IP/includes/MagicWord.php" );
  39. require_once( "$IP/includes/Namespace.php" );
  40. require_once( "$IP/includes/ProfilerStub.php" );
  41. require_once( "$IP/includes/GlobalFunctions.php" );
  42. require_once( "$IP/includes/Hooks.php" );
  43. require_once( "$IP/includes/Exception.php" );
  44. # If we get an exception, the user needs to know
  45. # all the details
  46. $wgShowExceptionDetails = true;
  47. $wgShowSQLErrors = true;
  48. wfInstallExceptionHandler();
  49. ## Databases we support:
  50. $ourdb = array();
  51. $ourdb['mysql']['fullname'] = 'MySQL';
  52. $ourdb['mysql']['havedriver'] = 0;
  53. $ourdb['mysql']['compile'] = 'mysql';
  54. $ourdb['mysql']['bgcolor'] = '#ffe5a7';
  55. $ourdb['mysql']['rootuser'] = 'root';
  56. $ourdb['postgres']['fullname'] = 'PostgreSQL';
  57. $ourdb['postgres']['havedriver'] = 0;
  58. $ourdb['postgres']['compile'] = 'pgsql';
  59. $ourdb['postgres']['bgcolor'] = '#aaccff';
  60. $ourdb['postgres']['rootuser'] = 'postgres';
  61. $ourdb['sqlite']['fullname'] = 'SQLite';
  62. $ourdb['sqlite']['havedriver'] = 0;
  63. $ourdb['sqlite']['compile'] = 'pdo_sqlite';
  64. $ourdb['sqlite']['bgcolor'] = '#b1ebb1';
  65. $ourdb['sqlite']['rootuser'] = '';
  66. $ourdb['mssql']['fullname'] = 'MSSQL';
  67. $ourdb['mssql']['havedriver'] = 0;
  68. $ourdb['mssql']['compile'] = 'mssql not ready'; # Change to 'mssql' after includes/DatabaseMssql.php added;
  69. $ourdb['mssql']['bgcolor'] = '#ffc0cb';
  70. $ourdb['mssql']['rootuser'] = 'administrator';
  71. $ourdb['ibm_db2']['fullname'] = 'DB2';
  72. $ourdb['ibm_db2']['havedriver'] = 0;
  73. $ourdb['ibm_db2']['compile'] = 'ibm_db2';
  74. $ourdb['ibm_db2']['bgcolor'] = '#ffeba1';
  75. $ourdb['ibm_db2']['rootuser'] = 'db2admin';
  76. ?>
  77. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  78. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  79. <head>
  80. <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  81. <meta name="robots" content="noindex,nofollow"/>
  82. <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?> Installation</title>
  83. <style type="text/css">
  84. @import "../skins/monobook/main.css";
  85. .env-check {
  86. font-size: 90%;
  87. margin: 1em 0 1em 2.5em;
  88. }
  89. .config-section {
  90. margin-top: 2em;
  91. }
  92. .config-section label.column {
  93. clear: left;
  94. font-weight: bold;
  95. width: 13em;
  96. float: left;
  97. text-align: right;
  98. padding-right: 1em;
  99. padding-top: .2em;
  100. }
  101. .config-input {
  102. clear: left;
  103. zoom: 100%; /* IE hack */
  104. }
  105. .config-section .config-desc {
  106. clear: left;
  107. margin: 0 0 2em 18em;
  108. padding-top: 1em;
  109. font-size: 85%;
  110. }
  111. .iput-text, .iput-password {
  112. width: 14em;
  113. margin-right: 1em;
  114. }
  115. .error {
  116. color: red;
  117. background-color: #fff;
  118. font-weight: bold;
  119. left: 1em;
  120. font-size: 100%;
  121. }
  122. .error-top {
  123. color: red;
  124. background-color: #FFF0F0;
  125. border: 2px solid red;
  126. font-size: 130%;
  127. font-weight: bold;
  128. padding: 1em 1.5em;
  129. margin: 2em 0 1em;
  130. }
  131. ul.plain {
  132. list-style-type: none;
  133. list-style-image: none;
  134. float: left;
  135. margin: 0;
  136. padding: 0;
  137. }
  138. .btn-install {
  139. font-weight: bold;
  140. font-size: 110%;
  141. padding: .2em .3em;
  142. }
  143. .license {
  144. font-size: 85%;
  145. padding-top: 3em;
  146. }
  147. span.success-message {
  148. font-weight: bold;
  149. font-size: 110%;
  150. color: green;
  151. }
  152. .success-box {
  153. font-size: 130%;
  154. }
  155. </style>
  156. <script type="text/javascript">
  157. <!--
  158. function hideall() {
  159. <?php foreach (array_keys($ourdb) as $db) {
  160. echo "\n var i = document.getElementById('$db'); if (i) i.style.display='none';";
  161. }
  162. ?>
  163. }
  164. function toggleDBarea(id,defaultroot) {
  165. hideall();
  166. var dbarea = document.getElementById(id);
  167. if (dbarea) dbarea.style.display = (dbarea.style.display == 'none') ? 'block' : 'none';
  168. var db = document.getElementById('RootUser');
  169. if (defaultroot) {
  170. <?php foreach (array_keys($ourdb) as $db) {
  171. echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
  172. }?>
  173. }
  174. }
  175. // -->
  176. </script>
  177. </head>
  178. <body>
  179. <div id="globalWrapper">
  180. <div id="column-content">
  181. <div id="content">
  182. <div id="bodyContent">
  183. <h1>MediaWiki <?php print htmlspecialchars( $wgVersion ) ?> Installation</h1>
  184. <?php
  185. $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout
  186. /* Check for existing configurations and bug out! */
  187. if( file_exists( "../LocalSettings.php" ) ) {
  188. $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
  189. dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
  190. <p>Please delete the /config directory for extra security.</p>" );
  191. }
  192. if( file_exists( "./LocalSettings.php" ) ) {
  193. writeSuccessMessage();
  194. dieout( '' );
  195. }
  196. if( !is_writable( "." ) ) {
  197. dieout( "<h2>Can't write config file, aborting</h2>
  198. <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
  199. writable by the web server. Once configuration is done you'll move the created
  200. <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
  201. then remove the <tt>config</tt> subdirectory entirely.</p>
  202. <p>To make the directory writable on a Unix/Linux system:</p>
  203. <pre>
  204. cd <i>/path/to/wiki</i>
  205. chmod a+w config
  206. </pre>
  207. <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
  208. }
  209. require_once( "$IP/install-utils.inc" );
  210. require_once( "$IP/maintenance/updaters.inc" );
  211. class ConfigData {
  212. function getEncoded( $data ) {
  213. # removing latin1 support, no need...
  214. return $data;
  215. }
  216. function getSitename() { return $this->getEncoded( $this->Sitename ); }
  217. function getSysopName() { return $this->getEncoded( $this->SysopName ); }
  218. function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
  219. function setSchema( $schema, $engine ) {
  220. $this->DBschema = $schema;
  221. if ( !preg_match( '/^\w*$/', $engine ) ){
  222. $engine = 'InnoDB';
  223. }
  224. switch ( $this->DBschema ) {
  225. case 'mysql5':
  226. $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=utf8";
  227. $this->DBmysql5 = 'true';
  228. break;
  229. case 'mysql5-binary':
  230. $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=binary";
  231. $this->DBmysql5 = 'true';
  232. break;
  233. default:
  234. $this->DBTableOptions = "TYPE=$engine";
  235. $this->DBmysql5 = 'false';
  236. }
  237. $this->DBengine = $engine;
  238. # Set the global for use during install
  239. global $wgDBTableOptions;
  240. $wgDBTableOptions = $this->DBTableOptions;
  241. }
  242. }
  243. ?>
  244. <ul>
  245. <li>
  246. <b>Don't forget security updates!</b> Keep an eye on the
  247. <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
  248. release announcements mailing list</a>.
  249. </li>
  250. </ul>
  251. <h2>Checking environment...</h2>
  252. <p><em>Please include all of the lines below when reporting installation problems.</em></p>
  253. <ul class="env-check">
  254. <?php
  255. $mainListOpened = true;
  256. $endl = "
  257. ";
  258. define( 'MW_NO_OUTPUT_BUFFER', 1 );
  259. $conf = new ConfigData;
  260. install_version_checks();
  261. $self = 'Installer'; # Maintenance script name, to please Setup.php
  262. print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n";
  263. error_reporting( 0 );
  264. $phpdatabases = array();
  265. foreach (array_keys($ourdb) as $db) {
  266. $compname = $ourdb[$db]['compile'];
  267. if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) {
  268. array_push($phpdatabases, $db);
  269. $ourdb[$db]['havedriver'] = 1;
  270. }
  271. }
  272. error_reporting( E_ALL );
  273. if (!$phpdatabases) {
  274. print "Could not find a suitable database driver!<ul>";
  275. foreach (array_keys($ourdb) AS $db) {
  276. $comp = $ourdb[$db]['compile'];
  277. $full = $ourdb[$db]['fullname'];
  278. print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
  279. ."or install the $comp.so module</li>\n";
  280. }
  281. echo '</ul>';
  282. dieout( '' );
  283. }
  284. print "<li>Found database drivers for:";
  285. $DefaultDBtype = '';
  286. foreach (array_keys($ourdb) AS $db) {
  287. if ($ourdb[$db]['havedriver']) {
  288. if ( $DefaultDBtype == '' ) {
  289. $DefaultDBtype = $db;
  290. }
  291. print " ".$ourdb[$db]['fullname'];
  292. }
  293. }
  294. print "</li>\n";
  295. if( wfIniGetBool( "register_globals" ) ) {
  296. ?>
  297. <li>
  298. <div style="font-size:110%">
  299. <strong class="error">Warning:</strong>
  300. <strong>PHP's <tt><a href="http://php.net/register_globals">register_globals</a></tt> option is enabled. Disable it if you can.</strong>
  301. </div>
  302. MediaWiki will work, but your server is more exposed to PHP-based security vulnerabilities.
  303. </li>
  304. <?php
  305. }
  306. $fatal = false;
  307. if( wfIniGetBool( "magic_quotes_runtime" ) ) {
  308. $fatal = true;
  309. ?><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>
  310. This option corrupts data input unpredictably; you cannot install or use
  311. MediaWiki unless this option is disabled.</li>
  312. <?php
  313. }
  314. if( wfIniGetBool( "magic_quotes_sybase" ) ) {
  315. $fatal = true;
  316. ?><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>
  317. This option corrupts data input unpredictably; you cannot install or use
  318. MediaWiki unless this option is disabled.</li>
  319. <?php
  320. }
  321. if( wfIniGetBool( "mbstring.func_overload" ) ) {
  322. $fatal = true;
  323. ?><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>
  324. This option causes errors and may corrupt data unpredictably;
  325. you cannot install or use MediaWiki unless this option is disabled.</li>
  326. <?php
  327. }
  328. if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) {
  329. $fatal = true;
  330. ?><li class="error"><strong>Fatal: <a href="http://www.php.net/manual/en/ini.core.php">zend.ze1_compatibility_mode</a> is active!</strong>
  331. This option causes horrible bugs with MediaWiki; you cannot install or use
  332. MediaWiki unless this option is disabled.</li>
  333. <?php
  334. }
  335. if( $fatal ) {
  336. dieout( "Cannot install MediaWiki." );
  337. }
  338. if( wfIniGetBool( "safe_mode" ) ) {
  339. $conf->safeMode = true;
  340. ?>
  341. <li><b class='error'>Warning:</b> <strong>PHP's
  342. <a href='http://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
  343. You may have problems caused by this, particularly if using image uploads.
  344. </li>
  345. <?php
  346. } else {
  347. $conf->safeMode = false;
  348. }
  349. $sapi = htmlspecialchars( php_sapi_name() );
  350. print "<li>PHP server API is $sapi; ";
  351. $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
  352. if( $wgUsePathInfo ) {
  353. print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
  354. } else {
  355. print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
  356. }
  357. print "</li>\n";
  358. $conf->xml = function_exists( "utf8_encode" );
  359. if( $conf->xml ) {
  360. print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
  361. } else {
  362. dieout( "PHP's XML module is missing; the wiki requires functions in
  363. this module and won't work in this configuration.
  364. If you're running Mandrake, install the php-xml package." );
  365. }
  366. # Check for session support
  367. if( !function_exists( 'session_name' ) )
  368. dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
  369. # session.save_path doesn't *have* to be set, but if it is, and it's
  370. # not valid/writable/etc. then it can cause problems
  371. $sessionSavePath = mw_get_session_save_path();
  372. $ssp = htmlspecialchars( $sessionSavePath );
  373. # Warn the user if it's not set, but let them proceed
  374. if( !$sessionSavePath ) {
  375. print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
  376. has not been set in PHP.ini. If the default value causes problems with
  377. saving session data, set it to a valid path which is read/write/execute
  378. for the user your web server is running under.</li>";
  379. } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
  380. # All good? Let the user know
  381. print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
  382. } else {
  383. # Something not right? Warn the user, but let them proceed
  384. print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
  385. appears to be invalid or is not writable. PHP needs to be able to save data to
  386. this location for correct session operation.</li>";
  387. }
  388. # Check for PCRE support
  389. if( !function_exists( 'preg_match' ) )
  390. dieout( "The PCRE support module appears to be missing. MediaWiki requires the
  391. Perl-compatible regular expression functions." );
  392. $memlimit = ini_get( "memory_limit" );
  393. $conf->raiseMemory = false;
  394. if( empty( $memlimit ) || $memlimit == -1 ) {
  395. print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
  396. } else {
  397. print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
  398. $n = intval( $memlimit );
  399. if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
  400. $n = intval( $m[1] * (1024*1024) );
  401. }
  402. if( $n < 20*1024*1024 ) {
  403. print "Attempting to raise limit to 20M... ";
  404. if( false === ini_set( "memory_limit", "20M" ) ) {
  405. print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
  406. } else {
  407. $conf->raiseMemory = true;
  408. print "ok.";
  409. }
  410. }
  411. print "</li>\n";
  412. }
  413. $conf->turck = function_exists( 'mmcache_get' );
  414. if ( $conf->turck ) {
  415. print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
  416. }
  417. $conf->xcache = function_exists( 'xcache_get' );
  418. if( $conf->xcache )
  419. print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>\n";
  420. $conf->apc = function_exists('apc_fetch');
  421. if ($conf->apc ) {
  422. print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>\n";
  423. }
  424. $conf->eaccel = function_exists( 'eaccelerator_get' );
  425. if ( $conf->eaccel ) {
  426. $conf->turck = 'eaccelerator';
  427. print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
  428. }
  429. $conf->dba = function_exists( 'dba_open' );
  430. if( !( $conf->turck || $conf->eaccel || $conf->apc || $conf->xcache ) ) {
  431. echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
  432. <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
  433. <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>;
  434. cannot use these for object caching.</li>' );
  435. }
  436. $conf->diff3 = false;
  437. $diff3locations = array_merge(
  438. array(
  439. "/usr/bin",
  440. "/usr/local/bin",
  441. "/opt/csw/bin",
  442. "/usr/gnu/bin",
  443. "/usr/sfw/bin" ),
  444. explode( PATH_SEPARATOR, getenv( "PATH" ) ) );
  445. $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
  446. $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
  447. foreach ($diff3locations as $loc) {
  448. $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
  449. if ($exe !== false) {
  450. $conf->diff3 = $exe;
  451. break;
  452. }
  453. }
  454. if ($conf->diff3)
  455. print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
  456. else
  457. print "<li>GNU diff3 not found.</li>";
  458. $conf->ImageMagick = false;
  459. $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
  460. foreach( $imcheck as $dir ) {
  461. $im = "$dir/convert";
  462. if( @file_exists( $im ) ) {
  463. print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
  464. $conf->ImageMagick = $im;
  465. break;
  466. }
  467. }
  468. $conf->HaveGD = function_exists( "imagejpeg" );
  469. if( $conf->HaveGD ) {
  470. print "<li>Found GD graphics library built-in";
  471. if( !$conf->ImageMagick ) {
  472. print ", image thumbnailing will be enabled if you enable uploads";
  473. }
  474. print ".</li>\n";
  475. } else {
  476. if( !$conf->ImageMagick ) {
  477. print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
  478. }
  479. }
  480. $conf->IP = dirname( dirname( __FILE__ ) );
  481. print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
  482. // PHP_SELF isn't available sometimes, such as when PHP is CGI but
  483. // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
  484. // to get the path to the current script... hopefully it's reliable. SIGH
  485. $path = ($_SERVER["PHP_SELF"] === '')
  486. ? $_SERVER["SCRIPT_NAME"]
  487. : $_SERVER["PHP_SELF"];
  488. $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $path );
  489. print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
  490. // We may be installing from *.php5 extension file, if so, print message
  491. $conf->ScriptExtension = '.php';
  492. if (defined('MW_INSTALL_PHP5_EXT')) {
  493. $conf->ScriptExtension = '.php5';
  494. print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
  495. } else {
  496. print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
  497. }
  498. print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
  499. $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
  500. $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
  501. $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
  502. ? 'root@localhost'
  503. : $_SERVER["SERVER_ADMIN"];
  504. $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail );
  505. $conf->DBtype = importPost( "DBtype", $DefaultDBtype );
  506. if ( !isset( $ourdb[$conf->DBtype] ) ) {
  507. $conf->DBtype = $DefaultDBtype;
  508. }
  509. $conf->DBserver = importPost( "DBserver", "localhost" );
  510. $conf->DBname = importPost( "DBname", "wikidb" );
  511. $conf->DBuser = importPost( "DBuser", "wikiuser" );
  512. $conf->DBpassword = importPost( "DBpassword" );
  513. $conf->DBpassword2 = importPost( "DBpassword2" );
  514. $conf->SysopName = importPost( "SysopName", "WikiSysop" );
  515. $conf->SysopPass = importPost( "SysopPass" );
  516. $conf->SysopPass2 = importPost( "SysopPass2" );
  517. $conf->RootUser = importPost( "RootUser", "root" );
  518. $conf->RootPW = importPost( "RootPW", "" );
  519. $useRoot = importCheck( 'useroot', false );
  520. $conf->LanguageCode = importPost( "LanguageCode", "en" );
  521. ## MySQL specific:
  522. $conf->DBprefix = importPost( "DBprefix" );
  523. $conf->setSchema(
  524. importPost( "DBschema", "mysql5-binary" ),
  525. importPost( "DBengine", "InnoDB" ) );
  526. ## Postgres specific:
  527. $conf->DBport = importPost( "DBport", "5432" );
  528. $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" );
  529. $conf->DBts2schema = importPost( "DBts2schema", "public" );
  530. ## SQLite specific
  531. $conf->SQLiteDataDir = importPost( "SQLiteDataDir", "" );
  532. ## MSSQL specific
  533. // We need a second field so it doesn't overwrite the MySQL one
  534. $conf->DBprefix2 = importPost( "DBprefix2" );
  535. ## DB2 specific:
  536. // New variable in order to have a different default port number
  537. $conf->DBport_db2 = importPost( "DBport_db2", "50000" );
  538. $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" );
  539. $conf->DBcataloged = importPost( "DBcataloged", "cataloged" );
  540. $conf->ShellLocale = getShellLocale( $conf->LanguageCode );
  541. /* Check for validity */
  542. $errs = array();
  543. if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename ) ) {
  544. $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\"";
  545. }
  546. if( $conf->DBuser == "" ) {
  547. $errs["DBuser"] = "Must not be blank";
  548. }
  549. if( ($conf->DBtype == 'mysql') && (strlen($conf->DBuser) > 16) ) {
  550. $errs["DBuser"] = "Username too long";
  551. }
  552. if( $conf->DBpassword == "" && $conf->DBtype != "postgres" ) {
  553. $errs["DBpassword"] = "Must not be blank";
  554. }
  555. if( $conf->DBpassword != $conf->DBpassword2 ) {
  556. $errs["DBpassword2"] = "Passwords don't match!";
  557. }
  558. if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) {
  559. $errs["DBprefix"] = "Invalid table prefix";
  560. } else {
  561. untaint( $conf->DBprefix, TC_MYSQL );
  562. }
  563. error_reporting( E_ALL );
  564. /**
  565. * Initialise $wgLang and $wgContLang to something so we can
  566. * call case-folding methods. Per Brion, this is English for
  567. * now, although we could be clever and initialise to the
  568. * user-selected language.
  569. */
  570. $wgContLang = Language::factory( 'en' );
  571. $wgLang = $wgContLang;
  572. /**
  573. * We're messing about with users, so we need a stub
  574. * authentication plugin...
  575. */
  576. $wgAuth = new AuthPlugin();
  577. /**
  578. * Validate the initial administrator account; username,
  579. * password checks, etc.
  580. */
  581. if( $conf->SysopName ) {
  582. # Check that the user can be created
  583. $u = User::newFromName( $conf->SysopName );
  584. if( is_a($u, 'User') ) { // please do not use instanceof, it breaks PHP4
  585. # Various password checks
  586. if( $conf->SysopPass != '' ) {
  587. if( $conf->SysopPass == $conf->SysopPass2 ) {
  588. if( !$u->isValidPassword( $conf->SysopPass ) ) {
  589. $errs['SysopPass'] = "Bad password";
  590. }
  591. } else {
  592. $errs['SysopPass2'] = "Passwords don't match";
  593. }
  594. } else {
  595. $errs['SysopPass'] = "Cannot be blank";
  596. }
  597. unset( $u );
  598. } else {
  599. $errs['SysopName'] = "Bad username";
  600. }
  601. }
  602. $conf->License = importRequest( "License", "none" );
  603. if( $conf->License == "gfdl1_2" ) {
  604. $conf->RightsUrl = "http://www.gnu.org/licenses/old-licenses/fdl-1.2.txt";
  605. $conf->RightsText = "GNU Free Documentation License 1.2";
  606. $conf->RightsCode = "gfdl1_2";
  607. $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png';
  608. } elseif( $conf->License == "gfdl1_3" ) {
  609. $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html";
  610. $conf->RightsText = "GNU Free Documentation License 1.3";
  611. $conf->RightsCode = "gfdl1_3";
  612. $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png';
  613. } elseif( $conf->License == "none" ) {
  614. $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = "";
  615. } elseif( $conf->License == "pd" ) {
  616. $conf->RightsUrl = "http://creativecommons.org/licenses/publicdomain/";
  617. $conf->RightsText = "Public Domain";
  618. $conf->RightsCode = "pd";
  619. $conf->RightsIcon = '${wgScriptPath}/skins/common/images/public-domain.png';
  620. } else {
  621. $conf->RightsUrl = importRequest( "RightsUrl", "" );
  622. $conf->RightsText = importRequest( "RightsText", "" );
  623. $conf->RightsCode = importRequest( "RightsCode", "" );
  624. $conf->RightsIcon = importRequest( "RightsIcon", "" );
  625. }
  626. $conf->Shm = importRequest( "Shm", "none" );
  627. $conf->MCServers = importRequest( "MCServers" );
  628. /* Test memcached servers */
  629. if ( $conf->Shm == 'memcached' && $conf->MCServers ) {
  630. $conf->MCServerArray = wfArrayMap( 'trim', explode( ',', $conf->MCServers ) );
  631. foreach ( $conf->MCServerArray as $server ) {
  632. $error = testMemcachedServer( $server );
  633. if ( $error ) {
  634. $errs["MCServers"] = $error;
  635. break;
  636. }
  637. }
  638. } else if ( $conf->Shm == 'memcached' ) {
  639. $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
  640. }
  641. /* default values for installation */
  642. $conf->Email = importRequest("Email", "email_enabled");
  643. $conf->Emailuser = importRequest("Emailuser", "emailuser_enabled");
  644. $conf->Enotif = importRequest("Enotif", "enotif_allpages");
  645. $conf->Eauthent = importRequest("Eauthent", "eauthent_enabled");
  646. if( $conf->posted && ( 0 == count( $errs ) ) ) {
  647. do { /* So we can 'continue' to end prematurely */
  648. $conf->Root = ($conf->RootPW != "");
  649. /* Load up the settings and get installin' */
  650. $local = writeLocalSettings( $conf );
  651. echo "<li style=\"list-style: none\">\n";
  652. echo "<p><b>Generating configuration file...</b></p>\n";
  653. echo "</li>\n";
  654. $wgCommandLineMode = false;
  655. chdir( ".." );
  656. $ok = eval( $local );
  657. if( $ok === false ) {
  658. dieout( "<p>Errors in generated configuration; " .
  659. "most likely due to a bug in the installer... " .
  660. "Config file was: </p>" .
  661. "<pre>" .
  662. htmlspecialchars( $local ) .
  663. "</pre>" );
  664. }
  665. $conf->DBtypename = '';
  666. foreach (array_keys($ourdb) as $db) {
  667. if ($conf->DBtype === $db)
  668. $conf->DBtypename = $ourdb[$db]['fullname'];
  669. }
  670. if ( ! strlen($conf->DBtype)) {
  671. $errs["DBpicktype"] = "Please choose a database type";
  672. continue;
  673. }
  674. if (! $conf->DBtypename) {
  675. $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
  676. continue;
  677. }
  678. print "<li>Database type: " . htmlspecialchars( $conf->DBtypename ) . "</li>\n";
  679. $dbclass = 'Database'.ucfirst($conf->DBtype);
  680. $wgDBtype = $conf->DBtype;
  681. $wgDBadminuser = "root";
  682. $wgDBadminpassword = $conf->RootPW;
  683. ## Mysql specific:
  684. $wgDBprefix = $conf->DBprefix;
  685. ## Postgres specific:
  686. $wgDBport = $conf->DBport;
  687. $wgDBmwschema = $conf->DBmwschema;
  688. $wgDBts2schema = $conf->DBts2schema;
  689. if( $conf->DBprefix2 != '' ) {
  690. // For MSSQL
  691. $wgDBprefix = $conf->DBprefix2;
  692. }
  693. ## DB2 specific:
  694. $wgDBcataloged = $conf->DBcataloged;
  695. $wgCommandLineMode = true;
  696. if (! defined ( 'STDERR' ) )
  697. define( 'STDERR', fopen("php://stderr", "wb"));
  698. $wgUseDatabaseMessages = false; /* FIXME: For database failure */
  699. require_once( "$IP/includes/Setup.php" );
  700. chdir( "config" );
  701. $wgTitle = Title::newFromText( "Installation script" );
  702. error_reporting( E_ALL );
  703. print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n";
  704. if ( $conf->DBtype != 'sqlite' ) {
  705. $dbc = new $dbclass;
  706. }
  707. if( $conf->DBtype == 'mysql' ) {
  708. $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
  709. if( $mysqlOldClient ) {
  710. print "<li><b>PHP is linked with old MySQL client libraries. If you are
  711. using a MySQL 4.1 server and have problems connecting to the database,
  712. see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
  713. >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
  714. }
  715. $ok = true; # Let's be optimistic
  716. # Decide if we're going to use the superuser or the regular database user
  717. $conf->Root = $useRoot;
  718. if( $conf->Root ) {
  719. $db_user = $conf->RootUser;
  720. $db_pass = $conf->RootPW;
  721. } else {
  722. $db_user = $wgDBuser;
  723. $db_pass = $wgDBpassword;
  724. }
  725. # Attempt to connect
  726. echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." );
  727. $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
  728. # Check the connection and respond to errors
  729. if( $wgDatabase->isOpen() ) {
  730. # Seems OK
  731. $ok = true;
  732. $wgDBadminuser = $db_user;
  733. $wgDBadminpassword = $db_pass;
  734. echo( "success.</li>\n" );
  735. $wgDatabase->ignoreErrors( true );
  736. $myver = $wgDatabase->getServerVersion();
  737. } else {
  738. # There were errors, report them and back out
  739. $ok = false;
  740. $errno = mysql_errno();
  741. $errtx = htmlspecialchars( mysql_error() );
  742. switch( $errno ) {
  743. case 1045:
  744. case 2000:
  745. echo( "failed due to authentication errors. Check passwords.</li>" );
  746. if( $conf->Root ) {
  747. # The superuser details are wrong
  748. $errs["RootUser"] = "Check username";
  749. $errs["RootPW"] = "and password";
  750. } else {
  751. # The regular user details are wrong
  752. $errs["DBuser"] = "Check username";
  753. $errs["DBpassword"] = "and password";
  754. }
  755. break;
  756. case 2002:
  757. case 2003:
  758. default:
  759. # General connection problem
  760. echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" );
  761. $errs["DBserver"] = "Connection failed";
  762. break;
  763. } # switch
  764. } #conn. att.
  765. if( !$ok ) { continue; }
  766. }
  767. else if( $conf->DBtype == 'ibm_db2' ) {
  768. if( $useRoot ) {
  769. $db_user = $conf->RootUser;
  770. $db_pass = $conf->RootPW;
  771. } else {
  772. $db_user = $wgDBuser;
  773. $db_pass = $wgDBpassword;
  774. }
  775. echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
  776. "\" as \"" . htmlspecialchars( $db_user ) . "\"..." );
  777. $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1);
  778. if (!$wgDatabase->isOpen()) {
  779. print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
  780. } else {
  781. $myver = $wgDatabase->getServerVersion();
  782. }
  783. if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
  784. } elseif ( $conf->DBtype == 'sqlite' ) {
  785. if ("$wgSQLiteDataDir" == '') {
  786. $wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']).'/data';
  787. }
  788. echo "<li>Attempting to connect to SQLite database at \"" .
  789. htmlspecialchars( $wgSQLiteDataDir ) . "\"";
  790. if ( !is_dir( $wgSQLiteDataDir ) ) {
  791. if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) {
  792. $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode );
  793. } else {
  794. $ok = false;
  795. }
  796. if ( !$ok ) {
  797. echo ": cannot create data directory</li>";
  798. $errs['SQLiteDataDir'] = 'Enter a valid data directory';
  799. continue;
  800. }
  801. }
  802. if ( !is_writable( $wgSQLiteDataDir ) ) {
  803. echo ": data directory not writable</li>";
  804. $errs['SQLiteDataDir'] = 'Enter a writable data directory';
  805. continue;
  806. }
  807. $dataFile = "$wgSQLiteDataDir/$wgDBname.sqlite";
  808. if ( file_exists( $dataFile ) && !is_writable( $dataFile ) ) {
  809. echo ": data file not writable</li>";
  810. $errs['SQLiteDataDir'] = "$wgDBname.sqlite is not writable";
  811. continue;
  812. }
  813. $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 );
  814. if (!$wgDatabase->isOpen()) {
  815. print ": error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
  816. $errs['SQLiteDataDir'] = 'Could not connect to database';
  817. continue;
  818. } else {
  819. $myver = $wgDatabase->getServerVersion();
  820. }
  821. if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
  822. echo "ok</li>\n";
  823. } else { # not mysql
  824. error_reporting( E_ALL );
  825. $wgSuperUser = '';
  826. ## Possible connect as a superuser
  827. // Changed !mysql to postgres check since it seems to only apply to postgres
  828. if( $useRoot && $conf->DBtype == 'postgres' ) {
  829. $wgDBsuperuser = $conf->RootUser;
  830. echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
  831. htmlspecialchars( $wgDBsuperuser ) . "\"..." );
  832. $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1);
  833. if (!$wgDatabase->isOpen()) {
  834. print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
  835. $errs["DBserver"] = "Could not connect to database as superuser";
  836. $errs["RootUser"] = "Check username";
  837. $errs["RootPW"] = "and password";
  838. continue;
  839. }
  840. $wgDatabase->initial_setup($conf->RootPW, 'postgres');
  841. }
  842. echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
  843. "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );
  844. $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
  845. if (!$wgDatabase->isOpen()) {
  846. print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
  847. } else {
  848. $myver = $wgDatabase->getServerVersion();
  849. }
  850. if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
  851. }
  852. if ( !$wgDatabase->isOpen() ) {
  853. $errs["DBserver"] = "Couldn't connect to database";
  854. continue;
  855. }
  856. print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" );
  857. if ($conf->DBtype == 'mysql') {
  858. if( version_compare( $myver, "4.0.14" ) < 0 ) {
  859. print "</li>\n";
  860. dieout( "-- mysql 4.0.14 or later required. Aborting." );
  861. }
  862. $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
  863. if( $mysqlNewAuth && $mysqlOldClient ) {
  864. print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
  865. to old client libraries; if you have trouble with authentication, see
  866. <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
  867. >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
  868. }
  869. if( $wgDBmysql5 ) {
  870. if( $mysqlNewAuth ) {
  871. print "; enabling MySQL 4.1/5.0 charset mode";
  872. } else {
  873. print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
  874. but older version detected; will likely fail.</b>";
  875. }
  876. }
  877. print "</li>\n";
  878. @$sel = $wgDatabase->selectDB( $wgDBname );
  879. if( $sel ) {
  880. print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
  881. } else {
  882. $err = mysql_errno();
  883. $databaseSafe = htmlspecialchars( $wgDBname );
  884. if( $err == 1102 /* Invalid database name */ ) {
  885. print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
  886. continue;
  887. } elseif( $err != 1049 /* Database doesn't exist */ ) {
  888. print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
  889. print htmlspecialchars( mysql_error() ) . "</li></ul>";
  890. continue;
  891. }
  892. print "<li>Attempting to create database...</li>";
  893. $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
  894. if( !$res ) {
  895. print "<li>Couldn't create database <tt>" .
  896. htmlspecialchars( $wgDBname ) .
  897. "</tt>; try with root access or check your username/pass.</li>\n";
  898. $errs["RootPW"] = "&lt;- Enter";
  899. continue;
  900. }
  901. print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
  902. }
  903. $wgDatabase->selectDB( $wgDBname );
  904. }
  905. else if ($conf->DBtype == 'postgres') {
  906. if( version_compare( $myver, "8.0" ) < 0 ) {
  907. dieout( "<b>Postgres 8.0 or later is required</b>. Aborting." );
  908. }
  909. }
  910. if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) {
  911. print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
  912. if ( $conf->DBtype == 'mysql') {
  913. # Determine existing default character set
  914. if ( $wgDatabase->tableExists( "revision" ) ) {
  915. $revision = $wgDatabase->escapeLike( $conf->DBprefix . 'revision' );
  916. $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
  917. $row = $wgDatabase->fetchObject( $res );
  918. if ( !$row ) {
  919. echo "<li>SHOW TABLE STATUS query failed!</li>\n";
  920. $existingSchema = false;
  921. $existingEngine = false;
  922. } else {
  923. if ( preg_match( '/^latin1/', $row->Collation ) ) {
  924. $existingSchema = 'mysql4';
  925. } elseif ( preg_match( '/^utf8/', $row->Collation ) ) {
  926. $existingSchema = 'mysql5';
  927. } elseif ( preg_match( '/^binary/', $row->Collation ) ) {
  928. $existingSchema = 'mysql5-binary';
  929. } else {
  930. $existingSchema = false;
  931. echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
  932. }
  933. if ( isset( $row->Engine ) ) {
  934. $existingEngine = $row->Engine;
  935. } else {
  936. $existingEngine = $row->Type;
  937. }
  938. }
  939. if ( $existingSchema && $existingSchema != $conf->DBschema ) {
  940. $encExisting = htmlspecialchars( $existingSchema );
  941. $encRequested = htmlspecialchars( $conf->DBschema );
  942. print "<li><strong>Warning:</strong> you requested the $encRequested schema, " .
  943. "but the existing database has the $encExisting schema. This upgrade script ".
  944. "can't convert it, so it will remain $encExisting.</li>\n";
  945. $conf->setSchema( $existingSchema, $conf->DBengine );
  946. }
  947. if ( $existingEngine && $existingEngine != $conf->DBengine ) {
  948. $encExisting = htmlspecialchars( $existingEngine );
  949. $encRequested = htmlspecialchars( $conf->DBengine );
  950. print "<li><strong>Warning:</strong> you requested the $encRequested storage " .
  951. "engine, but the existing database uses the $encExisting engine. This upgrade " .
  952. "script can't convert it, so it will remain $encExisting.</li>\n";
  953. $conf->setSchema( $conf->DBschema, $existingEngine );
  954. }
  955. }
  956. # Create user if required
  957. if ( $conf->Root ) {
  958. $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
  959. if ( $conn->isOpen() ) {
  960. print "<li>DB user account ok</li>\n";
  961. $conn->close();
  962. } else {
  963. print "<li>Granting user permissions...";
  964. if( $mysqlOldClient && $mysqlNewAuth ) {
  965. 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>";
  966. }
  967. print "</li>\n";
  968. dbsource( "../maintenance/users.sql", $wgDatabase );
  969. }
  970. }
  971. }
  972. print "</ul><pre>\n";
  973. chdir( ".." );
  974. flush();
  975. do_all_updates();
  976. chdir( "config" );
  977. print "</pre>\n";
  978. print "<ul><li>Finished update checks.</li>\n";
  979. } else {
  980. # Determine available storage engines if possible
  981. if ( $conf->DBtype == 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
  982. $res = $wgDatabase->query( 'SHOW ENGINES' );
  983. $found = false;
  984. while ( $row = $wgDatabase->fetchObject( $res ) ) {
  985. if ( $row->Engine == $conf->DBengine ) {
  986. $found = true;
  987. break;
  988. }
  989. }
  990. $wgDatabase->freeResult( $res );
  991. if ( !$found && $conf->DBengine != 'MyISAM' ) {
  992. echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine ) .
  993. " storage engine not available, " .
  994. "using MyISAM instead</li>\n";
  995. $conf->setSchema( $conf->DBschema, 'MyISAM' );
  996. }
  997. }
  998. # FIXME: Check for errors
  999. print "<li>Creating tables...";
  1000. if ($conf->DBtype == 'mysql') {
  1001. dbsource( "../maintenance/tables.sql", $wgDatabase );
  1002. dbsource( "../maintenance/interwiki.sql", $wgDatabase );
  1003. } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
  1004. $wgDatabase->setup_database();
  1005. }
  1006. else {
  1007. $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
  1008. continue;
  1009. }
  1010. print " done.</li>\n";
  1011. print "<li>Initializing statistics...</li>\n";
  1012. $wgDatabase->insert( 'site_stats',
  1013. array ( 'ss_row_id' => 1,
  1014. 'ss_total_views' => 0,
  1015. 'ss_total_edits' => 1, # Main page first edit
  1016. 'ss_good_articles' => 0, # Main page is not a good article - no internal link
  1017. 'ss_total_pages' => 1, # Main page
  1018. 'ss_users' => $conf->SysopName ? 1 : 0, # Sysop account, if created
  1019. 'ss_admins' => $conf->SysopName ? 1 : 0, # Sysop account, if created
  1020. 'ss_images' => 0 ) );
  1021. # Set up the "regular user" account *if we can, and if we need to*
  1022. if( $conf->Root and $conf->DBtype == 'mysql') {
  1023. # See if we need to
  1024. $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
  1025. if( $wgDatabase2->isOpen() ) {
  1026. # Nope, just close the test connection and continue
  1027. $wgDatabase2->close();
  1028. echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" );
  1029. } else {
  1030. # Yes, so run the grants
  1031. echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
  1032. dbsource( "../maintenance/users.sql", $wgDatabase );
  1033. echo( "success.</li>\n" );
  1034. }
  1035. }
  1036. if( $conf->SysopName ) {
  1037. $u = User::newFromName( $conf->getSysopName() );
  1038. if ( !$u ) {
  1039. print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
  1040. }
  1041. else if ( 0 == $u->idForName() ) {
  1042. $u->addToDatabase();
  1043. $u->setPassword( $conf->getSysopPass() );
  1044. $u->saveSettings();
  1045. $u->addGroup( "sysop" );
  1046. $u->addGroup( "bureaucrat" );
  1047. print "<li>Created sysop account <tt>" .
  1048. htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
  1049. } else {
  1050. print "<li>Could not create user - already exists!</li>\n";
  1051. }
  1052. } else {
  1053. print "<li>Skipped sysop account creation, no name given.</li>\n";
  1054. }
  1055. $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
  1056. $article = new Article( $titleobj );
  1057. $newid = $article->insertOn( $wgDatabase );
  1058. $revision = new Revision( array(
  1059. 'page' => $newid,
  1060. 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
  1061. 'comment' => '',
  1062. 'user' => 0,
  1063. 'user_text' => 'MediaWiki default',
  1064. ) );
  1065. $revid = $revision->insertOn( $wgDatabase );
  1066. $article->updateRevisionOn( $wgDatabase, $revision );
  1067. }
  1068. // Now that all database work is done, make sure everything is committed
  1069. $wgDatabase->commit();
  1070. /* Write out the config file now that all is well */
  1071. print "<li style=\"list-style: none\">\n";
  1072. print "<p>Creating LocalSettings.php...</p>\n\n";
  1073. $localSettings = "<" . "?php$endl$local";
  1074. // Fix up a common line-ending problem (due to CVS on Windows)
  1075. $localSettings = str_replace( "\r\n", "\n", $localSettings );
  1076. $f = fopen( "LocalSettings.php", 'xt' );
  1077. if( $f == false ) {
  1078. print( "</li>\n" );
  1079. 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" .
  1080. "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
  1081. "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
  1082. }
  1083. if(fwrite( $f, $localSettings ) ) {
  1084. fclose( $f );
  1085. print "<hr/>\n";
  1086. writeSuccessMessage();
  1087. print "</li>\n";
  1088. } else {
  1089. fclose( $f );
  1090. dieout( "<p class='error'>An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.</p></li>\n" );
  1091. }
  1092. } while( false );
  1093. }
  1094. print "</ul>\n";
  1095. $mainListOpened = false;
  1096. if( count( $errs ) ) {
  1097. /* Display options form */
  1098. if( $conf->posted ) {
  1099. echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
  1100. }
  1101. ?>
  1102. <form action="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name="config" method="post">
  1103. <h2>Site config</h2>
  1104. <div class="config-section">
  1105. <div class="config-input">
  1106. <?php aField( $conf, "Sitename", "Wiki name:" ); ?>
  1107. </div>
  1108. <p class="config-desc">
  1109. Preferably a short word without punctuation, i.e. "Wikipedia".<br />
  1110. Will appear as the namespace name for "meta" pages, and throughout the interface.
  1111. </p>
  1112. <div class="config-input"><?php aField( $conf, "EmergencyContact", "Contact e-mail:" ); ?></div>
  1113. <p class="config-desc">
  1114. 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.
  1115. </p>
  1116. <div class="config-input">
  1117. <label class='column' for="LanguageCode">Language:</label>
  1118. <select id="LanguageCode" name="LanguageCode"><?php
  1119. $list = getLanguageList();
  1120. foreach( $list as $code => $name ) {
  1121. $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : '';
  1122. $encCode = htmlspecialchars( $code );
  1123. $encName = htmlspecialchars( $name );
  1124. echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>";
  1125. }
  1126. echo "\n";
  1127. ?>
  1128. </select>
  1129. </div>
  1130. <p class="config-desc">
  1131. Select the language for your wiki's interface. Some localizations aren't fully complete. Unicode (UTF-8) is used for all localizations.
  1132. </p>
  1133. <div class="config-input">
  1134. <label class='column'>Copyright/license:</label>
  1135. <ul class="plain">
  1136. <li><?php aField( $conf, "License", "No license metadata", "radio", "none" ); ?></li>
  1137. <li><?php aField( $conf, "License", "Public Domain", "radio", "pd" ); ?></li>
  1138. <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl1_2" ); ?></li>
  1139. <li><?php aField( $conf, "License", "GNU Free Documentation License 1.3", "radio", "gfdl1_3" ); ?></li>
  1140. <li><?php
  1141. aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
  1142. $partner = "MediaWiki";
  1143. $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
  1144. $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
  1145. $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
  1146. $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
  1147. print "<a href=\"$ccApp\" target='_blank'>choose</a>";
  1148. if( $conf->License == "cc" ) { ?>
  1149. <ul>
  1150. <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?></li>
  1151. <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li>
  1152. <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li>
  1153. <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li>
  1154. </ul>
  1155. <?php } ?>
  1156. </li>
  1157. </ul>
  1158. </div>
  1159. <p class="config-desc">
  1160. A notice, icon, and machine-readable copyright metadata will be displayed for the license you pick.
  1161. </p>
  1162. <div class="config-input">
  1163. <?php aField( $conf, "SysopName", "Admin username:" ) ?>
  1164. </div>
  1165. <div class="config-input">
  1166. <?php aField( $conf, "SysopPass", "Password:", "password" ) ?>
  1167. </div>
  1168. <div class="config-input">
  1169. <?php aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?>
  1170. </div>
  1171. <p class="config-desc">
  1172. An admin can lock/delete pages, block users from editing, and do other maintenance tasks.<br />
  1173. A new account will be added only when creating a new wiki database.
  1174. <br /><br />
  1175. The password cannot be the same as the username.
  1176. </p>
  1177. <div class="config-input">
  1178. <label class='column'>Object caching:</label>
  1179. <ul class="plain">
  1180. <li><?php aField( $conf, "Shm", "No caching", "radio", "none" ); ?></li>
  1181. <?php
  1182. if ( $conf->turck ) {
  1183. echo "<li>";
  1184. aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
  1185. echo "</li>\n";
  1186. }
  1187. if( $conf->xcache ) {
  1188. echo "<li>";
  1189. aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
  1190. echo "</li>\n";
  1191. }
  1192. if ( $conf->apc ) {
  1193. echo "<li>";
  1194. aField( $conf, "Shm", "APC", "radio", "apc" );
  1195. echo "</li>\n";
  1196. }
  1197. if ( $conf->eaccel ) {
  1198. echo "<li>";
  1199. aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
  1200. echo "</li>\n";
  1201. }
  1202. if ( $conf->dba ) {
  1203. echo "<li>";
  1204. aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" );
  1205. echo "</li>";
  1206. }
  1207. ?>
  1208. <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li>
  1209. </ul>
  1210. <div style="clear:left"><?php aField( $conf, "MCServers", "Memcached servers:", "text" ) ?></div>
  1211. </div>
  1212. <p class="config-desc">
  1213. An object caching system such as memcached will provide a significant performance boost,
  1214. but needs to be installed. Provide the server addresses and ports in a comma-separated list.
  1215. <br /><br />
  1216. MediaWiki can also detect and support eAccelerator, Turck MMCache, APC, and XCache, but
  1217. these should not be used if the wiki will be running on multiple application servers.
  1218. <br/><br/>
  1219. DBA (Berkeley-style DB) is generally slower than using no cache at all, and is only
  1220. recommended for testing.
  1221. </p>
  1222. </div>
  1223. <h2>E-mail, e-mail notification and authentication setup</h2>
  1224. <div class="config-section">
  1225. <div class="config-input">
  1226. <label class='column'>E-mail features (global):</label>
  1227. <ul class="plain">
  1228. <li><?php aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?></li>
  1229. <li><?php aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?></li>
  1230. </ul>
  1231. </div>
  1232. <p class="config-desc">
  1233. Use this to disable all e-mail functions (password reminders, user-to-user e-mail, and e-mail notifications)
  1234. if sending mail doesn't work on your server.
  1235. </p>
  1236. <div class="config-input">
  1237. <label class='column'>User-to-user e-mail:</label>
  1238. <ul class="plain">
  1239. <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
  1240. <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
  1241. </ul>
  1242. </div>
  1243. <p class="config-desc">
  1244. The user-to-user e-mail feature (Special:Emailuser) lets the wiki act as a relay to allow users to exchange e-mail without publicly advertising their e-mail address.
  1245. </p>
  1246. <div class="config-input">
  1247. <label class='column'>E-mail notification about changes:</label>
  1248. <ul class="plain">
  1249. <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
  1250. <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
  1251. <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages, and to pages on watchlists (not recommended for large wikis)", "radio", "enotif_allpages" ); ?></li>
  1252. </ul>
  1253. </div>
  1254. <div class="config-desc">
  1255. <p>
  1256. For this feature to work, an e-mail address must be present for the user account, and the notification
  1257. options in the user's preferences must be enabled. Also note the
  1258. authentication option below. When testing the feature, keep in mind that your own changes will never trigger notifications to be sent to yourself.</p>
  1259. <p>There are additional options for fine tuning in /includes/DefaultSettings.php; copy these to your LocalSettings.php and edit them there to change them.</p>
  1260. </div>
  1261. <div class="config-input">
  1262. <label class='column'>E-mail address authentication:</label>
  1263. <ul class="plain">
  1264. <li><?php aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?></li>
  1265. <li><?php aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?></li>
  1266. </ul>
  1267. </div>
  1268. <div class="config-desc">
  1269. <p>If this option is enabled, users have to confirm their e-mail address using a magic link sent to them whenever they set or change it, and only authenticated e-mail addresses can receive mails from other users and/or
  1270. change notification mails. Setting this option is <b>recommended</b> for public wikis because of potential abuse of the e-mail features above.</p>
  1271. </div>
  1272. </div>
  1273. <h2>Database config</h2>
  1274. <div class="config-section">
  1275. <div class="config-input">
  1276. <label class='column'>Database type:</label>
  1277. <?php
  1278. if (isset($errs['DBpicktype'])) {
  1279. print "\t<span class='error'>" . htmlspecialchars( $errs['DBpicktype'] ) . "</span>\n";
  1280. }
  1281. ?>
  1282. <ul class='plain'><?php
  1283. database_picker($conf);
  1284. ?></ul>
  1285. </div>
  1286. <div class="config-input" style="clear:left">
  1287. <?php aField( $conf, "DBserver", "Database host:" ); ?>
  1288. </div>
  1289. <p class="config-desc">
  1290. If your database server isn't on your web server, enter the name or IP address here.
  1291. </p>
  1292. <div class="config-input"><?php aField( $conf, "DBname", "Database name:" ); ?></div>
  1293. <div class="config-input"><?php aField( $conf, "DBuser", "DB username:" ); ?></div>
  1294. <div class="config-input"><?php aField( $conf, "DBpassword", "DB password:", "password" ); ?></div>
  1295. <div class="config-input"><?php aField( $conf, "DBpassword2", "DB password confirm:", "password" ); ?></div>
  1296. <p class="config-desc">
  1297. If you only have a single user account and database available,
  1298. enter those here. If you have database root access (see below)
  1299. you can specify new accounts/databases to be created. This account
  1300. will not be created if it pre-exists. If this is the case, ensure that it
  1301. has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
  1302. </p>
  1303. <div class="config-input">
  1304. <label class="column">Superuser account:</label>
  1305. <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?> />
  1306. &nbsp;<label for="useroot">Use superuser account</label>
  1307. </div>
  1308. <div class="config-input"><?php aField( $conf, "RootUser", "Superuser name:", "text" ); ?></div>
  1309. <div class="config-input"><?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?></div>
  1310. <p class="config-desc">
  1311. If the database user specified above does not exist, or does not have access to create
  1312. the database (if needed) or tables within it, please check the box and provide details
  1313. of a superuser account, such as <strong>root</strong>, which does.
  1314. </p>
  1315. <?php database_switcher('mysql'); ?>
  1316. <div class="config-input"><?php aField( $conf, "DBprefix", "Database table prefix:" ); ?></div>
  1317. <div class="config-desc">
  1318. <p>If you need to share one database between multiple wikis, or
  1319. between MediaWiki and another web application, you may choose to
  1320. add a prefix to all the table names to avoid conflicts.</p>
  1321. <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
  1322. </div>
  1323. <div class="config-input"><label class="column">Storage Engine</label>
  1324. <div>Select one:</div>
  1325. <ul class="plain">
  1326. <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
  1327. <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
  1328. </ul>
  1329. </div>
  1330. <p class="config-desc">
  1331. InnoDB is best for public web installations, since it has good concurrency
  1332. support. MyISAM may be faster in single-user installations. MyISAM databases
  1333. tend to get corrupted more often than InnoDB databases.
  1334. </p>
  1335. <div class="config-input"><label class="column">Database character set</label>
  1336. <div>Select one:</div>
  1337. <ul class="plain">
  1338. <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
  1339. <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
  1340. <li><?php aField( $conf, "DBschema", "MySQL 4.0 backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
  1341. </ul>
  1342. </div>
  1343. <p class="config-desc">
  1344. This option is ignored on upgrade, the same character set will be kept.
  1345. <br/><br/>
  1346. <b>WARNING:</b> If you use <b>backwards-compatible UTF-8</b> on MySQL 4.1+, and subsequently back up the database with <tt>mysqldump</tt>, it may destroy all non-ASCII characters, irreversibly corrupting your backups!.
  1347. <br/><br/>
  1348. In <b>binary mode</b>, MediaWiki stores UTF-8 text to the database in binary fields. This is more efficient than MySQL's UTF-8 mode, and allows you to use the full range of Unicode characters. In <b>UTF-8 mode</b>, MySQL will know what character set your data is in, and can present and convert it appropriately, but it won't let you store characters above the <a target="_blank" href="http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes">Basic Multilingual Plane</a>.
  1349. </p>
  1350. </fieldset>
  1351. <?php database_switcher('postgres'); ?>
  1352. <div class="config-input"><?php aField( $conf, "DBport", "Database port:" ); ?></div>
  1353. <div class="config-input"><?php aField( $conf, "DBmwschema", "Schema for mediawiki:" ); ?></div>
  1354. <div class="config-input"><?php aField( $conf, "DBts2schema", "Schema for tsearch2:" ); ?></div>
  1355. <div class="config-desc">
  1356. <p>The username specified above (at "DB username") will have its search path set to the above schemas,
  1357. so it is recommended that you create a new user. The above schemas are generally correct:
  1358. only change them if you are sure you need to.</p>
  1359. </div>
  1360. </fieldset>
  1361. <?php database_switcher('sqlite'); ?>
  1362. <div class="config-desc">
  1363. <b>NOTE:</b> SQLite only uses the <i>Database name</i> setting above, the user, password and root settings are ignored.
  1364. </div>
  1365. <div class="config-input"><?php
  1366. aField( $conf, "SQLiteDataDir", "SQLite data directory:" );
  1367. ?></div>
  1368. <div class="config-desc">
  1369. <p>SQLite stores table data into files in the filesystem.
  1370. If you do not provide an explicit path, a "data" directory in
  1371. the parent of your document root will be used.</p>
  1372. <p>This directory must exist and be writable by the web server.</p>
  1373. </div>
  1374. </fieldset>
  1375. <?php database_switcher('mssql'); ?>
  1376. <div class="config-input"><?php
  1377. aField( $conf, "DBprefix2", "Database table prefix:" );
  1378. ?></div>
  1379. <div class="config-desc">
  1380. <p>If you need to share one database between multiple wikis, or
  1381. between MediaWiki and another web application, you may choose to
  1382. add a prefix to all the table names to avoid conflicts.</p>
  1383. <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
  1384. </div>
  1385. </fieldset>
  1386. <?php database_switcher('ibm_db2'); ?>
  1387. <div class="config-input"><?php
  1388. aField( $conf, "DBport_db2", "Database port:" );
  1389. ?></div>
  1390. <div class="config-input"><?php
  1391. aField( $conf, "DBmwschema", "Schema for mediawiki:" );
  1392. ?></div>
  1393. <div>Select one:</div>
  1394. <ul class="plain">
  1395. <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 installed locally)", "radio", "cataloged" ); ?></li>
  1396. <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote DB2 through ODBC)", "radio", "uncataloged" ); ?></li>
  1397. </ul>
  1398. <div class="config-desc">
  1399. <p>If you need to share one database between multiple wikis, or
  1400. between MediaWiki and another web application, you may specify
  1401. a different schema to avoid conflicts.</p>
  1402. </div>
  1403. </fieldset>
  1404. <div class="config-input" style="padding:2em 0 3em">
  1405. <label class='column'>&nbsp;</label>
  1406. <input type="submit" value="Install MediaWiki!" class="btn-install" />
  1407. </div>
  1408. </div>
  1409. </form>
  1410. <script type="text/javascript">
  1411. window.onload = toggleDBarea( <?php echo Xml::encodeJsVar( $conf->DBtype ); ?>,
  1412. <?php
  1413. ## If they passed in a root user name, don't populate it on page load
  1414. echo strlen(importPost('RootUser', '')) ? 0 : 1;
  1415. ?>);
  1416. </script>
  1417. <?php
  1418. }
  1419. /* -------------------------------------------------------------------------------------- */
  1420. function writeSuccessMessage() {
  1421. $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
  1422. if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
  1423. echo <<<EOT
  1424. <div class="success-box">
  1425. <p>Installation successful!</p>
  1426. <p>To complete the installation, please do the following:
  1427. <ol>
  1428. <li>Download config/LocalSettings.php with your FTP client or file manager</li>
  1429. <li>Upload it to the parent directory</li>
  1430. <li>Delete config/LocalSettings.php</li>
  1431. <li>Start using <a href='../$script'>your wiki</a>!
  1432. </ol>
  1433. <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
  1434. remotely. LocalSettings.php is currently owned by the user your webserver is running under,
  1435. which means that anyone on the same server can read your database password! Downloading
  1436. it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
  1437. </div>
  1438. EOT;
  1439. } else {
  1440. echo <<<EOT
  1441. <div class="success-box">
  1442. <p>
  1443. <span class="success-message">Installation successful!</span>
  1444. Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
  1445. <a href="../$script"> this link</a> to your wiki.</p>
  1446. <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
  1447. prevent other users on the server reading passwords and altering configuration data.</p>
  1448. </div>
  1449. EOT;
  1450. }
  1451. }
  1452. function escapePhpString( $string ) {
  1453. if ( is_array( $string ) || is_object( $string ) ) {
  1454. return false;
  1455. }
  1456. return strtr( $string,
  1457. array(
  1458. "\n" => "\\n",
  1459. "\r" => "\\r",
  1460. "\t" => "\\t",
  1461. "\\" => "\\\\",
  1462. "\$" => "\\\$",
  1463. "\"" => "\\\""
  1464. ));
  1465. }
  1466. function writeLocalSettings( $conf ) {
  1467. $conf->PasswordSender = $conf->EmergencyContact;
  1468. $magic = ($conf->ImageMagick ? "" : "# ");
  1469. $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
  1470. $rights = ($conf->RightsUrl) ? "" : "# ";
  1471. $hashedUploads = $conf->safeMode ? '' : '# ';
  1472. if ( $conf->ShellLocale ) {
  1473. $locale = '';
  1474. } else {
  1475. $locale = '# ';
  1476. $conf->ShellLocale = 'en_US.UTF-8';
  1477. }
  1478. switch ( $conf->Shm ) {
  1479. case 'memcached':
  1480. $cacheType = 'CACHE_MEMCACHED';
  1481. $mcservers = var_export( $conf->MCServerArray, true );
  1482. break;
  1483. case 'turck':
  1484. case 'xcache':
  1485. case 'apc':
  1486. case 'eaccel':
  1487. $cacheType = 'CACHE_ACCEL';
  1488. $mcservers = 'array()';
  1489. break;
  1490. case 'dba':
  1491. $cacheType = 'CACHE_DBA';
  1492. $mcservers = 'array()';
  1493. break;
  1494. default:
  1495. $cacheType = 'CACHE_NONE';
  1496. $mcservers = 'array()';
  1497. }
  1498. if ( $conf->Email == 'email_enabled' ) {
  1499. $enableemail = 'true';
  1500. $enableuseremail = ( $conf->Emailuser == 'emailuser_enabled' ) ? 'true' : 'false' ;
  1501. $eauthent = ( $conf->Eauthent == 'eauthent_enabled' ) ? 'true' : 'false' ;
  1502. switch ( $conf->Enotif ) {
  1503. case 'enotif_usertalk':
  1504. $enotifusertalk = 'true';
  1505. $enotifwatchlist = 'false';
  1506. break;
  1507. case 'enotif_allpages':
  1508. $enotifusertalk = 'true';
  1509. $enotifwatchlist = 'true';
  1510. break;
  1511. default:
  1512. $enotifusertalk = 'false';
  1513. $enotifwatchlist = 'false';
  1514. }
  1515. } else {
  1516. $enableuseremail = 'false';
  1517. $enableemail = 'false';
  1518. $eauthent = 'false';
  1519. $enotifusertalk = 'false';
  1520. $enotifwatchlist = 'false';
  1521. }
  1522. $file = @fopen( "/dev/urandom", "r" );
  1523. if ( $file ) {
  1524. $secretKey = bin2hex( fread( $file, 32 ) );
  1525. fclose( $file );
  1526. } else {
  1527. $secretKey = "";
  1528. for ( $i=0; $i<8; $i++ ) {
  1529. $secretKey .= dechex(mt_rand(0, 0x7fffffff));
  1530. }
  1531. print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
  1532. }
  1533. # Add slashes to strings for double quoting
  1534. $slconf = wfArrayMap( "escapePhpString", get_object_vars( $conf ) );
  1535. if( $conf->License == 'gfdl1_2' || $conf->License == 'pd' || $conf->License == 'gfdl1_3' ) {
  1536. # Needs literal string interpolation for the current style path
  1537. $slconf['RightsIcon'] = $conf->RightsIcon;
  1538. }
  1539. if( $conf->DBtype == 'mysql' ) {
  1540. $dbsettings =
  1541. "# MySQL specific settings
  1542. \$wgDBprefix = \"{$slconf['DBprefix']}\";
  1543. # MySQL table options to use during installation or update
  1544. \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
  1545. # Experimental charset support for MySQL 4.1/5.0.
  1546. \$wgDBmysql5 = {$conf->DBmysql5};";
  1547. } elseif( $conf->DBtype == 'postgres' ) {
  1548. $dbsettings =
  1549. "# Postgres specific settings
  1550. \$wgDBport = \"{$slconf['DBport']}\";
  1551. \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
  1552. \$wgDBts2schema = \"{$slconf['DBts2schema']}\";";
  1553. } elseif( $conf->DBtype == 'sqlite' ) {
  1554. $dbsettings =
  1555. "# SQLite-specific settings
  1556. \$wgSQLiteDataDir = \"{$slconf['SQLiteDataDir']}\";";
  1557. } elseif( $conf->DBtype == 'mssql' ) {
  1558. $dbsettings =
  1559. "# MSSQL specific settings
  1560. \$wgDBprefix = \"{$slconf['DBprefix2']}\";";
  1561. } elseif( $conf->DBtype == 'ibm_db2' ) {
  1562. $dbsettings =
  1563. "# DB2 specific settings
  1564. \$wgDBport_db2 = \"{$slconf['DBport_db2']}\";
  1565. \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
  1566. \$wgDBcataloged = \"{$slconf['DBcataloged']}\";";
  1567. } else {
  1568. // ummm... :D
  1569. $dbsettings = '';
  1570. }
  1571. $localsettings = "
  1572. # This file was automatically generated by the MediaWiki installer.
  1573. # If you make manual changes, please keep track in case you need to
  1574. # recreate them later.
  1575. #
  1576. # See includes/DefaultSettings.php for all configurable settings
  1577. # and their default values, but don't forget to make changes in _this_
  1578. # file, not there.
  1579. #
  1580. # Further documentation for configuration settings may be found at:
  1581. # http://www.mediawiki.org/wiki/Manual:Configuration_settings
  1582. # If you customize your file layout, set \$IP to the directory that contains
  1583. # the other MediaWiki files. It will be used as a base to locate files.
  1584. if( defined( 'MW_INSTALL_PATH' ) ) {
  1585. \$IP = MW_INSTALL_PATH;
  1586. } else {
  1587. \$IP = dirname( __FILE__ );
  1588. }
  1589. \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
  1590. set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
  1591. require_once( \"\$IP/includes/DefaultSettings.php\" );
  1592. # If PHP's memory limit is very low, some operations may fail.
  1593. " . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
  1594. if ( \$wgCommandLineMode ) {
  1595. if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
  1596. die( \"This script must be run from the command line\\n\" );
  1597. }
  1598. }
  1599. ## Uncomment this to disable output compression
  1600. # \$wgDisableOutputCompression = true;
  1601. \$wgSitename = \"{$slconf['Sitename']}\";
  1602. ## The URL base path to the directory containing the wiki;
  1603. ## defaults for all runtime URL paths are based off of this.
  1604. ## For more information on customizing the URLs please see:
  1605. ## http://www.mediawiki.org/wiki/Manual:Short_URL
  1606. \$wgScriptPath = \"{$slconf['ScriptPath']}\";
  1607. \$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
  1608. ## UPO means: this is also a user preference option
  1609. \$wgEnableEmail = $enableemail;
  1610. \$wgEnableUserEmail = $enableuseremail; # UPO
  1611. \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
  1612. \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
  1613. \$wgEnotifUserTalk = $enotifusertalk; # UPO
  1614. \$wgEnotifWatchlist = $enotifwatchlist; # UPO
  1615. \$wgEmailAuthentication = $eauthent;
  1616. ## Database settings
  1617. \$wgDBtype = \"{$slconf['DBtype']}\";
  1618. \$wgDBserver = \"{$slconf['DBserver']}\";
  1619. \$wgDBname = \"{$slconf['DBname']}\";
  1620. \$wgDBuser = \"{$slconf['DBuser']}\";
  1621. \$wgDBpassword = \"{$slconf['DBpassword']}\";
  1622. {$dbsettings}
  1623. ## Shared memory settings
  1624. \$wgMainCacheType = $cacheType;
  1625. \$wgMemCachedServers = $mcservers;
  1626. ## To enable image uploads, make sure the 'images' directory
  1627. ## is writable, then set this to true:
  1628. \$wgEnableUploads = false;
  1629. {$magic}\$wgUseImageMagick = true;
  1630. {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
  1631. ## If you use ImageMagick (or any other shell command) on a
  1632. ## Linux server, this will need to be set to the name of an
  1633. ## available UTF-8 locale
  1634. {$locale}\$wgShellLocale = \"{$slconf['ShellLocale']}\";
  1635. ## If you want to use image uploads under safe mode,
  1636. ## create the directories images/archive, images/thumb and
  1637. ## images/temp, and make them all writable. Then uncomment
  1638. ## this, if it's not already uncommented:
  1639. {$hashedUploads}\$wgHashedUploadDirectory = false;
  1640. ## If you have the appropriate support software installed
  1641. ## you can enable inline LaTeX equations:
  1642. \$wgUseTeX = false;
  1643. \$wgLocalInterwiki = strtolower( \$wgSitename );
  1644. \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
  1645. \$wgSecretKey = \"$secretKey\";
  1646. ## Default skin: you can change the default skin. Use the internal symbolic
  1647. ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
  1648. \$wgDefaultSkin = 'monobook';
  1649. ## For attaching licensing metadata to pages, and displaying an
  1650. ## appropriate copyright notice / icon. GNU Free Documentation
  1651. ## License and Creative Commons licenses are supported so far.
  1652. {$rights}\$wgEnableCreativeCommonsRdf = true;
  1653. \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
  1654. \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
  1655. \$wgRightsText = \"{$slconf['RightsText']}\";
  1656. \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
  1657. # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
  1658. \$wgDiff3 = \"{$slconf['diff3']}\";
  1659. # When you make changes to this configuration file, this will make
  1660. # sure that cached pages are cleared.
  1661. \$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
  1662. "; ## End of setting the $localsettings string
  1663. // Keep things in Unix line endings internally;
  1664. // the system will write out as local text type.
  1665. return str_replace( "\r\n", "\n", $localsettings );
  1666. }
  1667. function dieout( $text ) {
  1668. global $mainListOpened;
  1669. if( $mainListOpened ) echo( "</ul>" );
  1670. if( $text != '' && substr( $text, 0, 2 ) != '<p' && substr( $text, 0, 2 ) != '<h' ){
  1671. echo "<p>$text</p>\n";
  1672. } else {
  1673. echo $text;
  1674. }
  1675. die( "\n\n</div>\n</div>\n</div>\n</div>\n</body>\n</html>" );
  1676. }
  1677. function importVar( &$var, $name, $default = "" ) {
  1678. if( isset( $var[$name] ) ) {
  1679. $retval = $var[$name];
  1680. if ( get_magic_quotes_gpc() ) {
  1681. $retval = stripslashes( $retval );
  1682. }
  1683. } else {
  1684. $retval = $default;
  1685. }
  1686. taint( $retval );
  1687. return $retval;
  1688. }
  1689. function importPost( $name, $default = "" ) {
  1690. return importVar( $_POST, $name, $default );
  1691. }
  1692. function importCheck( $name ) {
  1693. return isset( $_POST[$name] );
  1694. }
  1695. function importRequest( $name, $default = "" ) {
  1696. return importVar( $_REQUEST, $name, $default );
  1697. }
  1698. function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
  1699. static $radioCount = 0;
  1700. if( $type != "" ) {
  1701. $xtype = "type=\"$type\"";
  1702. } else {
  1703. $xtype = "";
  1704. }
  1705. $id = $field;
  1706. $nolabel = ($type == "radio") || ($type == "hidden");
  1707. if ($type == 'radio')
  1708. $id .= $radioCount++;
  1709. if( !$nolabel ) {
  1710. echo "<label class='column' for=\"$id\">$text</label>";
  1711. }
  1712. if( $type == "radio" && $value == $conf->$field ) {
  1713. $checked = "checked='checked'";
  1714. } else {
  1715. $checked = "";
  1716. }
  1717. echo "<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
  1718. if ($onclick) {
  1719. echo " onclick='toggleDBarea(\"$value\",1)' " ;
  1720. }
  1721. echo "value=\"";
  1722. if( $type == "radio" ) {
  1723. echo htmlspecialchars( $value );
  1724. } else {
  1725. echo htmlspecialchars( $conf->$field );
  1726. }
  1727. echo "\" />";
  1728. if( $nolabel ) {
  1729. echo "<label for=\"$id\">$text</label>";
  1730. }
  1731. global $errs;
  1732. if(isset($errs[$field])) {
  1733. echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n";
  1734. }
  1735. }
  1736. function getLanguageList() {
  1737. global $wgLanguageNames, $IP;
  1738. if( !isset( $wgLanguageNames ) ) {
  1739. require_once( "$IP/languages/Names.php" );
  1740. }
  1741. $codes = array();
  1742. $d = opendir( "../languages/messages" );
  1743. /* In case we are called from the root directory */
  1744. if (!$d)
  1745. $d = opendir( "languages/messages");
  1746. while( false !== ($f = readdir( $d ) ) ) {
  1747. $m = array();
  1748. if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
  1749. $code = str_replace( '_', '-', strtolower( $m[1] ) );
  1750. if( isset( $wgLanguageNames[$code] ) ) {
  1751. $name = $code . ' - ' . $wgLanguageNames[$code];
  1752. } else {
  1753. $name = $code;
  1754. }
  1755. $codes[$code] = $name;
  1756. }
  1757. }
  1758. closedir( $d );
  1759. ksort( $codes );
  1760. return $codes;
  1761. }
  1762. #Check for location of an executable
  1763. # @param string $loc single location to check
  1764. # @param array $names filenames to check for.
  1765. # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
  1766. function locate_executable($loc, $names, $versioninfo = false) {
  1767. if (!is_array($names))
  1768. $names = array($names);
  1769. foreach ($names as $name) {
  1770. $command = "$loc".DIRECTORY_SEPARATOR."$name";
  1771. if (@file_exists($command)) {
  1772. if (!$versioninfo)
  1773. return $command;
  1774. $file = str_replace('$1', $command, $versioninfo[0]);
  1775. if (strstr(`$file`, $versioninfo[1]) !== false)
  1776. return $command;
  1777. }
  1778. }
  1779. return false;
  1780. }
  1781. # Test a memcached server
  1782. function testMemcachedServer( $server ) {
  1783. $hostport = explode(":", $server);
  1784. $errstr = false;
  1785. $fp = false;
  1786. if ( !function_exists( 'fsockopen' ) ) {
  1787. $errstr = "Can't connect to memcached, fsockopen() not present";
  1788. }
  1789. if ( !$errstr && count( $hostport ) != 2 ) {
  1790. $errstr = 'Please specify host and port';
  1791. }
  1792. if ( !$errstr ) {
  1793. list( $host, $port ) = $hostport;
  1794. $errno = 0;
  1795. $fsockerr = '';
  1796. $fp = @fsockopen( $host, $port, $errno, $fsockerr, 1.0 );
  1797. if ( $fp === false ) {
  1798. $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
  1799. }
  1800. }
  1801. if ( !$errstr ) {
  1802. $command = "version\r\n";
  1803. $bytes = fwrite( $fp, $command );
  1804. if ( $bytes != strlen( $command ) ) {
  1805. $errstr = "Cannot write to memcached socket on $host:$port";
  1806. }
  1807. }
  1808. if ( !$errstr ) {
  1809. $expected = "VERSION ";
  1810. $response = fread( $fp, strlen( $expected ) );
  1811. if ( $response != $expected ) {
  1812. $errstr = "Didn't get correct memcached response from $host:$port";
  1813. }
  1814. }
  1815. if ( $fp ) {
  1816. fclose( $fp );
  1817. }
  1818. if ( !$errstr ) {
  1819. echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>";
  1820. }
  1821. return $errstr;
  1822. }
  1823. function database_picker($conf) {
  1824. global $ourdb;
  1825. print "\n";
  1826. foreach(array_keys($ourdb) as $db) {
  1827. if ($ourdb[$db]['havedriver']) {
  1828. print "\t<li>";
  1829. aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
  1830. print "</li>\n";
  1831. }
  1832. }
  1833. print "\n\t";
  1834. }
  1835. function database_switcher($db) {
  1836. global $ourdb;
  1837. $color = $ourdb[$db]['bgcolor'];
  1838. $full = $ourdb[$db]['fullname'];
  1839. print "<fieldset id='$db'><legend>$full specific options</legend>\n";
  1840. }
  1841. function printListItem( $item ) {
  1842. print "<li>$item</li>";
  1843. }
  1844. # Determine a suitable value for $wgShellLocale
  1845. function getShellLocale( $wikiLang ) {
  1846. # Give up now if we're in safe mode or open_basedir
  1847. # It's theoretically possible but tricky to work with
  1848. if ( wfIniGetBool( "safe_mode" ) || ini_get( 'open_basedir' ) ) {
  1849. return false;
  1850. }
  1851. $os = php_uname( 's' );
  1852. $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these
  1853. if ( !in_array( $os, $supported ) ) {
  1854. return false;
  1855. }
  1856. # Get a list of available locales
  1857. $lines = $ret = false;
  1858. exec( '/usr/bin/locale -a', $lines, $ret );
  1859. if ( $ret ) {
  1860. return false;
  1861. }
  1862. $lines = wfArrayMap( 'trim', $lines );
  1863. $candidatesByLocale = array();
  1864. $candidatesByLang = array();
  1865. foreach ( $lines as $line ) {
  1866. if ( $line === '' ) {
  1867. continue;
  1868. }
  1869. if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
  1870. continue;
  1871. }
  1872. list( $all, $lang, $territory, $charset, $modifier ) = $m;
  1873. $candidatesByLocale[$m[0]] = $m;
  1874. $candidatesByLang[$lang][] = $m;
  1875. }
  1876. # Try the current value of LANG
  1877. if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
  1878. return getenv( 'LANG' );
  1879. }
  1880. # Try the most common ones
  1881. $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
  1882. foreach ( $commonLocales as $commonLocale ) {
  1883. if ( isset( $candidatesByLocale[$commonLocale] ) ) {
  1884. return $commonLocale;
  1885. }
  1886. }
  1887. # Is there an available locale in the Wiki's language?
  1888. if ( isset( $candidatesByLang[$wikiLang] ) ) {
  1889. $m = reset( $candidatesByLang[$wikiLang] );
  1890. return $m[0];
  1891. }
  1892. # Are there any at all?
  1893. if ( count( $candidatesByLocale ) ) {
  1894. $m = reset( $candidatesByLocale );
  1895. return $m[0];
  1896. }
  1897. # Give up
  1898. return false;
  1899. }
  1900. function wfArrayMap( $function, $input ) {
  1901. $ret = array_map( $function, $input );
  1902. foreach ( $ret as $key => $value ) {
  1903. $taint = istainted( $input[$key] );
  1904. if ( $taint ) {
  1905. taint( $ret[$key], $taint );
  1906. }
  1907. }
  1908. return $ret;
  1909. }
  1910. ?>
  1911. <div class="license">
  1912. <hr/>
  1913. <p>This program is free software; you can redistribute it and/or modify
  1914. it under the terms of the GNU General Public License as published by
  1915. the Free Software Foundation; either version 2 of the License, or
  1916. (at your option) any later version.</p>
  1917. <p>This program is distributed in the hope that it will be useful,
  1918. but WITHOUT ANY WARRANTY; without even the implied warranty of
  1919. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1920. GNU General Public License for more details.</p>
  1921. <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
  1922. along with this program; if not, write to the Free Software
  1923. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  1924. or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
  1925. </div>
  1926. </div></div></div>
  1927. <div id="column-one">
  1928. <div class="portlet" id="p-logo">
  1929. <a style="background-image: url(../skins/common/images/mediawiki.png);"
  1930. href="../"
  1931. title="Main Page"></a>
  1932. </div>
  1933. <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
  1934. <div class='portlet'><div class='pBody'>
  1935. <ul>
  1936. <li><a href="../README">Readme</a></li>
  1937. <li><a href="../RELEASE-NOTES">Release notes</a></li>
  1938. <li><a href="../docs/">Documentation</a></li>
  1939. <li><a href="http://www.mediawiki.org/wiki/Help:Contents">User's Guide</a></li>
  1940. <li><a href="http://www.mediawiki.org/wiki/Manual:Contents">Administrator's Guide</a></li>
  1941. <li><a href="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ</a></li>
  1942. </ul>
  1943. <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2009 by Magnus Manske, Brion Vibber,
  1944. Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke, Ævar Arnfjörð Bjarmason, Niklas Laxström,
  1945. Domas Mituzas, Rob Church, Yuri Astrakhan, Aryeh Gregor, Aaron Schulz and others.</p>
  1946. </div></div>
  1947. </div>
  1948. </div>
  1949. </body>
  1950. </html>