PageRenderTime 51ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/install.php

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