MDL-34762 course Hide system archetypes from mod chooser
[moodle.git] / install.php
CommitLineData
d764d4ca 1<?php
8b5b1028 2
d764d4ca 3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18/**
19 * This script creates config.php file during installation.
20 *
b7315f35 21 * @package core
95feaf96 22 * @subpackage install
d764d4ca 23 * @copyright 2009 Petr Skoda (http://skodak.org)
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 */
8b5b1028 26
3b093310 27if (isset($_REQUEST['lang'])) {
6dbcacee 28 $lang = preg_replace('/[^A-Za-z0-9_-]/i', '', $_REQUEST['lang']);
8b5b1028 29} else {
3a915b06 30 $lang = 'en';
8b5b1028 31}
32
3b093310 33if (isset($_REQUEST['admin'])) {
6dbcacee 34 $admin = preg_replace('/[^A-Za-z0-9_-]/i', '', $_REQUEST['admin']);
3b093310 35} else {
36 $admin = 'admin';
8b5b1028 37}
38
082157a8 39// If config.php exists we just created config.php and need to redirect to continue installation
3b093310 40$configfile = './config.php';
41if (file_exists($configfile)) {
42 header("Location: $admin/index.php?lang=$lang");
43 die;
d36afd6d 44}
8d783716 45
e2253187
PS
46define('CLI_SCRIPT', false); // prevents some warnings later
47define('AJAX_SCRIPT', false); // prevents some warnings later
48
4ede587e
PS
49// Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
50// This is a quick hack. Ideally we should ask the admin for a value. See MDL-22625 for more on this.
51if (function_exists('date_default_timezone_set') and function_exists('date_default_timezone_get')) {
52 @date_default_timezone_set(@date_default_timezone_get());
53}
54
082157a8 55// make sure PHP errors are displayed - helps with diagnosing of problems
3b093310 56@error_reporting(E_ALL);
57@ini_set('display_errors', '1');
3b093310 58
68cd60b7
59// Check that PHP is of a sufficient version.
60if (version_compare(phpversion(), '5.3.2') < 0) {
3b093310 61 $phpversion = phpversion();
62 // do NOT localise - lang strings would not work here and we CAN not move it after installib
eab044a0
PS
63 echo "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).<br />";
64 echo "Please upgrade your server software or install older Moodle version.";
3b093310 65 die;
8b5b1028 66}
67
695940df
PS
68// make sure iconv is available and actually works
69if (!function_exists('iconv')) {
70 // this should not happen, this must be very borked install
7d85a4e2 71 echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.';
695940df
PS
72 die();
73}
695940df 74
86449d22
PS
75if (PHP_INT_SIZE > 4) {
76 // most probably 64bit PHP - we need a lot more memory
77 $minrequiredmemory = '70M';
78} else {
79 // 32bit PHP
80 $minrequiredmemory = '40M';
81}
82// increase or decrease available memory - we need to make sure moodle
83// installs even with low memory, otherwise developers would overlook
84// sudden increases of memory needs ;-)
85@ini_set('memory_limit', $minrequiredmemory);
86
460ebd6c
PS
87/** Used by library scripts to check they are being called by Moodle */
88define('MOODLE_INTERNAL', true);
89
3b093310 90require dirname(__FILE__).'/lib/installlib.php';
bd507453 91
3b093310 92// TODO: add lang detection here if empty $_REQUEST['lang']
3b3b8029 93
5c1fb7d4 94// distro specific customisation
95$distro = null;
768408e8 96if (file_exists('install/distrolib.php')) {
97 require_once('install/distrolib.php');
98 if (function_exists('distro_get_config')) {
99 $distro = distro_get_config();
100 }
5c1fb7d4 101}
102
3b093310 103$config = new stdClass();
104$config->lang = $lang;
3b3b8029 105
3b093310 106if (!empty($_POST)) {
107 if (install_ini_get_bool('magic_quotes_gpc')) {
fa53493e 108 $_POST = array_map('stripslashes', $_POST);
3b093310 109 }
3b3b8029 110
3b093310 111 $config->stage = (int)$_POST['stage'];
56ca1c60 112
3b093310 113 if (isset($_POST['previous'])) {
114 $config->stage--;
5167827b 115 if (INSTALL_DATABASETYPE and !empty($distro->dbtype)) {
116 $config->stage--;
117 }
3b093310 118 if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_DOWNLOADLANG) {
119 $config->stage--;
56ca1c60 120 }
3b093310 121 } else if (isset($_POST['next'])) {
122 $config->stage++;
d36afd6d 123 }
3b3b8029 124
3b093310 125 $config->dbtype = trim($_POST['dbtype']);
126 $config->dbhost = trim($_POST['dbhost']);
127 $config->dbuser = trim($_POST['dbuser']);
128 $config->dbpass = trim($_POST['dbpass']);
129 $config->dbname = trim($_POST['dbname']);
130 $config->prefix = trim($_POST['prefix']);
131 $config->dbsocket = (int)(!empty($_POST['dbsocket']));
3b3b8029 132
3b093310 133 $config->admin = empty($_POST['admin']) ? 'admin' : trim($_POST['admin']);
53a0367d 134
3b093310 135 $config->dataroot = trim($_POST['dataroot']);
d36afd6d 136
3b3b8029 137} else {
3b093310 138 $config->stage = INSTALL_WELCOME;
8b5b1028 139
4f9dba35 140 $config->dbtype = empty($distro->dbtype) ? '' : $distro->dbtype; // let distro skip dbtype selection
6724b059 141 $config->dbhost = empty($distro->dbhost) ? 'localhost' : $distro->dbhost; // let distros set dbhost
142 $config->dbuser = empty($distro->dbuser) ? '' : $distro->dbuser; // let distros set dbuser
3b093310 143 $config->dbpass = '';
144 $config->dbname = 'moodle';
145 $config->prefix = 'mdl_';
146 $config->dbsocket = 0;
53a0367d 147
3b093310 148 $config->admin = 'admin';
8b5b1028 149
4f9dba35 150 $config->dataroot = empty($distro->dataroot) ? null : $distro->dataroot; // initialised later after including libs or by distro
3b093310 151}
8b5b1028 152
082157a8 153// Fake some settings so that we can use selected functions from moodlelib.php and weblib.php
3b093310 154$CFG = new stdClass();
155$CFG->lang = $config->lang;
3b5ff37f 156$CFG->dirroot = dirname(__FILE__);
3b093310 157$CFG->libdir = "$CFG->dirroot/lib";
158$CFG->wwwroot = install_guess_wwwroot(); // can not be changed - ppl must use the real address when installing
159$CFG->httpswwwroot = $CFG->wwwroot;
3b093310 160$CFG->dataroot = $config->dataroot;
f848c0f6 161$CFG->tempdir = $CFG->dataroot.'/temp';
12812ad5 162$CFG->cachedir = $CFG->dataroot.'/cache';
3b093310 163$CFG->admin = $config->admin;
164$CFG->docroot = 'http://docs.moodle.org';
d8fa5a13
PS
165$CFG->langotherroot = $CFG->dataroot.'/lang';
166$CFG->langlocalroot = $CFG->dataroot.'/lang';
70801baf 167$CFG->directorypermissions = isset($distro->directorypermissions) ? $distro->directorypermissions : 00777; // let distros set dir permissions
3b093310 168$CFG->running_installer = true;
3a915b06 169$CFG->early_install_lang = true;
8d783716 170
082157a8 171// Require all needed libs
d36afd6d 172require_once($CFG->libdir.'/setuplib.php');
86449d22
PS
173
174// we need to make sure we have enough memory to load all libraries
175$memlimit = @ini_get('memory_limit');
176if (!empty($memlimit) and $memlimit != -1) {
177 if (get_real_size($memlimit) < get_real_size($minrequiredmemory)) {
178 // do NOT localise - lang strings would not work here and we CAN not move it to later place
eab044a0 179 echo "Moodle requires at least {$minrequiredmemory}B of PHP memory.<br />";
86449d22
PS
180 echo "Please contact server administrator to fix PHP.ini memory settings.";
181 die;
182 }
183}
184
185// Continue with lib loading
3b093310 186require_once($CFG->libdir.'/textlib.class.php');
d36afd6d 187require_once($CFG->libdir.'/weblib.php');
318f0519 188require_once($CFG->libdir.'/outputlib.php');
3b093310 189require_once($CFG->libdir.'/dmllib.php');
251387d0 190require_once($CFG->libdir.'/moodlelib.php');
d4a03c00 191require_once($CFG->libdir .'/pagelib.php');
3b093310 192require_once($CFG->libdir.'/deprecatedlib.php');
251387d0 193require_once($CFG->libdir.'/adminlib.php');
d36afd6d 194require_once($CFG->libdir.'/environmentlib.php');
d36afd6d 195require_once($CFG->libdir.'/componentlib.class.php');
067200e2 196require_once($CFG->dirroot.'/cache/lib.php');
3b093310 197
e8da62a9
PS
198//point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
199//the problem is that we need specific version of quickforms and hacked excel files :-(
200ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
201//point zend include path to moodles lib/zend so that includes and requires will search there for files before anywhere else
202ini_set('include_path', $CFG->libdir.'/zend' . PATH_SEPARATOR . ini_get('include_path'));
6f5e0852 203
3b093310 204require('version.php');
9ace5094 205$CFG->target_release = $release;
3b093310 206
a226a972 207$SESSION = new stdClass();
3b093310 208$SESSION->lang = $CFG->lang;
209
a226a972 210$USER = new stdClass();
3b093310 211$USER->id = 0;
212
a226a972 213$COURSE = new stdClass();
3b093310 214$COURSE->id = 0;
215
216$SITE = $COURSE;
217define('SITEID', 0);
218
219$hint_dataroot = '';
3b093310 220$hint_admindir = '';
221$hint_database = '';
222
082157a8 223// Are we in help mode?
3b093310 224if (isset($_GET['help'])) {
225 install_print_help_page($_GET['help']);
226}
227
082157a8 228//first time here? find out suitable dataroot
3b093310 229if (is_null($CFG->dataroot)) {
3b5ff37f 230 $CFG->dataroot = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'moodledata';
add47d44 231
add47d44 232 $i = 0; //safety check - dirname might return some unexpected results
233 while(is_dataroot_insecure()) {
234 $parrent = dirname($CFG->dataroot);
235 $i++;
b735d140 236 if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
add47d44 237 $CFG->dataroot = ''; //can not find secure location for dataroot
238 break;
239 }
3b5ff37f 240 $CFG->dataroot = dirname($parrent).DIRECTORY_SEPARATOR.'moodledata';
add47d44 241 }
3b093310 242 $config->dataroot = $CFG->dataroot;
243 $config->stage = INSTALL_WELCOME;
8b5b1028 244}
245
3b093310 246// now let's do the stage work
247if ($config->stage < INSTALL_WELCOME) {
248 $config->stage = INSTALL_WELCOME;
249}
250if ($config->stage > INSTALL_SAVE) {
251 $config->stage = INSTALL_SAVE;
8d783716 252}
253
254
51e3e0b9 255
3b093310 256if ($config->stage == INSTALL_SAVE) {
3a915b06
PS
257 $CFG->early_install_lang = false;
258
3b093310 259 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
260 if (!$database->driver_installed()) {
261 $config->stage = INSTALL_DATABASETYPE;
262 } else {
082157a8 263 if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
a0b7200d 264 $distro = distro_pre_create_db($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbsocket'=>$config->dbsocket), $distro);
768408e8 265 }
a0b7200d 266 $hint_database = install_db_validate($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbsocket'=>$config->dbsocket));
edd3a5db 267
3b093310 268 if ($hint_database === '') {
3b5ff37f 269 $configphp = install_generate_configphp($database, $CFG);
53a0367d 270
3b093310 271 umask(0137);
3b093310 272 if (($fh = @fopen($configfile, 'w')) !== false) {
273 fwrite($fh, $configphp);
274 fclose($fh);
275 }
082157a8 276
3b093310 277 if (file_exists($configfile)) {
278 // config created, let's continue!
279 redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
280 }
2df3a721 281
3b093310 282 install_print_header($config, 'config.php',
283 get_string('configurationcompletehead', 'install'),
284 get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install'));
285 echo '<div class="configphp"><pre>';
286 echo p($configphp);
287 echo '</pre></div>';
bba0beae 288
3b093310 289 install_print_footer($config);
290 die;
8b5b1028 291
3b093310 292 } else {
293 $config->stage = INSTALL_DATABASE;
294 }
6d5a22b2 295 }
8b5b1028 296}
297
298
299
5167827b 300if ($config->stage == INSTALL_DOWNLOADLANG) {
301 if (empty($CFG->dataroot)) {
302 $config->stage = INSTALL_PATHS;
303
304 } else if (is_dataroot_insecure()) {
305 $hint_dataroot = get_string('pathsunsecuredataroot', 'install');
306 $config->stage = INSTALL_PATHS;
307
cf89052a 308 } else if (!file_exists($CFG->dataroot)) {
309 $a = new stdClass();
310 $a->parent = dirname($CFG->dataroot);
311 $a->dataroot = $CFG->dataroot;
e92977d3 312 if (!is_writable($a->parent)) {
cf89052a 313 $hint_dataroot = get_string('pathsroparentdataroot', 'install', $a);
314 $config->stage = INSTALL_PATHS;
315 } else {
0bda7031 316 if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
cf89052a 317 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', $a);
318 $config->stage = INSTALL_PATHS;
319 }
320 }
16564524
DM
321
322 } else if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
e92977d3 323 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', array('dataroot' => $CFG->dataroot));
16564524 324 $config->stage = INSTALL_PATHS;
cf89052a 325 }
326
327 if (empty($hint_dataroot) and !is_writable($CFG->dataroot)) {
5167827b 328 $hint_dataroot = get_string('pathsrodataroot', 'install');
329 $config->stage = INSTALL_PATHS;
330 }
331
3b5ff37f 332 if ($config->admin === '' or !file_exists($CFG->dirroot.'/'.$config->admin.'/environment.xml')) {
5167827b 333 $hint_admindir = get_string('pathswrongadmindir', 'install');
334 $config->stage = INSTALL_PATHS;
335 }
336}
337
338
339
340if ($config->stage == INSTALL_DOWNLOADLANG) {
341 // no need to download anything if en lang selected
3a915b06 342 if ($CFG->lang == 'en') {
5167827b 343 $config->stage = INSTALL_DATABASETYPE;
344 }
345}
346
347
348
349if ($config->stage == INSTALL_DATABASETYPE) {
350 // skip db selection if distro package supports only one db
351 if (!empty($distro->dbtype)) {
352 $config->stage = INSTALL_DATABASE;
353 }
354}
355
356
08261d3a 357if ($config->stage == INSTALL_DOWNLOADLANG) {
358 $downloaderror = '';
359
74a4c9a9
DM
360 // download and install required lang packs, the lang dir has already been created in install_init_dataroot
361 $installer = new lang_installer($CFG->lang);
362 $results = $installer->run();
363 foreach ($results as $langcode => $langstatus) {
364 if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
365 $a = new stdClass();
366 $a->url = $installer->lang_pack_url($langcode);
367 $a->dest = $CFG->dataroot.'/lang';
368 $downloaderror = get_string('remotedownloaderror', 'error', $a);
08261d3a 369 }
370 }
371
372 if ($downloaderror !== '') {
373 install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang), $downloaderror);
374 install_print_footer($config);
375 die;
376 } else {
377 if (empty($distro->dbtype)) {
378 $config->stage = INSTALL_DATABASETYPE;
379 } else {
380 $config->stage = INSTALL_DATABASE;
381 }
382 }
807ee8bc
DM
383
384 // switch the string_manager instance to stop using install/lang/
385 $CFG->early_install_lang = false;
386 $CFG->langotherroot = $CFG->dataroot.'/lang';
387 $CFG->langlocalroot = $CFG->dataroot.'/lang';
388 get_string_manager(true);
08261d3a 389}
390
5167827b 391
3b093310 392if ($config->stage == INSTALL_DATABASE) {
3a915b06
PS
393 $CFG->early_install_lang = false;
394
3b093310 395 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
8b5b1028 396
3b093310 397 $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
8d783716 398
3b093310 399 install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
53a0367d 400
3b093310 401 $strdbhost = get_string('databasehost', 'install');
402 $strdbname = get_string('databasename', 'install');
403 $strdbuser = get_string('databaseuser', 'install');
404 $strdbpass = get_string('databasepass', 'install');
405 $strprefix = get_string('dbprefix', 'install');
406 $strdbsocket = get_string('databasesocket', 'install');
8d783716 407
3b093310 408 echo '<div class="userinput">';
6724b059 409
410 $disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
3b093310 411 echo '<div class="formrow"><label for="id_dbhost" class="formlabel">'.$strdbhost.'</label>';
8231a0ca 412 echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="50" class="forminput" />';
3b093310 413 echo '</div>';
8b5b1028 414
3b093310 415 echo '<div class="formrow"><label for="id_dbname" class="formlabel">'.$strdbname.'</label>';
8231a0ca 416 echo '<input id="id_dbname" name="dbname" type="text" value="'.s($config->dbname).'" size="50" class="forminput" />';
3b093310 417 echo '</div>';
86453d8b 418
6724b059 419 $disabled = empty($distro->dbuser) ? '' : 'disabled="disabled';
3b093310 420 echo '<div class="formrow"><label for="id_dbuser" class="formlabel">'.$strdbuser.'</label>';
8231a0ca 421 echo '<input id="id_dbuser" name="dbuser" '.$disabled.' type="text" value="'.s($config->dbuser).'" size="50" class="forminput" />';
3b093310 422 echo '</div>';
86453d8b 423
3b093310 424 echo '<div class="formrow"><label for="id_dbpass" class="formlabel">'.$strdbpass.'</label>';
425 // no password field here, the password may be visible in config.php if we can not write it to disk
8231a0ca 426 echo '<input id="id_dbpass" name="dbpass" type="text" value="'.s($config->dbpass).'" size="50" class="forminput" />';
3b093310 427 echo '</div>';
86453d8b 428
3b093310 429 echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strprefix.'</label>';
430 echo '<input id="id_prefix" name="prefix" type="text" value="'.s($config->prefix).'" size="10" class="forminput" />';
431 echo '</div>';
fe515206 432
3b093310 433 if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
434 $checked = $config->dbsocket ? 'checked="checked' : '';
435 echo '<div class="formrow"><label for="id_dbsocket" class="formlabel">'.$strdbsocket.'</label>';
436 echo '<input type="hidden" value="0" name="dbsocket" />';
437 echo '<input type="checkbox" id="id_dbsocket" value="1" name="dbsocket" '.$checked.' class="forminput" />';
438 echo '</div>';
8b5b1028 439 }
440
3b093310 441 echo '<div class="hint">'.$hint_database.'</div>';
442 echo '</div>';
443 install_print_footer($config);
444 die;
8b5b1028 445}
446
447
3b093310 448if ($config->stage == INSTALL_DATABASETYPE) {
3a915b06
PS
449 $CFG->early_install_lang = false;
450
082157a8 451 // Finally ask for DB type
3b093310 452 install_print_header($config, get_string('database', 'install'),
453 get_string('databasetypehead', 'install'),
454 get_string('databasetypesub', 'install'));
51e3e0b9 455
3b093310 456 $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
457 'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
458 'oci' => moodle_database::get_driver_instance('oci', 'native'),
7e60d0d6 459 'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
a2b9bca5 460 'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
3b093310 461 );
51e3e0b9 462
3b093310 463 echo '<div class="userinput">';
464 echo '<div class="formrow"><label class="formlabel" for="dbtype">'.get_string('dbtype', 'install').'</label>';
465 echo '<select id="dbtype" name="dbtype" class="forminput">';
466 $disabled = array();
467 $options = array();
468 foreach ($databases as $type=>$database) {
469 if ($database->driver_installed() !== true) {
470 $disabled[$type] = $database;
471 continue;
472 }
473 echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
51e3e0b9 474 }
3b093310 475 if ($disabled) {
476 echo '<optgroup label="'.s(get_string('notavailable')).'">';
477 foreach ($disabled as $type=>$database) {
478 echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
479 }
480 echo '</optgroup>';
8b5b1028 481 }
3b093310 482 echo '</select></div>';
483 echo '</div>';
53a0367d 484
3b093310 485 install_print_footer($config);
486 die;
8b5b1028 487}
488
489
490
3b093310 491if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
eab044a0 492 $version_fail = (version_compare(phpversion(), "5.3.2") < 0);
3a915b06
PS
493 $curl_fail = ($lang !== 'en' and !extension_loaded('curl')); // needed for lang pack download
494 $zip_fail = ($lang !== 'en' and !extension_loaded('zip')); // needed for lang pack download
8b5b1028 495
3b093310 496 if ($version_fail or $curl_fail or $zip_fail) {
497 $config->stage = INSTALL_ENVIRONMENT;
8b5b1028 498
85ed076b 499 install_print_header($config, get_string('environmenthead', 'install'),
3b093310 500 get_string('errorsinenvironment', 'install'),
501 get_string('environmentsub2', 'install'));
8b5b1028 502
3b093310 503 echo '<div id="envresult"><dl>';
504 if ($version_fail) {
eab044a0 505 $a = (object)array('needed'=>'5.3.2', 'current'=>phpversion());
3b093310 506 echo '<dt>'.get_string('phpversion', 'install').'</dt><dd>'.get_string('environmentrequireversion', 'admin', $a).'</dd>';
507 }
508 if ($curl_fail) {
509 echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
510 }
511 if ($zip_fail) {
512 echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
513 }
514 echo '</dl></div>';
8d783716 515
3b093310 516 install_print_footer($config, true);
517 die;
51e3e0b9 518
8b5b1028 519 } else {
3b093310 520 $config->stage = INSTALL_PATHS;
8b5b1028 521 }
8b5b1028 522}
523
8b5b1028 524
8b5b1028 525
3b093310 526if ($config->stage == INSTALL_PATHS) {
527 $paths = array('wwwroot' => get_string('wwwroot', 'install'),
528 'dirroot' => get_string('dirroot', 'install'),
3b5ff37f 529 'dataroot' => get_string('dataroot', 'install'));
627d326a 530
3b093310 531 $sub = '<dl>';
532 foreach ($paths as $path=>$name) {
533 $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
8b5b1028 534 }
3b5ff37f
PS
535 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
536 $sub .= '<dt>'.get_string('admindirname', 'install').'</dt><dd>'.get_string('pathssubadmindir', 'install').'</dd>';
537 }
3b093310 538 $sub .= '</dl>';
cd0e958e 539
3b093310 540 install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
627d326a 541
3b093310 542 $strwwwroot = get_string('wwwroot', 'install');
543 $strdirroot = get_string('dirroot', 'install');
544 $strdataroot = get_string('dataroot', 'install');
545 $stradmindirname = get_string('admindirname', 'install');
cdef6d42 546
3b093310 547 echo '<div class="userinput">';
548 echo '<div class="formrow"><label for="id_wwwroot" class="formlabel">'.$paths['wwwroot'].'</label>';
ae3a7947 549 echo '<input id="id_wwwroot" name="wwwroot" type="text" value="'.s($CFG->wwwroot).'" disabled="disabled" size="70" class="forminput" />';
3b093310 550 echo '</div>';
cd0e958e 551
3b093310 552 echo '<div class="formrow"><label for="id_dirroot" class="formlabel">'.$paths['dirroot'].'</label>';
ae3a7947 553 echo '<input id="id_dirroot" name="dirroot" type="text" value="'.s($CFG->dirroot).'" disabled="disabled" size="70"class="forminput" />';
3b093310 554 echo '</div>';
53a0367d 555
3b093310 556 echo '<div class="formrow"><label for="id_dataroot" class="formlabel">'.$paths['dataroot'].'</label>';
ae3a7947 557 echo '<input id="id_dataroot" name="dataroot" type="text" value="'.s($config->dataroot).'" size="70" class="forminput" />';
3b093310 558 if ($hint_dataroot !== '') {
559 echo '<div class="hint">'.$hint_dataroot.'</div>';
cdef6d42 560 }
3b093310 561 echo '</div>';
8b5b1028 562
8d783716 563
3b5ff37f
PS
564 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
565 echo '<div class="formrow"><label for="id_admin" class="formlabel">'.$paths['admindir'].'</label>';
566 echo '<input id="id_admin" name="admin" type="text" value="'.s($config->admin).'" size="10" class="forminput" />';
567 if ($hint_admindir !== '') {
568 echo '<div class="hint">'.$hint_admindir.'</div>';
569 }
570 echo '</div>';
8d783716 571 }
8d783716 572
3b093310 573 echo '</div>';
8d783716 574
3b093310 575 install_print_footer($config);
576 die;
8d783716 577}
578
86453d8b 579
86453d8b 580
3b093310 581$config->stage = INSTALL_WELCOME;
64c368e3 582
583if ($distro) {
584 ob_start();
585 include('install/distribution.html');
586 $sub = ob_get_clean();
587
588 install_print_header($config, get_string('language'),
589 get_string('chooselanguagehead', 'install'),
590 $sub);
082157a8 591
64c368e3 592} else {
593 install_print_header($config, get_string('language'),
594 get_string('chooselanguagehead', 'install'),
595 get_string('chooselanguagesub', 'install'));
596}
86453d8b 597
1f96e907 598$languages = get_string_manager()->get_list_of_translations();
3b093310 599echo '<div class="userinput">';
600echo '<div class="formrow"><label class="formlabel" for="langselect">'.get_string('language').'</label>';
4d928665 601echo '<select id="langselect" name="lang" class="forminput" onchange="this.form.submit()">';
3b093310 602foreach ($languages as $name=>$value) {
603 $selected = ($name == $CFG->lang) ? 'selected="selected"' : '';
604 echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
86453d8b 605}
3b093310 606echo '</select></div>';
607echo '</div>';
86453d8b 608
3b093310 609install_print_footer($config);
610die;
2961367e 611