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