Added missing global that was causing perfinfo and others not to be respected.
[moodle.git] / install.php
CommitLineData
d764d4ca 1<?php
8b5b1028 2
d764d4ca 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.
14//
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/>.
17
18/**
19 * This script creates config.php file during installation.
20 *
21 * @package moodlecore
95feaf96 22 * @subpackage install
d764d4ca 23 * @copyright 2009 Petr Skoda (http://skodak.org)
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 */
8b5b1028 26
3b093310 27if (isset($_REQUEST['lang'])) {
6dbcacee 28 $lang = preg_replace('/[^A-Za-z0-9_-]/i', '', $_REQUEST['lang']);
8b5b1028 29} else {
3b093310 30 $lang = 'en_utf8';
8b5b1028 31}
32
3b093310 33if (isset($_REQUEST['admin'])) {
6dbcacee 34 $admin = preg_replace('/[^A-Za-z0-9_-]/i', '', $_REQUEST['admin']);
3b093310 35} else {
36 $admin = 'admin';
8b5b1028 37}
38
082157a8 39// If config.php exists we just created config.php and need to redirect to continue installation
3b093310 40$configfile = './config.php';
41if (file_exists($configfile)) {
42 header("Location: $admin/index.php?lang=$lang");
43 die;
d36afd6d 44}
8d783716 45
082157a8 46// make sure PHP errors are displayed - helps with diagnosing of problems
3b093310 47@error_reporting(E_ALL);
48@ini_set('display_errors', '1');
49// we need a lot of memory
50@ini_set('memory_limit', '40M');
51
082157a8 52// Check that PHP is of a sufficient version
3b093310 53if (version_compare(phpversion(), "5.2.0") < 0) {
54 $phpversion = phpversion();
55 // do NOT localise - lang strings would not work here and we CAN not move it after installib
56 echo "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion). ";
57 echo "Please upgrade your server software or install latest Moodle 1.9.x instead.";
58 die;
8b5b1028 59}
60
3b093310 61require dirname(__FILE__).'/lib/installlib.php';
bd507453 62
3b093310 63// TODO: add lang detection here if empty $_REQUEST['lang']
3b3b8029 64
5c1fb7d4 65// distro specific customisation
66$distro = null;
768408e8 67if (file_exists('install/distrolib.php')) {
68 require_once('install/distrolib.php');
69 if (function_exists('distro_get_config')) {
70 $distro = distro_get_config();
71 }
5c1fb7d4 72}
73
3b093310 74$config = new stdClass();
75$config->lang = $lang;
3b3b8029 76
3b093310 77if (!empty($_POST)) {
78 if (install_ini_get_bool('magic_quotes_gpc')) {
fa53493e 79 $_POST = array_map('stripslashes', $_POST);
3b093310 80 }
3b3b8029 81
3b093310 82 $config->stage = (int)$_POST['stage'];
56ca1c60 83
3b093310 84 if (isset($_POST['previous'])) {
85 $config->stage--;
5167827b 86 if (INSTALL_DATABASETYPE and !empty($distro->dbtype)) {
87 $config->stage--;
88 }
3b093310 89 if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_DOWNLOADLANG) {
90 $config->stage--;
56ca1c60 91 }
3b093310 92 } else if (isset($_POST['next'])) {
93 $config->stage++;
d36afd6d 94 }
3b3b8029 95
3b093310 96 $config->dbtype = trim($_POST['dbtype']);
97 $config->dbhost = trim($_POST['dbhost']);
98 $config->dbuser = trim($_POST['dbuser']);
99 $config->dbpass = trim($_POST['dbpass']);
100 $config->dbname = trim($_POST['dbname']);
101 $config->prefix = trim($_POST['prefix']);
102 $config->dbsocket = (int)(!empty($_POST['dbsocket']));
3b3b8029 103
3b093310 104 $config->dirroot = trim($_POST['dirroot']);
105 $config->admin = empty($_POST['admin']) ? 'admin' : trim($_POST['admin']);
53a0367d 106
3b093310 107 $config->dataroot = trim($_POST['dataroot']);
d36afd6d 108
3b3b8029 109} else {
3b093310 110 $config->stage = INSTALL_WELCOME;
8b5b1028 111
4f9dba35 112 $config->dbtype = empty($distro->dbtype) ? '' : $distro->dbtype; // let distro skip dbtype selection
6724b059 113 $config->dbhost = empty($distro->dbhost) ? 'localhost' : $distro->dbhost; // let distros set dbhost
114 $config->dbuser = empty($distro->dbuser) ? '' : $distro->dbuser; // let distros set dbuser
3b093310 115 $config->dbpass = '';
116 $config->dbname = 'moodle';
117 $config->prefix = 'mdl_';
118 $config->dbsocket = 0;
53a0367d 119
f571f5f5 120 $config->dirroot = str_replace('\\', '/', dirname(__FILE__)); // Fix for win32
3b093310 121 $config->admin = 'admin';
8b5b1028 122
4f9dba35 123 $config->dataroot = empty($distro->dataroot) ? null : $distro->dataroot; // initialised later after including libs or by distro
3b093310 124}
8b5b1028 125
082157a8 126// Fake some settings so that we can use selected functions from moodlelib.php and weblib.php
3b093310 127$CFG = new stdClass();
128$CFG->lang = $config->lang;
f571f5f5 129$CFG->dirroot = str_replace('\\', '/', dirname(__FILE__)); // Fix for win32
3b093310 130$CFG->libdir = "$CFG->dirroot/lib";
131$CFG->wwwroot = install_guess_wwwroot(); // can not be changed - ppl must use the real address when installing
318f0519 132$CFG->themedir = $CFG->dirroot.'/theme';
133$CFG->themewww = $CFG->wwwroot.'/theme';
3b093310 134$CFG->httpswwwroot = $CFG->wwwroot;
135$CFG->httpsthemewww = $CFG->wwwroot;
136$CFG->dataroot = $config->dataroot;
137$CFG->admin = $config->admin;
138$CFG->docroot = 'http://docs.moodle.org';
4b9efec4 139$CFG->directorypermissions = 00777;
3b093310 140$CFG->running_installer = true;
8d783716 141
082157a8 142// Require all needed libs
d36afd6d 143require_once($CFG->libdir.'/setuplib.php');
3b093310 144require_once($CFG->libdir.'/textlib.class.php');
d36afd6d 145require_once($CFG->libdir.'/weblib.php');
318f0519 146require_once($CFG->libdir.'/outputlib.php');
3b093310 147require_once($CFG->libdir.'/dmllib.php');
251387d0 148require_once($CFG->libdir.'/moodlelib.php');
d4a03c00 149require_once($CFG->libdir .'/pagelib.php');
3b093310 150require_once($CFG->libdir.'/deprecatedlib.php');
251387d0 151require_once($CFG->libdir.'/adminlib.php');
d36afd6d 152require_once($CFG->libdir.'/environmentlib.php');
153require_once($CFG->libdir.'/xmlize.php');
154require_once($CFG->libdir.'/componentlib.class.php');
3b093310 155
318f0519 156 //point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
157 //the problem is that we need specific version of quickforms and hacked excel files :-(
158 ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
159 //point zend include path to moodles lib/zend so that includes and requires will search there for files before anywhere else
160 ini_set('include_path', $CFG->libdir.'/zend' . PATH_SEPARATOR . ini_get('include_path'));
6f5e0852 161
3b093310 162require('version.php');
9ace5094 163$CFG->target_release = $release;
3b093310 164
165$SESSION = new object();
166$SESSION->lang = $CFG->lang;
167
168$USER = new object();
169$USER->id = 0;
170
171$COURSE = new object();
172$COURSE->id = 0;
173
174$SITE = $COURSE;
175define('SITEID', 0);
176
177$hint_dataroot = '';
178$hint_dirroot = '';
179$hint_admindir = '';
180$hint_database = '';
181
082157a8 182// Are we in help mode?
3b093310 183if (isset($_GET['help'])) {
184 install_print_help_page($_GET['help']);
185}
186
082157a8 187// send css?
3b093310 188if (isset($_GET['css'])) {
189 install_css_styles();
6d5a22b2 190}
8b5b1028 191
082157a8 192//first time here? find out suitable dataroot
3b093310 193if (is_null($CFG->dataroot)) {
194 $CFG->dataroot = str_replace('\\', '/', dirname(dirname(__FILE__)).'/moodledata');
add47d44 195
add47d44 196 $i = 0; //safety check - dirname might return some unexpected results
197 while(is_dataroot_insecure()) {
198 $parrent = dirname($CFG->dataroot);
199 $i++;
b735d140 200 if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
add47d44 201 $CFG->dataroot = ''; //can not find secure location for dataroot
202 break;
203 }
204 $CFG->dataroot = dirname($parrent).'/moodledata';
205 }
3b093310 206 $config->dataroot = $CFG->dataroot;
207 $config->stage = INSTALL_WELCOME;
8b5b1028 208}
209
3b093310 210// now let's do the stage work
211if ($config->stage < INSTALL_WELCOME) {
212 $config->stage = INSTALL_WELCOME;
213}
214if ($config->stage > INSTALL_SAVE) {
215 $config->stage = INSTALL_SAVE;
8d783716 216}
217
218
51e3e0b9 219
3b093310 220if ($config->stage == INSTALL_SAVE) {
221 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
222 if (!$database->driver_installed()) {
223 $config->stage = INSTALL_DATABASETYPE;
224 } else {
082157a8 225 if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
768408e8 226 $distro = distro_pre_create_db($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersit'=>0, 'dbsocket'=>$config->dbsocket), $distro);
227 }
228 $hint_database = install_db_validate($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersit'=>0, 'dbsocket'=>$config->dbsocket));
edd3a5db 229
3b093310 230 if ($hint_database === '') {
082157a8 231 // extra hackery needed for symbolic link support
232 if ($CFG->dirroot !== $config->dirroot) {
233 $CFG->dirroot = $config->dirroot;
234 $userealpath = true;
3b093310 235 } else {
082157a8 236 $userealpath = false;
3b093310 237 }
082157a8 238 $configphp = install_generate_configphp($database, $CFG, $userealpath);
53a0367d 239
3b093310 240 umask(0137);
3b093310 241 if (($fh = @fopen($configfile, 'w')) !== false) {
242 fwrite($fh, $configphp);
243 fclose($fh);
244 }
082157a8 245
3b093310 246 if (file_exists($configfile)) {
247 // config created, let's continue!
248 redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
249 }
2df3a721 250
3b093310 251 install_print_header($config, 'config.php',
252 get_string('configurationcompletehead', 'install'),
253 get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install'));
254 echo '<div class="configphp"><pre>';
255 echo p($configphp);
256 echo '</pre></div>';
bba0beae 257
3b093310 258 install_print_footer($config);
259 die;
8b5b1028 260
3b093310 261 } else {
262 $config->stage = INSTALL_DATABASE;
263 }
6d5a22b2 264 }
8b5b1028 265}
266
267
268
5167827b 269if ($config->stage == INSTALL_DOWNLOADLANG) {
270 if (empty($CFG->dataroot)) {
271 $config->stage = INSTALL_PATHS;
272
273 } else if (is_dataroot_insecure()) {
274 $hint_dataroot = get_string('pathsunsecuredataroot', 'install');
275 $config->stage = INSTALL_PATHS;
276
cf89052a 277 } else if (!file_exists($CFG->dataroot)) {
278 $a = new stdClass();
279 $a->parent = dirname($CFG->dataroot);
280 $a->dataroot = $CFG->dataroot;
281 if (!is_writable(dirname($CFG->dataroot))) {
282 $hint_dataroot = get_string('pathsroparentdataroot', 'install', $a);
283 $config->stage = INSTALL_PATHS;
284 } else {
082157a8 285 if (!make_upload_directory('lang', false)) {
cf89052a 286 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', $a);
287 $config->stage = INSTALL_PATHS;
288 }
289 }
290 }
291
292 if (empty($hint_dataroot) and !is_writable($CFG->dataroot)) {
5167827b 293 $hint_dataroot = get_string('pathsrodataroot', 'install');
294 $config->stage = INSTALL_PATHS;
295 }
296
297 if ($config->dirroot === '' or !file_exists($config->dirroot)) {
298 $hint_dirroot = get_string('pathswrongdirroot', 'install');
299 $config->stage = INSTALL_PATHS;
300 }
301
302 if ($config->admin === '' or !file_exists($config->dirroot.'/'.$config->admin.'/environment.xml')) {
303 $hint_admindir = get_string('pathswrongadmindir', 'install');
304 $config->stage = INSTALL_PATHS;
305 }
306}
307
308
309
310if ($config->stage == INSTALL_DOWNLOADLANG) {
311 // no need to download anything if en lang selected
312 if ($CFG->lang == 'en_utf8') {
313 $config->stage = INSTALL_DATABASETYPE;
314 }
315}
316
317
318
319if ($config->stage == INSTALL_DATABASETYPE) {
320 // skip db selection if distro package supports only one db
321 if (!empty($distro->dbtype)) {
322 $config->stage = INSTALL_DATABASE;
323 }
324}
325
326
08261d3a 327if ($config->stage == INSTALL_DOWNLOADLANG) {
328 $downloaderror = '';
329
082157a8 330// Create necessary lang dir
08261d3a 331 if (!make_upload_directory('lang', false)) {
332 $downloaderror = get_string('cannotcreatelangdir', 'error');
333
082157a8 334// Download and install lang component
08261d3a 335 } else if ($cd = new component_installer('http://download.moodle.org', 'lang16', $CFG->lang.'.zip', 'languages.md5', 'lang')) {
336 if ($cd->install() == COMPONENT_ERROR) {
337 if ($cd->get_error() == 'remotedownloaderror') {
338 $a = new stdClass();
339 $a->url = 'http://download.moodle.org/lang16/'.$INSTALL['language'].'.zip';
340 $a->dest = $CFG->dataroot.'/lang';
341 $downloaderror = get_string($cd->get_error(), 'error', $a);
342 } else {
343 $downloaderror = get_string($cd->get_error(), 'error');
344 }
345 } else {
346 // install parent lang if defined
347 if ($parentlang = get_parent_language()) {
348 if ($cd = new component_installer('http://download.moodle.org', 'lang16', $parentlang.'.zip', 'languages.md5', 'lang')) {
349 $cd->install();
350 }
351 }
352 }
353 }
354
355 if ($downloaderror !== '') {
356 install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang), $downloaderror);
357 install_print_footer($config);
358 die;
359 } else {
360 if (empty($distro->dbtype)) {
361 $config->stage = INSTALL_DATABASETYPE;
362 } else {
363 $config->stage = INSTALL_DATABASE;
364 }
365 }
366}
367
5167827b 368
3b093310 369if ($config->stage == INSTALL_DATABASE) {
370 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
8b5b1028 371
3b093310 372 $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
8d783716 373
3b093310 374 install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
53a0367d 375
3b093310 376 $strdbhost = get_string('databasehost', 'install');
377 $strdbname = get_string('databasename', 'install');
378 $strdbuser = get_string('databaseuser', 'install');
379 $strdbpass = get_string('databasepass', 'install');
380 $strprefix = get_string('dbprefix', 'install');
381 $strdbsocket = get_string('databasesocket', 'install');
8d783716 382
3b093310 383 echo '<div class="userinput">';
6724b059 384
385 $disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
3b093310 386 echo '<div class="formrow"><label for="id_dbhost" class="formlabel">'.$strdbhost.'</label>';
6724b059 387 echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="30" class="forminput" />';
3b093310 388 echo '</div>';
8b5b1028 389
3b093310 390 echo '<div class="formrow"><label for="id_dbname" class="formlabel">'.$strdbname.'</label>';
391 echo '<input id="id_dbname" name="dbname" type="text" value="'.s($config->dbname).'" size="30" class="forminput" />';
392 echo '</div>';
86453d8b 393
6724b059 394 $disabled = empty($distro->dbuser) ? '' : 'disabled="disabled';
3b093310 395 echo '<div class="formrow"><label for="id_dbuser" class="formlabel">'.$strdbuser.'</label>';
6724b059 396 echo '<input id="id_dbuser" name="dbuser" '.$disabled.' type="text" value="'.s($config->dbuser).'" size="30" class="forminput" />';
3b093310 397 echo '</div>';
86453d8b 398
3b093310 399 echo '<div class="formrow"><label for="id_dbpass" class="formlabel">'.$strdbpass.'</label>';
400 // no password field here, the password may be visible in config.php if we can not write it to disk
401 echo '<input id="id_dbpass" name="dbpass" type="text" value="'.s($config->dbpass).'" size="30" class="forminput" />';
402 echo '</div>';
86453d8b 403
3b093310 404 echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strprefix.'</label>';
405 echo '<input id="id_prefix" name="prefix" type="text" value="'.s($config->prefix).'" size="10" class="forminput" />';
406 echo '</div>';
fe515206 407
3b093310 408 if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
409 $checked = $config->dbsocket ? 'checked="checked' : '';
410 echo '<div class="formrow"><label for="id_dbsocket" class="formlabel">'.$strdbsocket.'</label>';
411 echo '<input type="hidden" value="0" name="dbsocket" />';
412 echo '<input type="checkbox" id="id_dbsocket" value="1" name="dbsocket" '.$checked.' class="forminput" />';
413 echo '</div>';
8b5b1028 414 }
415
3b093310 416 echo '<div class="hint">'.$hint_database.'</div>';
417 echo '</div>';
418 install_print_footer($config);
419 die;
8b5b1028 420}
421
422
3b093310 423if ($config->stage == INSTALL_DATABASETYPE) {
082157a8 424 // Finally ask for DB type
3b093310 425 install_print_header($config, get_string('database', 'install'),
426 get_string('databasetypehead', 'install'),
427 get_string('databasetypesub', 'install'));
51e3e0b9 428
3b093310 429 // TODO: move this PHP5 code to lib/installib.php so that this file parses in PHP4
430 $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
431 'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
432 'oci' => moodle_database::get_driver_instance('oci', 'native'),
433 //'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // new MS sql driver - win32 only
434 //'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
435 );
51e3e0b9 436
3b093310 437 echo '<div class="userinput">';
438 echo '<div class="formrow"><label class="formlabel" for="dbtype">'.get_string('dbtype', 'install').'</label>';
439 echo '<select id="dbtype" name="dbtype" class="forminput">';
440 $disabled = array();
441 $options = array();
442 foreach ($databases as $type=>$database) {
443 if ($database->driver_installed() !== true) {
444 $disabled[$type] = $database;
445 continue;
446 }
447 echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
51e3e0b9 448 }
3b093310 449 if ($disabled) {
450 echo '<optgroup label="'.s(get_string('notavailable')).'">';
451 foreach ($disabled as $type=>$database) {
452 echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
453 }
454 echo '</optgroup>';
8b5b1028 455 }
3b093310 456 echo '</select></div>';
457 echo '</div>';
53a0367d 458
3b093310 459 install_print_footer($config);
460 die;
8b5b1028 461}
462
463
464
3b093310 465if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
466 $version_fail = (version_compare(phpversion(), "5.2.8") < 0);
467 $curl_fail = ($lang !== 'en_utf8' and !extension_loaded('curl')); // needed for lang pack download
468 $zip_fail = ($lang !== 'en_utf8' and !extension_loaded('zip')); // needed for lang pack download
8b5b1028 469
3b093310 470 if ($version_fail or $curl_fail or $zip_fail) {
471 $config->stage = INSTALL_ENVIRONMENT;
8b5b1028 472
3b093310 473 install_print_header($config, get_string('environment', 'install'),
474 get_string('errorsinenvironment', 'install'),
475 get_string('environmentsub2', 'install'));
8b5b1028 476
3b093310 477 echo '<div id="envresult"><dl>';
478 if ($version_fail) {
479 $a = (object)array('needed'=>'5.2.8', 'current'=>phpversion());
480 echo '<dt>'.get_string('phpversion', 'install').'</dt><dd>'.get_string('environmentrequireversion', 'admin', $a).'</dd>';
481 }
482 if ($curl_fail) {
483 echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
484 }
485 if ($zip_fail) {
486 echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
487 }
488 echo '</dl></div>';
8d783716 489
3b093310 490 install_print_footer($config, true);
491 die;
51e3e0b9 492
8b5b1028 493 } else {
3b093310 494 $config->stage = INSTALL_PATHS;
8b5b1028 495 }
8b5b1028 496}
497
8b5b1028 498
8b5b1028 499
3b093310 500if ($config->stage == INSTALL_PATHS) {
501 $paths = array('wwwroot' => get_string('wwwroot', 'install'),
502 'dirroot' => get_string('dirroot', 'install'),
503 'dataroot' => get_string('dataroot', 'install'),
504 'admindir' => get_string('admindirname', 'install'));
627d326a 505
3b093310 506 $sub = '<dl>';
507 foreach ($paths as $path=>$name) {
508 $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
8b5b1028 509 }
3b093310 510 $sub .= '</dl>';
cd0e958e 511
3b093310 512 install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
627d326a 513
3b093310 514 $strwwwroot = get_string('wwwroot', 'install');
515 $strdirroot = get_string('dirroot', 'install');
516 $strdataroot = get_string('dataroot', 'install');
517 $stradmindirname = get_string('admindirname', 'install');
cdef6d42 518
3b093310 519 echo '<div class="userinput">';
520 echo '<div class="formrow"><label for="id_wwwroot" class="formlabel">'.$paths['wwwroot'].'</label>';
521 echo '<input id="id_wwwroot" name="wwwroot" type="text" value="'.s($CFG->wwwroot).'" disabled="disabled" size="45" class="forminput" />';
522 echo '</div>';
cd0e958e 523
3b093310 524 echo '<div class="formrow"><label for="id_dirroot" class="formlabel">'.$paths['dirroot'].'</label>';
525 echo '<input id="id_dirroot" name="dirroot" type="text" value="'.s($config->dirroot).'" size="45"class="forminput" />';
526 if ($hint_dirroot !== '') {
527 echo '<div class="hint">'.$hint_dirroot.'</div>';
cdef6d42 528 }
3b093310 529 echo '</div>';
53a0367d 530
3b093310 531 echo '<div class="formrow"><label for="id_dataroot" class="formlabel">'.$paths['dataroot'].'</label>';
532 echo '<input id="id_dataroot" name="dataroot" type="text" value="'.s($config->dataroot).'" size="45" class="forminput" />';
533 if ($hint_dataroot !== '') {
534 echo '<div class="hint">'.$hint_dataroot.'</div>';
cdef6d42 535 }
3b093310 536 echo '</div>';
8b5b1028 537
8d783716 538
3b093310 539 if (file_exists("$CFG->dirroot/admin/environment.xml")) {
540 $disabled = 'disabled="disabled"';
8d783716 541 } else {
3b093310 542 $disabled = '';
8d783716 543 }
3b093310 544 echo '<div class="formrow"><label for="id_admin" class="formlabel">'.$paths['admindir'].'</label>';
545 echo '<input id="id_admin" name="admin" type="text" value="'.s($config->admin).'" '.$disabled.' size="10" class="forminput" />';
546 if ($hint_admindir !== '') {
547 echo '<div class="hint">'.$hint_admindir.'</div>';
8d783716 548 }
3b093310 549 echo '</div>';
8d783716 550
3b093310 551 echo '</div>';
8d783716 552
3b093310 553 install_print_footer($config);
554 die;
8d783716 555}
556
86453d8b 557
86453d8b 558
3b093310 559$config->stage = INSTALL_WELCOME;
64c368e3 560
561if ($distro) {
562 ob_start();
563 include('install/distribution.html');
564 $sub = ob_get_clean();
565
566 install_print_header($config, get_string('language'),
567 get_string('chooselanguagehead', 'install'),
568 $sub);
082157a8 569
64c368e3 570} else {
571 install_print_header($config, get_string('language'),
572 get_string('chooselanguagehead', 'install'),
573 get_string('chooselanguagesub', 'install'));
574}
86453d8b 575
3b093310 576$languages = install_get_list_of_languages();
577echo '<div class="userinput">';
578echo '<div class="formrow"><label class="formlabel" for="langselect">'.get_string('language').'</label>';
4d928665 579echo '<select id="langselect" name="lang" class="forminput" onchange="this.form.submit()">';
3b093310 580foreach ($languages as $name=>$value) {
581 $selected = ($name == $CFG->lang) ? 'selected="selected"' : '';
582 echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
86453d8b 583}
3b093310 584echo '</select></div>';
585echo '</div>';
86453d8b 586
3b093310 587install_print_footer($config);
588die;
2961367e 589