MDL-18194 detect if driver install before trying to create db
[moodle.git] / install.php
CommitLineData
8b5b1028 1<?php /// $Id$
2 /// install.php - helps admin user to create a config.php file
3
8b5b1028 4
3b093310 5if (isset($_REQUEST['lang'])) {
6 $lang = eregi_replace('[^A-Za-z0-9_-]', '', $_REQUEST['lang']);
8b5b1028 7} else {
3b093310 8 $lang = 'en_utf8';
8b5b1028 9}
10
3b093310 11if (isset($_REQUEST['admin'])) {
12 $admin = eregi_replace('[^A-Za-z0-9_-]', '', $_REQUEST['admin']);
13} else {
14 $admin = 'admin';
8b5b1028 15}
16
3b093310 17/// If config.php exists we just created config.php and need to redirect to continue installation
18$configfile = './config.php';
19if (file_exists($configfile)) {
20 header("Location: $admin/index.php?lang=$lang");
21 die;
d36afd6d 22}
8d783716 23
3b093310 24/// make sure PHP errors are displayed - helps with diagnosing of problems
25@error_reporting(E_ALL);
26@ini_set('display_errors', '1');
27// we need a lot of memory
28@ini_set('memory_limit', '40M');
29
30/// Check that PHP is of a sufficient version
31if (version_compare(phpversion(), "5.2.0") < 0) {
32 $phpversion = phpversion();
33 // do NOT localise - lang strings would not work here and we CAN not move it after installib
34 echo "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion). ";
35 echo "Please upgrade your server software or install latest Moodle 1.9.x instead.";
36 die;
8b5b1028 37}
38
3b093310 39require dirname(__FILE__).'/lib/installlib.php';
bd507453 40
3b093310 41// TODO: add lang detection here if empty $_REQUEST['lang']
3b3b8029 42
5c1fb7d4 43// distro specific customisation
44$distro = null;
64c368e3 45if (file_exists('install/distro.php')) {
46 include('install/distro.php');
5c1fb7d4 47}
48
3b093310 49$config = new stdClass();
50$config->lang = $lang;
3b3b8029 51
3b093310 52if (!empty($_POST)) {
53 if (install_ini_get_bool('magic_quotes_gpc')) {
fa53493e 54 $_POST = array_map('stripslashes', $_POST);
3b093310 55 }
3b3b8029 56
3b093310 57 $config->stage = (int)$_POST['stage'];
56ca1c60 58
3b093310 59 if (isset($_POST['previous'])) {
60 $config->stage--;
5167827b 61 if (INSTALL_DATABASETYPE and !empty($distro->dbtype)) {
62 $config->stage--;
63 }
3b093310 64 if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_DOWNLOADLANG) {
65 $config->stage--;
56ca1c60 66 }
3b093310 67 } else if (isset($_POST['next'])) {
68 $config->stage++;
d36afd6d 69 }
3b3b8029 70
3b093310 71 $config->dbtype = trim($_POST['dbtype']);
72 $config->dbhost = trim($_POST['dbhost']);
73 $config->dbuser = trim($_POST['dbuser']);
74 $config->dbpass = trim($_POST['dbpass']);
75 $config->dbname = trim($_POST['dbname']);
76 $config->prefix = trim($_POST['prefix']);
77 $config->dbsocket = (int)(!empty($_POST['dbsocket']));
3b3b8029 78
3b093310 79 $config->dirroot = trim($_POST['dirroot']);
80 $config->admin = empty($_POST['admin']) ? 'admin' : trim($_POST['admin']);
53a0367d 81
3b093310 82 $config->dataroot = trim($_POST['dataroot']);
d36afd6d 83
3b3b8029 84} else {
3b093310 85 $config->stage = INSTALL_WELCOME;
8b5b1028 86
4f9dba35 87 $config->dbtype = empty($distro->dbtype) ? '' : $distro->dbtype; // let distro skip dbtype selection
6724b059 88 $config->dbhost = empty($distro->dbhost) ? 'localhost' : $distro->dbhost; // let distros set dbhost
89 $config->dbuser = empty($distro->dbuser) ? '' : $distro->dbuser; // let distros set dbuser
3b093310 90 $config->dbpass = '';
91 $config->dbname = 'moodle';
92 $config->prefix = 'mdl_';
93 $config->dbsocket = 0;
53a0367d 94
3b093310 95 $config->dirroot = dirname(__FILE__);
96 $config->admin = 'admin';
8b5b1028 97
4f9dba35 98 $config->dataroot = empty($distro->dataroot) ? null : $distro->dataroot; // initialised later after including libs or by distro
3b093310 99}
8b5b1028 100
101/// Fake some settings so that we can use selected functions from moodlelib.php and weblib.php
3b093310 102$CFG = new stdClass();
103$CFG->lang = $config->lang;
104$CFG->dirroot = dirname(__FILE__);
105$CFG->libdir = "$CFG->dirroot/lib";
106$CFG->wwwroot = install_guess_wwwroot(); // can not be changed - ppl must use the real address when installing
107$CFG->httpswwwroot = $CFG->wwwroot;
108$CFG->httpsthemewww = $CFG->wwwroot;
109$CFG->dataroot = $config->dataroot;
110$CFG->admin = $config->admin;
111$CFG->docroot = 'http://docs.moodle.org';
4b9efec4 112$CFG->directorypermissions = 00777;
3b093310 113$CFG->running_installer = true;
8d783716 114
3b093310 115/// Require all needed libs
d36afd6d 116require_once($CFG->libdir.'/setuplib.php');
3b093310 117require_once($CFG->libdir.'/textlib.class.php');
d36afd6d 118require_once($CFG->libdir.'/weblib.php');
3b093310 119require_once($CFG->libdir.'/dmllib.php');
251387d0 120require_once($CFG->libdir.'/moodlelib.php');
3b093310 121require_once($CFG->libdir.'/deprecatedlib.php');
251387d0 122require_once($CFG->libdir.'/adminlib.php');
d36afd6d 123require_once($CFG->libdir.'/environmentlib.php');
124require_once($CFG->libdir.'/xmlize.php');
125require_once($CFG->libdir.'/componentlib.class.php');
3b093310 126
127require('version.php');
9ace5094 128$CFG->target_release = $release;
3b093310 129
130$SESSION = new object();
131$SESSION->lang = $CFG->lang;
132
133$USER = new object();
134$USER->id = 0;
135
136$COURSE = new object();
137$COURSE->id = 0;
138
139$SITE = $COURSE;
140define('SITEID', 0);
141
142$hint_dataroot = '';
143$hint_dirroot = '';
144$hint_admindir = '';
145$hint_database = '';
146
147/// Are we in help mode?
148if (isset($_GET['help'])) {
149 install_print_help_page($_GET['help']);
150}
151
152/// send css?
153if (isset($_GET['css'])) {
154 install_css_styles();
6d5a22b2 155}
8b5b1028 156
3b093310 157///first time here? find out suitable dataroot
158if (is_null($CFG->dataroot)) {
159 $CFG->dataroot = str_replace('\\', '/', dirname(dirname(__FILE__)).'/moodledata');
add47d44 160
add47d44 161 $i = 0; //safety check - dirname might return some unexpected results
162 while(is_dataroot_insecure()) {
163 $parrent = dirname($CFG->dataroot);
164 $i++;
b735d140 165 if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
add47d44 166 $CFG->dataroot = ''; //can not find secure location for dataroot
167 break;
168 }
169 $CFG->dataroot = dirname($parrent).'/moodledata';
170 }
3b093310 171 $config->dataroot = $CFG->dataroot;
172 $config->stage = INSTALL_WELCOME;
8b5b1028 173}
174
3b093310 175// now let's do the stage work
176if ($config->stage < INSTALL_WELCOME) {
177 $config->stage = INSTALL_WELCOME;
178}
179if ($config->stage > INSTALL_SAVE) {
180 $config->stage = INSTALL_SAVE;
8d783716 181}
182
183
51e3e0b9 184
3b093310 185if ($config->stage == INSTALL_SAVE) {
186 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
187 if (!$database->driver_installed()) {
188 $config->stage = INSTALL_DATABASETYPE;
189 } else {
6724b059 190 $hint_database = install_db_validate($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersit'=>0, 'dbsocket'=>$config->dbsocket), $distro);
edd3a5db 191
3b093310 192 if ($hint_database === '') {
193 $configphp = '<?php /// Moodle Configuration File ' . "\r\n\r\n";
8d783716 194
3b093310 195 $configphp .= 'unset($CFG);'."\r\n";
196 $configphp .= '$CFG = new stdClass();'."\r\n\r\n"; // prevent PHP5 strict warnings
51e3e0b9 197
3b093310 198 $dbconfig = $database->export_dbconfig();
51e3e0b9 199
3b093310 200 foreach ($dbconfig as $key=>$value) {
201 $key = str_pad($key, 9);
202 $configphp .= '$CFG->'.$key.' = '.var_export($value, true).";\r\n";
203 }
204 $configphp .= "\r\n";
8b5b1028 205
3b093310 206 $configphp .= '$CFG->wwwroot = '.var_export($CFG->wwwroot, true).";\r\n";
8b5b1028 207
3b093310 208 if ($CFG->dirroot !== $config->dirroot) {
209 $configphp .= '$CFG->dirroot = realpath('.var_export($config->dirroot, true).");\r\n"; // fix for sym links
210 } else {
211 $dirroot = str_replace('\\', '/', $CFG->dirroot); // win32 fix
212 $dirroot = rtrim($dirroot, '/'); // no trailing /
213 $configphp .= '$CFG->dirroot = '.var_export($dirroot, true).";\r\n";
214 }
8b5b1028 215
3b093310 216 $dataroot = str_replace('\\', '/', $config->dataroot); // win32 fix
217 $dataroot = rtrim($dataroot, '/'); // no trailing /
218 $configphp .= '$CFG->dataroot = '.var_export($dataroot, true).";\r\n";
8d783716 219
3b093310 220 $configphp .= '$CFG->admin = '.var_export($config->admin, true).";\r\n\r\n";
8b5b1028 221
3b093310 222 $configphp .= '$CFG->directorypermissions = 00777; // try 02777 on a server in Safe Mode'."\r\n";
223 $configphp .= "\r\n";
53a0367d 224
3b093310 225 $configphp .= 'require_once("$CFG->dirroot/lib/setup.php");'."\r\n\r\n";
226 $configphp .= '// There is no php closing tag in this file,'."\r\n";
227 $configphp .= '// it is intentional because it prevents trailing whitespace problems!'."\r\n";
53a0367d 228
3b093310 229 umask(0137);
230
231 if (($fh = @fopen($configfile, 'w')) !== false) {
232 fwrite($fh, $configphp);
233 fclose($fh);
234 }
235
236 if (file_exists($configfile)) {
237 // config created, let's continue!
238 redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
239 }
2df3a721 240
3b093310 241 install_print_header($config, 'config.php',
242 get_string('configurationcompletehead', 'install'),
243 get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install'));
244 echo '<div class="configphp"><pre>';
245 echo p($configphp);
246 echo '</pre></div>';
bba0beae 247
3b093310 248 install_print_footer($config);
249 die;
8b5b1028 250
3b093310 251 } else {
252 $config->stage = INSTALL_DATABASE;
253 }
6d5a22b2 254 }
8b5b1028 255}
256
257
258
5167827b 259if ($config->stage == INSTALL_DOWNLOADLANG) {
260 if (empty($CFG->dataroot)) {
261 $config->stage = INSTALL_PATHS;
262
263 } else if (is_dataroot_insecure()) {
264 $hint_dataroot = get_string('pathsunsecuredataroot', 'install');
265 $config->stage = INSTALL_PATHS;
266
267 } else if (!is_writable($CFG->dataroot)) {
268 $hint_dataroot = get_string('pathsrodataroot', 'install');
269 $config->stage = INSTALL_PATHS;
270 }
271
272 if ($config->dirroot === '' or !file_exists($config->dirroot)) {
273 $hint_dirroot = get_string('pathswrongdirroot', 'install');
274 $config->stage = INSTALL_PATHS;
275 }
276
277 if ($config->admin === '' or !file_exists($config->dirroot.'/'.$config->admin.'/environment.xml')) {
278 $hint_admindir = get_string('pathswrongadmindir', 'install');
279 $config->stage = INSTALL_PATHS;
280 }
281}
282
283
284
285if ($config->stage == INSTALL_DOWNLOADLANG) {
286 // no need to download anything if en lang selected
287 if ($CFG->lang == 'en_utf8') {
288 $config->stage = INSTALL_DATABASETYPE;
289 }
290}
291
292
293
294if ($config->stage == INSTALL_DATABASETYPE) {
295 // skip db selection if distro package supports only one db
296 if (!empty($distro->dbtype)) {
297 $config->stage = INSTALL_DATABASE;
298 }
299}
300
301
302
3b093310 303if ($config->stage == INSTALL_DATABASE) {
304 $database = moodle_database::get_driver_instance($config->dbtype, 'native');
8b5b1028 305
3b093310 306 $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
8d783716 307
3b093310 308 install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
53a0367d 309
3b093310 310 $strdbhost = get_string('databasehost', 'install');
311 $strdbname = get_string('databasename', 'install');
312 $strdbuser = get_string('databaseuser', 'install');
313 $strdbpass = get_string('databasepass', 'install');
314 $strprefix = get_string('dbprefix', 'install');
315 $strdbsocket = get_string('databasesocket', 'install');
8d783716 316
3b093310 317 echo '<div class="userinput">';
6724b059 318
319 $disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
3b093310 320 echo '<div class="formrow"><label for="id_dbhost" class="formlabel">'.$strdbhost.'</label>';
6724b059 321 echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="30" class="forminput" />';
3b093310 322 echo '</div>';
8b5b1028 323
3b093310 324 echo '<div class="formrow"><label for="id_dbname" class="formlabel">'.$strdbname.'</label>';
325 echo '<input id="id_dbname" name="dbname" type="text" value="'.s($config->dbname).'" size="30" class="forminput" />';
326 echo '</div>';
86453d8b 327
6724b059 328 $disabled = empty($distro->dbuser) ? '' : 'disabled="disabled';
3b093310 329 echo '<div class="formrow"><label for="id_dbuser" class="formlabel">'.$strdbuser.'</label>';
6724b059 330 echo '<input id="id_dbuser" name="dbuser" '.$disabled.' type="text" value="'.s($config->dbuser).'" size="30" class="forminput" />';
3b093310 331 echo '</div>';
86453d8b 332
3b093310 333 echo '<div class="formrow"><label for="id_dbpass" class="formlabel">'.$strdbpass.'</label>';
334 // no password field here, the password may be visible in config.php if we can not write it to disk
335 echo '<input id="id_dbpass" name="dbpass" type="text" value="'.s($config->dbpass).'" size="30" class="forminput" />';
336 echo '</div>';
86453d8b 337
3b093310 338 echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strprefix.'</label>';
339 echo '<input id="id_prefix" name="prefix" type="text" value="'.s($config->prefix).'" size="10" class="forminput" />';
340 echo '</div>';
fe515206 341
3b093310 342 if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
343 $checked = $config->dbsocket ? 'checked="checked' : '';
344 echo '<div class="formrow"><label for="id_dbsocket" class="formlabel">'.$strdbsocket.'</label>';
345 echo '<input type="hidden" value="0" name="dbsocket" />';
346 echo '<input type="checkbox" id="id_dbsocket" value="1" name="dbsocket" '.$checked.' class="forminput" />';
347 echo '</div>';
8b5b1028 348 }
349
3b093310 350 echo '<div class="hint">'.$hint_database.'</div>';
351 echo '</div>';
352 install_print_footer($config);
353 die;
8b5b1028 354}
355
356
357
3b093310 358if ($config->stage == INSTALL_DOWNLOADLANG) {
cdef6d42 359 $downloaderror = '';
360
cdef6d42 361/// Create necessary lang dir
362 if (!make_upload_directory('lang', false)) {
363 $downloaderror = get_string('cannotcreatelangdir', 'error');
cdef6d42 364
3b093310 365/// Download and install lang component
366 } else if ($cd = new component_installer('http://download.moodle.org', 'lang16', $CFG->lang.'.zip', 'languages.md5', 'lang')) {
367 if ($cd->install() == COMPONENT_ERROR) {
368 if ($cd->get_error() == 'remotedownloaderror') {
369 $a = new stdClass();
370 $a->url = 'http://download.moodle.org/lang16/'.$INSTALL['language'].'.zip';
371 $a->dest = $CFG->dataroot.'/lang';
372 $downloaderror = get_string($cd->get_error(), 'error', $a);
373 } else {
374 $downloaderror = get_string($cd->get_error(), 'error');
375 }
cc872745 376 } else {
377 // install parent lang if defined
378 if ($parentlang = get_parent_language()) {
379 if ($cd = new component_installer('http://download.moodle.org', 'lang16', $parentlang.'.zip', 'languages.md5', 'lang')) {
380 $cd->install();
381 }
382 }
cdef6d42 383 }
cdef6d42 384 }
385
3b093310 386 if ($downloaderror !== '') {
387 install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang), $downloaderror);
388 install_print_footer($config);
389 die;
cdef6d42 390 } else {
3b093310 391 $config->stage = INSTALL_DATABASETYPE;
cdef6d42 392 }
53a0367d 393}
cdef6d42 394
395
396
3b093310 397if ($config->stage == INSTALL_DATABASETYPE) {
398 /// Finally ask for DB type
399 install_print_header($config, get_string('database', 'install'),
400 get_string('databasetypehead', 'install'),
401 get_string('databasetypesub', 'install'));
51e3e0b9 402
3b093310 403 // TODO: move this PHP5 code to lib/installib.php so that this file parses in PHP4
404 $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
405 'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
406 'oci' => moodle_database::get_driver_instance('oci', 'native'),
407 //'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // new MS sql driver - win32 only
408 //'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
409 );
51e3e0b9 410
3b093310 411 echo '<div class="userinput">';
412 echo '<div class="formrow"><label class="formlabel" for="dbtype">'.get_string('dbtype', 'install').'</label>';
413 echo '<select id="dbtype" name="dbtype" class="forminput">';
414 $disabled = array();
415 $options = array();
416 foreach ($databases as $type=>$database) {
417 if ($database->driver_installed() !== true) {
418 $disabled[$type] = $database;
419 continue;
420 }
421 echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
51e3e0b9 422 }
3b093310 423 if ($disabled) {
424 echo '<optgroup label="'.s(get_string('notavailable')).'">';
425 foreach ($disabled as $type=>$database) {
426 echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
427 }
428 echo '</optgroup>';
8b5b1028 429 }
3b093310 430 echo '</select></div>';
431 echo '</div>';
53a0367d 432
3b093310 433 install_print_footer($config);
434 die;
8b5b1028 435}
436
437
438
3b093310 439if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
440 $version_fail = (version_compare(phpversion(), "5.2.8") < 0);
441 $curl_fail = ($lang !== 'en_utf8' and !extension_loaded('curl')); // needed for lang pack download
442 $zip_fail = ($lang !== 'en_utf8' and !extension_loaded('zip')); // needed for lang pack download
8b5b1028 443
3b093310 444 if ($version_fail or $curl_fail or $zip_fail) {
445 $config->stage = INSTALL_ENVIRONMENT;
8b5b1028 446
3b093310 447 install_print_header($config, get_string('environment', 'install'),
448 get_string('errorsinenvironment', 'install'),
449 get_string('environmentsub2', 'install'));
8b5b1028 450
3b093310 451 echo '<div id="envresult"><dl>';
452 if ($version_fail) {
453 $a = (object)array('needed'=>'5.2.8', 'current'=>phpversion());
454 echo '<dt>'.get_string('phpversion', 'install').'</dt><dd>'.get_string('environmentrequireversion', 'admin', $a).'</dd>';
455 }
456 if ($curl_fail) {
457 echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
458 }
459 if ($zip_fail) {
460 echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
461 }
462 echo '</dl></div>';
8d783716 463
3b093310 464 install_print_footer($config, true);
465 die;
51e3e0b9 466
8b5b1028 467 } else {
3b093310 468 $config->stage = INSTALL_PATHS;
8b5b1028 469 }
8b5b1028 470}
471
8b5b1028 472
8b5b1028 473
3b093310 474if ($config->stage == INSTALL_PATHS) {
475 $paths = array('wwwroot' => get_string('wwwroot', 'install'),
476 'dirroot' => get_string('dirroot', 'install'),
477 'dataroot' => get_string('dataroot', 'install'),
478 'admindir' => get_string('admindirname', 'install'));
627d326a 479
3b093310 480 $sub = '<dl>';
481 foreach ($paths as $path=>$name) {
482 $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
8b5b1028 483 }
3b093310 484 $sub .= '</dl>';
cd0e958e 485
3b093310 486 install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
627d326a 487
3b093310 488 $strwwwroot = get_string('wwwroot', 'install');
489 $strdirroot = get_string('dirroot', 'install');
490 $strdataroot = get_string('dataroot', 'install');
491 $stradmindirname = get_string('admindirname', 'install');
cdef6d42 492
3b093310 493 echo '<div class="userinput">';
494 echo '<div class="formrow"><label for="id_wwwroot" class="formlabel">'.$paths['wwwroot'].'</label>';
495 echo '<input id="id_wwwroot" name="wwwroot" type="text" value="'.s($CFG->wwwroot).'" disabled="disabled" size="45" class="forminput" />';
496 echo '</div>';
cd0e958e 497
3b093310 498 echo '<div class="formrow"><label for="id_dirroot" class="formlabel">'.$paths['dirroot'].'</label>';
499 echo '<input id="id_dirroot" name="dirroot" type="text" value="'.s($config->dirroot).'" size="45"class="forminput" />';
500 if ($hint_dirroot !== '') {
501 echo '<div class="hint">'.$hint_dirroot.'</div>';
cdef6d42 502 }
3b093310 503 echo '</div>';
53a0367d 504
3b093310 505 echo '<div class="formrow"><label for="id_dataroot" class="formlabel">'.$paths['dataroot'].'</label>';
506 echo '<input id="id_dataroot" name="dataroot" type="text" value="'.s($config->dataroot).'" size="45" class="forminput" />';
507 if ($hint_dataroot !== '') {
508 echo '<div class="hint">'.$hint_dataroot.'</div>';
cdef6d42 509 }
3b093310 510 echo '</div>';
8b5b1028 511
8d783716 512
3b093310 513 if (file_exists("$CFG->dirroot/admin/environment.xml")) {
514 $disabled = 'disabled="disabled"';
8d783716 515 } else {
3b093310 516 $disabled = '';
8d783716 517 }
3b093310 518 echo '<div class="formrow"><label for="id_admin" class="formlabel">'.$paths['admindir'].'</label>';
519 echo '<input id="id_admin" name="admin" type="text" value="'.s($config->admin).'" '.$disabled.' size="10" class="forminput" />';
520 if ($hint_admindir !== '') {
521 echo '<div class="hint">'.$hint_admindir.'</div>';
8d783716 522 }
3b093310 523 echo '</div>';
8d783716 524
3b093310 525 echo '</div>';
8d783716 526
3b093310 527 install_print_footer($config);
528 die;
8d783716 529}
530
86453d8b 531
86453d8b 532
3b093310 533$config->stage = INSTALL_WELCOME;
64c368e3 534
535if ($distro) {
536 ob_start();
537 include('install/distribution.html');
538 $sub = ob_get_clean();
539
540 install_print_header($config, get_string('language'),
541 get_string('chooselanguagehead', 'install'),
542 $sub);
543
544} else {
545 install_print_header($config, get_string('language'),
546 get_string('chooselanguagehead', 'install'),
547 get_string('chooselanguagesub', 'install'));
548}
86453d8b 549
3b093310 550$languages = install_get_list_of_languages();
551echo '<div class="userinput">';
552echo '<div class="formrow"><label class="formlabel" for="langselect">'.get_string('language').'</label>';
4d928665 553echo '<select id="langselect" name="lang" class="forminput" onchange="this.form.submit()">';
3b093310 554foreach ($languages as $name=>$value) {
555 $selected = ($name == $CFG->lang) ? 'selected="selected"' : '';
556 echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
86453d8b 557}
3b093310 558echo '</select></div>';
559echo '</div>';
86453d8b 560
3b093310 561install_print_footer($config);
562die;
2961367e 563