index.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\CoreBundle\Framework\Container;
  4. use Chamilo\Kernel;
  5. use Symfony\Bundle\FrameworkBundle\Console\Application;
  6. use Symfony\Component\Console\Input\ArrayInput;
  7. use Symfony\Component\Console\Output\ConsoleOutput;
  8. use Symfony\Component\Dotenv\Dotenv;
  9. use Symfony\Component\Translation\Loader\PoFileLoader;
  10. use Symfony\Component\Translation\Translator;
  11. /**
  12. * Chamilo installation.
  13. *
  14. * As seen from the user, the installation proceeds in 6 steps.
  15. * The user is presented with several pages where he/she has to make choices
  16. * and/or fill in data.
  17. *
  18. * The aim is, as always, to have good default settings and suggestions.
  19. *
  20. * @todo reduce high level of duplication in this code
  21. * @todo (busy) organise code into functions
  22. */
  23. $originalDisplayErrors = ini_get('display_errors');
  24. $originalMemoryLimit = ini_get('memory_limit');
  25. ini_set('display_errors', '1');
  26. ini_set('log_errors', '1');
  27. ini_set('memory_limit', -1);
  28. ini_set('max_execution_time', 0);
  29. error_reporting(-1);
  30. require_once __DIR__.'/../../vendor/autoload.php';
  31. define('SYSTEM_INSTALLATION', 1);
  32. define('INSTALL_TYPE_UPDATE', 'update');
  33. define('FORM_FIELD_DISPLAY_LENGTH', 40);
  34. define('DATABASE_FORM_FIELD_DISPLAY_LENGTH', 25);
  35. define('MAX_FORM_FIELD_LENGTH', 80);
  36. api_check_php_version();
  37. ob_implicit_flush(true);
  38. // Defaults settings
  39. putenv('APP_LOCALE=en');
  40. putenv('APP_URL_APPEND=""');
  41. putenv('APP_ENCRYPT_METHOD="bcrypt"');
  42. putenv('DATABASE_HOST=');
  43. putenv('DATABASE_PORT=');
  44. putenv('DATABASE_NAME=');
  45. putenv('DATABASE_USER=');
  46. putenv('DATABASE_PASSWORD=');
  47. putenv('APP_ENV=dev');
  48. putenv('APP_DEBUG=1');
  49. session_start();
  50. require_once 'install.lib.php';
  51. $installationLanguage = 'en';
  52. // Determination of the language during the installation procedure.
  53. if (!empty($_POST['language_list'])) {
  54. $search = ['../', '\\0'];
  55. $installationLanguage = str_replace($search, '', urldecode($_POST['language_list']));
  56. //$_SESSION['install_language'] = $installationLanguage;
  57. } else {
  58. // Trying to switch to the browser's language, it is covenient for most of the cases.
  59. $installationLanguage = detect_browser_language();
  60. }
  61. // Language validation.
  62. if (!array_key_exists($installationLanguage, get_language_folder_list())) {
  63. $installationLanguage = 'en';
  64. }
  65. // Set translation
  66. $translator = new Translator($installationLanguage);
  67. $translator->addLoader('po', new PoFileLoader());
  68. $translator->addResource('po', "../../translations/installation.$installationLanguage.po", $installationLanguage);
  69. Container::$translator = $translator;
  70. // The function api_get_setting() might be called within the installation scripts.
  71. // We need to provide some limited support for it through initialization of the
  72. // global array-type variable $_setting.
  73. $_setting = [
  74. 'platform_charset' => 'UTF-8',
  75. 'server_type' => 'production', // 'production' | 'test'
  76. 'permissions_for_new_directories' => '0770',
  77. 'permissions_for_new_files' => '0660',
  78. 'stylesheets' => 'chamilo',
  79. ];
  80. $encryptPassForm = 'bcrypt';
  81. $urlAppendPath = '';
  82. $urlForm = '';
  83. $pathForm = '';
  84. $emailForm = '';
  85. $dbHostForm = 'localhost';
  86. $dbUsernameForm = 'root';
  87. $dbPassForm = '';
  88. $dbNameForm = 'chamilo';
  89. $dbPortForm = 3306;
  90. $allowSelfReg = 'approval';
  91. $allowSelfRegProf = 1;
  92. $adminLastName = get_lang('Doe');
  93. $adminFirstName = get_lang('John');
  94. $loginForm = 'admin';
  95. $passForm = '';
  96. $institutionUrlForm = 'http://www.chamilo.org';
  97. $languageForm = '';
  98. $campusForm = 'My campus';
  99. $educationForm = 'Albert Einstein';
  100. $adminPhoneForm = '(000) 001 02 03';
  101. $institutionForm = 'My Organisation';
  102. $session_lifetime = 360000;
  103. //$installLanguage = isset($_SESSION['install_language']) ? $_SESSION['install_language'] : 'english';
  104. $installLanguage = '';
  105. $installationGuideLink = '../../documentation/installation_guide.html';
  106. // Enables the portability layer and configures PHP for UTF-8
  107. \Patchwork\Utf8\Bootup::initAll();
  108. // Setting the error reporting levels.
  109. error_reporting(E_ALL);
  110. // Upgrading from any subversion of 1.9
  111. $update_from_version_8 = [
  112. '1.9.0',
  113. '1.9.2',
  114. '1.9.4',
  115. '1.9.6',
  116. '1.9.6.1',
  117. '1.9.8',
  118. '1.9.8.1',
  119. '1.9.8.2',
  120. '1.9.10',
  121. '1.9.10.2',
  122. '1.9.10.4',
  123. '1.9.10.6',
  124. '1.10.0',
  125. '1.10.2',
  126. '1.10.4',
  127. '1.10.6',
  128. '1.10.8',
  129. '1.11.0',
  130. '1.11.1',
  131. '1.11.2',
  132. '1.11.4',
  133. '1.11.6',
  134. '1.11.8',
  135. '1.11.10',
  136. '1.11.11',
  137. '1.11.12',
  138. '1.11.14',
  139. ];
  140. $my_old_version = '';
  141. if (empty($tmp_version)) {
  142. $tmp_version = get_config_param('system_version');
  143. }
  144. if (!empty($_POST['old_version'])) {
  145. $my_old_version = $_POST['old_version'];
  146. } elseif (!empty($tmp_version)) {
  147. $my_old_version = $tmp_version;
  148. }
  149. require_once __DIR__.'/version.php';
  150. // A protection measure for already installed systems.
  151. if (isAlreadyInstalledSystem()) {
  152. // The system has already been installed, so block re-installation.
  153. $global_error_code = 6;
  154. require '../inc/global_error_message.inc.php';
  155. exit;
  156. }
  157. /* STEP 1 : INITIALIZES FORM VARIABLES IF IT IS THE FIRST VISIT */
  158. $badUpdatePath = false;
  159. $emptyUpdatePath = true;
  160. $proposedUpdatePath = '';
  161. if (!empty($_POST['updatePath'])) {
  162. $proposedUpdatePath = $_POST['updatePath'];
  163. }
  164. if (isset($_POST['step2_install']) || isset($_POST['step2_update_8']) || isset($_POST['step2_update_6'])) {
  165. if (isset($_POST['step2_install'])) {
  166. $installType = 'new';
  167. $_POST['step2'] = 1;
  168. } else {
  169. $installType = 'update';
  170. if (isset($_POST['step2_update_8'])) {
  171. $emptyUpdatePath = false;
  172. $proposedUpdatePath = api_add_trailing_slash(empty($_POST['updatePath']) ? api_get_path(SYS_PATH) : $_POST['updatePath']);
  173. if (file_exists($proposedUpdatePath)) {
  174. if (in_array($my_old_version, $update_from_version_8)) {
  175. $_POST['step2'] = 1;
  176. } else {
  177. $badUpdatePath = true;
  178. }
  179. } else {
  180. $badUpdatePath = true;
  181. }
  182. }
  183. }
  184. } elseif (isset($_POST['step1'])) {
  185. $_POST['updatePath'] = '';
  186. $installType = '';
  187. $updateFromConfigFile = '';
  188. unset($_GET['running']);
  189. } else {
  190. $installType = isset($_GET['installType']) ? $_GET['installType'] : '';
  191. $updateFromConfigFile = isset($_GET['updateFromConfigFile']) ? $_GET['updateFromConfigFile'] : false;
  192. }
  193. if ($installType === 'update' && in_array($my_old_version, $update_from_version_8)) {
  194. // This is the main configuration file of the system before the upgrade.
  195. // Old configuration file.
  196. // Don't change to include_once
  197. $oldConfigPath = api_get_path(SYS_CODE_PATH).'inc/conf/configuration.php';
  198. if (file_exists($oldConfigPath)) {
  199. include $oldConfigPath;
  200. }
  201. }
  202. $showEmailNotCheckedToStudent = 1;
  203. if (!isset($_GET['running'])) {
  204. // Extract the path to append to the url if Chamilo is not installed on the web root directory.
  205. $urlAppendPath = api_remove_trailing_slash(api_get_path(REL_PATH));
  206. $urlForm = api_get_path(WEB_PATH);
  207. $pathForm = api_get_path(SYS_PATH);
  208. $emailForm = 'webmaster@localhost';
  209. if (!empty($_SERVER['SERVER_ADMIN'])) {
  210. $emailForm = $_SERVER['SERVER_ADMIN'];
  211. }
  212. $email_parts = explode('@', $emailForm);
  213. if (isset($email_parts[1]) && $email_parts[1] == 'localhost') {
  214. $emailForm .= '.localdomain';
  215. }
  216. $loginForm = 'admin';
  217. $passForm = api_generate_password();
  218. $institutionUrlForm = 'http://www.chamilo.org';
  219. $languageForm = api_get_interface_language();
  220. $checkEmailByHashSent = 0;
  221. $userMailCanBeEmpty = 1;
  222. $allowSelfReg = 'approval';
  223. $allowSelfRegProf = 1; //by default, a user can register as teacher (but moderation might be in place)
  224. if (!empty($_GET['profile'])) {
  225. $installationProfile = api_htmlentities($_GET['profile'], ENT_QUOTES);
  226. }
  227. } else {
  228. foreach ($_POST as $key => $val) {
  229. if (is_string($val)) {
  230. $val = trim($val);
  231. $_POST[$key] = $val;
  232. } elseif (is_array($val)) {
  233. foreach ($val as $key2 => $val2) {
  234. $val2 = trim($val2);
  235. $_POST[$key][$key2] = $val2;
  236. }
  237. }
  238. $GLOBALS[$key] = $_POST[$key];
  239. }
  240. }
  241. /* NEXT STEPS IMPLEMENTATION */
  242. $total_steps = 7;
  243. if (!$_POST) {
  244. $current_step = 1;
  245. } elseif (!empty($_POST['language_list']) or !empty($_POST['step1']) || ((!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6']))) && ($emptyUpdatePath or $badUpdatePath))) {
  246. $current_step = 2;
  247. } elseif (!empty($_POST['step2']) or (!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6'])))) {
  248. $current_step = 3;
  249. } elseif (!empty($_POST['step3'])) {
  250. $current_step = 4;
  251. } elseif (!empty($_POST['step4'])) {
  252. $current_step = 5;
  253. } elseif (!empty($_POST['step5'])) {
  254. $current_step = 6;
  255. } elseif (isset($_POST['step6'])) {
  256. $current_step = 7;
  257. }
  258. // Managing the $encryptPassForm
  259. if ($encryptPassForm == '1') {
  260. $encryptPassForm = 'bcrypt';
  261. } elseif ($encryptPassForm == '0') {
  262. $encryptPassForm = 'none';
  263. }
  264. $form = '';
  265. $instalation_type_label = '';
  266. if ($installType == 'new') {
  267. $instalation_type_label = get_lang('New installation');
  268. } elseif ($installType == 'update') {
  269. $update_from_version = isset($update_from_version) ? $update_from_version : null;
  270. $instalation_type_label = get_lang('Update from Chamilo').(is_array($update_from_version) ? implode('|', $update_from_version) : '');
  271. }
  272. if (!empty($instalation_type_label) && empty($_POST['step6'])) {
  273. $form .= '<div class="page-header"><h2>'.$instalation_type_label.'</h2></div>';
  274. }
  275. if (empty($installationProfile)) {
  276. $installationProfile = '';
  277. if (!empty($_POST['installationProfile'])) {
  278. $installationProfile = api_htmlentities($_POST['installationProfile']);
  279. }
  280. }
  281. $institutionUrlFormResult = api_stristr($institutionUrlForm, 'http://', false) ? api_htmlentities($institutionUrlForm, ENT_QUOTES) : api_stristr($institutionUrlForm, 'https://', false) ? api_htmlentities($institutionUrlForm, ENT_QUOTES) : 'http://'.api_htmlentities($institutionUrlForm, ENT_QUOTES);
  282. $form .= '<input type="hidden" name="updatePath" value="'.(!$badUpdatePath ? api_htmlentities($proposedUpdatePath, ENT_QUOTES) : '').'" />';
  283. $form .= '<input type="hidden" name="urlAppendPath" value="'.api_htmlentities($urlAppendPath, ENT_QUOTES).'"/>';
  284. $form .= '<input type="hidden" name="pathForm" value="'.api_htmlentities($pathForm, ENT_QUOTES).'"/>';
  285. $form .= '<input type="hidden" name="urlForm" value="'.api_htmlentities($urlForm, ENT_QUOTES).'"/>';
  286. $form .= '<input type="hidden" name="dbHostForm" value="'.api_htmlentities($dbHostForm, ENT_QUOTES).'"/>';
  287. $form .= '<input type="hidden" name="dbPortForm" value="'.api_htmlentities($dbPortForm, ENT_QUOTES).'"/>';
  288. $form .= '<input type="hidden" name="dbUsernameForm" value="'.api_htmlentities($dbUsernameForm, ENT_QUOTES).'"/>';
  289. $form .= '<input type="hidden" name="dbPassForm" value="'.api_htmlentities($dbPassForm, ENT_QUOTES).'"/>';
  290. $form .= '<input type="hidden" name="dbNameForm" value="'.api_htmlentities($dbNameForm, ENT_QUOTES).'"/>';
  291. $form .= '<input type="hidden" name="allowSelfReg" value="'.api_htmlentities($allowSelfReg, ENT_QUOTES).'"/>';
  292. $form .= '<input type="hidden" name="allowSelfRegProf" value="'.api_htmlentities($allowSelfRegProf, ENT_QUOTES).'"/>';
  293. $form .= '<input type="hidden" name="emailForm" value="'.api_htmlentities($emailForm, ENT_QUOTES).'"/>';
  294. $form .= '<input type="hidden" name="adminLastName" value="'.api_htmlentities($adminLastName, ENT_QUOTES).'"/>';
  295. $form .= '<input type="hidden" name="adminFirstName" value="'.api_htmlentities($adminFirstName, ENT_QUOTES).'"/>';
  296. $form .= '<input type="hidden" name="adminPhoneForm" value="'.api_htmlentities($adminPhoneForm, ENT_QUOTES).'"/>';
  297. $form .= '<input type="hidden" name="loginForm" value="'.api_htmlentities($loginForm, ENT_QUOTES).'"/>';
  298. $form .= '<input type="hidden" name="passForm" value="'.api_htmlentities($passForm, ENT_QUOTES).'"/>';
  299. $form .= '<input type="hidden" name="languageForm" value="'.api_htmlentities($languageForm, ENT_QUOTES).'"/>';
  300. $form .= '<input type="hidden" name="campusForm" value="'.api_htmlentities($campusForm, ENT_QUOTES).'"/>';
  301. $form .= '<input type="hidden" name="educationForm" value="'.api_htmlentities($educationForm, ENT_QUOTES).'"/>';
  302. $form .= '<input type="hidden" name="institutionForm" value="'.api_htmlentities($institutionForm, ENT_QUOTES).'"/>';
  303. $form .= '<input type="hidden" name="institutionUrlForm" value="'.$institutionUrlFormResult.'"/>';
  304. $form .= '<input type="hidden" name="checkEmailByHashSent" value="'.api_htmlentities($checkEmailByHashSent, ENT_QUOTES).'"/>';
  305. $form .= '<input type="hidden" name="ShowEmailNotCheckedToStudent" value="'.api_htmlentities($showEmailNotCheckedToStudent, ENT_QUOTES).'"/>';
  306. $form .= '<input type="hidden" name="userMailCanBeEmpty" value="'.api_htmlentities($userMailCanBeEmpty, ENT_QUOTES).'"/>';
  307. $form .= '<input type="hidden" name="encryptPassForm" value="'.api_htmlentities($encryptPassForm, ENT_QUOTES).'"/>';
  308. $form .= '<input type="hidden" name="session_lifetime" value="'.api_htmlentities($session_lifetime, ENT_QUOTES).'"/>';
  309. $form .= '<input type="hidden" name="old_version" value="'.api_htmlentities($my_old_version, ENT_QUOTES).'"/>';
  310. $form .= '<input type="hidden" name="new_version" value="'.api_htmlentities($new_version, ENT_QUOTES).'"/>';
  311. $form .= '<input type="hidden" name="installationProfile" value="'.api_htmlentities($installationProfile, ENT_QUOTES).'"/>';
  312. if (isset($_POST['step2'])) {
  313. // STEP 3 : LICENSE
  314. ob_start();
  315. display_license_agreement();
  316. $form .= ob_get_contents();
  317. ob_end_clean();
  318. } elseif (isset($_POST['step3'])) {
  319. // STEP 4 : MYSQL DATABASE SETTINGS
  320. ob_start();
  321. display_database_settings_form(
  322. $installType,
  323. $dbHostForm,
  324. $dbUsernameForm,
  325. $dbPassForm,
  326. $dbNameForm,
  327. $dbPortForm,
  328. $installationProfile
  329. );
  330. $form .= ob_get_contents();
  331. ob_end_clean();
  332. } elseif (isset($_POST['step4'])) {
  333. //STEP 5 : CONFIGURATION SETTINGS
  334. //if update, try getting settings from the database...
  335. if ($installType === 'update') {
  336. $db_name = $dbNameForm;
  337. $database = connectToDatabase(
  338. $dbHostForm,
  339. $dbUsernameForm,
  340. $dbPassForm,
  341. $dbNameForm,
  342. $dbPortForm
  343. );
  344. $manager = $database->getManager();
  345. $tmp = get_config_param_from_db('platformLanguage');
  346. if (!empty($tmp)) {
  347. $languageForm = $tmp;
  348. }
  349. $tmp = get_config_param_from_db('emailAdministrator');
  350. if (!empty($tmp)) {
  351. $emailForm = $tmp;
  352. }
  353. $tmp = get_config_param_from_db('administratorName');
  354. if (!empty($tmp)) {
  355. $adminFirstName = $tmp;
  356. }
  357. $tmp = get_config_param_from_db('administratorSurname');
  358. if (!empty($tmp)) {
  359. $adminLastName = $tmp;
  360. }
  361. $tmp = get_config_param_from_db('administratorTelephone');
  362. if (!empty($tmp)) {
  363. $adminPhoneForm = $tmp;
  364. }
  365. $tmp = get_config_param_from_db('siteName');
  366. if (!empty($tmp)) {
  367. $campusForm = $tmp;
  368. }
  369. $tmp = get_config_param_from_db('Institution');
  370. if (!empty($tmp)) {
  371. $institutionForm = $tmp;
  372. }
  373. $tmp = get_config_param_from_db('InstitutionUrl');
  374. if (!empty($tmp)) {
  375. $institutionUrlForm = $tmp;
  376. }
  377. // For version 1.9
  378. $encryptPassForm = get_config_param('password_encryption');
  379. // Managing the $encryptPassForm
  380. if ($encryptPassForm == '1') {
  381. $encryptPassForm = 'sha1';
  382. } elseif ($encryptPassForm == '0') {
  383. $encryptPassForm = 'none';
  384. }
  385. $allowSelfReg = 'approval';
  386. $tmp = get_config_param_from_db('allow_registration');
  387. if (!empty($tmp)) {
  388. $allowSelfReg = $tmp;
  389. }
  390. $allowSelfRegProf = false;
  391. $tmp = get_config_param_from_db('allow_registration_as_teacher');
  392. if (!empty($tmp)) {
  393. $allowSelfRegProf = $tmp;
  394. }
  395. }
  396. ob_start();
  397. display_configuration_settings_form(
  398. $installType,
  399. $urlForm,
  400. $languageForm,
  401. $emailForm,
  402. $adminFirstName,
  403. $adminLastName,
  404. $adminPhoneForm,
  405. $campusForm,
  406. $institutionForm,
  407. $institutionUrlForm,
  408. $encryptPassForm,
  409. $allowSelfReg,
  410. $allowSelfRegProf,
  411. $loginForm,
  412. $passForm
  413. );
  414. $form .= ob_get_contents();
  415. ob_end_clean();
  416. } elseif (isset($_POST['step5'])) {
  417. ob_start();
  418. //STEP 6 : LAST CHECK BEFORE INSTALL?>
  419. <div class="RequirementHeading">
  420. <h3><?php echo display_step_sequence().get_lang('Last check before install'); ?></h3>
  421. </div>
  422. <div class="RequirementContent">
  423. <?php echo get_lang('Here are the values you entered'); ?>
  424. </div>
  425. <?php
  426. if ($installType == 'new') {
  427. echo get_lang('Administrator login').' : <strong>'.$loginForm.'</strong><br />';
  428. echo get_lang('Administrator password (<font color="red">you may want to change this</font>)').' : <strong>'.$passForm.'</strong><br /><br />'; /* TODO: Maybe this password should be hidden too? */
  429. }
  430. $allowSelfRegistrationLiteral = ($allowSelfReg == 'true') ? get_lang('Yes') : ($allowSelfReg == 'approval' ? get_lang('Approval') : get_lang('No'));
  431. echo get_lang('Administrator first name').' : '.$adminFirstName, '<br />', get_lang('Administrator last name').' : '.$adminLastName, '<br />';
  432. echo get_lang('Administrator e-mail').' : '.$emailForm; ?><br />
  433. <?php echo get_lang('Administrator telephone').' : '.$adminPhoneForm; ?><br />
  434. <?php echo get_lang('Main language').' : '.$languageForm; ?><br /><br />
  435. <?php echo get_lang('Database Host').' : '.$dbHostForm; ?><br />
  436. <?php echo get_lang('Port').' : '.$dbPortForm; ?><br />
  437. <?php echo get_lang('Database Login').' : '.$dbUsernameForm; ?><br />
  438. <?php echo get_lang('Database Password').' : '.str_repeat('*', api_strlen($dbPassForm)); ?><br />
  439. <?php echo get_lang('Main Chamilo database (DB)').' : <strong>'.$dbNameForm; ?></strong><br />
  440. <?php echo get_lang('Allow self-registration').' : '.$allowSelfRegistrationLiteral; ?><br />
  441. <?php echo get_lang('Encryption method').' : ';
  442. echo $encryptPassForm; ?>
  443. <br /><br />
  444. <?php echo get_lang('Your portal name').' : '.$campusForm; ?><br />
  445. <?php echo get_lang('Your company short name').' : '.$institutionForm; ?><br />
  446. <?php echo get_lang('URL of this company').' : '.$institutionUrlForm; ?><br />
  447. <?php echo get_lang('Chamilo URL').' : '.$urlForm; ?><br /><br />
  448. <?php
  449. if ($installType == 'new') {
  450. echo Display::return_message(
  451. '<h4 style="text-align: center">'.get_lang(
  452. 'Warning'
  453. ).'</h4>'.get_lang('The install script will erase all tables of the selected database. We heavily recommend you do a full backup of them before confirming this last install step.'),
  454. 'warning',
  455. false
  456. );
  457. } ?>
  458. <table width="100%">
  459. <tr>
  460. <td>
  461. <button type="submit" class="btn btn-secondary" name="step4" value="&lt; <?php echo get_lang('Previous'); ?>" >
  462. <em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?>
  463. </button>
  464. </td>
  465. <td align="right">
  466. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  467. <input type="hidden" name="step6" value="1" />
  468. <button id="button_step6" class="btn btn-success" type="submit" name="button_step6" value="<?php echo get_lang('Install chamilo'); ?>">
  469. <em class="fa fa-floppy-o"> </em>
  470. <?php echo get_lang('Install chamilo'); ?>
  471. </button>
  472. <button class="btn btn-save" id="button_please_wait"></button>
  473. </td>
  474. </tr>
  475. </table>
  476. <?php
  477. $form .= ob_get_contents();
  478. ob_end_clean();
  479. } elseif (isset($_POST['step6'])) {
  480. ob_start();
  481. //STEP 6 : INSTALLATION PROCESS
  482. $current_step = 7;
  483. $msg = get_lang('Installation process execution');
  484. if ($installType === 'update') {
  485. $msg = get_lang('Update process execution');
  486. }
  487. $form .= '<div class="RequirementHeading">
  488. <h3>'.display_step_sequence().$msg.'</h3>';
  489. if (!empty($installationProfile)) {
  490. $form .= ' <h3>('.$installationProfile.')</h3>';
  491. }
  492. $form .= '<div id="pleasewait" class="alert alert-success">'.get_lang('Please wait. This could take a while...').'
  493. <div class="progress">
  494. <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
  495. <span class="sr-only">100% Complete</span>
  496. </div>
  497. </div>
  498. </div>
  499. </div>';
  500. if ($installType === 'update') {
  501. $database = connectToDatabase(
  502. $dbHostForm,
  503. $dbUsernameForm,
  504. $dbPassForm,
  505. $dbNameForm,
  506. $dbPortForm
  507. );
  508. $manager = $database->getManager();
  509. $perm = api_get_permissions_for_new_directories();
  510. $perm_file = api_get_permissions_for_new_files();
  511. migrateSwitch($my_old_version, $manager);
  512. // Create .env.local file
  513. $envFile = api_get_path(SYS_PATH).'.env.local';
  514. $distFile = api_get_path(SYS_PATH).'.env';
  515. $params = [
  516. '{{DATABASE_HOST}}' => $dbHostForm,
  517. '{{DATABASE_PORT}}' => $dbPortForm,
  518. '{{DATABASE_NAME}}' => $dbNameForm,
  519. '{{DATABASE_USER}}' => $dbUsernameForm,
  520. '{{DATABASE_PASSWORD}}' => $dbPassForm,
  521. '{{APP_INSTALLED}}' => 1,
  522. '{{APP_ENCRYPT_METHOD}}' => $encryptPassForm,
  523. '{{APP_URL_APPEND}}' => $urlAppendPath,
  524. ];
  525. error_log('Update env file');
  526. updateEnvFile($distFile, $envFile, $params);
  527. (new Dotenv())->load($envFile);
  528. // Load Symfony Kernel
  529. $kernel = new Kernel('dev', true);
  530. $application = new Application($kernel);
  531. error_log('Set Kernel');
  532. session_unset();
  533. $_SESSION = [];
  534. session_destroy();
  535. // No errors
  536. //if ($result == 0) {
  537. // Boot kernel and get the doctrine from Symfony container
  538. $kernel->boot();
  539. error_log('Boot');
  540. $containerDatabase = $kernel->getContainer();
  541. upgradeWithContainer($containerDatabase);
  542. error_log('Set upgradeWithContainer');
  543. } else {
  544. set_file_folder_permissions();
  545. $database = connectToDatabase(
  546. $dbHostForm,
  547. $dbUsernameForm,
  548. $dbPassForm,
  549. null,
  550. $dbPortForm
  551. );
  552. $manager = $database->getManager();
  553. $dbNameForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbNameForm);
  554. // Drop and create the database anyways
  555. $manager->getConnection()->getSchemaManager()->dropAndCreateDatabase($dbNameForm);
  556. $database = connectToDatabase(
  557. $dbHostForm,
  558. $dbUsernameForm,
  559. $dbPassForm,
  560. $dbNameForm,
  561. $dbPortForm
  562. );
  563. $manager = $database->getManager();
  564. // Create .env.local file
  565. $envFile = api_get_path(SYS_PATH).'.env.local';
  566. $distFile = api_get_path(SYS_PATH).'.env';
  567. $params = [
  568. '{{DATABASE_HOST}}' => $dbHostForm,
  569. '{{DATABASE_PORT}}' => $dbPortForm,
  570. '{{DATABASE_NAME}}' => $dbNameForm,
  571. '{{DATABASE_USER}}' => $dbUsernameForm,
  572. '{{DATABASE_PASSWORD}}' => $dbPassForm,
  573. '{{APP_INSTALLED}}' => 1,
  574. '{{APP_ENCRYPT_METHOD}}' => $encryptPassForm,
  575. '{{APP_URL_APPEND}}' => $urlAppendPath,
  576. ];
  577. updateEnvFile($distFile, $envFile, $params);
  578. (new Dotenv())->load($envFile);
  579. // Load Symfony Kernel
  580. $kernel = new Kernel('dev', true);
  581. $application = new Application($kernel);
  582. // Create database
  583. $input = new ArrayInput([]);
  584. $command = $application->find('doctrine:schema:create');
  585. $result = $command->run($input, new ConsoleOutput());
  586. // No errors
  587. if ($result == 0) {
  588. session_unset();
  589. $_SESSION = [];
  590. session_destroy();
  591. // Boot kernel and get the doctrine from Symfony container
  592. $kernel->boot();
  593. $containerDatabase = $kernel->getContainer();
  594. $sysPath = api_get_path(SYS_PATH);
  595. finishInstallationWithContainer(
  596. $containerDatabase,
  597. $sysPath,
  598. $encryptPassForm,
  599. $passForm,
  600. $adminLastName,
  601. $adminFirstName,
  602. $loginForm,
  603. $emailForm,
  604. $adminPhoneForm,
  605. $languageForm,
  606. $institutionForm,
  607. $institutionUrlForm,
  608. $campusForm,
  609. $allowSelfReg,
  610. $allowSelfRegProf,
  611. $installationProfile
  612. );
  613. include 'install_files.inc.php';
  614. }
  615. }
  616. $form .= display_after_install_message();
  617. // Hide the "please wait" message sent previously
  618. $form .= '<script>$(\'#pleasewait\').hide(\'fast\');</script>';
  619. $form .= ob_get_contents();
  620. ob_end_clean();
  621. } elseif (isset($_POST['step1']) || $badUpdatePath) {
  622. //STEP 1 : REQUIREMENTS
  623. //make sure that proposed path is set, shouldn't be necessary but...
  624. if (empty($proposedUpdatePath)) {
  625. $proposedUpdatePath = $_POST['updatePath'];
  626. }
  627. ob_start();
  628. display_requirements($installType, $badUpdatePath, $proposedUpdatePath, $update_from_version_8);
  629. $form .= ob_get_contents();
  630. ob_end_clean();
  631. } else {
  632. ob_start();
  633. // This is the start screen.
  634. display_language_selection();
  635. if (!empty($_GET['profile'])) {
  636. $installationProfile = api_htmlentities($_GET['profile'], ENT_QUOTES);
  637. }
  638. echo '<input type="hidden" name="installationProfile" value="'.api_htmlentities($installationProfile, ENT_QUOTES).'" />';
  639. $form .= ob_get_contents();
  640. ob_end_clean();
  641. }
  642. $poweredBy = 'Powered by <a href="http://www.chamilo.org" target="_blank"> Chamilo </a> &copy; '.date('Y');
  643. ?>
  644. <!DOCTYPE html>
  645. <head>
  646. <title>&mdash; <?php echo $translator->trans('Chamilo installation').' &mdash; '.$translator->trans('Version').' '.$new_version; ?></title>
  647. <meta charset="UTF-8">
  648. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  649. <style type="text/css" media="screen, projection">
  650. @import "../../public/build/css/app.css";
  651. @import "../../public/build/css/themes/chamilo/default.css";
  652. </style>
  653. <script type="text/javascript" src="../../public/build/runtime.js"></script>
  654. <script type="text/javascript" src="../../public/build/app.js"></script>
  655. <script>
  656. $(function() {
  657. $("#details_button").click(function() {
  658. $( "#details" ).toggle("slow", function() {
  659. });
  660. });
  661. $("#button_please_wait").hide();
  662. $("button").addClass('btn btn-secondary');
  663. // Allow Chamilo install in IE
  664. $("button").click(function() {
  665. $("#is_executable").attr("value",$(this).attr("name"));
  666. });
  667. //Blocking step6 button
  668. $("#button_step6").click(function() {
  669. $("#button_step6").hide();
  670. $("#button_please_wait").html('<?php echo addslashes($translator->trans('Continue')); ?>');
  671. $("#button_please_wait").show();
  672. $("#button_please_wait").attr('disabled', true);
  673. $("#is_executable").attr("value",'step6');
  674. });
  675. $(".advanced_parameters").click(function() {
  676. if ($("#id_contact_form").css("display") == "none") {
  677. $("#id_contact_form").css("display","block");
  678. $("#img_plus_and_minus").html(
  679. '&nbsp;<i class="fa fa-eye" aria-hidden="true"></i>&nbsp;<?php echo $translator->trans('Contact information'); ?>'
  680. );
  681. } else {
  682. $("#id_contact_form").css("display","none");
  683. $("#img_plus_and_minus").html(
  684. '&nbsp;<i class="fa fa-eye-slash" aria-hidden="true"></i>&nbsp;<?php echo $translator->trans('Contact information'); ?>'
  685. );
  686. }
  687. });
  688. });
  689. function send_contact_information() {
  690. if (!document.getElementById('accept_licence').checked) {
  691. alert('<?php echo $translator->trans('You must accept the licence'); ?>')
  692. ;return false;
  693. } else {
  694. var data_post = "";
  695. data_post += "person_name="+$("#person_name").val()+"&";
  696. data_post += "person_email="+$("#person_email").val()+"&";
  697. data_post += "company_name="+$("#company_name").val()+"&";
  698. data_post += "company_activity="+$("#company_activity option:selected").val()+"&";
  699. data_post += "person_role="+$("#person_role option:selected").val()+"&";
  700. data_post += "company_country="+$("#country option:selected").val()+"&";
  701. data_post += "company_city="+$("#company_city").val()+"&";
  702. data_post += "language="+$("#language option:selected").val()+"&";
  703. data_post += "financial_decision="+$("input[name='financial_decision']:checked").val();
  704. $.ajax({
  705. contentType: "application/x-www-form-urlencoded",
  706. beforeSend: function(objeto) {},
  707. type: "POST",
  708. url: "<?php echo api_get_path(WEB_AJAX_PATH); ?>install.ajax.php?a=send_contact_information",
  709. beforeSend : function() {
  710. $('#loader-button').append(' <em class="fa fa-spinner fa-pulse fa-fw"></em>');
  711. },
  712. data: data_post,
  713. success: function(datos) {
  714. if (datos == 'required_field_error') {
  715. message = "<?php echo $translator->trans('The form contains incorrect or incomplete data. Please check your input.'); ?>";
  716. } else if (datos == '1') {
  717. message = "<?php echo $translator->trans('Contact informationHasBeenSent'); ?>";
  718. } else {
  719. message = "<?php echo $translator->trans('Error').': '.$translator->trans('Contact informationHasNotBeenSent'); ?>";
  720. }
  721. alert(message);
  722. $('#license-next').trigger('click');
  723. $('#loader-button').html('');
  724. }
  725. });
  726. }
  727. }
  728. </script>
  729. </head>
  730. <body class="bg-chamilo bg-install">
  731. <div class="install-box">
  732. <div class="row">
  733. <div class="col-md-4">
  734. <div class="logo-install">
  735. <img src="header-logo.png" class="img-fluid" alt="Chamilo" />
  736. </div>
  737. <div class="install-steps">
  738. <ol class="list-group">
  739. <li class="list-group-item <?php step_active('1'); ?>">
  740. <span class="number"> 1 </span>
  741. <?php echo $translator->trans('Installation language'); ?>
  742. </li>
  743. <li class="list-group-item <?php step_active('2'); ?>">
  744. <span class="number"> 2 </span>
  745. <?php echo $translator->trans('Requirements'); ?>
  746. </li>
  747. <li class="list-group-item <?php step_active('3'); ?>">
  748. <span class="number"> 3 </span>
  749. <?php echo $translator->trans('Licence'); ?>
  750. </li>
  751. <li class="list-group-item <?php step_active('4'); ?>">
  752. <span class="number"> 4 </span>
  753. <?php echo $translator->trans('MySQL database settings'); ?>
  754. </li>
  755. <li class="list-group-item <?php step_active('5'); ?>">
  756. <span class="number"> 5 </span>
  757. <?php echo $translator->trans('Config settings'); ?>
  758. </li>
  759. <li class="list-group-item <?php step_active('6'); ?>">
  760. <span class="number"> 6 </span>
  761. <?php echo $translator->trans('Show Overview'); ?>
  762. </li>
  763. <li class="list-group-item <?php step_active('7'); ?>">
  764. <span class="number"> 7 </span>
  765. <?php echo $translator->trans('Install'); ?>
  766. </li>
  767. </ol>
  768. </div>
  769. <div id="note">
  770. <a class="btn btn-info btn-block" href="<?php echo $installationGuideLink; ?>" target="_blank">
  771. <em class="fa fa-file-text-o"></em> <?php echo $translator->trans('Read the installation guide'); ?>
  772. </a>
  773. </div>
  774. </div>
  775. <div class="col-md-8">
  776. <form class="form-horizontal" id="install_form" method="post"
  777. action="<?php echo api_get_self(); ?>?running=1&amp;installType=<?php echo $installType; ?>&amp;updateFromConfigFile=<?php echo urlencode($updateFromConfigFile); ?>">
  778. <?php echo $form; ?>
  779. </form>
  780. </div>
  781. <footer class="install-footer">
  782. <?php echo $poweredBy; ?>
  783. </footer>
  784. </div>
  785. </div>
  786. </body>
  787. </html>