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