PageRenderTime 29ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/install.php

https://bitbucket.org/kudutest1/moodlegit
PHP | 612 lines | 436 code | 120 blank | 56 comment | 94 complexity | 8f554b01d5c15f2e8ca6f04edcf5a2d1 MD5 | raw file
  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * This script creates config.php file during installation.
  18. *
  19. * @package core
  20. * @subpackage install
  21. * @copyright 2009 Petr Skoda (http://skodak.org)
  22. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23. */
  24. if (isset($_REQUEST['lang'])) {
  25. $lang = preg_replace('/[^A-Za-z0-9_-]/i', '', $_REQUEST['lang']);
  26. } else {
  27. $lang = 'en';
  28. }
  29. if (isset($_REQUEST['admin'])) {
  30. $admin = preg_replace('/[^A-Za-z0-9_-]/i', '', $_REQUEST['admin']);
  31. } else {
  32. $admin = 'admin';
  33. }
  34. // If config.php exists we just created config.php and need to redirect to continue installation
  35. $configfile = './config.php';
  36. if (file_exists($configfile)) {
  37. header("Location: $admin/index.php?lang=$lang");
  38. die;
  39. }
  40. define('CLI_SCRIPT', false); // prevents some warnings later
  41. define('AJAX_SCRIPT', false); // prevents some warnings later
  42. define('CACHE_DISABLE_ALL', true); // Disables caching.. just in case.
  43. // Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
  44. // This is a quick hack. Ideally we should ask the admin for a value. See MDL-22625 for more on this.
  45. if (function_exists('date_default_timezone_set') and function_exists('date_default_timezone_get')) {
  46. @date_default_timezone_set(@date_default_timezone_get());
  47. }
  48. // make sure PHP errors are displayed - helps with diagnosing of problems
  49. @error_reporting(E_ALL);
  50. @ini_set('display_errors', '1');
  51. // Check that PHP is of a sufficient version.
  52. if (version_compare(phpversion(), '5.3.3') < 0) {
  53. $phpversion = phpversion();
  54. // do NOT localise - lang strings would not work here and we CAN not move it after installib
  55. echo "Moodle 2.5 or later requires at least PHP 5.3.3 (currently using version $phpversion).<br />";
  56. echo "Please upgrade your server software or install older Moodle version.";
  57. die;
  58. }
  59. // make sure iconv is available and actually works
  60. if (!function_exists('iconv')) {
  61. // this should not happen, this must be very borked install
  62. echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.';
  63. die();
  64. }
  65. if (PHP_INT_SIZE > 4) {
  66. // most probably 64bit PHP - we need a lot more memory
  67. $minrequiredmemory = '70M';
  68. } else {
  69. // 32bit PHP
  70. $minrequiredmemory = '40M';
  71. }
  72. // increase or decrease available memory - we need to make sure moodle
  73. // installs even with low memory, otherwise developers would overlook
  74. // sudden increases of memory needs ;-)
  75. @ini_set('memory_limit', $minrequiredmemory);
  76. /** Used by library scripts to check they are being called by Moodle */
  77. define('MOODLE_INTERNAL', true);
  78. require dirname(__FILE__).'/lib/installlib.php';
  79. // TODO: add lang detection here if empty $_REQUEST['lang']
  80. // distro specific customisation
  81. $distro = null;
  82. if (file_exists('install/distrolib.php')) {
  83. require_once('install/distrolib.php');
  84. if (function_exists('distro_get_config')) {
  85. $distro = distro_get_config();
  86. }
  87. }
  88. $config = new stdClass();
  89. $config->lang = $lang;
  90. if (!empty($_POST)) {
  91. if (install_ini_get_bool('magic_quotes_gpc')) {
  92. $_POST = array_map('stripslashes', $_POST);
  93. }
  94. $config->stage = (int)$_POST['stage'];
  95. if (isset($_POST['previous'])) {
  96. $config->stage--;
  97. if (INSTALL_DATABASETYPE and !empty($distro->dbtype)) {
  98. $config->stage--;
  99. }
  100. if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_DOWNLOADLANG) {
  101. $config->stage--;
  102. }
  103. } else if (isset($_POST['next'])) {
  104. $config->stage++;
  105. }
  106. $config->dbtype = trim($_POST['dbtype']);
  107. $config->dbhost = trim($_POST['dbhost']);
  108. $config->dbuser = trim($_POST['dbuser']);
  109. $config->dbpass = trim($_POST['dbpass']);
  110. $config->dbname = trim($_POST['dbname']);
  111. $config->prefix = trim($_POST['prefix']);
  112. $config->dbsocket = (int)(!empty($_POST['dbsocket']));
  113. $config->admin = empty($_POST['admin']) ? 'admin' : trim($_POST['admin']);
  114. $config->dataroot = trim($_POST['dataroot']);
  115. } else {
  116. $config->stage = INSTALL_WELCOME;
  117. $config->dbtype = empty($distro->dbtype) ? '' : $distro->dbtype; // let distro skip dbtype selection
  118. $config->dbhost = empty($distro->dbhost) ? 'localhost' : $distro->dbhost; // let distros set dbhost
  119. $config->dbuser = empty($distro->dbuser) ? '' : $distro->dbuser; // let distros set dbuser
  120. $config->dbpass = '';
  121. $config->dbname = 'moodle';
  122. $config->prefix = 'mdl_';
  123. $config->dbsocket = 0;
  124. $config->admin = 'admin';
  125. $config->dataroot = empty($distro->dataroot) ? null : $distro->dataroot; // initialised later after including libs or by distro
  126. }
  127. // Fake some settings so that we can use selected functions from moodlelib.php and weblib.php
  128. $CFG = new stdClass();
  129. $CFG->lang = $config->lang;
  130. $CFG->dirroot = dirname(__FILE__);
  131. $CFG->libdir = "$CFG->dirroot/lib";
  132. $CFG->wwwroot = install_guess_wwwroot(); // can not be changed - ppl must use the real address when installing
  133. $CFG->httpswwwroot = $CFG->wwwroot;
  134. $CFG->dataroot = $config->dataroot;
  135. $CFG->tempdir = $CFG->dataroot.'/temp';
  136. $CFG->cachedir = $CFG->dataroot.'/cache';
  137. $CFG->admin = $config->admin;
  138. $CFG->docroot = 'http://docs.moodle.org';
  139. $CFG->langotherroot = $CFG->dataroot.'/lang';
  140. $CFG->langlocalroot = $CFG->dataroot.'/lang';
  141. $CFG->directorypermissions = isset($distro->directorypermissions) ? $distro->directorypermissions : 00777; // let distros set dir permissions
  142. $CFG->running_installer = true;
  143. $CFG->early_install_lang = true;
  144. // Require all needed libs
  145. require_once($CFG->libdir.'/setuplib.php');
  146. // we need to make sure we have enough memory to load all libraries
  147. $memlimit = @ini_get('memory_limit');
  148. if (!empty($memlimit) and $memlimit != -1) {
  149. if (get_real_size($memlimit) < get_real_size($minrequiredmemory)) {
  150. // do NOT localise - lang strings would not work here and we CAN not move it to later place
  151. echo "Moodle requires at least {$minrequiredmemory}B of PHP memory.<br />";
  152. echo "Please contact server administrator to fix PHP.ini memory settings.";
  153. die;
  154. }
  155. }
  156. // Continue with lib loading
  157. require_once($CFG->libdir.'/textlib.class.php');
  158. require_once($CFG->libdir.'/weblib.php');
  159. require_once($CFG->libdir.'/outputlib.php');
  160. require_once($CFG->libdir.'/dmllib.php');
  161. require_once($CFG->libdir.'/moodlelib.php');
  162. require_once($CFG->libdir .'/pagelib.php');
  163. require_once($CFG->libdir.'/deprecatedlib.php');
  164. require_once($CFG->libdir.'/adminlib.php');
  165. require_once($CFG->libdir.'/environmentlib.php');
  166. require_once($CFG->libdir.'/componentlib.class.php');
  167. require_once($CFG->dirroot.'/cache/lib.php');
  168. //point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
  169. //the problem is that we need specific version of quickforms and hacked excel files :-(
  170. ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
  171. //point zend include path to moodles lib/zend so that includes and requires will search there for files before anywhere else
  172. ini_set('include_path', $CFG->libdir.'/zend' . PATH_SEPARATOR . ini_get('include_path'));
  173. require('version.php');
  174. $CFG->target_release = $release;
  175. $SESSION = new stdClass();
  176. $SESSION->lang = $CFG->lang;
  177. $USER = new stdClass();
  178. $USER->id = 0;
  179. $COURSE = new stdClass();
  180. $COURSE->id = 0;
  181. $SITE = $COURSE;
  182. define('SITEID', 0);
  183. $hint_dataroot = '';
  184. $hint_admindir = '';
  185. $hint_database = '';
  186. // Are we in help mode?
  187. if (isset($_GET['help'])) {
  188. install_print_help_page($_GET['help']);
  189. }
  190. //first time here? find out suitable dataroot
  191. if (is_null($CFG->dataroot)) {
  192. $CFG->dataroot = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'moodledata';
  193. $i = 0; //safety check - dirname might return some unexpected results
  194. while(is_dataroot_insecure()) {
  195. $parrent = dirname($CFG->dataroot);
  196. $i++;
  197. if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
  198. $CFG->dataroot = ''; //can not find secure location for dataroot
  199. break;
  200. }
  201. $CFG->dataroot = dirname($parrent).DIRECTORY_SEPARATOR.'moodledata';
  202. }
  203. $config->dataroot = $CFG->dataroot;
  204. $config->stage = INSTALL_WELCOME;
  205. }
  206. // now let's do the stage work
  207. if ($config->stage < INSTALL_WELCOME) {
  208. $config->stage = INSTALL_WELCOME;
  209. }
  210. if ($config->stage > INSTALL_SAVE) {
  211. $config->stage = INSTALL_SAVE;
  212. }
  213. if ($config->stage == INSTALL_SAVE) {
  214. $CFG->early_install_lang = false;
  215. $database = moodle_database::get_driver_instance($config->dbtype, 'native');
  216. if (!$database->driver_installed()) {
  217. $config->stage = INSTALL_DATABASETYPE;
  218. } else {
  219. if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
  220. $distro = distro_pre_create_db($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbsocket'=>$config->dbsocket), $distro);
  221. }
  222. $hint_database = install_db_validate($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbsocket'=>$config->dbsocket));
  223. if ($hint_database === '') {
  224. $configphp = install_generate_configphp($database, $CFG);
  225. umask(0137);
  226. if (($fh = @fopen($configfile, 'w')) !== false) {
  227. fwrite($fh, $configphp);
  228. fclose($fh);
  229. }
  230. if (file_exists($configfile)) {
  231. // config created, let's continue!
  232. redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
  233. }
  234. install_print_header($config, 'config.php',
  235. get_string('configurationcompletehead', 'install'),
  236. get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install'));
  237. echo '<div class="configphp"><pre>';
  238. echo p($configphp);
  239. echo '</pre></div>';
  240. install_print_footer($config);
  241. die;
  242. } else {
  243. $config->stage = INSTALL_DATABASE;
  244. }
  245. }
  246. }
  247. if ($config->stage == INSTALL_DOWNLOADLANG) {
  248. if (empty($CFG->dataroot)) {
  249. $config->stage = INSTALL_PATHS;
  250. } else if (is_dataroot_insecure()) {
  251. $hint_dataroot = get_string('pathsunsecuredataroot', 'install');
  252. $config->stage = INSTALL_PATHS;
  253. } else if (!file_exists($CFG->dataroot)) {
  254. $a = new stdClass();
  255. $a->parent = dirname($CFG->dataroot);
  256. $a->dataroot = $CFG->dataroot;
  257. if (!is_writable($a->parent)) {
  258. $hint_dataroot = get_string('pathsroparentdataroot', 'install', $a);
  259. $config->stage = INSTALL_PATHS;
  260. } else {
  261. if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
  262. $hint_dataroot = get_string('pathserrcreatedataroot', 'install', $a);
  263. $config->stage = INSTALL_PATHS;
  264. }
  265. }
  266. } else if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
  267. $hint_dataroot = get_string('pathserrcreatedataroot', 'install', array('dataroot' => $CFG->dataroot));
  268. $config->stage = INSTALL_PATHS;
  269. }
  270. if (empty($hint_dataroot) and !is_writable($CFG->dataroot)) {
  271. $hint_dataroot = get_string('pathsrodataroot', 'install');
  272. $config->stage = INSTALL_PATHS;
  273. }
  274. if ($config->admin === '' or !file_exists($CFG->dirroot.'/'.$config->admin.'/environment.xml')) {
  275. $hint_admindir = get_string('pathswrongadmindir', 'install');
  276. $config->stage = INSTALL_PATHS;
  277. }
  278. }
  279. if ($config->stage == INSTALL_DOWNLOADLANG) {
  280. // no need to download anything if en lang selected
  281. if ($CFG->lang == 'en') {
  282. $config->stage = INSTALL_DATABASETYPE;
  283. }
  284. }
  285. if ($config->stage == INSTALL_DATABASETYPE) {
  286. // skip db selection if distro package supports only one db
  287. if (!empty($distro->dbtype)) {
  288. $config->stage = INSTALL_DATABASE;
  289. }
  290. }
  291. if ($config->stage == INSTALL_DOWNLOADLANG) {
  292. $downloaderror = '';
  293. // download and install required lang packs, the lang dir has already been created in install_init_dataroot
  294. $installer = new lang_installer($CFG->lang);
  295. $results = $installer->run();
  296. foreach ($results as $langcode => $langstatus) {
  297. if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
  298. $a = new stdClass();
  299. $a->url = $installer->lang_pack_url($langcode);
  300. $a->dest = $CFG->dataroot.'/lang';
  301. $downloaderror = get_string('remotedownloaderror', 'error', $a);
  302. }
  303. }
  304. if ($downloaderror !== '') {
  305. install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang), $downloaderror);
  306. install_print_footer($config);
  307. die;
  308. } else {
  309. if (empty($distro->dbtype)) {
  310. $config->stage = INSTALL_DATABASETYPE;
  311. } else {
  312. $config->stage = INSTALL_DATABASE;
  313. }
  314. }
  315. // switch the string_manager instance to stop using install/lang/
  316. $CFG->early_install_lang = false;
  317. $CFG->langotherroot = $CFG->dataroot.'/lang';
  318. $CFG->langlocalroot = $CFG->dataroot.'/lang';
  319. get_string_manager(true);
  320. }
  321. if ($config->stage == INSTALL_DATABASE) {
  322. $CFG->early_install_lang = false;
  323. $database = moodle_database::get_driver_instance($config->dbtype, 'native');
  324. $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
  325. install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
  326. $strdbhost = get_string('databasehost', 'install');
  327. $strdbname = get_string('databasename', 'install');
  328. $strdbuser = get_string('databaseuser', 'install');
  329. $strdbpass = get_string('databasepass', 'install');
  330. $strprefix = get_string('dbprefix', 'install');
  331. $strdbsocket = get_string('databasesocket', 'install');
  332. echo '<div class="userinput">';
  333. $disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
  334. echo '<div class="formrow"><label for="id_dbhost" class="formlabel">'.$strdbhost.'</label>';
  335. echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="50" class="forminput" />';
  336. echo '</div>';
  337. echo '<div class="formrow"><label for="id_dbname" class="formlabel">'.$strdbname.'</label>';
  338. echo '<input id="id_dbname" name="dbname" type="text" value="'.s($config->dbname).'" size="50" class="forminput" />';
  339. echo '</div>';
  340. $disabled = empty($distro->dbuser) ? '' : 'disabled="disabled';
  341. echo '<div class="formrow"><label for="id_dbuser" class="formlabel">'.$strdbuser.'</label>';
  342. echo '<input id="id_dbuser" name="dbuser" '.$disabled.' type="text" value="'.s($config->dbuser).'" size="50" class="forminput" />';
  343. echo '</div>';
  344. echo '<div class="formrow"><label for="id_dbpass" class="formlabel">'.$strdbpass.'</label>';
  345. // no password field here, the password may be visible in config.php if we can not write it to disk
  346. echo '<input id="id_dbpass" name="dbpass" type="text" value="'.s($config->dbpass).'" size="50" class="forminput" />';
  347. echo '</div>';
  348. echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strprefix.'</label>';
  349. echo '<input id="id_prefix" name="prefix" type="text" value="'.s($config->prefix).'" size="10" class="forminput" />';
  350. echo '</div>';
  351. if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
  352. $checked = $config->dbsocket ? 'checked="checked' : '';
  353. echo '<div class="formrow"><label for="id_dbsocket" class="formlabel">'.$strdbsocket.'</label>';
  354. echo '<input type="hidden" value="0" name="dbsocket" />';
  355. echo '<input type="checkbox" id="id_dbsocket" value="1" name="dbsocket" '.$checked.' class="forminput" />';
  356. echo '</div>';
  357. }
  358. echo '<div class="hint">'.$hint_database.'</div>';
  359. echo '</div>';
  360. install_print_footer($config);
  361. die;
  362. }
  363. if ($config->stage == INSTALL_DATABASETYPE) {
  364. $CFG->early_install_lang = false;
  365. // Finally ask for DB type
  366. install_print_header($config, get_string('database', 'install'),
  367. get_string('databasetypehead', 'install'),
  368. get_string('databasetypesub', 'install'));
  369. $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
  370. 'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
  371. 'oci' => moodle_database::get_driver_instance('oci', 'native'),
  372. 'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
  373. 'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
  374. );
  375. echo '<div class="userinput">';
  376. echo '<div class="formrow"><label class="formlabel" for="dbtype">'.get_string('dbtype', 'install').'</label>';
  377. echo '<select id="dbtype" name="dbtype" class="forminput">';
  378. $disabled = array();
  379. $options = array();
  380. foreach ($databases as $type=>$database) {
  381. if ($database->driver_installed() !== true) {
  382. $disabled[$type] = $database;
  383. continue;
  384. }
  385. echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
  386. }
  387. if ($disabled) {
  388. echo '<optgroup label="'.s(get_string('notavailable')).'">';
  389. foreach ($disabled as $type=>$database) {
  390. echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
  391. }
  392. echo '</optgroup>';
  393. }
  394. echo '</select></div>';
  395. echo '</div>';
  396. install_print_footer($config);
  397. die;
  398. }
  399. if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
  400. $version_fail = (version_compare(phpversion(), "5.3.3") < 0);
  401. $curl_fail = ($lang !== 'en' and !extension_loaded('curl')); // needed for lang pack download
  402. $zip_fail = ($lang !== 'en' and !extension_loaded('zip')); // needed for lang pack download
  403. if ($version_fail or $curl_fail or $zip_fail) {
  404. $config->stage = INSTALL_ENVIRONMENT;
  405. install_print_header($config, get_string('environmenthead', 'install'),
  406. get_string('errorsinenvironment', 'install'),
  407. get_string('environmentsub2', 'install'));
  408. echo '<div id="envresult"><dl>';
  409. if ($version_fail) {
  410. $a = (object)array('needed'=>'5.3.3', 'current'=>phpversion());
  411. echo '<dt>'.get_string('phpversion', 'install').'</dt><dd>'.get_string('environmentrequireversion', 'admin', $a).'</dd>';
  412. }
  413. if ($curl_fail) {
  414. echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
  415. }
  416. if ($zip_fail) {
  417. echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
  418. }
  419. echo '</dl></div>';
  420. install_print_footer($config, true);
  421. die;
  422. } else {
  423. $config->stage = INSTALL_PATHS;
  424. }
  425. }
  426. if ($config->stage == INSTALL_PATHS) {
  427. $paths = array('wwwroot' => get_string('wwwroot', 'install'),
  428. 'dirroot' => get_string('dirroot', 'install'),
  429. 'dataroot' => get_string('dataroot', 'install'));
  430. $sub = '<dl>';
  431. foreach ($paths as $path=>$name) {
  432. $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
  433. }
  434. if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
  435. $sub .= '<dt>'.get_string('admindirname', 'install').'</dt><dd>'.get_string('pathssubadmindir', 'install').'</dd>';
  436. }
  437. $sub .= '</dl>';
  438. install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
  439. $strwwwroot = get_string('wwwroot', 'install');
  440. $strdirroot = get_string('dirroot', 'install');
  441. $strdataroot = get_string('dataroot', 'install');
  442. $stradmindirname = get_string('admindirname', 'install');
  443. echo '<div class="userinput">';
  444. echo '<div class="formrow"><label for="id_wwwroot" class="formlabel">'.$paths['wwwroot'].'</label>';
  445. echo '<input id="id_wwwroot" name="wwwroot" type="text" value="'.s($CFG->wwwroot).'" disabled="disabled" size="70" class="forminput" />';
  446. echo '</div>';
  447. echo '<div class="formrow"><label for="id_dirroot" class="formlabel">'.$paths['dirroot'].'</label>';
  448. echo '<input id="id_dirroot" name="dirroot" type="text" value="'.s($CFG->dirroot).'" disabled="disabled" size="70"class="forminput" />';
  449. echo '</div>';
  450. echo '<div class="formrow"><label for="id_dataroot" class="formlabel">'.$paths['dataroot'].'</label>';
  451. echo '<input id="id_dataroot" name="dataroot" type="text" value="'.s($config->dataroot).'" size="70" class="forminput" />';
  452. if ($hint_dataroot !== '') {
  453. echo '<div class="hint">'.$hint_dataroot.'</div>';
  454. }
  455. echo '</div>';
  456. if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
  457. echo '<div class="formrow"><label for="id_admin" class="formlabel">'.$paths['admindir'].'</label>';
  458. echo '<input id="id_admin" name="admin" type="text" value="'.s($config->admin).'" size="10" class="forminput" />';
  459. if ($hint_admindir !== '') {
  460. echo '<div class="hint">'.$hint_admindir.'</div>';
  461. }
  462. echo '</div>';
  463. }
  464. echo '</div>';
  465. install_print_footer($config);
  466. die;
  467. }
  468. $config->stage = INSTALL_WELCOME;
  469. if ($distro) {
  470. ob_start();
  471. include('install/distribution.html');
  472. $sub = ob_get_clean();
  473. install_print_header($config, get_string('language'),
  474. get_string('chooselanguagehead', 'install'),
  475. $sub);
  476. } else {
  477. install_print_header($config, get_string('language'),
  478. get_string('chooselanguagehead', 'install'),
  479. get_string('chooselanguagesub', 'install'));
  480. }
  481. $languages = get_string_manager()->get_list_of_translations();
  482. echo '<div class="userinput">';
  483. echo '<div class="formrow"><label class="formlabel" for="langselect">'.get_string('language').'</label>';
  484. echo '<select id="langselect" name="lang" class="forminput" onchange="this.form.submit()">';
  485. foreach ($languages as $name=>$value) {
  486. $selected = ($name == $CFG->lang) ? 'selected="selected"' : '';
  487. echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
  488. }
  489. echo '</select></div>';
  490. echo '</div>';
  491. install_print_footer($config);
  492. die;