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