quiz editing: unindent entire file.
[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
f571f5f5 98 $config->dirroot = str_replace('\\', '/', dirname(__FILE__)); // Fix for win32
3b093310 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;
f571f5f5 107$CFG->dirroot = str_replace('\\', '/', dirname(__FILE__)); // Fix for win32
3b093310 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) {
f571f5f5 215 $dirroot = str_replace('\\', '/', $config->dirroot); // win32 fix
216 $dirroot = rtrim($dirroot, '/'); // no trailing /
217 $configphp .= '$CFG->dirroot = realpath('.var_export($dirroot, true).");\r\n"; // fix for sym links
3b093310 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
cf89052a 275 } else if (!file_exists($CFG->dataroot)) {
276 $a = new stdClass();
277 $a->parent = dirname($CFG->dataroot);
278 $a->dataroot = $CFG->dataroot;
279 if (!is_writable(dirname($CFG->dataroot))) {
280 $hint_dataroot = get_string('pathsroparentdataroot', 'install', $a);
281 $config->stage = INSTALL_PATHS;
282 } else {
283 if (!make_upload_directory(false, false)) {
284 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', $a);
285 $config->stage = INSTALL_PATHS;
286 }
287 }
288 }
289
290 if (empty($hint_dataroot) and !is_writable($CFG->dataroot)) {
5167827b 291 $hint_dataroot = get_string('pathsrodataroot', 'install');
292 $config->stage = INSTALL_PATHS;
293 }
294
295 if ($config->dirroot === '' or !file_exists($config->dirroot)) {
296 $hint_dirroot = get_string('pathswrongdirroot', 'install');
297 $config->stage = INSTALL_PATHS;
298 }
299
300 if ($config->admin === '' or !file_exists($config->dirroot.'/'.$config->admin.'/environment.xml')) {
301 $hint_admindir = get_string('pathswrongadmindir', 'install');
302 $config->stage = INSTALL_PATHS;
303 }
304}
305
306
307
308if ($config->stage == INSTALL_DOWNLOADLANG) {
309 // no need to download anything if en lang selected
310 if ($CFG->lang == 'en_utf8') {
311 $config->stage = INSTALL_DATABASETYPE;
312 }
313}
314
315
316
317if ($config->stage == INSTALL_DATABASETYPE) {
318 // skip db selection if distro package supports only one db
319 if (!empty($distro->dbtype)) {
320 $config->stage = INSTALL_DATABASE;
321 }
322}
323
324
08261d3a 325if ($config->stage == INSTALL_DOWNLOADLANG) {
326 $downloaderror = '';
327
328/// Create necessary lang dir
329 if (!make_upload_directory('lang', false)) {
330 $downloaderror = get_string('cannotcreatelangdir', 'error');
331
332/// Download and install lang component
333 } else if ($cd = new component_installer('http://download.moodle.org', 'lang16', $CFG->lang.'.zip', 'languages.md5', 'lang')) {
334 if ($cd->install() == COMPONENT_ERROR) {
335 if ($cd->get_error() == 'remotedownloaderror') {
336 $a = new stdClass();
337 $a->url = 'http://download.moodle.org/lang16/'.$INSTALL['language'].'.zip';
338 $a->dest = $CFG->dataroot.'/lang';
339 $downloaderror = get_string($cd->get_error(), 'error', $a);
340 } else {
341 $downloaderror = get_string($cd->get_error(), 'error');
342 }
343 } else {
344 // install parent lang if defined
345 if ($parentlang = get_parent_language()) {
346 if ($cd = new component_installer('http://download.moodle.org', 'lang16', $parentlang.'.zip', 'languages.md5', 'lang')) {
347 $cd->install();
348 }
349 }
350 }
351 }
352
353 if ($downloaderror !== '') {
354 install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang), $downloaderror);
355 install_print_footer($config);
356 die;
357 } else {
358 if (empty($distro->dbtype)) {
359 $config->stage = INSTALL_DATABASETYPE;
360 } else {
361 $config->stage = INSTALL_DATABASE;
362 }
363 }
364}
365
5167827b 366
3b093310 367if ($config->stage == INSTALL_DATABASE) {
368 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
8b5b1028 369
3b093310 370 $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
8d783716 371
3b093310 372 install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
53a0367d 373
3b093310 374 $strdbhost = get_string('databasehost', 'install');
375 $strdbname = get_string('databasename', 'install');
376 $strdbuser = get_string('databaseuser', 'install');
377 $strdbpass = get_string('databasepass', 'install');
378 $strprefix = get_string('dbprefix', 'install');
379 $strdbsocket = get_string('databasesocket', 'install');
8d783716 380
3b093310 381 echo '<div class="userinput">';
6724b059 382
383 $disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
3b093310 384 echo '<div class="formrow"><label for="id_dbhost" class="formlabel">'.$strdbhost.'</label>';
6724b059 385 echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="30" class="forminput" />';
3b093310 386 echo '</div>';
8b5b1028 387
3b093310 388 echo '<div class="formrow"><label for="id_dbname" class="formlabel">'.$strdbname.'</label>';
389 echo '<input id="id_dbname" name="dbname" type="text" value="'.s($config->dbname).'" size="30" class="forminput" />';
390 echo '</div>';
86453d8b 391
6724b059 392 $disabled = empty($distro->dbuser) ? '' : 'disabled="disabled';
3b093310 393 echo '<div class="formrow"><label for="id_dbuser" class="formlabel">'.$strdbuser.'</label>';
6724b059 394 echo '<input id="id_dbuser" name="dbuser" '.$disabled.' type="text" value="'.s($config->dbuser).'" size="30" class="forminput" />';
3b093310 395 echo '</div>';
86453d8b 396
3b093310 397 echo '<div class="formrow"><label for="id_dbpass" class="formlabel">'.$strdbpass.'</label>';
398 // no password field here, the password may be visible in config.php if we can not write it to disk
399 echo '<input id="id_dbpass" name="dbpass" type="text" value="'.s($config->dbpass).'" size="30" class="forminput" />';
400 echo '</div>';
86453d8b 401
3b093310 402 echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strprefix.'</label>';
403 echo '<input id="id_prefix" name="prefix" type="text" value="'.s($config->prefix).'" size="10" class="forminput" />';
404 echo '</div>';
fe515206 405
3b093310 406 if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
407 $checked = $config->dbsocket ? 'checked="checked' : '';
408 echo '<div class="formrow"><label for="id_dbsocket" class="formlabel">'.$strdbsocket.'</label>';
409 echo '<input type="hidden" value="0" name="dbsocket" />';
410 echo '<input type="checkbox" id="id_dbsocket" value="1" name="dbsocket" '.$checked.' class="forminput" />';
411 echo '</div>';
8b5b1028 412 }
413
3b093310 414 echo '<div class="hint">'.$hint_database.'</div>';
415 echo '</div>';
416 install_print_footer($config);
417 die;
8b5b1028 418}
419
420
3b093310 421if ($config->stage == INSTALL_DATABASETYPE) {
422 /// Finally ask for DB type
423 install_print_header($config, get_string('database', 'install'),
424 get_string('databasetypehead', 'install'),
425 get_string('databasetypesub', 'install'));
51e3e0b9 426
3b093310 427 // TODO: move this PHP5 code to lib/installib.php so that this file parses in PHP4
428 $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
429 'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
430 'oci' => moodle_database::get_driver_instance('oci', 'native'),
431 //'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // new MS sql driver - win32 only
432 //'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
433 );
51e3e0b9 434
3b093310 435 echo '<div class="userinput">';
436 echo '<div class="formrow"><label class="formlabel" for="dbtype">'.get_string('dbtype', 'install').'</label>';
437 echo '<select id="dbtype" name="dbtype" class="forminput">';
438 $disabled = array();
439 $options = array();
440 foreach ($databases as $type=>$database) {
441 if ($database->driver_installed() !== true) {
442 $disabled[$type] = $database;
443 continue;
444 }
445 echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
51e3e0b9 446 }
3b093310 447 if ($disabled) {
448 echo '<optgroup label="'.s(get_string('notavailable')).'">';
449 foreach ($disabled as $type=>$database) {
450 echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
451 }
452 echo '</optgroup>';
8b5b1028 453 }
3b093310 454 echo '</select></div>';
455 echo '</div>';
53a0367d 456
3b093310 457 install_print_footer($config);
458 die;
8b5b1028 459}
460
461
462
3b093310 463if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
464 $version_fail = (version_compare(phpversion(), "5.2.8") < 0);
465 $curl_fail = ($lang !== 'en_utf8' and !extension_loaded('curl')); // needed for lang pack download
466 $zip_fail = ($lang !== 'en_utf8' and !extension_loaded('zip')); // needed for lang pack download
8b5b1028 467
3b093310 468 if ($version_fail or $curl_fail or $zip_fail) {
469 $config->stage = INSTALL_ENVIRONMENT;
8b5b1028 470
3b093310 471 install_print_header($config, get_string('environment', 'install'),
472 get_string('errorsinenvironment', 'install'),
473 get_string('environmentsub2', 'install'));
8b5b1028 474
3b093310 475 echo '<div id="envresult"><dl>';
476 if ($version_fail) {
477 $a = (object)array('needed'=>'5.2.8', 'current'=>phpversion());
478 echo '<dt>'.get_string('phpversion', 'install').'</dt><dd>'.get_string('environmentrequireversion', 'admin', $a).'</dd>';
479 }
480 if ($curl_fail) {
481 echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
482 }
483 if ($zip_fail) {
484 echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
485 }
486 echo '</dl></div>';
8d783716 487
3b093310 488 install_print_footer($config, true);
489 die;
51e3e0b9 490
8b5b1028 491 } else {
3b093310 492 $config->stage = INSTALL_PATHS;
8b5b1028 493 }
8b5b1028 494}
495
8b5b1028 496
8b5b1028 497
3b093310 498if ($config->stage == INSTALL_PATHS) {
499 $paths = array('wwwroot' => get_string('wwwroot', 'install'),
500 'dirroot' => get_string('dirroot', 'install'),
501 'dataroot' => get_string('dataroot', 'install'),
502 'admindir' => get_string('admindirname', 'install'));
627d326a 503
3b093310 504 $sub = '<dl>';
505 foreach ($paths as $path=>$name) {
506 $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
8b5b1028 507 }
3b093310 508 $sub .= '</dl>';
cd0e958e 509
3b093310 510 install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
627d326a 511
3b093310 512 $strwwwroot = get_string('wwwroot', 'install');
513 $strdirroot = get_string('dirroot', 'install');
514 $strdataroot = get_string('dataroot', 'install');
515 $stradmindirname = get_string('admindirname', 'install');
cdef6d42 516
3b093310 517 echo '<div class="userinput">';
518 echo '<div class="formrow"><label for="id_wwwroot" class="formlabel">'.$paths['wwwroot'].'</label>';
519 echo '<input id="id_wwwroot" name="wwwroot" type="text" value="'.s($CFG->wwwroot).'" disabled="disabled" size="45" class="forminput" />';
520 echo '</div>';
cd0e958e 521
3b093310 522 echo '<div class="formrow"><label for="id_dirroot" class="formlabel">'.$paths['dirroot'].'</label>';
523 echo '<input id="id_dirroot" name="dirroot" type="text" value="'.s($config->dirroot).'" size="45"class="forminput" />';
524 if ($hint_dirroot !== '') {
525 echo '<div class="hint">'.$hint_dirroot.'</div>';
cdef6d42 526 }
3b093310 527 echo '</div>';
53a0367d 528
3b093310 529 echo '<div class="formrow"><label for="id_dataroot" class="formlabel">'.$paths['dataroot'].'</label>';
530 echo '<input id="id_dataroot" name="dataroot" type="text" value="'.s($config->dataroot).'" size="45" class="forminput" />';
531 if ($hint_dataroot !== '') {
532 echo '<div class="hint">'.$hint_dataroot.'</div>';
cdef6d42 533 }
3b093310 534 echo '</div>';
8b5b1028 535
8d783716 536
3b093310 537 if (file_exists("$CFG->dirroot/admin/environment.xml")) {
538 $disabled = 'disabled="disabled"';
8d783716 539 } else {
3b093310 540 $disabled = '';
8d783716 541 }
3b093310 542 echo '<div class="formrow"><label for="id_admin" class="formlabel">'.$paths['admindir'].'</label>';
543 echo '<input id="id_admin" name="admin" type="text" value="'.s($config->admin).'" '.$disabled.' size="10" class="forminput" />';
544 if ($hint_admindir !== '') {
545 echo '<div class="hint">'.$hint_admindir.'</div>';
8d783716 546 }
3b093310 547 echo '</div>';
8d783716 548
3b093310 549 echo '</div>';
8d783716 550
3b093310 551 install_print_footer($config);
552 die;
8d783716 553}
554
86453d8b 555
86453d8b 556
3b093310 557$config->stage = INSTALL_WELCOME;
64c368e3 558
559if ($distro) {
560 ob_start();
561 include('install/distribution.html');
562 $sub = ob_get_clean();
563
564 install_print_header($config, get_string('language'),
565 get_string('chooselanguagehead', 'install'),
566 $sub);
567
568} else {
569 install_print_header($config, get_string('language'),
570 get_string('chooselanguagehead', 'install'),
571 get_string('chooselanguagesub', 'install'));
572}
86453d8b 573
3b093310 574$languages = install_get_list_of_languages();
575echo '<div class="userinput">';
576echo '<div class="formrow"><label class="formlabel" for="langselect">'.get_string('language').'</label>';
4d928665 577echo '<select id="langselect" name="lang" class="forminput" onchange="this.form.submit()">';
3b093310 578foreach ($languages as $name=>$value) {
579 $selected = ($name == $CFG->lang) ? 'selected="selected"' : '';
580 echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
86453d8b 581}
3b093310 582echo '</select></div>';
583echo '</div>';
86453d8b 584
3b093310 585install_print_footer($config);
586die;
2961367e 587