Moodle release 2.8.9
[moodle.git] / install.php
blobd23f4006f084d828c855219aad5f80c2e0ebdb6a
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 // This is a quick hack. Ideally we should ask the admin for a value. See MDL-22625 for more on this.
55 if (function_exists('date_default_timezone_set') and function_exists('date_default_timezone_get')) {
56 @date_default_timezone_set(@date_default_timezone_get());
59 // make sure PHP errors are displayed - helps with diagnosing of problems
60 @error_reporting(E_ALL);
61 @ini_set('display_errors', '1');
63 // Check that PHP is of a sufficient version.
64 if (version_compare(phpversion(), '5.4.4') < 0) {
65 $phpversion = phpversion();
66 // do NOT localise - lang strings would not work here and we CAN not move it after installib
67 echo "Moodle 2.7 or later requires at least PHP 5.4.4 (currently using version $phpversion).<br />";
68 echo "Please upgrade your server software or install older Moodle version.";
69 die;
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 = dirname(__FILE__);
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->cachedir = $CFG->dataroot.'/cache';
171 $CFG->localcachedir = $CFG->dataroot.'/localcache';
172 $CFG->admin = $config->admin;
173 $CFG->docroot = 'http://docs.moodle.org';
174 $CFG->langotherroot = $CFG->dataroot.'/lang';
175 $CFG->langlocalroot = $CFG->dataroot.'/lang';
176 $CFG->directorypermissions = isset($distro->directorypermissions) ? $distro->directorypermissions : 00777; // let distros set dir permissions
177 $CFG->filepermissions = ($CFG->directorypermissions & 0666);
178 $CFG->umaskpermissions = (($CFG->directorypermissions & 0777) ^ 0777);
179 $CFG->running_installer = true;
180 $CFG->early_install_lang = true;
181 $CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
182 $CFG->debug = (E_ALL | E_STRICT);
183 $CFG->debugdisplay = true;
184 $CFG->debugdeveloper = true;
186 // Require all needed libs
187 require_once($CFG->libdir.'/setuplib.php');
189 // we need to make sure we have enough memory to load all libraries
190 $memlimit = @ini_get('memory_limit');
191 if (!empty($memlimit) and $memlimit != -1) {
192 if (get_real_size($memlimit) < get_real_size($minrequiredmemory)) {
193 // do NOT localise - lang strings would not work here and we CAN not move it to later place
194 echo "Moodle requires at least {$minrequiredmemory}B of PHP memory.<br />";
195 echo "Please contact server administrator to fix PHP.ini memory settings.";
196 die;
200 // Continue with lib loading
201 require_once($CFG->libdir.'/classes/text.php');
202 require_once($CFG->libdir.'/classes/string_manager.php');
203 require_once($CFG->libdir.'/classes/string_manager_install.php');
204 require_once($CFG->libdir.'/classes/string_manager_standard.php');
205 require_once($CFG->libdir.'/weblib.php');
206 require_once($CFG->libdir.'/outputlib.php');
207 require_once($CFG->libdir.'/dmllib.php');
208 require_once($CFG->libdir.'/moodlelib.php');
209 require_once($CFG->libdir .'/pagelib.php');
210 require_once($CFG->libdir.'/deprecatedlib.php');
211 require_once($CFG->libdir.'/adminlib.php');
212 require_once($CFG->libdir.'/environmentlib.php');
213 require_once($CFG->libdir.'/componentlib.class.php');
214 require_once($CFG->dirroot.'/cache/lib.php');
216 //point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
217 //the problem is that we need specific version of quickforms and hacked excel files :-(
218 ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
219 //point zend include path to moodles lib/zend so that includes and requires will search there for files before anywhere else
220 ini_set('include_path', $CFG->libdir.'/zend' . PATH_SEPARATOR . ini_get('include_path'));
222 // Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
223 // Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
224 if (defined('COMPONENT_CLASSLOADER')) {
225 spl_autoload_register(COMPONENT_CLASSLOADER);
226 } else {
227 spl_autoload_register('core_component::classloader');
230 require('version.php');
231 $CFG->target_release = $release;
233 \core\session\manager::init_empty_session();
234 global $SESSION;
235 global $USER;
237 global $COURSE;
238 $COURSE = new stdClass();
239 $COURSE->id = 1;
241 global $SITE;
242 $SITE = $COURSE;
243 define('SITEID', 1);
245 $hint_dataroot = '';
246 $hint_admindir = '';
247 $hint_database = '';
249 // Are we in help mode?
250 if (isset($_GET['help'])) {
251 install_print_help_page($_GET['help']);
254 //first time here? find out suitable dataroot
255 if (is_null($CFG->dataroot)) {
256 $CFG->dataroot = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'moodledata';
258 $i = 0; //safety check - dirname might return some unexpected results
259 while(is_dataroot_insecure()) {
260 $parrent = dirname($CFG->dataroot);
261 $i++;
262 if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
263 $CFG->dataroot = ''; //can not find secure location for dataroot
264 break;
266 $CFG->dataroot = dirname($parrent).DIRECTORY_SEPARATOR.'moodledata';
268 $config->dataroot = $CFG->dataroot;
269 $config->stage = INSTALL_WELCOME;
272 // now let's do the stage work
273 if ($config->stage < INSTALL_WELCOME) {
274 $config->stage = INSTALL_WELCOME;
276 if ($config->stage > INSTALL_SAVE) {
277 $config->stage = INSTALL_SAVE;
282 if ($config->stage == INSTALL_SAVE) {
283 $CFG->early_install_lang = false;
285 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
286 if (!$database->driver_installed()) {
287 $config->stage = INSTALL_DATABASETYPE;
288 } else {
289 if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
290 $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);
292 $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));
294 if ($hint_database === '') {
295 $configphp = install_generate_configphp($database, $CFG);
297 umask(0137);
298 if (($fh = @fopen($configfile, 'w')) !== false) {
299 fwrite($fh, $configphp);
300 fclose($fh);
303 if (file_exists($configfile)) {
304 // config created, let's continue!
305 redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
308 install_print_header($config, 'config.php',
309 get_string('configurationcompletehead', 'install'),
310 get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install'), 'alert-error');
311 echo '<div class="configphp"><pre>';
312 echo p($configphp);
313 echo '</pre></div>';
315 install_print_footer($config);
316 die;
318 } else {
319 $config->stage = INSTALL_DATABASE;
326 if ($config->stage == INSTALL_DOWNLOADLANG) {
327 if (empty($CFG->dataroot)) {
328 $config->stage = INSTALL_PATHS;
330 } else if (is_dataroot_insecure()) {
331 $hint_dataroot = get_string('pathsunsecuredataroot', 'install');
332 $config->stage = INSTALL_PATHS;
334 } else if (!file_exists($CFG->dataroot)) {
335 $a = new stdClass();
336 $a->parent = dirname($CFG->dataroot);
337 $a->dataroot = $CFG->dataroot;
338 if (!is_writable($a->parent)) {
339 $hint_dataroot = get_string('pathsroparentdataroot', 'install', $a);
340 $config->stage = INSTALL_PATHS;
341 } else {
342 if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
343 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', $a);
344 $config->stage = INSTALL_PATHS;
348 } else if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
349 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', array('dataroot' => $CFG->dataroot));
350 $config->stage = INSTALL_PATHS;
353 if (empty($hint_dataroot) and !is_writable($CFG->dataroot)) {
354 $hint_dataroot = get_string('pathsrodataroot', 'install');
355 $config->stage = INSTALL_PATHS;
358 if ($config->admin === '' or !file_exists($CFG->dirroot.'/'.$config->admin.'/environment.xml')) {
359 $hint_admindir = get_string('pathswrongadmindir', 'install');
360 $config->stage = INSTALL_PATHS;
366 if ($config->stage == INSTALL_DOWNLOADLANG) {
367 // no need to download anything if en lang selected
368 if ($CFG->lang == 'en') {
369 $config->stage = INSTALL_DATABASETYPE;
375 if ($config->stage == INSTALL_DATABASETYPE) {
376 // skip db selection if distro package supports only one db
377 if (!empty($distro->dbtype)) {
378 $config->stage = INSTALL_DATABASE;
383 if ($config->stage == INSTALL_DOWNLOADLANG) {
384 $downloaderror = '';
386 // download and install required lang packs, the lang dir has already been created in install_init_dataroot
387 $installer = new lang_installer($CFG->lang);
388 $results = $installer->run();
389 foreach ($results as $langcode => $langstatus) {
390 if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
391 $a = new stdClass();
392 $a->url = $installer->lang_pack_url($langcode);
393 $a->dest = $CFG->dataroot.'/lang';
394 $downloaderror = get_string('remotedownloaderror', 'error', $a);
398 if ($downloaderror !== '') {
399 install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang), $downloaderror);
400 install_print_footer($config);
401 die;
402 } else {
403 if (empty($distro->dbtype)) {
404 $config->stage = INSTALL_DATABASETYPE;
405 } else {
406 $config->stage = INSTALL_DATABASE;
410 // switch the string_manager instance to stop using install/lang/
411 $CFG->early_install_lang = false;
412 $CFG->langotherroot = $CFG->dataroot.'/lang';
413 $CFG->langlocalroot = $CFG->dataroot.'/lang';
414 get_string_manager(true);
418 if ($config->stage == INSTALL_DATABASE) {
419 $CFG->early_install_lang = false;
421 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
423 $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
425 install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
427 $strdbhost = get_string('databasehost', 'install');
428 $strdbname = get_string('databasename', 'install');
429 $strdbuser = get_string('databaseuser', 'install');
430 $strdbpass = get_string('databasepass', 'install');
431 $strprefix = get_string('dbprefix', 'install');
432 $strdbport = get_string('databaseport', 'install');
433 $strdbsocket = get_string('databasesocket', 'install');
435 echo '<div class="userinput">';
437 $disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
438 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbhost">'.$strdbhost.'</label></div>';
439 echo '<div class="fitemelement"><input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="50" /></div>';
440 echo '</div>';
442 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbname">'.$strdbname.'</label></div>';
443 echo '<div class="fitemelement"><input id="id_dbname" name="dbname" type="text" value="'.s($config->dbname).'" size="50" /></div>';
444 echo '</div>';
446 $disabled = empty($distro->dbuser) ? '' : 'disabled="disabled';
447 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbuser">'.$strdbuser.'</label></div>';
448 echo '<div class="fitemelement"><input id="id_dbuser" name="dbuser" '.$disabled.' type="text" value="'.s($config->dbuser).'" size="50" /></div>';
449 echo '</div>';
451 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbpass">'.$strdbpass.'</label></div>';
452 // no password field here, the password may be visible in config.php if we can not write it to disk
453 echo '<div class="fitemelement"><input id="id_dbpass" name="dbpass" type="text" value="'.s($config->dbpass).'" size="50" /></div>';
454 echo '</div>';
456 echo '<div class="fitem"><div class="fitemtitle"><label for="id_prefix">'.$strprefix.'</label></div>';
457 echo '<div class="fitemelement"><input id="id_prefix" name="prefix" type="text" value="'.s($config->prefix).'" size="10" /></div>';
458 echo '</div>';
460 echo '<div class="fitem"><div class="fitemtitle"><label for="id_prefix">'.$strdbport.'</label></div>';
461 echo '<div class="fitemelement"><input id="id_dbport" name="dbport" type="text" value="'.s($config->dbport).'" size="10" /></div>';
462 echo '</div>';
464 if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
465 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbsocket">'.$strdbsocket.'</label></div>';
466 echo '<div class="fitemelement"><input id="id_dbsocket" name="dbsocket" type="text" value="'.s($config->dbsocket).'" size="50" /></div>';
467 echo '</div>';
470 if ($hint_database !== '') {
471 echo '<div class="alert alert-error">'.$hint_database.'</div>';
473 echo '</div>';
474 install_print_footer($config);
475 die;
479 if ($config->stage == INSTALL_DATABASETYPE) {
480 $CFG->early_install_lang = false;
482 // Finally ask for DB type
483 install_print_header($config, get_string('database', 'install'),
484 get_string('databasetypehead', 'install'),
485 get_string('databasetypesub', 'install'));
487 $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
488 'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
489 'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
490 'oci' => moodle_database::get_driver_instance('oci', 'native'),
491 'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
492 'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
495 echo '<div class="userinput">';
496 echo '<div class="fitem"><div class="fitemtitle"><label for="dbtype">'.get_string('dbtype', 'install').'</label></div>';
497 echo '<div class="fitemelement"><select id="dbtype" name="dbtype">';
498 $disabled = array();
499 $options = array();
500 foreach ($databases as $type=>$database) {
501 if ($database->driver_installed() !== true) {
502 $disabled[$type] = $database;
503 continue;
505 echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
507 if ($disabled) {
508 echo '<optgroup label="'.s(get_string('notavailable')).'">';
509 foreach ($disabled as $type=>$database) {
510 echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
512 echo '</optgroup>';
514 echo '</select></div></div>';
515 echo '</div>';
517 install_print_footer($config);
518 die;
523 if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
524 $curl_fail = ($lang !== 'en' and !extension_loaded('curl')); // needed for lang pack download
525 $zip_fail = ($lang !== 'en' and !extension_loaded('zip')); // needed for lang pack download
527 if ($curl_fail or $zip_fail) {
528 $config->stage = INSTALL_ENVIRONMENT;
530 install_print_header($config, get_string('environmenthead', 'install'),
531 get_string('errorsinenvironment', 'install'),
532 get_string('environmentsub2', 'install'));
534 echo '<div id="envresult"><dl>';
535 if ($curl_fail) {
536 echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
538 if ($zip_fail) {
539 echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
541 echo '</dl></div>';
543 install_print_footer($config, true);
544 die;
546 } else {
547 $config->stage = INSTALL_PATHS;
553 if ($config->stage == INSTALL_PATHS) {
554 $paths = array('wwwroot' => get_string('wwwroot', 'install'),
555 'dirroot' => get_string('dirroot', 'install'),
556 'dataroot' => get_string('dataroot', 'install'));
558 $sub = '<dl>';
559 foreach ($paths as $path=>$name) {
560 $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
562 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
563 $sub .= '<dt>'.get_string('admindirname', 'install').'</dt><dd>'.get_string('pathssubadmindir', 'install').'</dd>';
565 $sub .= '</dl>';
567 install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
569 $strwwwroot = get_string('wwwroot', 'install');
570 $strdirroot = get_string('dirroot', 'install');
571 $strdataroot = get_string('dataroot', 'install');
572 $stradmindirname = get_string('admindirname', 'install');
574 echo '<div class="userinput">';
575 echo '<div class="fitem"><div class="fitemtitle"><label for="id_wwwroot">'.$paths['wwwroot'].'</label></div>';
576 echo '<div class="fitemelement"><input id="id_wwwroot" name="wwwroot" type="text" value="'.s($CFG->wwwroot).'" disabled="disabled" size="70" /></div>';
577 echo '</div>';
579 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dirroot">'.$paths['dirroot'].'</label></div>';
580 echo '<div class="fitemelement"><input id="id_dirroot" name="dirroot" type="text" value="'.s($CFG->dirroot).'" disabled="disabled" size="70" /></div>';
581 echo '</div>';
583 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dataroot">'.$paths['dataroot'].'</label></div>';
584 echo '<div class="fitemelement"><input id="id_dataroot" name="dataroot" type="text" value="'.s($config->dataroot).'" size="70" /></div>';
585 if ($hint_dataroot !== '') {
586 echo '<div class="alert alert-error">'.$hint_dataroot.'</div>';
588 echo '</div>';
591 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
592 echo '<div class="fitem"><div class="fitemtitle"><label for="id_admin">'.$paths['admindir'].'</label></div>';
593 echo '<div class="fitemelement"><input id="id_admin" name="admin" type="text" value="'.s($config->admin).'" size="10" /></div>';
594 if ($hint_admindir !== '') {
595 echo '<div class="alert alert-error">'.$hint_admindir.'</div>';
597 echo '</div>';
600 echo '</div>';
602 install_print_footer($config);
603 die;
608 $config->stage = INSTALL_WELCOME;
610 if ($distro) {
611 ob_start();
612 include('install/distribution.html');
613 $sub = ob_get_clean();
615 install_print_header($config, get_string('language'),
616 get_string('chooselanguagehead', 'install'),
617 $sub, 'alert-success');
619 } else {
620 install_print_header($config, get_string('language'),
621 get_string('chooselanguagehead', 'install'),
622 get_string('chooselanguagesub', 'install'));
625 $languages = get_string_manager()->get_list_of_translations();
626 echo '<div class="userinput">';
627 echo '<div class="fitem"><div class="fitemtitle"><label for="langselect">'.get_string('language').'</label></div>';
628 echo '<div class="fitemelement"><select id="langselect" name="lang" onchange="this.form.submit()">';
629 foreach ($languages as $name=>$value) {
630 $selected = ($name == $CFG->lang) ? 'selected="selected"' : '';
631 echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
633 echo '</select></div></div>';
634 echo '</div>';
636 install_print_footer($config);
637 die;