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