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