MDL-41304: Hide and handle LDAP error when user not in context being checked
[moodle.git] / install.php
blob7b5fa23967776460414530c1b4aad797cfffa1ff
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);
52 // Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
53 // This is a quick hack. Ideally we should ask the admin for a value. See MDL-22625 for more on this.
54 if (function_exists('date_default_timezone_set') and function_exists('date_default_timezone_get')) {
55 @date_default_timezone_set(@date_default_timezone_get());
58 // make sure PHP errors are displayed - helps with diagnosing of problems
59 @error_reporting(E_ALL);
60 @ini_set('display_errors', '1');
62 // Check that PHP is of a sufficient version.
63 if (version_compare(phpversion(), '5.3.3') < 0) {
64 $phpversion = phpversion();
65 // do NOT localise - lang strings would not work here and we CAN not move it after installib
66 echo "Moodle 2.5 or later requires at least PHP 5.3.3 (currently using version $phpversion).<br />";
67 echo "Please upgrade your server software or install older Moodle version.";
68 die;
71 // make sure iconv is available and actually works
72 if (!function_exists('iconv')) {
73 // this should not happen, this must be very borked install
74 echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.';
75 die();
78 if (PHP_INT_SIZE > 4) {
79 // most probably 64bit PHP - we need a lot more memory
80 $minrequiredmemory = '70M';
81 } else {
82 // 32bit PHP
83 $minrequiredmemory = '40M';
85 // increase or decrease available memory - we need to make sure moodle
86 // installs even with low memory, otherwise developers would overlook
87 // sudden increases of memory needs ;-)
88 @ini_set('memory_limit', $minrequiredmemory);
90 /** Used by library scripts to check they are being called by Moodle */
91 define('MOODLE_INTERNAL', true);
93 require_once(__DIR__.'/lib/classes/component.php');
94 require_once(__DIR__.'/lib/installlib.php');
96 // TODO: add lang detection here if empty $_REQUEST['lang']
98 // distro specific customisation
99 $distro = null;
100 if (file_exists('install/distrolib.php')) {
101 require_once('install/distrolib.php');
102 if (function_exists('distro_get_config')) {
103 $distro = distro_get_config();
107 $config = new stdClass();
108 $config->lang = $lang;
110 if (!empty($_POST)) {
111 if (install_ini_get_bool('magic_quotes_gpc')) {
112 $_POST = array_map('stripslashes', $_POST);
115 $config->stage = (int)$_POST['stage'];
117 if (isset($_POST['previous'])) {
118 $config->stage--;
119 if (INSTALL_DATABASETYPE and !empty($distro->dbtype)) {
120 $config->stage--;
122 if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_DOWNLOADLANG) {
123 $config->stage--;
125 } else if (isset($_POST['next'])) {
126 $config->stage++;
129 $config->dbtype = trim($_POST['dbtype']);
130 $config->dbhost = trim($_POST['dbhost']);
131 $config->dbuser = trim($_POST['dbuser']);
132 $config->dbpass = trim($_POST['dbpass']);
133 $config->dbname = trim($_POST['dbname']);
134 $config->prefix = trim($_POST['prefix']);
135 $config->dbport = (int)trim($_POST['dbport']);
136 $config->dbsocket = trim($_POST['dbsocket']);
138 if ($config->dbport <= 0) {
139 $config->dbport = '';
142 $config->admin = empty($_POST['admin']) ? 'admin' : trim($_POST['admin']);
144 $config->dataroot = trim($_POST['dataroot']);
146 } else {
147 $config->stage = INSTALL_WELCOME;
149 $config->dbtype = empty($distro->dbtype) ? '' : $distro->dbtype; // let distro skip dbtype selection
150 $config->dbhost = empty($distro->dbhost) ? 'localhost' : $distro->dbhost; // let distros set dbhost
151 $config->dbuser = empty($distro->dbuser) ? '' : $distro->dbuser; // let distros set dbuser
152 $config->dbpass = '';
153 $config->dbname = 'moodle';
154 $config->prefix = 'mdl_';
155 $config->dbport = empty($distro->dbport) ? '' : $distro->dbport;
156 $config->dbsocket = empty($distro->dbsocket) ? '' : $distro->dbsocket;
158 $config->admin = 'admin';
160 $config->dataroot = empty($distro->dataroot) ? null : $distro->dataroot; // initialised later after including libs or by distro
163 // Fake some settings so that we can use selected functions from moodlelib.php, weblib.php and filelib.php.
164 $CFG = new stdClass();
165 $CFG->lang = $config->lang;
166 $CFG->dirroot = dirname(__FILE__);
167 $CFG->libdir = "$CFG->dirroot/lib";
168 $CFG->wwwroot = install_guess_wwwroot(); // can not be changed - ppl must use the real address when installing
169 $CFG->httpswwwroot = $CFG->wwwroot;
170 $CFG->dataroot = $config->dataroot;
171 $CFG->tempdir = $CFG->dataroot.'/temp';
172 $CFG->cachedir = $CFG->dataroot.'/cache';
173 $CFG->localcachedir = $CFG->dataroot.'/localcache';
174 $CFG->admin = $config->admin;
175 $CFG->docroot = 'http://docs.moodle.org';
176 $CFG->langotherroot = $CFG->dataroot.'/lang';
177 $CFG->langlocalroot = $CFG->dataroot.'/lang';
178 $CFG->directorypermissions = isset($distro->directorypermissions) ? $distro->directorypermissions : 00777; // let distros set dir permissions
179 $CFG->filepermissions = ($CFG->directorypermissions & 0666);
180 $CFG->umaskpermissions = (($CFG->directorypermissions & 0777) ^ 0777);
181 $CFG->running_installer = true;
182 $CFG->early_install_lang = true;
183 $CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
185 // Require all needed libs
186 require_once($CFG->libdir.'/setuplib.php');
188 // we need to make sure we have enough memory to load all libraries
189 $memlimit = @ini_get('memory_limit');
190 if (!empty($memlimit) and $memlimit != -1) {
191 if (get_real_size($memlimit) < get_real_size($minrequiredmemory)) {
192 // do NOT localise - lang strings would not work here and we CAN not move it to later place
193 echo "Moodle requires at least {$minrequiredmemory}B of PHP memory.<br />";
194 echo "Please contact server administrator to fix PHP.ini memory settings.";
195 die;
199 // Continue with lib loading
200 require_once($CFG->libdir.'/classes/text.php');
201 require_once($CFG->libdir.'/classes/string_manager.php');
202 require_once($CFG->libdir.'/classes/string_manager_install.php');
203 require_once($CFG->libdir.'/classes/string_manager_standard.php');
204 require_once($CFG->libdir.'/weblib.php');
205 require_once($CFG->libdir.'/outputlib.php');
206 require_once($CFG->libdir.'/dmllib.php');
207 require_once($CFG->libdir.'/moodlelib.php');
208 require_once($CFG->libdir .'/pagelib.php');
209 require_once($CFG->libdir.'/deprecatedlib.php');
210 require_once($CFG->libdir.'/adminlib.php');
211 require_once($CFG->libdir.'/environmentlib.php');
212 require_once($CFG->libdir.'/componentlib.class.php');
213 require_once($CFG->dirroot.'/cache/lib.php');
215 //point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
216 //the problem is that we need specific version of quickforms and hacked excel files :-(
217 ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
218 //point zend include path to moodles lib/zend so that includes and requires will search there for files before anywhere else
219 ini_set('include_path', $CFG->libdir.'/zend' . PATH_SEPARATOR . ini_get('include_path'));
221 require('version.php');
222 $CFG->target_release = $release;
224 $SESSION = new stdClass();
225 $SESSION->lang = $CFG->lang;
227 $USER = new stdClass();
228 $USER->id = 0;
230 $COURSE = new stdClass();
231 $COURSE->id = 0;
233 $SITE = $COURSE;
234 define('SITEID', 0);
236 $hint_dataroot = '';
237 $hint_admindir = '';
238 $hint_database = '';
240 // Are we in help mode?
241 if (isset($_GET['help'])) {
242 install_print_help_page($_GET['help']);
245 //first time here? find out suitable dataroot
246 if (is_null($CFG->dataroot)) {
247 $CFG->dataroot = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'moodledata';
249 $i = 0; //safety check - dirname might return some unexpected results
250 while(is_dataroot_insecure()) {
251 $parrent = dirname($CFG->dataroot);
252 $i++;
253 if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
254 $CFG->dataroot = ''; //can not find secure location for dataroot
255 break;
257 $CFG->dataroot = dirname($parrent).DIRECTORY_SEPARATOR.'moodledata';
259 $config->dataroot = $CFG->dataroot;
260 $config->stage = INSTALL_WELCOME;
263 // now let's do the stage work
264 if ($config->stage < INSTALL_WELCOME) {
265 $config->stage = INSTALL_WELCOME;
267 if ($config->stage > INSTALL_SAVE) {
268 $config->stage = INSTALL_SAVE;
273 if ($config->stage == INSTALL_SAVE) {
274 $CFG->early_install_lang = false;
276 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
277 if (!$database->driver_installed()) {
278 $config->stage = INSTALL_DATABASETYPE;
279 } else {
280 if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
281 $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);
283 $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));
285 if ($hint_database === '') {
286 $configphp = install_generate_configphp($database, $CFG);
288 umask(0137);
289 if (($fh = @fopen($configfile, 'w')) !== false) {
290 fwrite($fh, $configphp);
291 fclose($fh);
294 if (file_exists($configfile)) {
295 // config created, let's continue!
296 redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
299 install_print_header($config, 'config.php',
300 get_string('configurationcompletehead', 'install'),
301 get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install'));
302 echo '<div class="configphp"><pre>';
303 echo p($configphp);
304 echo '</pre></div>';
306 install_print_footer($config);
307 die;
309 } else {
310 $config->stage = INSTALL_DATABASE;
317 if ($config->stage == INSTALL_DOWNLOADLANG) {
318 if (empty($CFG->dataroot)) {
319 $config->stage = INSTALL_PATHS;
321 } else if (is_dataroot_insecure()) {
322 $hint_dataroot = get_string('pathsunsecuredataroot', 'install');
323 $config->stage = INSTALL_PATHS;
325 } else if (!file_exists($CFG->dataroot)) {
326 $a = new stdClass();
327 $a->parent = dirname($CFG->dataroot);
328 $a->dataroot = $CFG->dataroot;
329 if (!is_writable($a->parent)) {
330 $hint_dataroot = get_string('pathsroparentdataroot', 'install', $a);
331 $config->stage = INSTALL_PATHS;
332 } else {
333 if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
334 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', $a);
335 $config->stage = INSTALL_PATHS;
339 } else if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
340 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', array('dataroot' => $CFG->dataroot));
341 $config->stage = INSTALL_PATHS;
344 if (empty($hint_dataroot) and !is_writable($CFG->dataroot)) {
345 $hint_dataroot = get_string('pathsrodataroot', 'install');
346 $config->stage = INSTALL_PATHS;
349 if ($config->admin === '' or !file_exists($CFG->dirroot.'/'.$config->admin.'/environment.xml')) {
350 $hint_admindir = get_string('pathswrongadmindir', 'install');
351 $config->stage = INSTALL_PATHS;
357 if ($config->stage == INSTALL_DOWNLOADLANG) {
358 // no need to download anything if en lang selected
359 if ($CFG->lang == 'en') {
360 $config->stage = INSTALL_DATABASETYPE;
366 if ($config->stage == INSTALL_DATABASETYPE) {
367 // skip db selection if distro package supports only one db
368 if (!empty($distro->dbtype)) {
369 $config->stage = INSTALL_DATABASE;
374 if ($config->stage == INSTALL_DOWNLOADLANG) {
375 $downloaderror = '';
377 // download and install required lang packs, the lang dir has already been created in install_init_dataroot
378 $installer = new lang_installer($CFG->lang);
379 $results = $installer->run();
380 foreach ($results as $langcode => $langstatus) {
381 if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
382 $a = new stdClass();
383 $a->url = $installer->lang_pack_url($langcode);
384 $a->dest = $CFG->dataroot.'/lang';
385 $downloaderror = get_string('remotedownloaderror', 'error', $a);
389 if ($downloaderror !== '') {
390 install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang), $downloaderror);
391 install_print_footer($config);
392 die;
393 } else {
394 if (empty($distro->dbtype)) {
395 $config->stage = INSTALL_DATABASETYPE;
396 } else {
397 $config->stage = INSTALL_DATABASE;
401 // switch the string_manager instance to stop using install/lang/
402 $CFG->early_install_lang = false;
403 $CFG->langotherroot = $CFG->dataroot.'/lang';
404 $CFG->langlocalroot = $CFG->dataroot.'/lang';
405 get_string_manager(true);
409 if ($config->stage == INSTALL_DATABASE) {
410 $CFG->early_install_lang = false;
412 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
414 $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
416 install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
418 $strdbhost = get_string('databasehost', 'install');
419 $strdbname = get_string('databasename', 'install');
420 $strdbuser = get_string('databaseuser', 'install');
421 $strdbpass = get_string('databasepass', 'install');
422 $strprefix = get_string('dbprefix', 'install');
423 $strdbport = get_string('databaseport', 'install');
424 $strdbsocket = get_string('databasesocket', 'install');
426 echo '<div class="userinput">';
428 $disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
429 echo '<div class="formrow"><label for="id_dbhost" class="formlabel">'.$strdbhost.'</label>';
430 echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="50" class="forminput" />';
431 echo '</div>';
433 echo '<div class="formrow"><label for="id_dbname" class="formlabel">'.$strdbname.'</label>';
434 echo '<input id="id_dbname" name="dbname" type="text" value="'.s($config->dbname).'" size="50" class="forminput" />';
435 echo '</div>';
437 $disabled = empty($distro->dbuser) ? '' : 'disabled="disabled';
438 echo '<div class="formrow"><label for="id_dbuser" class="formlabel">'.$strdbuser.'</label>';
439 echo '<input id="id_dbuser" name="dbuser" '.$disabled.' type="text" value="'.s($config->dbuser).'" size="50" class="forminput" />';
440 echo '</div>';
442 echo '<div class="formrow"><label for="id_dbpass" class="formlabel">'.$strdbpass.'</label>';
443 // no password field here, the password may be visible in config.php if we can not write it to disk
444 echo '<input id="id_dbpass" name="dbpass" type="text" value="'.s($config->dbpass).'" size="50" class="forminput" />';
445 echo '</div>';
447 echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strprefix.'</label>';
448 echo '<input id="id_prefix" name="prefix" type="text" value="'.s($config->prefix).'" size="10" class="forminput" />';
449 echo '</div>';
451 echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strdbport.'</label>';
452 echo '<input id="id_dbport" name="dbport" type="text" value="'.s($config->dbport).'" size="10" class="forminput" />';
453 echo '</div>';
455 if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
456 echo '<div class="formrow"><label for="id_dbsocket" class="formlabel">'.$strdbsocket.'</label>';
457 echo '<input id="id_dbsocket" name="dbsocket" type="text" value="'.s($config->dbsocket).'" size="50" class="forminput" />';
458 echo '</div>';
461 echo '<div class="hint">'.$hint_database.'</div>';
462 echo '</div>';
463 install_print_footer($config);
464 die;
468 if ($config->stage == INSTALL_DATABASETYPE) {
469 $CFG->early_install_lang = false;
471 // Finally ask for DB type
472 install_print_header($config, get_string('database', 'install'),
473 get_string('databasetypehead', 'install'),
474 get_string('databasetypesub', 'install'));
476 $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
477 'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
478 'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
479 'oci' => moodle_database::get_driver_instance('oci', 'native'),
480 'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
481 'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
484 echo '<div class="userinput">';
485 echo '<div class="formrow"><label class="formlabel" for="dbtype">'.get_string('dbtype', 'install').'</label>';
486 echo '<select id="dbtype" name="dbtype" class="forminput">';
487 $disabled = array();
488 $options = array();
489 foreach ($databases as $type=>$database) {
490 if ($database->driver_installed() !== true) {
491 $disabled[$type] = $database;
492 continue;
494 echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
496 if ($disabled) {
497 echo '<optgroup label="'.s(get_string('notavailable')).'">';
498 foreach ($disabled as $type=>$database) {
499 echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
501 echo '</optgroup>';
503 echo '</select></div>';
504 echo '</div>';
506 install_print_footer($config);
507 die;
512 if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
513 $version_fail = (version_compare(phpversion(), "5.3.3") < 0);
514 $curl_fail = ($lang !== 'en' and !extension_loaded('curl')); // needed for lang pack download
515 $zip_fail = ($lang !== 'en' and !extension_loaded('zip')); // needed for lang pack download
517 if ($version_fail or $curl_fail or $zip_fail) {
518 $config->stage = INSTALL_ENVIRONMENT;
520 install_print_header($config, get_string('environmenthead', 'install'),
521 get_string('errorsinenvironment', 'install'),
522 get_string('environmentsub2', 'install'));
524 echo '<div id="envresult"><dl>';
525 if ($version_fail) {
526 $a = (object)array('needed'=>'5.3.3', 'current'=>phpversion());
527 echo '<dt>'.get_string('phpversion', 'install').'</dt><dd>'.get_string('environmentrequireversion', 'admin', $a).'</dd>';
529 if ($curl_fail) {
530 echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
532 if ($zip_fail) {
533 echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
535 echo '</dl></div>';
537 install_print_footer($config, true);
538 die;
540 } else {
541 $config->stage = INSTALL_PATHS;
547 if ($config->stage == INSTALL_PATHS) {
548 $paths = array('wwwroot' => get_string('wwwroot', 'install'),
549 'dirroot' => get_string('dirroot', 'install'),
550 'dataroot' => get_string('dataroot', 'install'));
552 $sub = '<dl>';
553 foreach ($paths as $path=>$name) {
554 $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
556 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
557 $sub .= '<dt>'.get_string('admindirname', 'install').'</dt><dd>'.get_string('pathssubadmindir', 'install').'</dd>';
559 $sub .= '</dl>';
561 install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
563 $strwwwroot = get_string('wwwroot', 'install');
564 $strdirroot = get_string('dirroot', 'install');
565 $strdataroot = get_string('dataroot', 'install');
566 $stradmindirname = get_string('admindirname', 'install');
568 echo '<div class="userinput">';
569 echo '<div class="formrow"><label for="id_wwwroot" class="formlabel">'.$paths['wwwroot'].'</label>';
570 echo '<input id="id_wwwroot" name="wwwroot" type="text" value="'.s($CFG->wwwroot).'" disabled="disabled" size="70" class="forminput" />';
571 echo '</div>';
573 echo '<div class="formrow"><label for="id_dirroot" class="formlabel">'.$paths['dirroot'].'</label>';
574 echo '<input id="id_dirroot" name="dirroot" type="text" value="'.s($CFG->dirroot).'" disabled="disabled" size="70"class="forminput" />';
575 echo '</div>';
577 echo '<div class="formrow"><label for="id_dataroot" class="formlabel">'.$paths['dataroot'].'</label>';
578 echo '<input id="id_dataroot" name="dataroot" type="text" value="'.s($config->dataroot).'" size="70" class="forminput" />';
579 if ($hint_dataroot !== '') {
580 echo '<div class="hint">'.$hint_dataroot.'</div>';
582 echo '</div>';
585 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
586 echo '<div class="formrow"><label for="id_admin" class="formlabel">'.$paths['admindir'].'</label>';
587 echo '<input id="id_admin" name="admin" type="text" value="'.s($config->admin).'" size="10" class="forminput" />';
588 if ($hint_admindir !== '') {
589 echo '<div class="hint">'.$hint_admindir.'</div>';
591 echo '</div>';
594 echo '</div>';
596 install_print_footer($config);
597 die;
602 $config->stage = INSTALL_WELCOME;
604 if ($distro) {
605 ob_start();
606 include('install/distribution.html');
607 $sub = ob_get_clean();
609 install_print_header($config, get_string('language'),
610 get_string('chooselanguagehead', 'install'),
611 $sub);
613 } else {
614 install_print_header($config, get_string('language'),
615 get_string('chooselanguagehead', 'install'),
616 get_string('chooselanguagesub', 'install'));
619 $languages = get_string_manager()->get_list_of_translations();
620 echo '<div class="userinput">';
621 echo '<div class="formrow"><label class="formlabel" for="langselect">'.get_string('language').'</label>';
622 echo '<select id="langselect" name="lang" class="forminput" onchange="this.form.submit()">';
623 foreach ($languages as $name=>$value) {
624 $selected = ($name == $CFG->lang) ? 'selected="selected"' : '';
625 echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
627 echo '</select></div>';
628 echo '</div>';
630 install_print_footer($config);
631 die;