MDL-51539 javascript: Update loglevel library to 1.4
[moodle.git] / install.php
blob0f6575580608707954fee32d0fa15dd40aa6fd1d
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.
65 if (version_compare(phpversion(), '5.4.4') < 0) {
66 $phpversion = phpversion();
67 // do NOT localise - lang strings would not work here and we CAN not move it after installib
68 echo "Moodle 2.7 or later requires at least PHP 5.4.4 (currently using version $phpversion).<br />";
69 echo "Please upgrade your server software or install older Moodle version.";
70 die;
73 // make sure iconv is available and actually works
74 if (!function_exists('iconv')) {
75 // this should not happen, this must be very borked install
76 echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.';
77 die();
80 if (PHP_INT_SIZE > 4) {
81 // most probably 64bit PHP - we need a lot more memory
82 $minrequiredmemory = '70M';
83 } else {
84 // 32bit PHP
85 $minrequiredmemory = '40M';
87 // increase or decrease available memory - we need to make sure moodle
88 // installs even with low memory, otherwise developers would overlook
89 // sudden increases of memory needs ;-)
90 @ini_set('memory_limit', $minrequiredmemory);
92 /** Used by library scripts to check they are being called by Moodle */
93 define('MOODLE_INTERNAL', true);
95 require_once(__DIR__.'/lib/classes/component.php');
96 require_once(__DIR__.'/lib/installlib.php');
98 // TODO: add lang detection here if empty $_REQUEST['lang']
100 // distro specific customisation
101 $distro = null;
102 if (file_exists('install/distrolib.php')) {
103 require_once('install/distrolib.php');
104 if (function_exists('distro_get_config')) {
105 $distro = distro_get_config();
109 $config = new stdClass();
110 $config->lang = $lang;
112 if (!empty($_POST)) {
113 $config->stage = (int)$_POST['stage'];
115 if (isset($_POST['previous'])) {
116 $config->stage--;
117 if (INSTALL_DATABASETYPE and !empty($distro->dbtype)) {
118 $config->stage--;
120 if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_DOWNLOADLANG) {
121 $config->stage--;
123 } else if (isset($_POST['next'])) {
124 $config->stage++;
127 $config->dbtype = trim($_POST['dbtype']);
128 $config->dbhost = trim($_POST['dbhost']);
129 $config->dbuser = trim($_POST['dbuser']);
130 $config->dbpass = trim($_POST['dbpass']);
131 $config->dbname = trim($_POST['dbname']);
132 $config->prefix = trim($_POST['prefix']);
133 $config->dbport = (int)trim($_POST['dbport']);
134 $config->dbsocket = trim($_POST['dbsocket']);
136 if ($config->dbport <= 0) {
137 $config->dbport = '';
140 $config->admin = empty($_POST['admin']) ? 'admin' : trim($_POST['admin']);
142 $config->dataroot = trim($_POST['dataroot']);
144 } else {
145 $config->stage = INSTALL_WELCOME;
147 $config->dbtype = empty($distro->dbtype) ? '' : $distro->dbtype; // let distro skip dbtype selection
148 $config->dbhost = empty($distro->dbhost) ? 'localhost' : $distro->dbhost; // let distros set dbhost
149 $config->dbuser = empty($distro->dbuser) ? '' : $distro->dbuser; // let distros set dbuser
150 $config->dbpass = '';
151 $config->dbname = 'moodle';
152 $config->prefix = 'mdl_';
153 $config->dbport = empty($distro->dbport) ? '' : $distro->dbport;
154 $config->dbsocket = empty($distro->dbsocket) ? '' : $distro->dbsocket;
156 $config->admin = 'admin';
158 $config->dataroot = empty($distro->dataroot) ? null : $distro->dataroot; // initialised later after including libs or by distro
161 // Fake some settings so that we can use selected functions from moodlelib.php, weblib.php and filelib.php.
162 global $CFG;
163 $CFG = new stdClass();
164 $CFG->lang = $config->lang;
165 $CFG->dirroot = dirname(__FILE__);
166 $CFG->libdir = "$CFG->dirroot/lib";
167 $CFG->wwwroot = install_guess_wwwroot(); // can not be changed - ppl must use the real address when installing
168 $CFG->httpswwwroot = $CFG->wwwroot;
169 $CFG->dataroot = $config->dataroot;
170 $CFG->tempdir = $CFG->dataroot.'/temp';
171 $CFG->cachedir = $CFG->dataroot.'/cache';
172 $CFG->localcachedir = $CFG->dataroot.'/localcache';
173 $CFG->admin = $config->admin;
174 $CFG->docroot = 'http://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'));
220 //point zend include path to moodles lib/zend so that includes and requires will search there for files before anywhere else
221 ini_set('include_path', $CFG->libdir.'/zend' . PATH_SEPARATOR . ini_get('include_path'));
223 // Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
224 // Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
225 if (defined('COMPONENT_CLASSLOADER')) {
226 spl_autoload_register(COMPONENT_CLASSLOADER);
227 } else {
228 spl_autoload_register('core_component::classloader');
231 require('version.php');
232 $CFG->target_release = $release;
234 \core\session\manager::init_empty_session();
235 global $SESSION;
236 global $USER;
238 global $COURSE;
239 $COURSE = new stdClass();
240 $COURSE->id = 1;
242 global $SITE;
243 $SITE = $COURSE;
244 define('SITEID', 1);
246 $hint_dataroot = '';
247 $hint_admindir = '';
248 $hint_database = '';
250 // Are we in help mode?
251 if (isset($_GET['help'])) {
252 install_print_help_page($_GET['help']);
255 //first time here? find out suitable dataroot
256 if (is_null($CFG->dataroot)) {
257 $CFG->dataroot = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'moodledata';
259 $i = 0; //safety check - dirname might return some unexpected results
260 while(is_dataroot_insecure()) {
261 $parrent = dirname($CFG->dataroot);
262 $i++;
263 if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
264 $CFG->dataroot = ''; //can not find secure location for dataroot
265 break;
267 $CFG->dataroot = dirname($parrent).DIRECTORY_SEPARATOR.'moodledata';
269 $config->dataroot = $CFG->dataroot;
270 $config->stage = INSTALL_WELCOME;
273 // now let's do the stage work
274 if ($config->stage < INSTALL_WELCOME) {
275 $config->stage = INSTALL_WELCOME;
277 if ($config->stage > INSTALL_SAVE) {
278 $config->stage = INSTALL_SAVE;
283 if ($config->stage == INSTALL_SAVE) {
284 $CFG->early_install_lang = false;
286 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
287 if (!$database->driver_installed()) {
288 $config->stage = INSTALL_DATABASETYPE;
289 } else {
290 if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
291 $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);
293 $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));
295 if ($hint_database === '') {
296 $configphp = install_generate_configphp($database, $CFG);
298 umask(0137);
299 if (($fh = @fopen($configfile, 'w')) !== false) {
300 fwrite($fh, $configphp);
301 fclose($fh);
304 if (file_exists($configfile)) {
305 // config created, let's continue!
306 redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
309 install_print_header($config, 'config.php',
310 get_string('configurationcompletehead', 'install'),
311 get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install'), 'alert-error');
312 echo '<div class="configphp"><pre>';
313 echo p($configphp);
314 echo '</pre></div>';
316 install_print_footer($config);
317 die;
319 } else {
320 $config->stage = INSTALL_DATABASE;
327 if ($config->stage == INSTALL_DOWNLOADLANG) {
328 if (empty($CFG->dataroot)) {
329 $config->stage = INSTALL_PATHS;
331 } else if (is_dataroot_insecure()) {
332 $hint_dataroot = get_string('pathsunsecuredataroot', 'install');
333 $config->stage = INSTALL_PATHS;
335 } else if (!file_exists($CFG->dataroot)) {
336 $a = new stdClass();
337 $a->parent = dirname($CFG->dataroot);
338 $a->dataroot = $CFG->dataroot;
339 if (!is_writable($a->parent)) {
340 $hint_dataroot = get_string('pathsroparentdataroot', 'install', $a);
341 $config->stage = INSTALL_PATHS;
342 } else {
343 if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
344 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', $a);
345 $config->stage = INSTALL_PATHS;
349 } else if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
350 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', array('dataroot' => $CFG->dataroot));
351 $config->stage = INSTALL_PATHS;
354 if (empty($hint_dataroot) and !is_writable($CFG->dataroot)) {
355 $hint_dataroot = get_string('pathsrodataroot', 'install');
356 $config->stage = INSTALL_PATHS;
359 if ($config->admin === '' or !file_exists($CFG->dirroot.'/'.$config->admin.'/environment.xml')) {
360 $hint_admindir = get_string('pathswrongadmindir', 'install');
361 $config->stage = INSTALL_PATHS;
367 if ($config->stage == INSTALL_DOWNLOADLANG) {
368 // no need to download anything if en lang selected
369 if ($CFG->lang == 'en') {
370 $config->stage = INSTALL_DATABASETYPE;
376 if ($config->stage == INSTALL_DATABASETYPE) {
377 // skip db selection if distro package supports only one db
378 if (!empty($distro->dbtype)) {
379 $config->stage = INSTALL_DATABASE;
384 if ($config->stage == INSTALL_DOWNLOADLANG) {
385 $downloaderror = '';
387 // download and install required lang packs, the lang dir has already been created in install_init_dataroot
388 $installer = new lang_installer($CFG->lang);
389 $results = $installer->run();
390 foreach ($results as $langcode => $langstatus) {
391 if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
392 $a = new stdClass();
393 $a->url = $installer->lang_pack_url($langcode);
394 $a->dest = $CFG->dataroot.'/lang';
395 $downloaderror = get_string('remotedownloaderror', 'error', $a);
399 if ($downloaderror !== '') {
400 install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang), $downloaderror);
401 install_print_footer($config);
402 die;
403 } else {
404 if (empty($distro->dbtype)) {
405 $config->stage = INSTALL_DATABASETYPE;
406 } else {
407 $config->stage = INSTALL_DATABASE;
411 // switch the string_manager instance to stop using install/lang/
412 $CFG->early_install_lang = false;
413 $CFG->langotherroot = $CFG->dataroot.'/lang';
414 $CFG->langlocalroot = $CFG->dataroot.'/lang';
415 get_string_manager(true);
419 if ($config->stage == INSTALL_DATABASE) {
420 $CFG->early_install_lang = false;
422 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
424 $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
426 install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
428 $strdbhost = get_string('databasehost', 'install');
429 $strdbname = get_string('databasename', 'install');
430 $strdbuser = get_string('databaseuser', 'install');
431 $strdbpass = get_string('databasepass', 'install');
432 $strprefix = get_string('dbprefix', 'install');
433 $strdbport = get_string('databaseport', 'install');
434 $strdbsocket = get_string('databasesocket', 'install');
436 echo '<div class="userinput">';
438 $disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
439 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbhost">'.$strdbhost.'</label></div>';
440 echo '<div class="fitemelement"><input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="50" /></div>';
441 echo '</div>';
443 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbname">'.$strdbname.'</label></div>';
444 echo '<div class="fitemelement"><input id="id_dbname" name="dbname" type="text" value="'.s($config->dbname).'" size="50" /></div>';
445 echo '</div>';
447 $disabled = empty($distro->dbuser) ? '' : 'disabled="disabled';
448 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbuser">'.$strdbuser.'</label></div>';
449 echo '<div class="fitemelement"><input id="id_dbuser" name="dbuser" '.$disabled.' type="text" value="'.s($config->dbuser).'" size="50" /></div>';
450 echo '</div>';
452 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbpass">'.$strdbpass.'</label></div>';
453 // no password field here, the password may be visible in config.php if we can not write it to disk
454 echo '<div class="fitemelement"><input id="id_dbpass" name="dbpass" type="text" value="'.s($config->dbpass).'" size="50" /></div>';
455 echo '</div>';
457 echo '<div class="fitem"><div class="fitemtitle"><label for="id_prefix">'.$strprefix.'</label></div>';
458 echo '<div class="fitemelement"><input id="id_prefix" name="prefix" type="text" value="'.s($config->prefix).'" size="10" /></div>';
459 echo '</div>';
461 echo '<div class="fitem"><div class="fitemtitle"><label for="id_prefix">'.$strdbport.'</label></div>';
462 echo '<div class="fitemelement"><input id="id_dbport" name="dbport" type="text" value="'.s($config->dbport).'" size="10" /></div>';
463 echo '</div>';
465 if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
466 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbsocket">'.$strdbsocket.'</label></div>';
467 echo '<div class="fitemelement"><input id="id_dbsocket" name="dbsocket" type="text" value="'.s($config->dbsocket).'" size="50" /></div>';
468 echo '</div>';
471 if ($hint_database !== '') {
472 echo '<div class="alert alert-error">'.$hint_database.'</div>';
474 echo '</div>';
475 install_print_footer($config);
476 die;
480 if ($config->stage == INSTALL_DATABASETYPE) {
481 $CFG->early_install_lang = false;
483 // Finally ask for DB type
484 install_print_header($config, get_string('database', 'install'),
485 get_string('databasetypehead', 'install'),
486 get_string('databasetypesub', 'install'));
488 $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
489 'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
490 'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
491 'oci' => moodle_database::get_driver_instance('oci', 'native'),
492 'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
493 'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
496 echo '<div class="userinput">';
497 echo '<div class="fitem"><div class="fitemtitle"><label for="dbtype">'.get_string('dbtype', 'install').'</label></div>';
498 echo '<div class="fitemelement"><select id="dbtype" name="dbtype">';
499 $disabled = array();
500 $options = array();
501 foreach ($databases as $type=>$database) {
502 if ($database->driver_installed() !== true) {
503 $disabled[$type] = $database;
504 continue;
506 echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
508 if ($disabled) {
509 echo '<optgroup label="'.s(get_string('notavailable')).'">';
510 foreach ($disabled as $type=>$database) {
511 echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
513 echo '</optgroup>';
515 echo '</select></div></div>';
516 echo '</div>';
518 install_print_footer($config);
519 die;
524 if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
525 $curl_fail = ($lang !== 'en' and !extension_loaded('curl')); // needed for lang pack download
526 $zip_fail = ($lang !== 'en' and !extension_loaded('zip')); // needed for lang pack download
528 if ($curl_fail or $zip_fail) {
529 $config->stage = INSTALL_ENVIRONMENT;
531 install_print_header($config, get_string('environmenthead', 'install'),
532 get_string('errorsinenvironment', 'install'),
533 get_string('environmentsub2', 'install'));
535 echo '<div id="envresult"><dl>';
536 if ($curl_fail) {
537 echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
539 if ($zip_fail) {
540 echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
542 echo '</dl></div>';
544 install_print_footer($config, true);
545 die;
547 } else {
548 $config->stage = INSTALL_PATHS;
554 if ($config->stage == INSTALL_PATHS) {
555 $paths = array('wwwroot' => get_string('wwwroot', 'install'),
556 'dirroot' => get_string('dirroot', 'install'),
557 'dataroot' => get_string('dataroot', 'install'));
559 $sub = '<dl>';
560 foreach ($paths as $path=>$name) {
561 $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
563 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
564 $sub .= '<dt>'.get_string('admindirname', 'install').'</dt><dd>'.get_string('pathssubadmindir', 'install').'</dd>';
566 $sub .= '</dl>';
568 install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
570 $strwwwroot = get_string('wwwroot', 'install');
571 $strdirroot = get_string('dirroot', 'install');
572 $strdataroot = get_string('dataroot', 'install');
573 $stradmindirname = get_string('admindirname', 'install');
575 echo '<div class="userinput">';
576 echo '<div class="fitem"><div class="fitemtitle"><label for="id_wwwroot">'.$paths['wwwroot'].'</label></div>';
577 echo '<div class="fitemelement"><input id="id_wwwroot" name="wwwroot" type="text" value="'.s($CFG->wwwroot).'" disabled="disabled" size="70" /></div>';
578 echo '</div>';
580 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dirroot">'.$paths['dirroot'].'</label></div>';
581 echo '<div class="fitemelement"><input id="id_dirroot" name="dirroot" type="text" value="'.s($CFG->dirroot).'" disabled="disabled" size="70" /></div>';
582 echo '</div>';
584 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dataroot">'.$paths['dataroot'].'</label></div>';
585 echo '<div class="fitemelement"><input id="id_dataroot" name="dataroot" type="text" value="'.s($config->dataroot).'" size="70" /></div>';
586 if ($hint_dataroot !== '') {
587 echo '<div class="alert alert-error">'.$hint_dataroot.'</div>';
589 echo '</div>';
592 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
593 echo '<div class="fitem"><div class="fitemtitle"><label for="id_admin">'.$paths['admindir'].'</label></div>';
594 echo '<div class="fitemelement"><input id="id_admin" name="admin" type="text" value="'.s($config->admin).'" size="10" /></div>';
595 if ($hint_admindir !== '') {
596 echo '<div class="alert alert-error">'.$hint_admindir.'</div>';
598 echo '</div>';
601 echo '</div>';
603 install_print_footer($config);
604 die;
609 $config->stage = INSTALL_WELCOME;
611 if ($distro) {
612 ob_start();
613 include('install/distribution.html');
614 $sub = ob_get_clean();
616 install_print_header($config, get_string('language'),
617 get_string('chooselanguagehead', 'install'),
618 $sub, 'alert-success');
620 } else {
621 install_print_header($config, get_string('language'),
622 get_string('chooselanguagehead', 'install'),
623 get_string('chooselanguagesub', 'install'));
626 $languages = get_string_manager()->get_list_of_translations();
627 echo '<div class="userinput">';
628 echo '<div class="fitem"><div class="fitemtitle"><label for="langselect">'.get_string('language').'</label></div>';
629 echo '<div class="fitemelement"><select id="langselect" name="lang" onchange="this.form.submit()">';
630 foreach ($languages as $name=>$value) {
631 $selected = ($name == $CFG->lang) ? 'selected="selected"' : '';
632 echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
634 echo '</select></div></div>';
635 echo '</div>';
637 install_print_footer($config);
638 die;