MDL-65970 airnotifier: Set lower timeout for Push curl requests
[moodle.git] / install.php
blobd2c2f501e6a6cbd0625b1257eaeeb01aecaa608a
1 <?php
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.
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/>.
18 /**
19 * This script creates config.php file during installation.
21 * @package core
22 * @subpackage install
23 * @copyright 2009 Petr Skoda (http://skodak.org)
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 if (isset($_REQUEST['lang'])) {
28 $lang = preg_replace('/[^A-Za-z0-9_-]/i', '', $_REQUEST['lang']);
29 } else {
30 $lang = 'en';
33 if (isset($_REQUEST['admin'])) {
34 $admin = preg_replace('/[^A-Za-z0-9_-]/i', '', $_REQUEST['admin']);
35 } else {
36 $admin = 'admin';
39 // If config.php exists we just created config.php and need to redirect to continue installation
40 $configfile = './config.php';
41 if (file_exists($configfile)) {
42 header("Location: $admin/index.php?lang=$lang");
43 die;
46 define('CLI_SCRIPT', false); // prevents some warnings later
47 define('AJAX_SCRIPT', false); // prevents some warnings later
48 define('CACHE_DISABLE_ALL', true); // Disables caching.. just in case.
49 define('PHPUNIT_TEST', false);
50 define('IGNORE_COMPONENT_CACHE', true);
51 define('MDL_PERF_TEST', false);
53 // Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
54 if (!function_exists('date_default_timezone_set') or !function_exists('date_default_timezone_get')) {
55 echo("Timezone functions are not available.");
56 die;
58 date_default_timezone_set(@date_default_timezone_get());
60 // make sure PHP errors are displayed - helps with diagnosing of problems
61 @error_reporting(E_ALL);
62 @ini_set('display_errors', '1');
64 // Check that PHP is of a sufficient version as soon as possible.
65 require_once(__DIR__.'/lib/phpminimumversionlib.php');
66 moodle_require_minimum_php_version();
68 // make sure iconv is available and actually works
69 if (!function_exists('iconv')) {
70 // this should not happen, this must be very borked install
71 echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.';
72 die();
75 if (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';
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);
87 /** Used by library scripts to check they are being called by Moodle */
88 define('MOODLE_INTERNAL', true);
90 require_once(__DIR__.'/lib/classes/component.php');
91 require_once(__DIR__.'/lib/installlib.php');
93 // TODO: add lang detection here if empty $_REQUEST['lang']
95 // distro specific customisation
96 $distro = null;
97 if (file_exists('install/distrolib.php')) {
98 require_once('install/distrolib.php');
99 if (function_exists('distro_get_config')) {
100 $distro = distro_get_config();
104 $config = new stdClass();
105 $config->lang = $lang;
107 if (!empty($_POST)) {
108 $config->stage = (int)$_POST['stage'];
110 if (isset($_POST['previous'])) {
111 $config->stage--;
112 if (INSTALL_DATABASETYPE and !empty($distro->dbtype)) {
113 $config->stage--;
115 if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_DOWNLOADLANG) {
116 $config->stage--;
118 } else if (isset($_POST['next'])) {
119 $config->stage++;
122 $config->dbtype = trim($_POST['dbtype']);
123 $config->dbhost = trim($_POST['dbhost']);
124 $config->dbuser = trim($_POST['dbuser']);
125 $config->dbpass = trim($_POST['dbpass']);
126 $config->dbname = trim($_POST['dbname']);
127 $config->prefix = trim($_POST['prefix']);
128 $config->dbport = (int)trim($_POST['dbport']);
129 $config->dbsocket = trim($_POST['dbsocket']);
131 if ($config->dbport <= 0) {
132 $config->dbport = '';
135 $config->admin = empty($_POST['admin']) ? 'admin' : trim($_POST['admin']);
137 $config->dataroot = trim($_POST['dataroot']);
139 } else {
140 $config->stage = INSTALL_WELCOME;
142 $config->dbtype = empty($distro->dbtype) ? '' : $distro->dbtype; // let distro skip dbtype selection
143 $config->dbhost = empty($distro->dbhost) ? 'localhost' : $distro->dbhost; // let distros set dbhost
144 $config->dbuser = empty($distro->dbuser) ? '' : $distro->dbuser; // let distros set dbuser
145 $config->dbpass = '';
146 $config->dbname = 'moodle';
147 $config->prefix = 'mdl_';
148 $config->dbport = empty($distro->dbport) ? '' : $distro->dbport;
149 $config->dbsocket = empty($distro->dbsocket) ? '' : $distro->dbsocket;
151 $config->admin = 'admin';
153 $config->dataroot = empty($distro->dataroot) ? null : $distro->dataroot; // initialised later after including libs or by distro
156 // Fake some settings so that we can use selected functions from moodlelib.php, weblib.php and filelib.php.
157 global $CFG;
158 $CFG = new stdClass();
159 $CFG->lang = $config->lang;
160 $CFG->dirroot = __DIR__;
161 $CFG->libdir = "$CFG->dirroot/lib";
162 $CFG->wwwroot = install_guess_wwwroot(); // can not be changed - ppl must use the real address when installing
163 $CFG->dataroot = $config->dataroot;
164 $CFG->tempdir = $CFG->dataroot.'/temp';
165 $CFG->backuptempdir = $CFG->tempdir.'/backup';
166 $CFG->cachedir = $CFG->dataroot.'/cache';
167 $CFG->localcachedir = $CFG->dataroot.'/localcache';
168 $CFG->admin = $config->admin;
169 $CFG->docroot = 'https://docs.moodle.org';
170 $CFG->langotherroot = $CFG->dataroot.'/lang';
171 $CFG->langlocalroot = $CFG->dataroot.'/lang';
172 $CFG->directorypermissions = isset($distro->directorypermissions) ? $distro->directorypermissions : 00777; // let distros set dir permissions
173 $CFG->filepermissions = ($CFG->directorypermissions & 0666);
174 $CFG->umaskpermissions = (($CFG->directorypermissions & 0777) ^ 0777);
175 $CFG->running_installer = true;
176 $CFG->early_install_lang = true;
177 $CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
178 $CFG->debug = (E_ALL | E_STRICT);
179 $CFG->debugdisplay = true;
180 $CFG->debugdeveloper = true;
182 // Require all needed libs
183 require_once($CFG->libdir.'/setuplib.php');
185 // we need to make sure we have enough memory to load all libraries
186 $memlimit = @ini_get('memory_limit');
187 if (!empty($memlimit) and $memlimit != -1) {
188 if (get_real_size($memlimit) < get_real_size($minrequiredmemory)) {
189 // do NOT localise - lang strings would not work here and we CAN not move it to later place
190 echo "Moodle requires at least {$minrequiredmemory}B of PHP memory.<br />";
191 echo "Please contact server administrator to fix PHP.ini memory settings.";
192 die;
196 // Continue with lib loading
197 require_once($CFG->libdir.'/classes/text.php');
198 require_once($CFG->libdir.'/classes/string_manager.php');
199 require_once($CFG->libdir.'/classes/string_manager_install.php');
200 require_once($CFG->libdir.'/classes/string_manager_standard.php');
201 require_once($CFG->libdir.'/weblib.php');
202 require_once($CFG->libdir.'/outputlib.php');
203 require_once($CFG->libdir.'/dmllib.php');
204 require_once($CFG->libdir.'/moodlelib.php');
205 require_once($CFG->libdir .'/pagelib.php');
206 require_once($CFG->libdir.'/deprecatedlib.php');
207 require_once($CFG->libdir.'/adminlib.php');
208 require_once($CFG->libdir.'/environmentlib.php');
209 require_once($CFG->libdir.'/componentlib.class.php');
210 require_once($CFG->dirroot.'/cache/lib.php');
212 //point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
213 //the problem is that we need specific version of quickforms and hacked excel files :-(
214 ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
216 // Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
217 // Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
218 if (defined('COMPONENT_CLASSLOADER')) {
219 spl_autoload_register(COMPONENT_CLASSLOADER);
220 } else {
221 spl_autoload_register('core_component::classloader');
224 require('version.php');
225 $CFG->target_release = $release;
227 \core\session\manager::init_empty_session();
228 global $SESSION;
229 global $USER;
231 global $COURSE;
232 $COURSE = new stdClass();
233 $COURSE->id = 1;
235 global $SITE;
236 $SITE = $COURSE;
237 define('SITEID', 1);
239 $hint_dataroot = '';
240 $hint_admindir = '';
241 $hint_database = '';
243 // Are we in help mode?
244 if (isset($_GET['help'])) {
245 install_print_help_page($_GET['help']);
248 //first time here? find out suitable dataroot
249 if (is_null($CFG->dataroot)) {
250 $CFG->dataroot = __DIR__.'/../moodledata';
252 $i = 0; //safety check - dirname might return some unexpected results
253 while(is_dataroot_insecure()) {
254 $parrent = dirname($CFG->dataroot);
255 $i++;
256 if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
257 $CFG->dataroot = ''; //can not find secure location for dataroot
258 break;
260 $CFG->dataroot = dirname($parrent).DIRECTORY_SEPARATOR.'moodledata';
262 $config->dataroot = $CFG->dataroot;
263 $config->stage = INSTALL_WELCOME;
266 // now let's do the stage work
267 if ($config->stage < INSTALL_WELCOME) {
268 $config->stage = INSTALL_WELCOME;
270 if ($config->stage > INSTALL_SAVE) {
271 $config->stage = INSTALL_SAVE;
276 if ($config->stage == INSTALL_SAVE) {
277 $CFG->early_install_lang = false;
279 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
280 if (!$database->driver_installed()) {
281 $config->stage = INSTALL_DATABASETYPE;
282 } else {
283 if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
284 $distro = distro_pre_create_db($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbport'=>$config->dbport, 'dbsocket'=>$config->dbsocket), $distro);
286 $hint_database = install_db_validate($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbport'=>$config->dbport, 'dbsocket'=>$config->dbsocket));
288 if ($hint_database === '') {
289 $configphp = install_generate_configphp($database, $CFG);
291 umask(0137);
292 if (($fh = @fopen($configfile, 'w')) !== false) {
293 fwrite($fh, $configphp);
294 fclose($fh);
297 if (file_exists($configfile)) {
298 // config created, let's continue!
299 redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
302 install_print_header($config, 'config.php',
303 get_string('configurationcompletehead', 'install'),
304 get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install'), 'alert-error');
305 echo '<div class="configphp"><pre>';
306 echo p($configphp);
307 echo '</pre></div>';
309 install_print_footer($config);
310 die;
312 } else {
313 $config->stage = INSTALL_DATABASE;
320 if ($config->stage == INSTALL_DOWNLOADLANG) {
321 if (empty($CFG->dataroot)) {
322 $config->stage = INSTALL_PATHS;
324 } else if (is_dataroot_insecure()) {
325 $hint_dataroot = get_string('pathsunsecuredataroot', 'install');
326 $config->stage = INSTALL_PATHS;
328 } else if (!file_exists($CFG->dataroot)) {
329 $a = new stdClass();
330 $a->parent = dirname($CFG->dataroot);
331 $a->dataroot = $CFG->dataroot;
332 if (!is_writable($a->parent)) {
333 $hint_dataroot = get_string('pathsroparentdataroot', 'install', $a);
334 $config->stage = INSTALL_PATHS;
335 } else {
336 if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
337 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', $a);
338 $config->stage = INSTALL_PATHS;
342 } else if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
343 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', array('dataroot' => $CFG->dataroot));
344 $config->stage = INSTALL_PATHS;
347 if (empty($hint_dataroot) and !is_writable($CFG->dataroot)) {
348 $hint_dataroot = get_string('pathsrodataroot', 'install');
349 $config->stage = INSTALL_PATHS;
352 if ($config->admin === '' or !file_exists($CFG->dirroot.'/'.$config->admin.'/environment.xml')) {
353 $hint_admindir = get_string('pathswrongadmindir', 'install');
354 $config->stage = INSTALL_PATHS;
360 if ($config->stage == INSTALL_DOWNLOADLANG) {
361 // no need to download anything if en lang selected
362 if ($CFG->lang == 'en') {
363 $config->stage = INSTALL_DATABASETYPE;
369 if ($config->stage == INSTALL_DATABASETYPE) {
370 // skip db selection if distro package supports only one db
371 if (!empty($distro->dbtype)) {
372 $config->stage = INSTALL_DATABASE;
377 if ($config->stage == INSTALL_DOWNLOADLANG) {
378 $downloaderror = '';
380 // download and install required lang packs, the lang dir has already been created in install_init_dataroot
381 $installer = new lang_installer($CFG->lang);
382 $results = $installer->run();
383 foreach ($results as $langcode => $langstatus) {
384 if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
385 $a = new stdClass();
386 $a->url = $installer->lang_pack_url($langcode);
387 $a->dest = $CFG->dataroot.'/lang';
388 $downloaderror = get_string('remotedownloaderror', 'error', $a);
392 if ($downloaderror !== '') {
393 install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang), $downloaderror);
394 install_print_footer($config);
395 die;
396 } else {
397 if (empty($distro->dbtype)) {
398 $config->stage = INSTALL_DATABASETYPE;
399 } else {
400 $config->stage = INSTALL_DATABASE;
404 // switch the string_manager instance to stop using install/lang/
405 $CFG->early_install_lang = false;
406 $CFG->langotherroot = $CFG->dataroot.'/lang';
407 $CFG->langlocalroot = $CFG->dataroot.'/lang';
408 get_string_manager(true);
412 if ($config->stage == INSTALL_DATABASE) {
413 $CFG->early_install_lang = false;
415 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
417 $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
419 install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
421 $strdbhost = get_string('databasehost', 'install');
422 $strdbname = get_string('databasename', 'install');
423 $strdbuser = get_string('databaseuser', 'install');
424 $strdbpass = get_string('databasepass', 'install');
425 $strprefix = get_string('dbprefix', 'install');
426 $strdbport = get_string('databaseport', 'install');
427 $strdbsocket = get_string('databasesocket', 'install');
429 echo '<div class="row mb-4">';
431 $disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
432 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbhost">'.$strdbhost.'</label></div>';
433 echo '<div class="col-md-9" data-fieldtype="text">';
434 echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" class="form-control text-ltr" value="'.s($config->dbhost).'" size="50" /></div>';
435 echo '</div>';
437 echo '<div class="row mb-4">';
438 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbname">'.$strdbname.'</label></div>';
439 echo '<div class="col-md-9" data-fieldtype="text">';
440 echo '<input id="id_dbname" name="dbname" type="text" class="form-control text-ltr" value="'.s($config->dbname).'" size="50" /></div>';
441 echo '</div>';
443 $disabled = empty($distro->dbuser) ? '' : 'disabled="disabled';
444 echo '<div class="row mb-4">';
445 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbuser">'.$strdbuser.'</label></div>';
446 echo '<div class="col-md-9" data-fieldtype="text">';
447 echo '<input id="id_dbuser" name="dbuser" '.$disabled.' type="text" class="form-control text-ltr" value="'.s($config->dbuser).'" size="50" /></div>';
448 echo '</div>';
450 echo '<div class="row mb-4">';
451 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbpass">'.$strdbpass.'</label></div>';
452 // no password field here, the password may be visible in config.php if we can not write it to disk
453 echo '<div class="col-md-9" data-fieldtype="text">';
454 echo '<input id="id_dbpass" name="dbpass" type="text" class="form-control text-ltr" value="'.s($config->dbpass).'" size="50" /></div>';
455 echo '</div>';
457 echo '<div class="row mb-4">';
458 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_prefix">'.$strprefix.'</label></div>';
459 echo '<div class="col-md-9" data-fieldtype="text">';
460 echo '<input id="id_prefix" name="prefix" type="text" class="form-control text-ltr" value="'.s($config->prefix).'" size="10" /></div>';
461 echo '</div>';
463 echo '<div class="row mb-4">';
464 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_prefix">'.$strdbport.'</label></div>';
465 echo '<div class="col-md-9" data-fieldtype="text">';
466 echo '<input id="id_dbport" name="dbport" type="text" class="form-control text-ltr" value="'.s($config->dbport).'" size="10" /></div>';
467 echo '</div>';
469 if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
470 echo '<div class="row mb-4">';
471 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbsocket">'.$strdbsocket.'</label></div>';
472 echo '<div class="col-md-9" data-fieldtype="text">';
473 echo '<input id="id_dbsocket" name="dbsocket" type="text" class="form-control text-ltr" value="'.s($config->dbsocket).'" size="50" /></div>';
474 echo '</div>';
477 if ($hint_database !== '') {
478 echo '<div class="alert alert-danger">'.$hint_database.'</div>';
480 echo '</div>';
481 install_print_footer($config);
482 die;
486 if ($config->stage == INSTALL_DATABASETYPE) {
487 $CFG->early_install_lang = false;
489 // Finally ask for DB type
490 install_print_header($config, get_string('database', 'install'),
491 get_string('databasetypehead', 'install'),
492 get_string('databasetypesub', 'install'));
494 $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
495 'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
496 'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
497 'oci' => moodle_database::get_driver_instance('oci', 'native'),
498 'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
501 echo '<div class="row mb-4">';
502 echo '<div class="col-md-3 text-md-right pt-1"><label for="dbtype">'.get_string('dbtype', 'install').'</label></div>';
503 echo '<div class="col-md-9" data-fieldtype="select">';
504 echo '<select class="form-control" id="dbtype" name="dbtype">';
505 $disabled = array();
506 $options = array();
507 foreach ($databases as $type=>$database) {
508 if ($database->driver_installed() !== true) {
509 $disabled[$type] = $database;
510 continue;
512 echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
514 if ($disabled) {
515 echo '<optgroup label="'.s(get_string('notavailable')).'">';
516 foreach ($disabled as $type=>$database) {
517 echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
519 echo '</optgroup>';
521 echo '</select></div></div>';
523 install_print_footer($config);
524 die;
529 if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
530 $curl_fail = ($lang !== 'en' and !extension_loaded('curl')); // needed for lang pack download
531 $zip_fail = ($lang !== 'en' and !extension_loaded('zip')); // needed for lang pack download
533 if ($curl_fail or $zip_fail) {
534 $config->stage = INSTALL_ENVIRONMENT;
536 install_print_header($config, get_string('environmenthead', 'install'),
537 get_string('errorsinenvironment', 'install'),
538 get_string('environmentsub2', 'install'));
540 echo '<div id="envresult"><dl>';
541 if ($curl_fail) {
542 echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
544 if ($zip_fail) {
545 echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
547 echo '</dl></div>';
549 install_print_footer($config, true);
550 die;
552 } else {
553 $config->stage = INSTALL_PATHS;
559 if ($config->stage == INSTALL_PATHS) {
560 $paths = array('wwwroot' => get_string('wwwroot', 'install'),
561 'dirroot' => get_string('dirroot', 'install'),
562 'dataroot' => get_string('dataroot', 'install'));
564 $sub = '<dl>';
565 foreach ($paths as $path=>$name) {
566 $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
568 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
569 $sub .= '<dt>'.get_string('admindirname', 'install').'</dt><dd>'.get_string('pathssubadmindir', 'install').'</dd>';
571 $sub .= '</dl>';
573 install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
575 $strwwwroot = get_string('wwwroot', 'install');
576 $strdirroot = get_string('dirroot', 'install');
577 $strdataroot = get_string('dataroot', 'install');
578 $stradmindirname = get_string('admindirname', 'install');
580 echo '<div class="row mb-4">';
581 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_wwwroot">'.$paths['wwwroot'].'</label></div>';
582 echo '<div class="col-md-9" data-fieldtype="text">';
583 echo '<input id="id_wwwroot" name="wwwroot" type="text" class="form-control text-ltr" value="'.s($CFG->wwwroot).'" disabled="disabled" size="70" /></div>';
584 echo '</div>';
586 echo '<div class="row mb-4">';
587 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dirroot">'.$paths['dirroot'].'</label></div>';
588 echo '<div class="col-md-9" data-fieldtype="text">';
589 echo '<input id="id_dirroot" name="dirroot" type="text" class="form-control text-ltr" value="'.s($CFG->dirroot).'" disabled="disabled" size="70" /></div>';
590 echo '</div>';
592 echo '<div class="row mb-4">';
593 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dataroot">'.$paths['dataroot'].'</label></div>';
594 echo '<div class="col-md-9" data-fieldtype="text">';
595 echo '<input id="id_dataroot" name="dataroot" type="text" class="form-control text-ltr" value="'.s($config->dataroot).'" size="70" /></div>';
596 echo '</div>';
597 if ($hint_dataroot !== '') {
598 echo '<div class="alert alert-danger">'.$hint_dataroot.'</div>';
602 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
603 echo '<div class="row mb-4">';
604 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_admin">'.$paths['admindir'].'</label></div>';
605 echo '<div class="col-md-9" data-fieldtype="text">';
606 echo '<input id="id_admin" name="admin" type="text" class="form-control text-ltr" value="'.s($config->admin).'" size="10" /></div>';
607 echo '</div>';
608 if ($hint_admindir !== '') {
609 echo '<div class="alert alert-danger">'.$hint_admindir.'</div>';
611 echo '</div>';
614 echo '</div>';
616 install_print_footer($config);
617 die;
622 $config->stage = INSTALL_WELCOME;
624 if ($distro) {
625 ob_start();
626 include('install/distribution.html');
627 $sub = ob_get_clean();
629 install_print_header($config, get_string('language'),
630 get_string('chooselanguagehead', 'install'),
631 $sub, 'alert-success');
633 } else {
634 install_print_header($config, get_string('language'),
635 get_string('chooselanguagehead', 'install'),
636 get_string('chooselanguagesub', 'install'));
639 $languages = get_string_manager()->get_list_of_translations();
640 echo '<div class="row mb-4">';
641 echo '<div class="col-md-3 text-md-right pt-1"><label for="langselect">'.get_string('language').'</label></div>';
642 echo '<div class="col-md-9" data-fieldtype="select">';
643 echo '<select id="langselect" class="form-control" name="lang" onchange="this.form.submit()">';
644 foreach ($languages as $name=>$value) {
645 $selected = ($name == $CFG->lang) ? 'selected="selected"' : '';
646 echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
648 echo '</select></div>';
649 echo '</div>';
651 install_print_footer($config);
652 die;