3 // This file is part of Moodle - http://moodle.org/
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.
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/>.
19 * This script creates config.php file during installation.
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']);
33 if (isset($_REQUEST['admin'])) {
34 $admin = preg_replace('/[^A-Za-z0-9_-]/i', '', $_REQUEST['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");
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.");
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.';
79 if (PHP_INT_SIZE
> 4) {
80 // most probably 64bit PHP - we need a lot more memory
81 $minrequiredmemory = '70M';
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
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'])) {
116 if (INSTALL_DATABASETYPE
and !empty($distro->dbtype
)) {
119 if ($config->stage
== INSTALL_ENVIRONMENT
or $config->stage
== INSTALL_DOWNLOADLANG
) {
122 } else if (isset($_POST['next'])) {
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']);
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.
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.";
201 // Point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
202 // the problem is that we need specific version of quickforms and hacked excel files :-(.
203 ini_set('include_path', $CFG->libdir
.'/pear' . PATH_SEPARATOR
. ini_get('include_path'));
205 // Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
206 if (defined('COMPONENT_CLASSLOADER')) {
207 spl_autoload_register(COMPONENT_CLASSLOADER
);
209 spl_autoload_register('core_component::classloader');
212 // Continue with lib loading.
213 require_once($CFG->libdir
.'/classes/text.php');
214 require_once($CFG->libdir
.'/classes/string_manager.php');
215 require_once($CFG->libdir
.'/classes/string_manager_install.php');
216 require_once($CFG->libdir
.'/classes/string_manager_standard.php');
217 require_once($CFG->libdir
.'/weblib.php');
218 require_once($CFG->libdir
.'/outputlib.php');
219 require_once($CFG->libdir
.'/dmllib.php');
220 require_once($CFG->libdir
.'/moodlelib.php');
221 require_once($CFG->libdir
.'/pagelib.php');
222 require_once($CFG->libdir
.'/deprecatedlib.php');
223 require_once($CFG->libdir
.'/adminlib.php');
224 require_once($CFG->libdir
.'/environmentlib.php');
225 require_once($CFG->libdir
.'/componentlib.class.php');
226 require_once($CFG->dirroot
.'/cache/lib.php');
228 require('version.php');
229 $CFG->target_release
= $release;
231 \core\session\manager
::init_empty_session();
236 $COURSE = new stdClass();
247 // Are we in help mode?
248 if (isset($_GET['help'])) {
249 install_print_help_page($_GET['help']);
252 //first time here? find out suitable dataroot
253 if (is_null($CFG->dataroot
)) {
254 $CFG->dataroot
= __DIR__
.'/../moodledata';
256 $i = 0; //safety check - dirname might return some unexpected results
257 while(is_dataroot_insecure()) {
258 $parrent = dirname($CFG->dataroot
);
260 if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
261 $CFG->dataroot
= ''; //can not find secure location for dataroot
264 $CFG->dataroot
= dirname($parrent).DIRECTORY_SEPARATOR
.'moodledata';
266 $config->dataroot
= $CFG->dataroot
;
267 $config->stage
= INSTALL_WELCOME
;
270 // now let's do the stage work
271 if ($config->stage
< INSTALL_WELCOME
) {
272 $config->stage
= INSTALL_WELCOME
;
274 if ($config->stage
> INSTALL_SAVE
) {
275 $config->stage
= INSTALL_SAVE
;
280 if ($config->stage
== INSTALL_SAVE
) {
281 $CFG->early_install_lang
= false;
283 $database = moodle_database
::get_driver_instance($config->dbtype
, 'native');
284 if (!$database->driver_installed()) {
285 $config->stage
= INSTALL_DATABASETYPE
;
287 if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
288 $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);
290 $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
));
292 if ($hint_database === '') {
293 $configphp = install_generate_configphp($database, $CFG);
296 if (($fh = @fopen
($configfile, 'w')) !== false) {
297 fwrite($fh, $configphp);
301 if (file_exists($configfile)) {
302 // config created, let's continue!
303 redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
306 install_print_header($config, 'config.php',
307 get_string('configurationcompletehead', 'install'),
308 get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install'), 'alert-error');
309 echo '<div class="configphp"><pre>';
313 install_print_footer($config);
317 $config->stage
= INSTALL_DATABASE
;
324 if ($config->stage
== INSTALL_DOWNLOADLANG
) {
325 if (empty($CFG->dataroot
)) {
326 $config->stage
= INSTALL_PATHS
;
328 } else if (is_dataroot_insecure()) {
329 $hint_dataroot = get_string('pathsunsecuredataroot', 'install');
330 $config->stage
= INSTALL_PATHS
;
332 } else if (!file_exists($CFG->dataroot
)) {
334 $a->parent
= dirname($CFG->dataroot
);
335 $a->dataroot
= $CFG->dataroot
;
336 if (!is_writable($a->parent
)) {
337 $hint_dataroot = get_string('pathsroparentdataroot', 'install', $a);
338 $config->stage
= INSTALL_PATHS
;
340 if (!install_init_dataroot($CFG->dataroot
, $CFG->directorypermissions
)) {
341 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', $a);
342 $config->stage
= INSTALL_PATHS
;
346 } else if (!install_init_dataroot($CFG->dataroot
, $CFG->directorypermissions
)) {
347 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', array('dataroot' => $CFG->dataroot
));
348 $config->stage
= INSTALL_PATHS
;
351 if (empty($hint_dataroot) and !is_writable($CFG->dataroot
)) {
352 $hint_dataroot = get_string('pathsrodataroot', 'install');
353 $config->stage
= INSTALL_PATHS
;
356 if ($config->admin
=== '' or !file_exists($CFG->dirroot
.'/'.$config->admin
.'/environment.xml')) {
357 $hint_admindir = get_string('pathswrongadmindir', 'install');
358 $config->stage
= INSTALL_PATHS
;
364 if ($config->stage
== INSTALL_DOWNLOADLANG
) {
365 // no need to download anything if en lang selected
366 if ($CFG->lang
== 'en') {
367 $config->stage
= INSTALL_DATABASETYPE
;
373 if ($config->stage
== INSTALL_DATABASETYPE
) {
374 // skip db selection if distro package supports only one db
375 if (!empty($distro->dbtype
)) {
376 $config->stage
= INSTALL_DATABASE
;
381 if ($config->stage
== INSTALL_DOWNLOADLANG
) {
384 // download and install required lang packs, the lang dir has already been created in install_init_dataroot
385 $installer = new lang_installer($CFG->lang
);
386 $results = $installer->run();
387 foreach ($results as $langcode => $langstatus) {
388 if ($langstatus === lang_installer
::RESULT_DOWNLOADERROR
) {
390 $a->url
= $installer->lang_pack_url($langcode);
391 $a->dest
= $CFG->dataroot
.'/lang';
392 $downloaderror = get_string('remotedownloaderror', 'error', $a);
396 if ($downloaderror !== '') {
397 install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang
), $downloaderror);
398 install_print_footer($config);
401 if (empty($distro->dbtype
)) {
402 $config->stage
= INSTALL_DATABASETYPE
;
404 $config->stage
= INSTALL_DATABASE
;
408 // switch the string_manager instance to stop using install/lang/
409 $CFG->early_install_lang
= false;
410 $CFG->langotherroot
= $CFG->dataroot
.'/lang';
411 $CFG->langlocalroot
= $CFG->dataroot
.'/lang';
412 get_string_manager(true);
416 if ($config->stage
== INSTALL_DATABASE
) {
417 $CFG->early_install_lang
= false;
419 $database = moodle_database
::get_driver_instance($config->dbtype
, 'native');
421 $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
423 install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
425 $strdbhost = get_string('databasehost', 'install');
426 $strdbname = get_string('databasename', 'install');
427 $strdbuser = get_string('databaseuser', 'install');
428 $strdbpass = get_string('databasepass', 'install');
429 $strprefix = get_string('dbprefix', 'install');
430 $strdbport = get_string('databaseport', 'install');
431 $strdbsocket = get_string('databasesocket', 'install');
433 echo '<div class="row mb-4">';
435 $disabled = empty($distro->dbhost
) ?
'' : 'disabled="disabled';
436 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbhost">'.$strdbhost.'</label></div>';
437 echo '<div class="col-md-9" data-fieldtype="text">';
438 echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" class="form-control text-ltr" value="'.s($config->dbhost
).'" size="50" /></div>';
441 echo '<div class="row mb-4">';
442 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbname">'.$strdbname.'</label></div>';
443 echo '<div class="col-md-9" data-fieldtype="text">';
444 echo '<input id="id_dbname" name="dbname" type="text" class="form-control text-ltr" value="'.s($config->dbname
).'" size="50" /></div>';
447 $disabled = empty($distro->dbuser
) ?
'' : 'disabled="disabled';
448 echo '<div class="row mb-4">';
449 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbuser">'.$strdbuser.'</label></div>';
450 echo '<div class="col-md-9" data-fieldtype="text">';
451 echo '<input id="id_dbuser" name="dbuser" '.$disabled.' type="text" class="form-control text-ltr" value="'.s($config->dbuser
).'" size="50" /></div>';
454 echo '<div class="row mb-4">';
455 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbpass">'.$strdbpass.'</label></div>';
456 // no password field here, the password may be visible in config.php if we can not write it to disk
457 echo '<div class="col-md-9" data-fieldtype="text">';
458 echo '<input id="id_dbpass" name="dbpass" type="text" class="form-control text-ltr" value="'.s($config->dbpass
).'" size="50" /></div>';
461 echo '<div class="row mb-4">';
462 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_prefix">'.$strprefix.'</label></div>';
463 echo '<div class="col-md-9" data-fieldtype="text">';
464 echo '<input id="id_prefix" name="prefix" type="text" class="form-control text-ltr" value="'.s($config->prefix
).'" size="10" /></div>';
467 echo '<div class="row mb-4">';
468 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_prefix">'.$strdbport.'</label></div>';
469 echo '<div class="col-md-9" data-fieldtype="text">';
470 echo '<input id="id_dbport" name="dbport" type="text" class="form-control text-ltr" value="'.s($config->dbport
).'" size="10" /></div>';
473 if (!(stristr(PHP_OS
, 'win') && !stristr(PHP_OS
, 'darwin'))) {
474 echo '<div class="row mb-4">';
475 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dbsocket">'.$strdbsocket.'</label></div>';
476 echo '<div class="col-md-9" data-fieldtype="text">';
477 echo '<input id="id_dbsocket" name="dbsocket" type="text" class="form-control text-ltr" value="'.s($config->dbsocket
).'" size="50" /></div>';
481 if ($hint_database !== '') {
482 echo '<div class="alert alert-danger">'.$hint_database.'</div>';
485 install_print_footer($config);
490 if ($config->stage
== INSTALL_DATABASETYPE
) {
491 $CFG->early_install_lang
= false;
493 // Finally ask for DB type
494 install_print_header($config, get_string('database', 'install'),
495 get_string('databasetypehead', 'install'),
496 get_string('databasetypesub', 'install'));
498 $databases = array('mysqli' => moodle_database
::get_driver_instance('mysqli', 'native'),
499 'auroramysql' => moodle_database
::get_driver_instance('auroramysql', 'native'),
500 'mariadb'=> moodle_database
::get_driver_instance('mariadb', 'native'),
501 'pgsql' => moodle_database
::get_driver_instance('pgsql', 'native'),
502 'oci' => moodle_database
::get_driver_instance('oci', 'native'),
503 'sqlsrv' => moodle_database
::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
506 echo '<div class="row mb-4">';
507 echo '<div class="col-md-3 text-md-right pt-1"><label for="dbtype">'.get_string('dbtype', 'install').'</label></div>';
508 echo '<div class="col-md-9" data-fieldtype="select">';
509 echo '<select class="form-control" id="dbtype" name="dbtype">';
512 foreach ($databases as $type=>$database) {
513 if ($database->driver_installed() !== true) {
514 $disabled[$type] = $database;
517 echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
520 echo '<optgroup label="'.s(get_string('notavailable')).'">';
521 foreach ($disabled as $type=>$database) {
522 echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
526 echo '</select></div></div>';
528 install_print_footer($config);
534 if ($config->stage
== INSTALL_ENVIRONMENT
or $config->stage
== INSTALL_PATHS
) {
535 $curl_fail = ($lang !== 'en' and !extension_loaded('curl')); // needed for lang pack download
536 $zip_fail = ($lang !== 'en' and !extension_loaded('zip')); // needed for lang pack download
538 if ($curl_fail or $zip_fail) {
539 $config->stage
= INSTALL_ENVIRONMENT
;
541 install_print_header($config, get_string('environmenthead', 'install'),
542 get_string('errorsinenvironment', 'install'),
543 get_string('environmentsub2', 'install'));
545 echo '<div id="envresult"><dl>';
547 echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
550 echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
554 install_print_footer($config, true);
558 $config->stage
= INSTALL_PATHS
;
564 if ($config->stage
== INSTALL_PATHS
) {
565 $paths = array('wwwroot' => get_string('wwwroot', 'install'),
566 'dirroot' => get_string('dirroot', 'install'),
567 'dataroot' => get_string('dataroot', 'install'));
570 foreach ($paths as $path=>$name) {
571 $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
573 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
574 $sub .= '<dt>'.get_string('admindirname', 'install').'</dt><dd>'.get_string('pathssubadmindir', 'install').'</dd>';
578 install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
580 $strwwwroot = get_string('wwwroot', 'install');
581 $strdirroot = get_string('dirroot', 'install');
582 $strdataroot = get_string('dataroot', 'install');
583 $stradmindirname = get_string('admindirname', 'install');
585 echo '<div class="row mb-4">';
586 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_wwwroot">'.$paths['wwwroot'].'</label></div>';
587 echo '<div class="col-md-9" data-fieldtype="text">';
588 echo '<input id="id_wwwroot" name="wwwroot" type="text" class="form-control text-ltr" value="'.s($CFG->wwwroot
).'" disabled="disabled" size="70" /></div>';
591 echo '<div class="row mb-4">';
592 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dirroot">'.$paths['dirroot'].'</label></div>';
593 echo '<div class="col-md-9" data-fieldtype="text">';
594 echo '<input id="id_dirroot" name="dirroot" type="text" class="form-control text-ltr" value="'.s($CFG->dirroot
).'" disabled="disabled" size="70" /></div>';
597 echo '<div class="row mb-4">';
598 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_dataroot">'.$paths['dataroot'].'</label></div>';
599 echo '<div class="col-md-9" data-fieldtype="text">';
600 echo '<input id="id_dataroot" name="dataroot" type="text" class="form-control text-ltr" value="'.s($config->dataroot
).'" size="70" /></div>';
602 if ($hint_dataroot !== '') {
603 echo '<div class="alert alert-danger">'.$hint_dataroot.'</div>';
607 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
608 echo '<div class="row mb-4">';
609 echo '<div class="col-md-3 text-md-right pt-1"><label for="id_admin">'.$paths['admindir'].'</label></div>';
610 echo '<div class="col-md-9" data-fieldtype="text">';
611 echo '<input id="id_admin" name="admin" type="text" class="form-control text-ltr" value="'.s($config->admin
).'" size="10" /></div>';
613 if ($hint_admindir !== '') {
614 echo '<div class="alert alert-danger">'.$hint_admindir.'</div>';
618 install_print_footer($config);
624 $config->stage
= INSTALL_WELCOME
;
628 include('install/distribution.html');
629 $sub = ob_get_clean();
631 install_print_header($config, get_string('language'),
632 get_string('chooselanguagehead', 'install'),
633 $sub, 'alert-success');
636 install_print_header($config, get_string('language'),
637 get_string('chooselanguagehead', 'install'),
638 get_string('chooselanguagesub', 'install'));
641 $languages = get_string_manager()->get_list_of_translations();
642 echo '<div class="row mb-4">';
643 echo '<div class="col-md-3 text-md-right pt-1"><label for="langselect">'.get_string('language').'</label></div>';
644 echo '<div class="col-md-9" data-fieldtype="select">';
645 echo '<select id="langselect" class="form-control" name="lang" onchange="this.form.submit()">';
646 foreach ($languages as $name=>$value) {
647 $selected = ($name == $CFG->lang
) ?
'selected="selected"' : '';
648 echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
650 echo '</select></div>';
653 install_print_footer($config);