MDL-79863 qtype_ordering: Moodle.2x qtype/ordering standardize version.php and add...
[moodle.git] / install.php
blob76a2b568a1ceb425451b1449bbe205b09bfe6fb3
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);
52 define('MDL_PERF', false);
53 define('MDL_PERFTOFOOT', false);
54 define('MDL_PERFTOLOG', false);
55 define('MDL_PERFINC', false);
57 // Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
58 if (!function_exists('date_default_timezone_set') or !function_exists('date_default_timezone_get')) {
59 echo("Timezone functions are not available.");
60 die;
62 date_default_timezone_set(@date_default_timezone_get());
64 // make sure PHP errors are displayed - helps with diagnosing of problems
65 @error_reporting(E_ALL);
66 @ini_set('display_errors', '1');
68 // Check that PHP is of a sufficient version as soon as possible.
69 require_once(__DIR__.'/lib/phpminimumversionlib.php');
70 moodle_require_minimum_php_version();
72 // make sure iconv is available and actually works
73 if (!function_exists('iconv')) {
74 // this should not happen, this must be very borked install
75 echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.';
76 die();
79 if (PHP_INT_SIZE > 4) {
80 // most probably 64bit PHP - we need a lot more memory
81 $minrequiredmemory = '70M';
82 } else {
83 // 32bit PHP
84 $minrequiredmemory = '40M';
86 // increase or decrease available memory - we need to make sure moodle
87 // installs even with low memory, otherwise developers would overlook
88 // sudden increases of memory needs ;-)
89 @ini_set('memory_limit', $minrequiredmemory);
91 /** Used by library scripts to check they are being called by Moodle */
92 define('MOODLE_INTERNAL', true);
94 require_once(__DIR__.'/lib/classes/component.php');
95 require_once(__DIR__.'/lib/installlib.php');
97 // TODO: add lang detection here if empty $_REQUEST['lang']
99 // distro specific customisation
100 $distro = null;
101 if (file_exists('install/distrolib.php')) {
102 require_once('install/distrolib.php');
103 if (function_exists('distro_get_config')) {
104 $distro = distro_get_config();
108 $config = new stdClass();
109 $config->lang = $lang;
111 if (!empty($_POST)) {
112 $config->stage = (int)$_POST['stage'];
114 if (isset($_POST['previous'])) {
115 $config->stage--;
116 if (INSTALL_DATABASETYPE and !empty($distro->dbtype)) {
117 $config->stage--;
119 if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_DOWNLOADLANG) {
120 $config->stage--;
122 } else if (isset($_POST['next'])) {
123 $config->stage++;
126 $config->dbtype = trim($_POST['dbtype']);
127 $config->dbhost = trim($_POST['dbhost']);
128 $config->dbuser = trim($_POST['dbuser']);
129 $config->dbpass = trim($_POST['dbpass']);
130 $config->dbname = trim($_POST['dbname']);
131 $config->prefix = trim($_POST['prefix']);
132 $config->dbport = (int)trim($_POST['dbport']);
133 $config->dbsocket = trim($_POST['dbsocket']);
135 if ($config->dbport <= 0) {
136 $config->dbport = '';
139 $config->admin = empty($_POST['admin']) ? 'admin' : trim($_POST['admin']);
141 $config->dataroot = trim($_POST['dataroot']);
143 } else {
144 $config->stage = INSTALL_WELCOME;
146 $config->dbtype = empty($distro->dbtype) ? '' : $distro->dbtype; // let distro skip dbtype selection
147 $config->dbhost = empty($distro->dbhost) ? 'localhost' : $distro->dbhost; // let distros set dbhost
148 $config->dbuser = empty($distro->dbuser) ? '' : $distro->dbuser; // let distros set dbuser
149 $config->dbpass = '';
150 $config->dbname = 'moodle';
151 $config->prefix = 'mdl_';
152 $config->dbport = empty($distro->dbport) ? '' : $distro->dbport;
153 $config->dbsocket = empty($distro->dbsocket) ? '' : $distro->dbsocket;
155 $config->admin = 'admin';
157 $config->dataroot = empty($distro->dataroot) ? null : $distro->dataroot; // initialised later after including libs or by distro
160 // Fake some settings so that we can use selected functions from moodlelib.php, weblib.php and filelib.php.
161 global $CFG;
162 $CFG = new stdClass();
163 $CFG->lang = $config->lang;
164 $CFG->dirroot = __DIR__;
165 $CFG->libdir = "$CFG->dirroot/lib";
166 $CFG->wwwroot = install_guess_wwwroot(); // can not be changed - ppl must use the real address when installing
167 $CFG->httpswwwroot = $CFG->wwwroot;
168 $CFG->dataroot = $config->dataroot;
169 $CFG->tempdir = $CFG->dataroot.'/temp';
170 $CFG->backuptempdir = $CFG->tempdir.'/backup';
171 $CFG->cachedir = $CFG->dataroot.'/cache';
172 $CFG->localcachedir = $CFG->dataroot.'/localcache';
173 $CFG->admin = $config->admin;
174 $CFG->docroot = 'https://docs.moodle.org';
175 $CFG->langotherroot = $CFG->dataroot.'/lang';
176 $CFG->langlocalroot = $CFG->dataroot.'/lang';
177 $CFG->directorypermissions = isset($distro->directorypermissions) ? $distro->directorypermissions : 00777; // let distros set dir permissions
178 $CFG->filepermissions = ($CFG->directorypermissions & 0666);
179 $CFG->umaskpermissions = (($CFG->directorypermissions & 0777) ^ 0777);
180 $CFG->running_installer = true;
181 $CFG->early_install_lang = true;
182 $CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
183 $CFG->debug = (E_ALL | E_STRICT);
184 $CFG->debugdisplay = true;
185 $CFG->debugdeveloper = true;
187 // Require all needed libs
188 require_once($CFG->libdir.'/setuplib.php');
190 // we need to make sure we have enough memory to load all libraries
191 $memlimit = @ini_get('memory_limit');
192 if (!empty($memlimit) and $memlimit != -1) {
193 if (get_real_size($memlimit) < get_real_size($minrequiredmemory)) {
194 // do NOT localise - lang strings would not work here and we CAN not move it to later place
195 echo "Moodle requires at least {$minrequiredmemory}B of PHP memory.<br />";
196 echo "Please contact server administrator to fix PHP.ini memory settings.";
197 die;
201 // Continue with lib loading
202 require_once($CFG->libdir.'/classes/text.php');
203 require_once($CFG->libdir.'/classes/string_manager.php');
204 require_once($CFG->libdir.'/classes/string_manager_install.php');
205 require_once($CFG->libdir.'/classes/string_manager_standard.php');
206 require_once($CFG->libdir.'/weblib.php');
207 require_once($CFG->libdir.'/outputlib.php');
208 require_once($CFG->libdir.'/dmllib.php');
209 require_once($CFG->libdir.'/moodlelib.php');
210 require_once($CFG->libdir .'/pagelib.php');
211 require_once($CFG->libdir.'/deprecatedlib.php');
212 require_once($CFG->libdir.'/adminlib.php');
213 require_once($CFG->libdir.'/environmentlib.php');
214 require_once($CFG->libdir.'/componentlib.class.php');
215 require_once($CFG->dirroot.'/cache/lib.php');
217 //point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
218 //the problem is that we need specific version of quickforms and hacked excel files :-(
219 ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
221 // Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
222 // Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
223 if (defined('COMPONENT_CLASSLOADER')) {
224 spl_autoload_register(COMPONENT_CLASSLOADER);
225 } else {
226 spl_autoload_register('core_component::classloader');
229 require('version.php');
230 $CFG->target_release = $release;
232 \core\session\manager::init_empty_session();
233 global $SESSION;
234 global $USER;
236 global $COURSE;
237 $COURSE = new stdClass();
238 $COURSE->id = 1;
240 global $SITE;
241 $SITE = $COURSE;
242 define('SITEID', 1);
244 $hint_dataroot = '';
245 $hint_admindir = '';
246 $hint_database = '';
248 // Are we in help mode?
249 if (isset($_GET['help'])) {
250 install_print_help_page($_GET['help']);
253 //first time here? find out suitable dataroot
254 if (is_null($CFG->dataroot)) {
255 $CFG->dataroot = __DIR__.'/../moodledata';
257 $i = 0; //safety check - dirname might return some unexpected results
258 while(is_dataroot_insecure()) {
259 $parrent = dirname($CFG->dataroot);
260 $i++;
261 if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
262 $CFG->dataroot = ''; //can not find secure location for dataroot
263 break;
265 $CFG->dataroot = dirname($parrent).DIRECTORY_SEPARATOR.'moodledata';
267 $config->dataroot = $CFG->dataroot;
268 $config->stage = INSTALL_WELCOME;
271 // now let's do the stage work
272 if ($config->stage < INSTALL_WELCOME) {
273 $config->stage = INSTALL_WELCOME;
275 if ($config->stage > INSTALL_SAVE) {
276 $config->stage = INSTALL_SAVE;
281 if ($config->stage == INSTALL_SAVE) {
282 $CFG->early_install_lang = false;
284 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
285 if (!$database->driver_installed()) {
286 $config->stage = INSTALL_DATABASETYPE;
287 } else {
288 if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
289 $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);
291 $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));
293 if ($hint_database === '') {
294 $configphp = install_generate_configphp($database, $CFG);
296 umask(0137);
297 if (($fh = @fopen($configfile, 'w')) !== false) {
298 fwrite($fh, $configphp);
299 fclose($fh);
302 if (file_exists($configfile)) {
303 // config created, let's continue!
304 redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
307 install_print_header($config, 'config.php',
308 get_string('configurationcompletehead', 'install'),
309 get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install'), 'alert-error');
310 echo '<div class="configphp"><pre>';
311 echo p($configphp);
312 echo '</pre></div>';
314 install_print_footer($config);
315 die;
317 } else {
318 $config->stage = INSTALL_DATABASE;
325 if ($config->stage == INSTALL_DOWNLOADLANG) {
326 if (empty($CFG->dataroot)) {
327 $config->stage = INSTALL_PATHS;
329 } else if (is_dataroot_insecure()) {
330 $hint_dataroot = get_string('pathsunsecuredataroot', 'install');
331 $config->stage = INSTALL_PATHS;
333 } else if (!file_exists($CFG->dataroot)) {
334 $a = new stdClass();
335 $a->parent = dirname($CFG->dataroot);
336 $a->dataroot = $CFG->dataroot;
337 if (!is_writable($a->parent)) {
338 $hint_dataroot = get_string('pathsroparentdataroot', 'install', $a);
339 $config->stage = INSTALL_PATHS;
340 } else {
341 if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
342 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', $a);
343 $config->stage = INSTALL_PATHS;
347 } else if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
348 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', array('dataroot' => $CFG->dataroot));
349 $config->stage = INSTALL_PATHS;
352 if (empty($hint_dataroot) and !is_writable($CFG->dataroot)) {
353 $hint_dataroot = get_string('pathsrodataroot', 'install');
354 $config->stage = INSTALL_PATHS;
357 if ($config->admin === '' or !file_exists($CFG->dirroot.'/'.$config->admin.'/environment.xml')) {
358 $hint_admindir = get_string('pathswrongadmindir', 'install');
359 $config->stage = INSTALL_PATHS;
365 if ($config->stage == INSTALL_DOWNLOADLANG) {
366 // no need to download anything if en lang selected
367 if ($CFG->lang == 'en') {
368 $config->stage = INSTALL_DATABASETYPE;
374 if ($config->stage == INSTALL_DATABASETYPE) {
375 // skip db selection if distro package supports only one db
376 if (!empty($distro->dbtype)) {
377 $config->stage = INSTALL_DATABASE;
382 if ($config->stage == INSTALL_DOWNLOADLANG) {
383 $downloaderror = '';
385 // download and install required lang packs, the lang dir has already been created in install_init_dataroot
386 $installer = new lang_installer($CFG->lang);
387 $results = $installer->run();
388 foreach ($results as $langcode => $langstatus) {
389 if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
390 $a = new stdClass();
391 $a->url = $installer->lang_pack_url($langcode);
392 $a->dest = $CFG->dataroot.'/lang';
393 $downloaderror = get_string('remotedownloaderror', 'error', $a);
397 if ($downloaderror !== '') {
398 install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang), $downloaderror);
399 install_print_footer($config);
400 die;
401 } else {
402 if (empty($distro->dbtype)) {
403 $config->stage = INSTALL_DATABASETYPE;
404 } else {
405 $config->stage = INSTALL_DATABASE;
409 // switch the string_manager instance to stop using install/lang/
410 $CFG->early_install_lang = false;
411 $CFG->langotherroot = $CFG->dataroot.'/lang';
412 $CFG->langlocalroot = $CFG->dataroot.'/lang';
413 get_string_manager(true);
417 if ($config->stage == INSTALL_DATABASE) {
418 $CFG->early_install_lang = false;
420 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
422 $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
424 install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
426 $strdbhost = get_string('databasehost', 'install');
427 $strdbname = get_string('databasename', 'install');
428 $strdbuser = get_string('databaseuser', 'install');
429 $strdbpass = get_string('databasepass', 'install');
430 $strprefix = get_string('dbprefix', 'install');
431 $strdbport = get_string('databaseport', 'install');
432 $strdbsocket = get_string('databasesocket', 'install');
434 echo '<div class="row mb-4">';
436 $disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
437 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbhost">'.$strdbhost.'</label></div>';
438 echo '<div class="col-md-9" data-fieldtype="text">';
439 echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" class="form-control text-ltr" value="'.s($config->dbhost).'" size="50" /></div>';
440 echo '</div>';
442 echo '<div class="row mb-4">';
443 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbname">'.$strdbname.'</label></div>';
444 echo '<div class="col-md-9" data-fieldtype="text">';
445 echo '<input id="id_dbname" name="dbname" type="text" class="form-control text-ltr" value="'.s($config->dbname).'" size="50" /></div>';
446 echo '</div>';
448 $disabled = empty($distro->dbuser) ? '' : 'disabled="disabled';
449 echo '<div class="row mb-4">';
450 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbuser">'.$strdbuser.'</label></div>';
451 echo '<div class="col-md-9" data-fieldtype="text">';
452 echo '<input id="id_dbuser" name="dbuser" '.$disabled.' type="text" class="form-control text-ltr" value="'.s($config->dbuser).'" size="50" /></div>';
453 echo '</div>';
455 echo '<div class="row mb-4">';
456 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbpass">'.$strdbpass.'</label></div>';
457 // no password field here, the password may be visible in config.php if we can not write it to disk
458 echo '<div class="col-md-9" data-fieldtype="text">';
459 echo '<input id="id_dbpass" name="dbpass" type="text" class="form-control text-ltr" value="'.s($config->dbpass).'" size="50" /></div>';
460 echo '</div>';
462 echo '<div class="row mb-4">';
463 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_prefix">'.$strprefix.'</label></div>';
464 echo '<div class="col-md-9" data-fieldtype="text">';
465 echo '<input id="id_prefix" name="prefix" type="text" class="form-control text-ltr" value="'.s($config->prefix).'" size="10" /></div>';
466 echo '</div>';
468 echo '<div class="row mb-4">';
469 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_prefix">'.$strdbport.'</label></div>';
470 echo '<div class="col-md-9" data-fieldtype="text">';
471 echo '<input id="id_dbport" name="dbport" type="text" class="form-control text-ltr" value="'.s($config->dbport).'" size="10" /></div>';
472 echo '</div>';
474 if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
475 echo '<div class="row mb-4">';
476 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbsocket">'.$strdbsocket.'</label></div>';
477 echo '<div class="col-md-9" data-fieldtype="text">';
478 echo '<input id="id_dbsocket" name="dbsocket" type="text" class="form-control text-ltr" value="'.s($config->dbsocket).'" size="50" /></div>';
479 echo '</div>';
482 if ($hint_database !== '') {
483 echo '<div class="alert alert-danger">'.$hint_database.'</div>';
485 echo '</div>';
486 install_print_footer($config);
487 die;
491 if ($config->stage == INSTALL_DATABASETYPE) {
492 $CFG->early_install_lang = false;
494 // Finally ask for DB type
495 install_print_header($config, get_string('database', 'install'),
496 get_string('databasetypehead', 'install'),
497 get_string('databasetypesub', 'install'));
499 $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
500 'auroramysql' => moodle_database::get_driver_instance('auroramysql', 'native'),
501 'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
502 'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
503 'oci' => moodle_database::get_driver_instance('oci', 'native'),
504 'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
507 echo '<div class="row mb-4">';
508 echo '<div class="col-md-3 text-md-right pt-1"><label for="dbtype">'.get_string('dbtype', 'install').'</label></div>';
509 echo '<div class="col-md-9" data-fieldtype="select">';
510 echo '<select class="form-control" id="dbtype" name="dbtype">';
511 $disabled = array();
512 $options = array();
513 foreach ($databases as $type=>$database) {
514 if ($database->driver_installed() !== true) {
515 $disabled[$type] = $database;
516 continue;
518 echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
520 if ($disabled) {
521 echo '<optgroup label="'.s(get_string('notavailable')).'">';
522 foreach ($disabled as $type=>$database) {
523 echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
525 echo '</optgroup>';
527 echo '</select></div></div>';
529 install_print_footer($config);
530 die;
535 if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
536 $curl_fail = ($lang !== 'en' and !extension_loaded('curl')); // needed for lang pack download
537 $zip_fail = ($lang !== 'en' and !extension_loaded('zip')); // needed for lang pack download
539 if ($curl_fail or $zip_fail) {
540 $config->stage = INSTALL_ENVIRONMENT;
542 install_print_header($config, get_string('environmenthead', 'install'),
543 get_string('errorsinenvironment', 'install'),
544 get_string('environmentsub2', 'install'));
546 echo '<div id="envresult"><dl>';
547 if ($curl_fail) {
548 echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
550 if ($zip_fail) {
551 echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
553 echo '</dl></div>';
555 install_print_footer($config, true);
556 die;
558 } else {
559 $config->stage = INSTALL_PATHS;
565 if ($config->stage == INSTALL_PATHS) {
566 $paths = array('wwwroot' => get_string('wwwroot', 'install'),
567 'dirroot' => get_string('dirroot', 'install'),
568 'dataroot' => get_string('dataroot', 'install'));
570 $sub = '<dl>';
571 foreach ($paths as $path=>$name) {
572 $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
574 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
575 $sub .= '<dt>'.get_string('admindirname', 'install').'</dt><dd>'.get_string('pathssubadmindir', 'install').'</dd>';
577 $sub .= '</dl>';
579 install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
581 $strwwwroot = get_string('wwwroot', 'install');
582 $strdirroot = get_string('dirroot', 'install');
583 $strdataroot = get_string('dataroot', 'install');
584 $stradmindirname = get_string('admindirname', 'install');
586 echo '<div class="row mb-4">';
587 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_wwwroot">'.$paths['wwwroot'].'</label></div>';
588 echo '<div class="col-md-9" data-fieldtype="text">';
589 echo '<input id="id_wwwroot" name="wwwroot" type="text" class="form-control text-ltr" value="'.s($CFG->wwwroot).'" 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_dirroot">'.$paths['dirroot'].'</label></div>';
594 echo '<div class="col-md-9" data-fieldtype="text">';
595 echo '<input id="id_dirroot" name="dirroot" type="text" class="form-control text-ltr" value="'.s($CFG->dirroot).'" disabled="disabled" size="70" /></div>';
596 echo '</div>';
598 echo '<div class="row mb-4">';
599 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dataroot">'.$paths['dataroot'].'</label></div>';
600 echo '<div class="col-md-9" data-fieldtype="text">';
601 echo '<input id="id_dataroot" name="dataroot" type="text" class="form-control text-ltr" value="'.s($config->dataroot).'" size="70" /></div>';
602 echo '</div>';
603 if ($hint_dataroot !== '') {
604 echo '<div class="alert alert-danger">'.$hint_dataroot.'</div>';
608 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
609 echo '<div class="row mb-4">';
610 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_admin">'.$paths['admindir'].'</label></div>';
611 echo '<div class="col-md-9" data-fieldtype="text">';
612 echo '<input id="id_admin" name="admin" type="text" class="form-control text-ltr" value="'.s($config->admin).'" size="10" /></div>';
613 echo '</div>';
614 if ($hint_admindir !== '') {
615 echo '<div class="alert alert-danger">'.$hint_admindir.'</div>';
617 echo '</div>';
620 echo '</div>';
622 install_print_footer($config);
623 die;
628 $config->stage = INSTALL_WELCOME;
630 if ($distro) {
631 ob_start();
632 include('install/distribution.html');
633 $sub = ob_get_clean();
635 install_print_header($config, get_string('language'),
636 get_string('chooselanguagehead', 'install'),
637 $sub, 'alert-success');
639 } else {
640 install_print_header($config, get_string('language'),
641 get_string('chooselanguagehead', 'install'),
642 get_string('chooselanguagesub', 'install'));
645 $languages = get_string_manager()->get_list_of_translations();
646 echo '<div class="row mb-4">';
647 echo '<div class="col-md-3 text-md-right pt-1"><label for="langselect">'.get_string('language').'</label></div>';
648 echo '<div class="col-md-9" data-fieldtype="select">';
649 echo '<select id="langselect" class="form-control" name="lang" onchange="this.form.submit()">';
650 foreach ($languages as $name=>$value) {
651 $selected = ($name == $CFG->lang) ? 'selected="selected"' : '';
652 echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
654 echo '</select></div>';
655 echo '</div>';
657 install_print_footer($config);
658 die;