3 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
19 * This script creates config.php file during installation.
23 * @copyright 2009 Petr Skoda (http://skodak.org)
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 if (isset($_REQUEST['lang'])) {
28 $lang = preg_replace('/[^A-Za-z0-9_-]/i', '', $_REQUEST['lang']);
33 if (isset($_REQUEST['admin'])) {
34 $admin = preg_replace('/[^A-Za-z0-9_-]/i', '', $_REQUEST['admin']);
39 // If config.php exists we just created config.php and need to redirect to continue installation
40 $configfile = './config.php';
41 if (file_exists($configfile)) {
42 header("Location: $admin/index.php?lang=$lang");
46 define('CLI_SCRIPT', false); // prevents some warnings later
47 define('AJAX_SCRIPT', false); // prevents some warnings later
48 define('CACHE_DISABLE_ALL', true); // Disables caching.. just in case.
49 define('PHPUNIT_TEST', false);
50 define('IGNORE_COMPONENT_CACHE', true);
51 define('MDL_PERF_TEST', false);
53 // Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
54 if (!function_exists('date_default_timezone_set') or !function_exists('date_default_timezone_get')) {
55 echo("Timezone functions are not available.");
58 date_default_timezone_set(@date_default_timezone_get
());
60 // make sure PHP errors are displayed - helps with diagnosing of problems
61 @error_reporting
(E_ALL
);
62 @ini_set
('display_errors', '1');
64 // Check that PHP is of a sufficient version as soon as possible.
65 require_once(__DIR__
.'/lib/phpminimumversionlib.php');
66 moodle_require_minimum_php_version();
68 // make sure iconv is available and actually works
69 if (!function_exists('iconv')) {
70 // this should not happen, this must be very borked install
71 echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.';
75 if (PHP_INT_SIZE
> 4) {
76 // most probably 64bit PHP - we need a lot more memory
77 $minrequiredmemory = '70M';
80 $minrequiredmemory = '40M';
82 // increase or decrease available memory - we need to make sure moodle
83 // installs even with low memory, otherwise developers would overlook
84 // sudden increases of memory needs ;-)
85 @ini_set
('memory_limit', $minrequiredmemory);
87 /** Used by library scripts to check they are being called by Moodle */
88 define('MOODLE_INTERNAL', true);
90 require_once(__DIR__
.'/lib/classes/component.php');
91 require_once(__DIR__
.'/lib/installlib.php');
93 // TODO: add lang detection here if empty $_REQUEST['lang']
95 // distro specific customisation
97 if (file_exists('install/distrolib.php')) {
98 require_once('install/distrolib.php');
99 if (function_exists('distro_get_config')) {
100 $distro = distro_get_config();
104 $config = new stdClass();
105 $config->lang
= $lang;
107 if (!empty($_POST)) {
108 $config->stage
= (int)$_POST['stage'];
110 if (isset($_POST['previous'])) {
112 if (INSTALL_DATABASETYPE
and !empty($distro->dbtype
)) {
115 if ($config->stage
== INSTALL_ENVIRONMENT
or $config->stage
== INSTALL_DOWNLOADLANG
) {
118 } else if (isset($_POST['next'])) {
122 $config->dbtype
= trim($_POST['dbtype']);
123 $config->dbhost
= trim($_POST['dbhost']);
124 $config->dbuser
= trim($_POST['dbuser']);
125 $config->dbpass
= trim($_POST['dbpass']);
126 $config->dbname
= trim($_POST['dbname']);
127 $config->prefix
= trim($_POST['prefix']);
128 $config->dbport
= (int)trim($_POST['dbport']);
129 $config->dbsocket
= trim($_POST['dbsocket']);
131 if ($config->dbport
<= 0) {
132 $config->dbport
= '';
135 $config->admin
= empty($_POST['admin']) ?
'admin' : trim($_POST['admin']);
137 $config->dataroot
= trim($_POST['dataroot']);
140 $config->stage
= INSTALL_WELCOME
;
142 $config->dbtype
= empty($distro->dbtype
) ?
'' : $distro->dbtype
; // let distro skip dbtype selection
143 $config->dbhost
= empty($distro->dbhost
) ?
'localhost' : $distro->dbhost
; // let distros set dbhost
144 $config->dbuser
= empty($distro->dbuser
) ?
'' : $distro->dbuser
; // let distros set dbuser
145 $config->dbpass
= '';
146 $config->dbname
= 'moodle';
147 $config->prefix
= 'mdl_';
148 $config->dbport
= empty($distro->dbport
) ?
'' : $distro->dbport
;
149 $config->dbsocket
= empty($distro->dbsocket
) ?
'' : $distro->dbsocket
;
151 $config->admin
= 'admin';
153 $config->dataroot
= empty($distro->dataroot
) ?
null : $distro->dataroot
; // initialised later after including libs or by distro
156 // Fake some settings so that we can use selected functions from moodlelib.php, weblib.php and filelib.php.
158 $CFG = new stdClass();
159 $CFG->lang
= $config->lang
;
160 $CFG->dirroot
= __DIR__
;
161 $CFG->libdir
= "$CFG->dirroot/lib";
162 $CFG->wwwroot
= install_guess_wwwroot(); // can not be changed - ppl must use the real address when installing
163 $CFG->httpswwwroot
= $CFG->wwwroot
;
164 $CFG->dataroot
= $config->dataroot
;
165 $CFG->tempdir
= $CFG->dataroot
.'/temp';
166 $CFG->backuptempdir
= $CFG->tempdir
.'/backup';
167 $CFG->cachedir
= $CFG->dataroot
.'/cache';
168 $CFG->localcachedir
= $CFG->dataroot
.'/localcache';
169 $CFG->admin
= $config->admin
;
170 $CFG->docroot
= 'https://docs.moodle.org';
171 $CFG->langotherroot
= $CFG->dataroot
.'/lang';
172 $CFG->langlocalroot
= $CFG->dataroot
.'/lang';
173 $CFG->directorypermissions
= isset($distro->directorypermissions
) ?
$distro->directorypermissions
: 00777; // let distros set dir permissions
174 $CFG->filepermissions
= ($CFG->directorypermissions
& 0666);
175 $CFG->umaskpermissions
= (($CFG->directorypermissions
& 0777) ^
0777);
176 $CFG->running_installer
= true;
177 $CFG->early_install_lang
= true;
178 $CFG->ostype
= (stristr(PHP_OS
, 'win') && !stristr(PHP_OS
, 'darwin')) ?
'WINDOWS' : 'UNIX';
179 $CFG->debug
= (E_ALL | E_STRICT
);
180 $CFG->debugdisplay
= true;
181 $CFG->debugdeveloper
= true;
183 // Require all needed libs
184 require_once($CFG->libdir
.'/setuplib.php');
186 // we need to make sure we have enough memory to load all libraries
187 $memlimit = @ini_get
('memory_limit');
188 if (!empty($memlimit) and $memlimit != -1) {
189 if (get_real_size($memlimit) < get_real_size($minrequiredmemory)) {
190 // do NOT localise - lang strings would not work here and we CAN not move it to later place
191 echo "Moodle requires at least {$minrequiredmemory}B of PHP memory.<br />";
192 echo "Please contact server administrator to fix PHP.ini memory settings.";
197 // Continue with lib loading
198 require_once($CFG->libdir
.'/classes/text.php');
199 require_once($CFG->libdir
.'/classes/string_manager.php');
200 require_once($CFG->libdir
.'/classes/string_manager_install.php');
201 require_once($CFG->libdir
.'/classes/string_manager_standard.php');
202 require_once($CFG->libdir
.'/weblib.php');
203 require_once($CFG->libdir
.'/outputlib.php');
204 require_once($CFG->libdir
.'/dmllib.php');
205 require_once($CFG->libdir
.'/moodlelib.php');
206 require_once($CFG->libdir
.'/pagelib.php');
207 require_once($CFG->libdir
.'/deprecatedlib.php');
208 require_once($CFG->libdir
.'/adminlib.php');
209 require_once($CFG->libdir
.'/environmentlib.php');
210 require_once($CFG->libdir
.'/componentlib.class.php');
211 require_once($CFG->dirroot
.'/cache/lib.php');
213 //point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
214 //the problem is that we need specific version of quickforms and hacked excel files :-(
215 ini_set('include_path', $CFG->libdir
.'/pear' . PATH_SEPARATOR
. ini_get('include_path'));
217 // Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
218 // Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
219 if (defined('COMPONENT_CLASSLOADER')) {
220 spl_autoload_register(COMPONENT_CLASSLOADER
);
222 spl_autoload_register('core_component::classloader');
225 require('version.php');
226 $CFG->target_release
= $release;
228 \core\session\manager
::init_empty_session();
233 $COURSE = new stdClass();
244 // Are we in help mode?
245 if (isset($_GET['help'])) {
246 install_print_help_page($_GET['help']);
249 //first time here? find out suitable dataroot
250 if (is_null($CFG->dataroot
)) {
251 $CFG->dataroot
= __DIR__
.'/../moodledata';
253 $i = 0; //safety check - dirname might return some unexpected results
254 while(is_dataroot_insecure()) {
255 $parrent = dirname($CFG->dataroot
);
257 if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
258 $CFG->dataroot
= ''; //can not find secure location for dataroot
261 $CFG->dataroot
= dirname($parrent).DIRECTORY_SEPARATOR
.'moodledata';
263 $config->dataroot
= $CFG->dataroot
;
264 $config->stage
= INSTALL_WELCOME
;
267 // now let's do the stage work
268 if ($config->stage
< INSTALL_WELCOME
) {
269 $config->stage
= INSTALL_WELCOME
;
271 if ($config->stage
> INSTALL_SAVE
) {
272 $config->stage
= INSTALL_SAVE
;
277 if ($config->stage
== INSTALL_SAVE
) {
278 $CFG->early_install_lang
= false;
280 $database = moodle_database
::get_driver_instance($config->dbtype
, 'native');
281 if (!$database->driver_installed()) {
282 $config->stage
= INSTALL_DATABASETYPE
;
284 if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
285 $distro = distro_pre_create_db($database, $config->dbhost
, $config->dbuser
, $config->dbpass
, $config->dbname
, $config->prefix
, array('dbpersist'=>0, 'dbport'=>$config->dbport
, 'dbsocket'=>$config->dbsocket
), $distro);
287 $hint_database = install_db_validate($database, $config->dbhost
, $config->dbuser
, $config->dbpass
, $config->dbname
, $config->prefix
, array('dbpersist'=>0, 'dbport'=>$config->dbport
, 'dbsocket'=>$config->dbsocket
));
289 if ($hint_database === '') {
290 $configphp = install_generate_configphp($database, $CFG);
293 if (($fh = @fopen
($configfile, 'w')) !== false) {
294 fwrite($fh, $configphp);
298 if (file_exists($configfile)) {
299 // config created, let's continue!
300 redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
303 install_print_header($config, 'config.php',
304 get_string('configurationcompletehead', 'install'),
305 get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install'), 'alert-error');
306 echo '<div class="configphp"><pre>';
310 install_print_footer($config);
314 $config->stage
= INSTALL_DATABASE
;
321 if ($config->stage
== INSTALL_DOWNLOADLANG
) {
322 if (empty($CFG->dataroot
)) {
323 $config->stage
= INSTALL_PATHS
;
325 } else if (is_dataroot_insecure()) {
326 $hint_dataroot = get_string('pathsunsecuredataroot', 'install');
327 $config->stage
= INSTALL_PATHS
;
329 } else if (!file_exists($CFG->dataroot
)) {
331 $a->parent
= dirname($CFG->dataroot
);
332 $a->dataroot
= $CFG->dataroot
;
333 if (!is_writable($a->parent
)) {
334 $hint_dataroot = get_string('pathsroparentdataroot', 'install', $a);
335 $config->stage
= INSTALL_PATHS
;
337 if (!install_init_dataroot($CFG->dataroot
, $CFG->directorypermissions
)) {
338 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', $a);
339 $config->stage
= INSTALL_PATHS
;
343 } else if (!install_init_dataroot($CFG->dataroot
, $CFG->directorypermissions
)) {
344 $hint_dataroot = get_string('pathserrcreatedataroot', 'install', array('dataroot' => $CFG->dataroot
));
345 $config->stage
= INSTALL_PATHS
;
348 if (empty($hint_dataroot) and !is_writable($CFG->dataroot
)) {
349 $hint_dataroot = get_string('pathsrodataroot', 'install');
350 $config->stage
= INSTALL_PATHS
;
353 if ($config->admin
=== '' or !file_exists($CFG->dirroot
.'/'.$config->admin
.'/environment.xml')) {
354 $hint_admindir = get_string('pathswrongadmindir', 'install');
355 $config->stage
= INSTALL_PATHS
;
361 if ($config->stage
== INSTALL_DOWNLOADLANG
) {
362 // no need to download anything if en lang selected
363 if ($CFG->lang
== 'en') {
364 $config->stage
= INSTALL_DATABASETYPE
;
370 if ($config->stage
== INSTALL_DATABASETYPE
) {
371 // skip db selection if distro package supports only one db
372 if (!empty($distro->dbtype
)) {
373 $config->stage
= INSTALL_DATABASE
;
378 if ($config->stage
== INSTALL_DOWNLOADLANG
) {
381 // download and install required lang packs, the lang dir has already been created in install_init_dataroot
382 $installer = new lang_installer($CFG->lang
);
383 $results = $installer->run();
384 foreach ($results as $langcode => $langstatus) {
385 if ($langstatus === lang_installer
::RESULT_DOWNLOADERROR
) {
387 $a->url
= $installer->lang_pack_url($langcode);
388 $a->dest
= $CFG->dataroot
.'/lang';
389 $downloaderror = get_string('remotedownloaderror', 'error', $a);
393 if ($downloaderror !== '') {
394 install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang
), $downloaderror);
395 install_print_footer($config);
398 if (empty($distro->dbtype
)) {
399 $config->stage
= INSTALL_DATABASETYPE
;
401 $config->stage
= INSTALL_DATABASE
;
405 // switch the string_manager instance to stop using install/lang/
406 $CFG->early_install_lang
= false;
407 $CFG->langotherroot
= $CFG->dataroot
.'/lang';
408 $CFG->langlocalroot
= $CFG->dataroot
.'/lang';
409 get_string_manager(true);
413 if ($config->stage
== INSTALL_DATABASE
) {
414 $CFG->early_install_lang
= false;
416 $database = moodle_database
::get_driver_instance($config->dbtype
, 'native');
418 $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
420 install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
422 $strdbhost = get_string('databasehost', 'install');
423 $strdbname = get_string('databasename', 'install');
424 $strdbuser = get_string('databaseuser', 'install');
425 $strdbpass = get_string('databasepass', 'install');
426 $strprefix = get_string('dbprefix', 'install');
427 $strdbport = get_string('databaseport', 'install');
428 $strdbsocket = get_string('databasesocket', 'install');
430 echo '<div class="userinput">';
432 $disabled = empty($distro->dbhost
) ?
'' : 'disabled="disabled';
433 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbhost">'.$strdbhost.'</label></div>';
434 echo '<div class="fitemelement"><input id="id_dbhost" name="dbhost" '.$disabled.' type="text" class="text-ltr" value="'.s($config->dbhost
).'" size="50" /></div>';
437 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbname">'.$strdbname.'</label></div>';
438 echo '<div class="fitemelement"><input id="id_dbname" name="dbname" type="text" class="text-ltr" value="'.s($config->dbname
).'" size="50" /></div>';
441 $disabled = empty($distro->dbuser
) ?
'' : 'disabled="disabled';
442 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbuser">'.$strdbuser.'</label></div>';
443 echo '<div class="fitemelement"><input id="id_dbuser" name="dbuser" '.$disabled.' type="text" class="text-ltr" value="'.s($config->dbuser
).'" size="50" /></div>';
446 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbpass">'.$strdbpass.'</label></div>';
447 // no password field here, the password may be visible in config.php if we can not write it to disk
448 echo '<div class="fitemelement"><input id="id_dbpass" name="dbpass" type="text" class="text-ltr" value="'.s($config->dbpass
).'" size="50" /></div>';
451 echo '<div class="fitem"><div class="fitemtitle"><label for="id_prefix">'.$strprefix.'</label></div>';
452 echo '<div class="fitemelement"><input id="id_prefix" name="prefix" type="text" class="text-ltr" value="'.s($config->prefix
).'" size="10" /></div>';
455 echo '<div class="fitem"><div class="fitemtitle"><label for="id_prefix">'.$strdbport.'</label></div>';
456 echo '<div class="fitemelement"><input id="id_dbport" name="dbport" type="text" class="text-ltr" value="'.s($config->dbport
).'" size="10" /></div>';
459 if (!(stristr(PHP_OS
, 'win') && !stristr(PHP_OS
, 'darwin'))) {
460 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dbsocket">'.$strdbsocket.'</label></div>';
461 echo '<div class="fitemelement"><input id="id_dbsocket" name="dbsocket" type="text" class="text-ltr" value="'.s($config->dbsocket
).'" size="50" /></div>';
465 if ($hint_database !== '') {
466 echo '<div class="alert alert-error">'.$hint_database.'</div>';
469 install_print_footer($config);
474 if ($config->stage
== INSTALL_DATABASETYPE
) {
475 $CFG->early_install_lang
= false;
477 // Finally ask for DB type
478 install_print_header($config, get_string('database', 'install'),
479 get_string('databasetypehead', 'install'),
480 get_string('databasetypesub', 'install'));
482 $databases = array('mysqli' => moodle_database
::get_driver_instance('mysqli', 'native'),
483 'mariadb'=> moodle_database
::get_driver_instance('mariadb', 'native'),
484 'pgsql' => moodle_database
::get_driver_instance('pgsql', 'native'),
485 'oci' => moodle_database
::get_driver_instance('oci', 'native'),
486 'sqlsrv' => moodle_database
::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
489 echo '<div class="userinput">';
490 echo '<div class="fitem"><div class="fitemtitle"><label for="dbtype">'.get_string('dbtype', 'install').'</label></div>';
491 echo '<div class="fitemelement"><select id="dbtype" name="dbtype">';
494 foreach ($databases as $type=>$database) {
495 if ($database->driver_installed() !== true) {
496 $disabled[$type] = $database;
499 echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
502 echo '<optgroup label="'.s(get_string('notavailable')).'">';
503 foreach ($disabled as $type=>$database) {
504 echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
508 echo '</select></div></div>';
511 install_print_footer($config);
517 if ($config->stage
== INSTALL_ENVIRONMENT
or $config->stage
== INSTALL_PATHS
) {
518 $curl_fail = ($lang !== 'en' and !extension_loaded('curl')); // needed for lang pack download
519 $zip_fail = ($lang !== 'en' and !extension_loaded('zip')); // needed for lang pack download
521 if ($curl_fail or $zip_fail) {
522 $config->stage
= INSTALL_ENVIRONMENT
;
524 install_print_header($config, get_string('environmenthead', 'install'),
525 get_string('errorsinenvironment', 'install'),
526 get_string('environmentsub2', 'install'));
528 echo '<div id="envresult"><dl>';
530 echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
533 echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
537 install_print_footer($config, true);
541 $config->stage
= INSTALL_PATHS
;
547 if ($config->stage
== INSTALL_PATHS
) {
548 $paths = array('wwwroot' => get_string('wwwroot', 'install'),
549 'dirroot' => get_string('dirroot', 'install'),
550 'dataroot' => get_string('dataroot', 'install'));
553 foreach ($paths as $path=>$name) {
554 $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
556 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
557 $sub .= '<dt>'.get_string('admindirname', 'install').'</dt><dd>'.get_string('pathssubadmindir', 'install').'</dd>';
561 install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
563 $strwwwroot = get_string('wwwroot', 'install');
564 $strdirroot = get_string('dirroot', 'install');
565 $strdataroot = get_string('dataroot', 'install');
566 $stradmindirname = get_string('admindirname', 'install');
568 echo '<div class="userinput">';
569 echo '<div class="fitem"><div class="fitemtitle"><label for="id_wwwroot">'.$paths['wwwroot'].'</label></div>';
570 echo '<div class="fitemelement"><input id="id_wwwroot" name="wwwroot" type="text" class="text-ltr" value="'.s($CFG->wwwroot
).'" disabled="disabled" size="70" /></div>';
573 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dirroot">'.$paths['dirroot'].'</label></div>';
574 echo '<div class="fitemelement"><input id="id_dirroot" name="dirroot" type="text" class="text-ltr" value="'.s($CFG->dirroot
).'" disabled="disabled" size="70" /></div>';
577 echo '<div class="fitem"><div class="fitemtitle"><label for="id_dataroot">'.$paths['dataroot'].'</label></div>';
578 echo '<div class="fitemelement"><input id="id_dataroot" name="dataroot" type="text" class="text-ltr" value="'.s($config->dataroot
).'" size="70" /></div>';
579 if ($hint_dataroot !== '') {
580 echo '<div class="alert alert-error">'.$hint_dataroot.'</div>';
585 if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
586 echo '<div class="fitem"><div class="fitemtitle"><label for="id_admin">'.$paths['admindir'].'</label></div>';
587 echo '<div class="fitemelement"><input id="id_admin" name="admin" type="text" class="text-ltr" value="'.s($config->admin
).'" size="10" /></div>';
588 if ($hint_admindir !== '') {
589 echo '<div class="alert alert-error">'.$hint_admindir.'</div>';
596 install_print_footer($config);
602 $config->stage
= INSTALL_WELCOME
;
606 include('install/distribution.html');
607 $sub = ob_get_clean();
609 install_print_header($config, get_string('language'),
610 get_string('chooselanguagehead', 'install'),
611 $sub, 'alert-success');
614 install_print_header($config, get_string('language'),
615 get_string('chooselanguagehead', 'install'),
616 get_string('chooselanguagesub', 'install'));
619 $languages = get_string_manager()->get_list_of_translations();
620 echo '<div class="userinput">';
621 echo '<div class="fitem"><div class="fitemtitle"><label for="langselect">'.get_string('language').'</label></div>';
622 echo '<div class="fitemelement"><select id="langselect" name="lang" onchange="this.form.submit()">';
623 foreach ($languages as $name=>$value) {
624 $selected = ($name == $CFG->lang
) ?
'selected="selected"' : '';
625 echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
627 echo '</select></div></div>';
630 install_print_footer($config);