MDL-22059 fixing install_string_manager to work with new installer language formats
[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
3b093310 54if (version_compare(phpversion(), "5.2.0") < 0) {
55 $phpversion = phpversion();
56 // do NOT localise - lang strings would not work here and we CAN not move it after installib
86449d22 57 echo "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion).<br />";
3b093310 58 echo "Please upgrade your server software or install latest Moodle 1.9.x instead.";
59 die;
8b5b1028 60}
61
86449d22
PS
62if (PHP_INT_SIZE > 4) {
63 // most probably 64bit PHP - we need a lot more memory
64 $minrequiredmemory = '70M';
65} else {
66 // 32bit PHP
67 $minrequiredmemory = '40M';
68}
69// increase or decrease available memory - we need to make sure moodle
70// installs even with low memory, otherwise developers would overlook
71// sudden increases of memory needs ;-)
72@ini_set('memory_limit', $minrequiredmemory);
73
3b093310 74require dirname(__FILE__).'/lib/installlib.php';
bd507453 75
3b093310 76// TODO: add lang detection here if empty $_REQUEST['lang']
3b3b8029 77
5c1fb7d4 78// distro specific customisation
79$distro = null;
768408e8 80if (file_exists('install/distrolib.php')) {
81 require_once('install/distrolib.php');
82 if (function_exists('distro_get_config')) {
83 $distro = distro_get_config();
84 }
5c1fb7d4 85}
86
3b093310 87$config = new stdClass();
88$config->lang = $lang;
3b3b8029 89
3b093310 90if (!empty($_POST)) {
91 if (install_ini_get_bool('magic_quotes_gpc')) {
fa53493e 92 $_POST = array_map('stripslashes', $_POST);
3b093310 93 }
3b3b8029 94
3b093310 95 $config->stage = (int)$_POST['stage'];
56ca1c60 96
3b093310 97 if (isset($_POST['previous'])) {
98 $config->stage--;
5167827b 99 if (INSTALL_DATABASETYPE and !empty($distro->dbtype)) {
100 $config->stage--;
101 }
3b093310 102 if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_DOWNLOADLANG) {
103 $config->stage--;
56ca1c60 104 }
3b093310 105 } else if (isset($_POST['next'])) {
106 $config->stage++;
d36afd6d 107 }
3b3b8029 108
3b093310 109 $config->dbtype = trim($_POST['dbtype']);
110 $config->dbhost = trim($_POST['dbhost']);
111 $config->dbuser = trim($_POST['dbuser']);
112 $config->dbpass = trim($_POST['dbpass']);
113 $config->dbname = trim($_POST['dbname']);
114 $config->prefix = trim($_POST['prefix']);
115 $config->dbsocket = (int)(!empty($_POST['dbsocket']));
3b3b8029 116
3b093310 117 $config->dirroot = trim($_POST['dirroot']);
118 $config->admin = empty($_POST['admin']) ? 'admin' : trim($_POST['admin']);
53a0367d 119
3b093310 120 $config->dataroot = trim($_POST['dataroot']);
d36afd6d 121
3b3b8029 122} else {
3b093310 123 $config->stage = INSTALL_WELCOME;
8b5b1028 124
4f9dba35 125 $config->dbtype = empty($distro->dbtype) ? '' : $distro->dbtype; // let distro skip dbtype selection
6724b059 126 $config->dbhost = empty($distro->dbhost) ? 'localhost' : $distro->dbhost; // let distros set dbhost
127 $config->dbuser = empty($distro->dbuser) ? '' : $distro->dbuser; // let distros set dbuser
3b093310 128 $config->dbpass = '';
129 $config->dbname = 'moodle';
130 $config->prefix = 'mdl_';
131 $config->dbsocket = 0;
53a0367d 132
f571f5f5 133 $config->dirroot = str_replace('\\', '/', dirname(__FILE__)); // Fix for win32
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;
f571f5f5 142$CFG->dirroot = str_replace('\\', '/', dirname(__FILE__)); // Fix for win32
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 = '';
204$hint_dirroot = '';
205$hint_admindir = '';
206$hint_database = '';
207
082157a8 208// Are we in help mode?
3b093310 209if (isset($_GET['help'])) {
210 install_print_help_page($_GET['help']);
211}
212
082157a8 213// send css?
3b093310 214if (isset($_GET['css'])) {
215 install_css_styles();
6d5a22b2 216}
8b5b1028 217
082157a8 218//first time here? find out suitable dataroot
3b093310 219if (is_null($CFG->dataroot)) {
220 $CFG->dataroot = str_replace('\\', '/', dirname(dirname(__FILE__)).'/moodledata');
add47d44 221
add47d44 222 $i = 0; //safety check - dirname might return some unexpected results
223 while(is_dataroot_insecure()) {
224 $parrent = dirname($CFG->dataroot);
225 $i++;
b735d140 226 if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
add47d44 227 $CFG->dataroot = ''; //can not find secure location for dataroot
228 break;
229 }
230 $CFG->dataroot = dirname($parrent).'/moodledata';
231 }
3b093310 232 $config->dataroot = $CFG->dataroot;
233 $config->stage = INSTALL_WELCOME;
8b5b1028 234}
235
3b093310 236// now let's do the stage work
237if ($config->stage < INSTALL_WELCOME) {
238 $config->stage = INSTALL_WELCOME;
239}
240if ($config->stage > INSTALL_SAVE) {
241 $config->stage = INSTALL_SAVE;
8d783716 242}
243
244
51e3e0b9 245
3b093310 246if ($config->stage == INSTALL_SAVE) {
3a915b06
PS
247 $CFG->early_install_lang = false;
248
3b093310 249 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
250 if (!$database->driver_installed()) {
251 $config->stage = INSTALL_DATABASETYPE;
252 } else {
082157a8 253 if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
a0b7200d 254 $distro = distro_pre_create_db($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbsocket'=>$config->dbsocket), $distro);
768408e8 255 }
a0b7200d 256 $hint_database = install_db_validate($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbsocket'=>$config->dbsocket));
edd3a5db 257
3b093310 258 if ($hint_database === '') {
082157a8 259 // extra hackery needed for symbolic link support
260 if ($CFG->dirroot !== $config->dirroot) {
261 $CFG->dirroot = $config->dirroot;
262 $userealpath = true;
3b093310 263 } else {
082157a8 264 $userealpath = false;
3b093310 265 }
082157a8 266 $configphp = install_generate_configphp($database, $CFG, $userealpath);
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 {
082157a8 313 if (!make_upload_directory('lang', false)) {
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
325 if ($config->dirroot === '' or !file_exists($config->dirroot)) {
326 $hint_dirroot = get_string('pathswrongdirroot', 'install');
327 $config->stage = INSTALL_PATHS;
328 }
329
330 if ($config->admin === '' or !file_exists($config->dirroot.'/'.$config->admin.'/environment.xml')) {
331 $hint_admindir = get_string('pathswrongadmindir', 'install');
332 $config->stage = INSTALL_PATHS;
333 }
334}
335
336
337
338if ($config->stage == INSTALL_DOWNLOADLANG) {
339 // no need to download anything if en lang selected
3a915b06 340 if ($CFG->lang == 'en') {
5167827b 341 $config->stage = INSTALL_DATABASETYPE;
342 }
343}
344
345
346
347if ($config->stage == INSTALL_DATABASETYPE) {
348 // skip db selection if distro package supports only one db
349 if (!empty($distro->dbtype)) {
350 $config->stage = INSTALL_DATABASE;
351 }
352}
353
354
08261d3a 355if ($config->stage == INSTALL_DOWNLOADLANG) {
356 $downloaderror = '';
357
082157a8 358// Create necessary lang dir
08261d3a 359 if (!make_upload_directory('lang', false)) {
360 $downloaderror = get_string('cannotcreatelangdir', 'error');
361
082157a8 362// Download and install lang component
3a915b06 363 } else if ($cd = new component_installer('http://download.moodle.org', 'lang20', $CFG->lang.'.zip', 'languages.md5', 'lang')) {
08261d3a 364 if ($cd->install() == COMPONENT_ERROR) {
365 if ($cd->get_error() == 'remotedownloaderror') {
366 $a = new stdClass();
d8fa5a13 367 $a->url = 'http://download.moodle.org/lang20/'.$config->lang.'.zip';
08261d3a 368 $a->dest = $CFG->dataroot.'/lang';
369 $downloaderror = get_string($cd->get_error(), 'error', $a);
370 } else {
371 $downloaderror = get_string($cd->get_error(), 'error');
372 }
373 } else {
374 // install parent lang if defined
375 if ($parentlang = get_parent_language()) {
3a915b06 376 if ($cd = new component_installer('http://download.moodle.org', 'lang20', $parentlang.'.zip', 'languages.md5', 'lang')) {
08261d3a 377 $cd->install();
378 }
379 }
380 }
381 }
382
383 if ($downloaderror !== '') {
384 install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang), $downloaderror);
385 install_print_footer($config);
386 die;
387 } else {
388 if (empty($distro->dbtype)) {
389 $config->stage = INSTALL_DATABASETYPE;
390 } else {
391 $config->stage = INSTALL_DATABASE;
392 }
393 }
394}
395
5167827b 396
3b093310 397if ($config->stage == INSTALL_DATABASE) {
3a915b06
PS
398 $CFG->early_install_lang = false;
399
3b093310 400 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
8b5b1028 401
3b093310 402 $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
8d783716 403
3b093310 404 install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
53a0367d 405
3b093310 406 $strdbhost = get_string('databasehost', 'install');
407 $strdbname = get_string('databasename', 'install');
408 $strdbuser = get_string('databaseuser', 'install');
409 $strdbpass = get_string('databasepass', 'install');
410 $strprefix = get_string('dbprefix', 'install');
411 $strdbsocket = get_string('databasesocket', 'install');
8d783716 412
3b093310 413 echo '<div class="userinput">';
6724b059 414
415 $disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
3b093310 416 echo '<div class="formrow"><label for="id_dbhost" class="formlabel">'.$strdbhost.'</label>';
6724b059 417 echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="30" class="forminput" />';
3b093310 418 echo '</div>';
8b5b1028 419
3b093310 420 echo '<div class="formrow"><label for="id_dbname" class="formlabel">'.$strdbname.'</label>';
421 echo '<input id="id_dbname" name="dbname" type="text" value="'.s($config->dbname).'" size="30" class="forminput" />';
422 echo '</div>';
86453d8b 423
6724b059 424 $disabled = empty($distro->dbuser) ? '' : 'disabled="disabled';
3b093310 425 echo '<div class="formrow"><label for="id_dbuser" class="formlabel">'.$strdbuser.'</label>';
6724b059 426 echo '<input id="id_dbuser" name="dbuser" '.$disabled.' type="text" value="'.s($config->dbuser).'" size="30" class="forminput" />';
3b093310 427 echo '</div>';
86453d8b 428
3b093310 429 echo '<div class="formrow"><label for="id_dbpass" class="formlabel">'.$strdbpass.'</label>';
430 // no password field here, the password may be visible in config.php if we can not write it to disk
431 echo '<input id="id_dbpass" name="dbpass" type="text" value="'.s($config->dbpass).'" size="30" class="forminput" />';
432 echo '</div>';
86453d8b 433
3b093310 434 echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strprefix.'</label>';
435 echo '<input id="id_prefix" name="prefix" type="text" value="'.s($config->prefix).'" size="10" class="forminput" />';
436 echo '</div>';
fe515206 437
3b093310 438 if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
439 $checked = $config->dbsocket ? 'checked="checked' : '';
440 echo '<div class="formrow"><label for="id_dbsocket" class="formlabel">'.$strdbsocket.'</label>';
441 echo '<input type="hidden" value="0" name="dbsocket" />';
442 echo '<input type="checkbox" id="id_dbsocket" value="1" name="dbsocket" '.$checked.' class="forminput" />';
443 echo '</div>';
8b5b1028 444 }
445
3b093310 446 echo '<div class="hint">'.$hint_database.'</div>';
447 echo '</div>';
448 install_print_footer($config);
449 die;
8b5b1028 450}
451
452
3b093310 453if ($config->stage == INSTALL_DATABASETYPE) {
3a915b06
PS
454 $CFG->early_install_lang = false;
455
082157a8 456 // Finally ask for DB type
3b093310 457 install_print_header($config, get_string('database', 'install'),
458 get_string('databasetypehead', 'install'),
459 get_string('databasetypesub', 'install'));
51e3e0b9 460
3b093310 461 // TODO: move this PHP5 code to lib/installib.php so that this file parses in PHP4
462 $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
463 'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
464 'oci' => moodle_database::get_driver_instance('oci', 'native'),
465 //'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // new MS sql driver - win32 only
466 //'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
467 );
51e3e0b9 468
3b093310 469 echo '<div class="userinput">';
470 echo '<div class="formrow"><label class="formlabel" for="dbtype">'.get_string('dbtype', 'install').'</label>';
471 echo '<select id="dbtype" name="dbtype" class="forminput">';
472 $disabled = array();
473 $options = array();
474 foreach ($databases as $type=>$database) {
475 if ($database->driver_installed() !== true) {
476 $disabled[$type] = $database;
477 continue;
478 }
479 echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
51e3e0b9 480 }
3b093310 481 if ($disabled) {
482 echo '<optgroup label="'.s(get_string('notavailable')).'">';
483 foreach ($disabled as $type=>$database) {
484 echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
485 }
486 echo '</optgroup>';
8b5b1028 487 }
3b093310 488 echo '</select></div>';
489 echo '</div>';
53a0367d 490
3b093310 491 install_print_footer($config);
492 die;
8b5b1028 493}
494
495
496
3b093310 497if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
498 $version_fail = (version_compare(phpversion(), "5.2.8") < 0);
3a915b06
PS
499 $curl_fail = ($lang !== 'en' and !extension_loaded('curl')); // needed for lang pack download
500 $zip_fail = ($lang !== 'en' and !extension_loaded('zip')); // needed for lang pack download
8b5b1028 501
3b093310 502 if ($version_fail or $curl_fail or $zip_fail) {
503 $config->stage = INSTALL_ENVIRONMENT;
8b5b1028 504
3b093310 505 install_print_header($config, get_string('environment', 'install'),
506 get_string('errorsinenvironment', 'install'),
507 get_string('environmentsub2', 'install'));
8b5b1028 508
3b093310 509 echo '<div id="envresult"><dl>';
510 if ($version_fail) {
511 $a = (object)array('needed'=>'5.2.8', 'current'=>phpversion());
512 echo '<dt>'.get_string('phpversion', 'install').'</dt><dd>'.get_string('environmentrequireversion', 'admin', $a).'</dd>';
513 }
514 if ($curl_fail) {
515 echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
516 }
517 if ($zip_fail) {
518 echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
519 }
520 echo '</dl></div>';
8d783716 521
3b093310 522 install_print_footer($config, true);
523 die;
51e3e0b9 524
8b5b1028 525 } else {
3b093310 526 $config->stage = INSTALL_PATHS;
8b5b1028 527 }
8b5b1028 528}
529
8b5b1028 530
8b5b1028 531
3b093310 532if ($config->stage == INSTALL_PATHS) {
533 $paths = array('wwwroot' => get_string('wwwroot', 'install'),
534 'dirroot' => get_string('dirroot', 'install'),
535 'dataroot' => get_string('dataroot', 'install'),
536 'admindir' => get_string('admindirname', 'install'));
627d326a 537
3b093310 538 $sub = '<dl>';
539 foreach ($paths as $path=>$name) {
540 $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
8b5b1028 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>';
553 echo '<input id="id_wwwroot" name="wwwroot" type="text" value="'.s($CFG->wwwroot).'" disabled="disabled" size="45" class="forminput" />';
554 echo '</div>';
cd0e958e 555
3b093310 556 echo '<div class="formrow"><label for="id_dirroot" class="formlabel">'.$paths['dirroot'].'</label>';
557 echo '<input id="id_dirroot" name="dirroot" type="text" value="'.s($config->dirroot).'" size="45"class="forminput" />';
558 if ($hint_dirroot !== '') {
559 echo '<div class="hint">'.$hint_dirroot.'</div>';
cdef6d42 560 }
3b093310 561 echo '</div>';
53a0367d 562
3b093310 563 echo '<div class="formrow"><label for="id_dataroot" class="formlabel">'.$paths['dataroot'].'</label>';
564 echo '<input id="id_dataroot" name="dataroot" type="text" value="'.s($config->dataroot).'" size="45" class="forminput" />';
565 if ($hint_dataroot !== '') {
566 echo '<div class="hint">'.$hint_dataroot.'</div>';
cdef6d42 567 }
3b093310 568 echo '</div>';
8b5b1028 569
8d783716 570
3b093310 571 if (file_exists("$CFG->dirroot/admin/environment.xml")) {
572 $disabled = 'disabled="disabled"';
8d783716 573 } else {
3b093310 574 $disabled = '';
8d783716 575 }
3b093310 576 echo '<div class="formrow"><label for="id_admin" class="formlabel">'.$paths['admindir'].'</label>';
577 echo '<input id="id_admin" name="admin" type="text" value="'.s($config->admin).'" '.$disabled.' size="10" class="forminput" />';
578 if ($hint_admindir !== '') {
579 echo '<div class="hint">'.$hint_admindir.'</div>';
8d783716 580 }
3b093310 581 echo '</div>';
8d783716 582
3b093310 583 echo '</div>';
8d783716 584
3b093310 585 install_print_footer($config);
586 die;
8d783716 587}
588
86453d8b 589
86453d8b 590
3b093310 591$config->stage = INSTALL_WELCOME;
64c368e3 592
593if ($distro) {
594 ob_start();
595 include('install/distribution.html');
596 $sub = ob_get_clean();
597
598 install_print_header($config, get_string('language'),
599 get_string('chooselanguagehead', 'install'),
600 $sub);
082157a8 601
64c368e3 602} else {
603 install_print_header($config, get_string('language'),
604 get_string('chooselanguagehead', 'install'),
605 get_string('chooselanguagesub', 'install'));
606}
86453d8b 607
2357ab49 608$languages = get_list_of_languages();
3b093310 609echo '<div class="userinput">';
610echo '<div class="formrow"><label class="formlabel" for="langselect">'.get_string('language').'</label>';
4d928665 611echo '<select id="langselect" name="lang" class="forminput" onchange="this.form.submit()">';
3b093310 612foreach ($languages as $name=>$value) {
613 $selected = ($name == $CFG->lang) ? 'selected="selected"' : '';
614 echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
86453d8b 615}
3b093310 616echo '</select></div>';
617echo '</div>';
86453d8b 618
3b093310 619install_print_footer($config);
620die;
2961367e 621