MDL-29016 allow distributions to set dataroot permissions
[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 *
b7315f35 21 * @package core
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
4ede587e
PS
49// Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
50// This is a quick hack. Ideally we should ask the admin for a value. See MDL-22625 for more on this.
51if (function_exists('date_default_timezone_set') and function_exists('date_default_timezone_get')) {
52 @date_default_timezone_set(@date_default_timezone_get());
53}
54
082157a8 55// make sure PHP errors are displayed - helps with diagnosing of problems
3b093310 56@error_reporting(E_ALL);
57@ini_set('display_errors', '1');
3b093310 58
082157a8 59// Check that PHP is of a sufficient version
90150c08
DM
60// PHP 5.2.0 is intentionally checked here even though a higher version is required by the environment
61// check. This is not a typo - see MDL-18112
3b093310 62if (version_compare(phpversion(), "5.2.0") < 0) {
63 $phpversion = phpversion();
64 // do NOT localise - lang strings would not work here and we CAN not move it after installib
eab044a0
PS
65 echo "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).<br />";
66 echo "Please upgrade your server software or install older Moodle version.";
3b093310 67 die;
8b5b1028 68}
69
695940df
PS
70// make sure iconv is available and actually works
71if (!function_exists('iconv')) {
72 // this should not happen, this must be very borked install
7d85a4e2 73 echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.';
695940df
PS
74 die();
75}
76if (iconv('UTF-8', 'UTF-8//IGNORE', 'abc') !== 'abc') {
77 // known to be broken in mid-2011 MAMP installations
78 echo 'Broken iconv PHP extension detected, installation can not continue.';
79 die;
80}
81
86449d22
PS
82if (PHP_INT_SIZE > 4) {
83 // most probably 64bit PHP - we need a lot more memory
84 $minrequiredmemory = '70M';
85} else {
86 // 32bit PHP
87 $minrequiredmemory = '40M';
88}
89// increase or decrease available memory - we need to make sure moodle
90// installs even with low memory, otherwise developers would overlook
91// sudden increases of memory needs ;-)
92@ini_set('memory_limit', $minrequiredmemory);
93
460ebd6c
PS
94/** Used by library scripts to check they are being called by Moodle */
95define('MOODLE_INTERNAL', true);
96
3b093310 97require dirname(__FILE__).'/lib/installlib.php';
bd507453 98
3b093310 99// TODO: add lang detection here if empty $_REQUEST['lang']
3b3b8029 100
5c1fb7d4 101// distro specific customisation
102$distro = null;
768408e8 103if (file_exists('install/distrolib.php')) {
104 require_once('install/distrolib.php');
105 if (function_exists('distro_get_config')) {
106 $distro = distro_get_config();
107 }
5c1fb7d4 108}
109
3b093310 110$config = new stdClass();
111$config->lang = $lang;
3b3b8029 112
3b093310 113if (!empty($_POST)) {
114 if (install_ini_get_bool('magic_quotes_gpc')) {
fa53493e 115 $_POST = array_map('stripslashes', $_POST);
3b093310 116 }
3b3b8029 117
3b093310 118 $config->stage = (int)$_POST['stage'];
56ca1c60 119
3b093310 120 if (isset($_POST['previous'])) {
121 $config->stage--;
5167827b 122 if (INSTALL_DATABASETYPE and !empty($distro->dbtype)) {
123 $config->stage--;
124 }
3b093310 125 if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_DOWNLOADLANG) {
126 $config->stage--;
56ca1c60 127 }
3b093310 128 } else if (isset($_POST['next'])) {
129 $config->stage++;
d36afd6d 130 }
3b3b8029 131
3b093310 132 $config->dbtype = trim($_POST['dbtype']);
133 $config->dbhost = trim($_POST['dbhost']);
134 $config->dbuser = trim($_POST['dbuser']);
135 $config->dbpass = trim($_POST['dbpass']);
136 $config->dbname = trim($_POST['dbname']);
137 $config->prefix = trim($_POST['prefix']);
138 $config->dbsocket = (int)(!empty($_POST['dbsocket']));
3b3b8029 139
3b093310 140 $config->admin = empty($_POST['admin']) ? 'admin' : trim($_POST['admin']);
53a0367d 141
3b093310 142 $config->dataroot = trim($_POST['dataroot']);
d36afd6d 143
3b3b8029 144} else {
3b093310 145 $config->stage = INSTALL_WELCOME;
8b5b1028 146
4f9dba35 147 $config->dbtype = empty($distro->dbtype) ? '' : $distro->dbtype; // let distro skip dbtype selection
6724b059 148 $config->dbhost = empty($distro->dbhost) ? 'localhost' : $distro->dbhost; // let distros set dbhost
149 $config->dbuser = empty($distro->dbuser) ? '' : $distro->dbuser; // let distros set dbuser
3b093310 150 $config->dbpass = '';
151 $config->dbname = 'moodle';
152 $config->prefix = 'mdl_';
153 $config->dbsocket = 0;
53a0367d 154
3b093310 155 $config->admin = 'admin';
8b5b1028 156
4f9dba35 157 $config->dataroot = empty($distro->dataroot) ? null : $distro->dataroot; // initialised later after including libs or by distro
3b093310 158}
8b5b1028 159
082157a8 160// Fake some settings so that we can use selected functions from moodlelib.php and weblib.php
3b093310 161$CFG = new stdClass();
162$CFG->lang = $config->lang;
3b5ff37f 163$CFG->dirroot = dirname(__FILE__);
3b093310 164$CFG->libdir = "$CFG->dirroot/lib";
165$CFG->wwwroot = install_guess_wwwroot(); // can not be changed - ppl must use the real address when installing
166$CFG->httpswwwroot = $CFG->wwwroot;
3b093310 167$CFG->dataroot = $config->dataroot;
168$CFG->admin = $config->admin;
169$CFG->docroot = 'http://docs.moodle.org';
d8fa5a13
PS
170$CFG->langotherroot = $CFG->dataroot.'/lang';
171$CFG->langlocalroot = $CFG->dataroot.'/lang';
70801baf 172$CFG->directorypermissions = isset($distro->directorypermissions) ? $distro->directorypermissions : 00777; // let distros set dir permissions
3b093310 173$CFG->running_installer = true;
3a915b06 174$CFG->early_install_lang = true;
8d783716 175
082157a8 176// Require all needed libs
d36afd6d 177require_once($CFG->libdir.'/setuplib.php');
86449d22
PS
178
179// we need to make sure we have enough memory to load all libraries
180$memlimit = @ini_get('memory_limit');
181if (!empty($memlimit) and $memlimit != -1) {
182 if (get_real_size($memlimit) < get_real_size($minrequiredmemory)) {
183 // do NOT localise - lang strings would not work here and we CAN not move it to later place
eab044a0 184 echo "Moodle requires at least {$minrequiredmemory}B of PHP memory.<br />";
86449d22
PS
185 echo "Please contact server administrator to fix PHP.ini memory settings.";
186 die;
187 }
188}
189
190// Continue with lib loading
3b093310 191require_once($CFG->libdir.'/textlib.class.php');
d36afd6d 192require_once($CFG->libdir.'/weblib.php');
318f0519 193require_once($CFG->libdir.'/outputlib.php');
3b093310 194require_once($CFG->libdir.'/dmllib.php');
251387d0 195require_once($CFG->libdir.'/moodlelib.php');
d4a03c00 196require_once($CFG->libdir .'/pagelib.php');
3b093310 197require_once($CFG->libdir.'/deprecatedlib.php');
251387d0 198require_once($CFG->libdir.'/adminlib.php');
d36afd6d 199require_once($CFG->libdir.'/environmentlib.php');
d36afd6d 200require_once($CFG->libdir.'/componentlib.class.php');
3b093310 201
e8da62a9
PS
202//point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
203//the problem is that we need specific version of quickforms and hacked excel files :-(
204ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
205//point zend include path to moodles lib/zend so that includes and requires will search there for files before anywhere else
206ini_set('include_path', $CFG->libdir.'/zend' . PATH_SEPARATOR . ini_get('include_path'));
6f5e0852 207
3b093310 208require('version.php');
9ace5094 209$CFG->target_release = $release;
3b093310 210
a226a972 211$SESSION = new stdClass();
3b093310 212$SESSION->lang = $CFG->lang;
213
a226a972 214$USER = new stdClass();
3b093310 215$USER->id = 0;
216
a226a972 217$COURSE = new stdClass();
3b093310 218$COURSE->id = 0;
219
220$SITE = $COURSE;
221define('SITEID', 0);
222
223$hint_dataroot = '';
3b093310 224$hint_admindir = '';
225$hint_database = '';
226
082157a8 227// Are we in help mode?
3b093310 228if (isset($_GET['help'])) {
229 install_print_help_page($_GET['help']);
230}
231
082157a8 232//first time here? find out suitable dataroot
3b093310 233if (is_null($CFG->dataroot)) {
3b5ff37f 234 $CFG->dataroot = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'moodledata';
add47d44 235
add47d44 236 $i = 0; //safety check - dirname might return some unexpected results
237 while(is_dataroot_insecure()) {
238 $parrent = dirname($CFG->dataroot);
239 $i++;
b735d140 240 if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
add47d44 241 $CFG->dataroot = ''; //can not find secure location for dataroot
242 break;
243 }
3b5ff37f 244 $CFG->dataroot = dirname($parrent).DIRECTORY_SEPARATOR.'moodledata';
add47d44 245 }
3b093310 246 $config->dataroot = $CFG->dataroot;
247 $config->stage = INSTALL_WELCOME;
8b5b1028 248}
249
3b093310 250// now let's do the stage work
251if ($config->stage < INSTALL_WELCOME) {
252 $config->stage = INSTALL_WELCOME;
253}
254if ($config->stage > INSTALL_SAVE) {
255 $config->stage = INSTALL_SAVE;
8d783716 256}
257
258
51e3e0b9 259
3b093310 260if ($config->stage == INSTALL_SAVE) {
3a915b06
PS
261 $CFG->early_install_lang = false;
262
3b093310 263 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
264 if (!$database->driver_installed()) {
265 $config->stage = INSTALL_DATABASETYPE;
266 } else {
082157a8 267 if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
a0b7200d 268 $distro = distro_pre_create_db($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbsocket'=>$config->dbsocket), $distro);
768408e8 269 }
a0b7200d 270 $hint_database = install_db_validate($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbsocket'=>$config->dbsocket));
edd3a5db 271
3b093310 272 if ($hint_database === '') {
3b5ff37f 273 $configphp = install_generate_configphp($database, $CFG);
53a0367d 274
3b093310 275 umask(0137);
3b093310 276 if (($fh = @fopen($configfile, 'w')) !== false) {
277 fwrite($fh, $configphp);
278 fclose($fh);
279 }
082157a8 280
3b093310 281 if (file_exists($configfile)) {
282 // config created, let's continue!
283 redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
284 }
2df3a721 285
3b093310 286 install_print_header($config, 'config.php',
287 get_string('configurationcompletehead', 'install'),
288 get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install'));
289 echo '<div class="configphp"><pre>';
290 echo p($configphp);
291 echo '</pre></div>';
bba0beae 292
3b093310 293 install_print_footer($config);
294 die;
8b5b1028 295
3b093310 296 } else {
297 $config->stage = INSTALL_DATABASE;
298 }
6d5a22b2 299 }
8b5b1028 300}
301
302
303
5167827b 304if ($config->stage == INSTALL_DOWNLOADLANG) {
305 if (empty($CFG->dataroot)) {
306 $config->stage = INSTALL_PATHS;
307
308 } else if (is_dataroot_insecure()) {
309 $hint_dataroot = get_string('pathsunsecuredataroot', 'install');
310 $config->stage = INSTALL_PATHS;
311
cf89052a 312 } else if (!file_exists($CFG->dataroot)) {
313 $a = new stdClass();
314 $a->parent = dirname($CFG->dataroot);
315 $a->dataroot = $CFG->dataroot;
e92977d3 316 if (!is_writable($a->parent)) {
cf89052a 317 $hint_dataroot = get_string('pathsroparentdataroot', 'install', $a);
318 $config->stage = INSTALL_PATHS;
319 } else {
0bda7031 320 if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
cf89052a 321 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', $a);
322 $config->stage = INSTALL_PATHS;
323 }
324 }
16564524
DM
325
326 } else if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
e92977d3 327 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', array('dataroot' => $CFG->dataroot));
16564524 328 $config->stage = INSTALL_PATHS;
cf89052a 329 }
330
331 if (empty($hint_dataroot) and !is_writable($CFG->dataroot)) {
5167827b 332 $hint_dataroot = get_string('pathsrodataroot', 'install');
333 $config->stage = INSTALL_PATHS;
334 }
335
3b5ff37f 336 if ($config->admin === '' or !file_exists($CFG->dirroot.'/'.$config->admin.'/environment.xml')) {
5167827b 337 $hint_admindir = get_string('pathswrongadmindir', 'install');
338 $config->stage = INSTALL_PATHS;
339 }
340}
341
342
343
344if ($config->stage == INSTALL_DOWNLOADLANG) {
345 // no need to download anything if en lang selected
3a915b06 346 if ($CFG->lang == 'en') {
5167827b 347 $config->stage = INSTALL_DATABASETYPE;
348 }
349}
350
351
352
353if ($config->stage == INSTALL_DATABASETYPE) {
354 // skip db selection if distro package supports only one db
355 if (!empty($distro->dbtype)) {
356 $config->stage = INSTALL_DATABASE;
357 }
358}
359
360
08261d3a 361if ($config->stage == INSTALL_DOWNLOADLANG) {
362 $downloaderror = '';
363
74a4c9a9
DM
364 // download and install required lang packs, the lang dir has already been created in install_init_dataroot
365 $installer = new lang_installer($CFG->lang);
366 $results = $installer->run();
367 foreach ($results as $langcode => $langstatus) {
368 if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
369 $a = new stdClass();
370 $a->url = $installer->lang_pack_url($langcode);
371 $a->dest = $CFG->dataroot.'/lang';
372 $downloaderror = get_string('remotedownloaderror', 'error', $a);
08261d3a 373 }
374 }
375
376 if ($downloaderror !== '') {
377 install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang), $downloaderror);
378 install_print_footer($config);
379 die;
380 } else {
381 if (empty($distro->dbtype)) {
382 $config->stage = INSTALL_DATABASETYPE;
383 } else {
384 $config->stage = INSTALL_DATABASE;
385 }
386 }
807ee8bc
DM
387
388 // switch the string_manager instance to stop using install/lang/
389 $CFG->early_install_lang = false;
390 $CFG->langotherroot = $CFG->dataroot.'/lang';
391 $CFG->langlocalroot = $CFG->dataroot.'/lang';
392 get_string_manager(true);
08261d3a 393}
394
5167827b 395
3b093310 396if ($config->stage == INSTALL_DATABASE) {
3a915b06
PS
397 $CFG->early_install_lang = false;
398
3b093310 399 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
8b5b1028 400
3b093310 401 $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
8d783716 402
3b093310 403 install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
53a0367d 404
3b093310 405 $strdbhost = get_string('databasehost', 'install');
406 $strdbname = get_string('databasename', 'install');
407 $strdbuser = get_string('databaseuser', 'install');
408 $strdbpass = get_string('databasepass', 'install');
409 $strprefix = get_string('dbprefix', 'install');
410 $strdbsocket = get_string('databasesocket', 'install');
8d783716 411
3b093310 412 echo '<div class="userinput">';
6724b059 413
414 $disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
3b093310 415 echo '<div class="formrow"><label for="id_dbhost" class="formlabel">'.$strdbhost.'</label>';
ae3a7947 416 echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="50" class="forminput" />';
3b093310 417 echo '</div>';
8b5b1028 418
3b093310 419 echo '<div class="formrow"><label for="id_dbname" class="formlabel">'.$strdbname.'</label>';
420 echo '<input id="id_dbname" name="dbname" type="text" value="'.s($config->dbname).'" size="30" class="forminput" />';
421 echo '</div>';
86453d8b 422
6724b059 423 $disabled = empty($distro->dbuser) ? '' : 'disabled="disabled';
3b093310 424 echo '<div class="formrow"><label for="id_dbuser" class="formlabel">'.$strdbuser.'</label>';
6724b059 425 echo '<input id="id_dbuser" name="dbuser" '.$disabled.' type="text" value="'.s($config->dbuser).'" size="30" class="forminput" />';
3b093310 426 echo '</div>';
86453d8b 427
3b093310 428 echo '<div class="formrow"><label for="id_dbpass" class="formlabel">'.$strdbpass.'</label>';
429 // no password field here, the password may be visible in config.php if we can not write it to disk
430 echo '<input id="id_dbpass" name="dbpass" type="text" value="'.s($config->dbpass).'" size="30" class="forminput" />';
431 echo '</div>';
86453d8b 432
3b093310 433 echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strprefix.'</label>';
434 echo '<input id="id_prefix" name="prefix" type="text" value="'.s($config->prefix).'" size="10" class="forminput" />';
435 echo '</div>';
fe515206 436
3b093310 437 if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
438 $checked = $config->dbsocket ? 'checked="checked' : '';
439 echo '<div class="formrow"><label for="id_dbsocket" class="formlabel">'.$strdbsocket.'</label>';
440 echo '<input type="hidden" value="0" name="dbsocket" />';
441 echo '<input type="checkbox" id="id_dbsocket" value="1" name="dbsocket" '.$checked.' class="forminput" />';
442 echo '</div>';
8b5b1028 443 }
444
3b093310 445 echo '<div class="hint">'.$hint_database.'</div>';
446 echo '</div>';
447 install_print_footer($config);
448 die;
8b5b1028 449}
450
451
3b093310 452if ($config->stage == INSTALL_DATABASETYPE) {
3a915b06
PS
453 $CFG->early_install_lang = false;
454
082157a8 455 // Finally ask for DB type
3b093310 456 install_print_header($config, get_string('database', 'install'),
457 get_string('databasetypehead', 'install'),
458 get_string('databasetypesub', 'install'));
51e3e0b9 459
3b093310 460 $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
461 'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
462 'oci' => moodle_database::get_driver_instance('oci', 'native'),
7e60d0d6 463 'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
a2b9bca5 464 'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
3b093310 465 );
51e3e0b9 466
3b093310 467 echo '<div class="userinput">';
468 echo '<div class="formrow"><label class="formlabel" for="dbtype">'.get_string('dbtype', 'install').'</label>';
469 echo '<select id="dbtype" name="dbtype" class="forminput">';
470 $disabled = array();
471 $options = array();
472 foreach ($databases as $type=>$database) {
473 if ($database->driver_installed() !== true) {
474 $disabled[$type] = $database;
475 continue;
476 }
477 echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
51e3e0b9 478 }
3b093310 479 if ($disabled) {
480 echo '<optgroup label="'.s(get_string('notavailable')).'">';
481 foreach ($disabled as $type=>$database) {
482 echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
483 }
484 echo '</optgroup>';
8b5b1028 485 }
3b093310 486 echo '</select></div>';
487 echo '</div>';
53a0367d 488
3b093310 489 install_print_footer($config);
490 die;
8b5b1028 491}
492
493
494
3b093310 495if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
eab044a0 496 $version_fail = (version_compare(phpversion(), "5.3.2") < 0);
3a915b06
PS
497 $curl_fail = ($lang !== 'en' and !extension_loaded('curl')); // needed for lang pack download
498 $zip_fail = ($lang !== 'en' and !extension_loaded('zip')); // needed for lang pack download
8b5b1028 499
3b093310 500 if ($version_fail or $curl_fail or $zip_fail) {
501 $config->stage = INSTALL_ENVIRONMENT;
8b5b1028 502
85ed076b 503 install_print_header($config, get_string('environmenthead', 'install'),
3b093310 504 get_string('errorsinenvironment', 'install'),
505 get_string('environmentsub2', 'install'));
8b5b1028 506
3b093310 507 echo '<div id="envresult"><dl>';
508 if ($version_fail) {
eab044a0 509 $a = (object)array('needed'=>'5.3.2', 'current'=>phpversion());
3b093310 510 echo '<dt>'.get_string('phpversion', 'install').'</dt><dd>'.get_string('environmentrequireversion', 'admin', $a).'</dd>';
511 }
512 if ($curl_fail) {
513 echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
514 }
515 if ($zip_fail) {
516 echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
517 }
518 echo '</dl></div>';
8d783716 519
3b093310 520 install_print_footer($config, true);
521 die;
51e3e0b9 522
8b5b1028 523 } else {
3b093310 524 $config->stage = INSTALL_PATHS;
8b5b1028 525 }
8b5b1028 526}
527
8b5b1028 528
8b5b1028 529
3b093310 530if ($config->stage == INSTALL_PATHS) {
531 $paths = array('wwwroot' => get_string('wwwroot', 'install'),
532 'dirroot' => get_string('dirroot', 'install'),
3b5ff37f 533 'dataroot' => get_string('dataroot', 'install'));
627d326a 534
3b093310 535 $sub = '<dl>';
536 foreach ($paths as $path=>$name) {
537 $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
8b5b1028 538 }
3b5ff37f
PS
539 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
540 $sub .= '<dt>'.get_string('admindirname', 'install').'</dt><dd>'.get_string('pathssubadmindir', 'install').'</dd>';
541 }
3b093310 542 $sub .= '</dl>';
cd0e958e 543
3b093310 544 install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
627d326a 545
3b093310 546 $strwwwroot = get_string('wwwroot', 'install');
547 $strdirroot = get_string('dirroot', 'install');
548 $strdataroot = get_string('dataroot', 'install');
549 $stradmindirname = get_string('admindirname', 'install');
cdef6d42 550
3b093310 551 echo '<div class="userinput">';
552 echo '<div class="formrow"><label for="id_wwwroot" class="formlabel">'.$paths['wwwroot'].'</label>';
ae3a7947 553 echo '<input id="id_wwwroot" name="wwwroot" type="text" value="'.s($CFG->wwwroot).'" disabled="disabled" size="70" class="forminput" />';
3b093310 554 echo '</div>';
cd0e958e 555
3b093310 556 echo '<div class="formrow"><label for="id_dirroot" class="formlabel">'.$paths['dirroot'].'</label>';
ae3a7947 557 echo '<input id="id_dirroot" name="dirroot" type="text" value="'.s($CFG->dirroot).'" disabled="disabled" size="70"class="forminput" />';
3b093310 558 echo '</div>';
53a0367d 559
3b093310 560 echo '<div class="formrow"><label for="id_dataroot" class="formlabel">'.$paths['dataroot'].'</label>';
ae3a7947 561 echo '<input id="id_dataroot" name="dataroot" type="text" value="'.s($config->dataroot).'" size="70" class="forminput" />';
3b093310 562 if ($hint_dataroot !== '') {
563 echo '<div class="hint">'.$hint_dataroot.'</div>';
cdef6d42 564 }
3b093310 565 echo '</div>';
8b5b1028 566
8d783716 567
3b5ff37f
PS
568 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
569 echo '<div class="formrow"><label for="id_admin" class="formlabel">'.$paths['admindir'].'</label>';
570 echo '<input id="id_admin" name="admin" type="text" value="'.s($config->admin).'" size="10" class="forminput" />';
571 if ($hint_admindir !== '') {
572 echo '<div class="hint">'.$hint_admindir.'</div>';
573 }
574 echo '</div>';
8d783716 575 }
8d783716 576
3b093310 577 echo '</div>';
8d783716 578
3b093310 579 install_print_footer($config);
580 die;
8d783716 581}
582
86453d8b 583
86453d8b 584
3b093310 585$config->stage = INSTALL_WELCOME;
64c368e3 586
587if ($distro) {
588 ob_start();
589 include('install/distribution.html');
590 $sub = ob_get_clean();
591
592 install_print_header($config, get_string('language'),
593 get_string('chooselanguagehead', 'install'),
594 $sub);
082157a8 595
64c368e3 596} else {
597 install_print_header($config, get_string('language'),
598 get_string('chooselanguagehead', 'install'),
599 get_string('chooselanguagesub', 'install'));
600}
86453d8b 601
1f96e907 602$languages = get_string_manager()->get_list_of_translations();
3b093310 603echo '<div class="userinput">';
604echo '<div class="formrow"><label class="formlabel" for="langselect">'.get_string('language').'</label>';
4d928665 605echo '<select id="langselect" name="lang" class="forminput" onchange="this.form.submit()">';
3b093310 606foreach ($languages as $name=>$value) {
607 $selected = ($name == $CFG->lang) ? 'selected="selected"' : '';
608 echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
86453d8b 609}
3b093310 610echo '</select></div>';
611echo '</div>';
86453d8b 612
3b093310 613install_print_footer($config);
614die;
2961367e 615