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