index.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Chamilo installation
  5. *
  6. * As seen from the user, the installation proceeds in 6 steps.
  7. * The user is presented with several webpages where he/she has to make choices
  8. * and/or fill in data.
  9. *
  10. * The aim is, as always, to have good default settings and suggestions.
  11. *
  12. * @todo reduce high level of duplication in this code
  13. * @todo (busy) organise code into functions
  14. * @package chamilo.install
  15. */
  16. use ChamiloSession as Session;
  17. require_once __DIR__.'/../../vendor/autoload.php';
  18. define('SYSTEM_INSTALLATION', 1);
  19. define('INSTALL_TYPE_UPDATE', 'update');
  20. define('FORM_FIELD_DISPLAY_LENGTH', 40);
  21. define('DATABASE_FORM_FIELD_DISPLAY_LENGTH', 25);
  22. define('MAX_FORM_FIELD_LENGTH', 80);
  23. // Including necessary libraries.
  24. require_once '../inc/lib/api.lib.php';
  25. api_check_php_version('../inc/');
  26. /* INITIALIZATION SECTION */
  27. ob_implicit_flush(true);
  28. session_start();
  29. require_once api_get_path(LIBRARY_PATH).'database.constants.inc.php';
  30. require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
  31. require_once 'install.lib.php';
  32. // The function api_get_setting() might be called within the installation scripts.
  33. // We need to provide some limited support for it through initialization of the
  34. // global array-type variable $_setting.
  35. $_setting = array(
  36. 'platform_charset' => 'UTF-8',
  37. 'server_type' => 'production', // 'production' | 'test'
  38. 'permissions_for_new_directories' => '0770',
  39. 'permissions_for_new_files' => '0660',
  40. 'stylesheets' => 'chamilo'
  41. );
  42. // Determination of the language during the installation procedure.
  43. if (!empty($_POST['language_list'])) {
  44. $search = array('../', '\\0');
  45. $install_language = str_replace($search, '', urldecode($_POST['language_list']));
  46. Session::write('install_language', $install_language);
  47. } elseif (isset($_SESSION['install_language']) && $_SESSION['install_language']) {
  48. $install_language = $_SESSION['install_language'];
  49. } else {
  50. // Trying to switch to the browser's language, it is covenient for most of the cases.
  51. $install_language = detect_browser_language();
  52. }
  53. // Language validation.
  54. if (!array_key_exists($install_language, get_language_folder_list())) {
  55. $install_language = 'english';
  56. }
  57. $installationGuideLink = '../../documentation/installation_guide.html';
  58. // Loading language files.
  59. require api_get_path(SYS_LANG_PATH).'english/trad4all.inc.php';
  60. if ($install_language != 'english') {
  61. include_once api_get_path(SYS_LANG_PATH).$install_language.'/trad4all.inc.php';
  62. switch ($install_language) {
  63. case 'french':
  64. $installationGuideLink = '../../documentation/installation_guide_fr_FR.html';
  65. break;
  66. case 'spanish':
  67. $installationGuideLink = '../../documentation/installation_guide_es_ES.html';
  68. break;
  69. case 'italian':
  70. $installationGuideLink = '../../documentation/installation_guide_it_IT.html';
  71. break;
  72. default:
  73. break;
  74. }
  75. }
  76. // These global variables must be set for proper working of the function get_lang(...) during the installation.
  77. $language_interface = $install_language;
  78. $language_interface_initial_value = $install_language;
  79. // Character set during the installation, it is always to be 'UTF-8'.
  80. $charset = 'UTF-8';
  81. // Enables the portablity layer and configures PHP for UTF-8
  82. \Patchwork\Utf8\Bootup::initAll();
  83. // Page encoding initialization.
  84. header('Content-Type: text/html; charset='. $charset);
  85. // Setting the error reporting levels.
  86. error_reporting(E_ALL);
  87. // Overriding the timelimit (for large campusses that have to be migrated).
  88. @set_time_limit(0);
  89. // Upgrading from any subversion of 1.9
  90. $update_from_version_8 = array(
  91. '1.9.0',
  92. '1.9.2',
  93. '1.9.4',
  94. '1.9.6',
  95. '1.9.6.1',
  96. '1.9.8',
  97. '1.9.8.1',
  98. '1.9.8.2',
  99. '1.9.10',
  100. '1.9.10.2'
  101. );
  102. $my_old_version = '';
  103. if (empty($tmp_version)) {
  104. $tmp_version = get_config_param('system_version');
  105. }
  106. if (!empty($_POST['old_version'])) {
  107. $my_old_version = $_POST['old_version'];
  108. } elseif (!empty($tmp_version)) {
  109. $my_old_version = $tmp_version;
  110. }
  111. require_once __DIR__.'/version.php';
  112. // Try to delete old symfony folder (generates conflicts with composer)
  113. $oldSymfonyFolder = '../inc/lib/symfony';
  114. if (is_dir($oldSymfonyFolder)) {
  115. @rmdir($oldSymfonyFolder);
  116. }
  117. // A protection measure for already installed systems.
  118. if (isAlreadyInstalledSystem()) {
  119. // The system has already been installed, so block re-installation.
  120. $global_error_code = 6;
  121. require '../inc/global_error_message.inc.php';
  122. die();
  123. }
  124. /* STEP 1 : INITIALIZES FORM VARIABLES IF IT IS THE FIRST VISIT */
  125. // Is valid request
  126. $is_valid_request = isset($_REQUEST['is_executable']) ? $_REQUEST['is_executable'] : null;
  127. /*foreach ($_POST as $request_index => $request_value) {
  128. if (substr($request_index, 0, 4) == 'step') {
  129. if ($request_index != $is_valid_request) {
  130. unset($_POST[$request_index]);
  131. }
  132. }
  133. }*/
  134. $badUpdatePath = false;
  135. $emptyUpdatePath = true;
  136. $proposedUpdatePath = '';
  137. if (!empty($_POST['updatePath'])) {
  138. $proposedUpdatePath = $_POST['updatePath'];
  139. }
  140. if (@$_POST['step2_install'] || @$_POST['step2_update_8'] || @$_POST['step2_update_6']) {
  141. if (@$_POST['step2_install']) {
  142. $installType = 'new';
  143. $_POST['step2'] = 1;
  144. } else {
  145. $installType = 'update';
  146. if (@$_POST['step2_update_8']) {
  147. $emptyUpdatePath = false;
  148. $proposedUpdatePath = api_add_trailing_slash(empty($_POST['updatePath']) ? api_get_path(SYS_PATH) : $_POST['updatePath']);
  149. if (file_exists($proposedUpdatePath)) {
  150. if (in_array($my_old_version, $update_from_version_8)) {
  151. $_POST['step2'] = 1;
  152. } else {
  153. $badUpdatePath = true;
  154. }
  155. } else {
  156. $badUpdatePath = true;
  157. }
  158. }
  159. }
  160. } elseif (@$_POST['step1']) {
  161. $_POST['updatePath'] = '';
  162. $installType = '';
  163. $updateFromConfigFile = '';
  164. unset($_GET['running']);
  165. } else {
  166. $installType = isset($_GET['installType']) ? $_GET['installType'] : null;
  167. $updateFromConfigFile = isset($_GET['updateFromConfigFile']) ? $_GET['updateFromConfigFile'] : false;
  168. }
  169. if ($installType == 'update' && in_array($my_old_version, $update_from_version_8)) {
  170. // This is the main configuration file of the system before the upgrade.
  171. // Old configuration file.
  172. // Don't change to include_once
  173. $oldConfigPath = api_get_path(SYS_CODE_PATH) . 'inc/conf/configuration.php';
  174. if (file_exists($oldConfigPath)) {
  175. include $oldConfigPath;
  176. }
  177. }
  178. if (!isset($_GET['running'])) {
  179. $dbHostForm = 'localhost';
  180. $dbUsernameForm = 'root';
  181. $dbPassForm = '';
  182. $dbNameForm = 'chamilo';
  183. // Extract the path to append to the url if Chamilo is not installed on the web root directory.
  184. $urlAppendPath = api_remove_trailing_slash(api_get_path(REL_PATH));
  185. $urlForm = api_get_path(WEB_PATH);
  186. $pathForm = api_get_path(SYS_PATH);
  187. $emailForm = 'webmaster@localhost';
  188. if (!empty($_SERVER['SERVER_ADMIN'])) {
  189. $emailForm = $_SERVER['SERVER_ADMIN'];
  190. }
  191. $email_parts = explode('@', $emailForm);
  192. if (isset($email_parts[1]) && $email_parts[1] == 'localhost') {
  193. $emailForm .= '.localdomain';
  194. }
  195. $adminLastName = get_lang('DefaultInstallAdminLastname');
  196. $adminFirstName = get_lang('DefaultInstallAdminFirstname');
  197. $loginForm = 'admin';
  198. $passForm = api_generate_password();
  199. $campusForm = 'My campus';
  200. $educationForm = 'Albert Einstein';
  201. $adminPhoneForm = '(000) 001 02 03';
  202. $institutionForm = 'My Organisation';
  203. $institutionUrlForm = 'http://www.chamilo.org';
  204. $languageForm = api_get_interface_language();
  205. $checkEmailByHashSent = 0;
  206. $ShowEmailNotCheckedToStudent = 1;
  207. $userMailCanBeEmpty = 1;
  208. $allowSelfReg = 1;
  209. $allowSelfRegProf = 1;
  210. $encryptPassForm = 'sha1';
  211. $session_lifetime = 360000;
  212. if (!empty($_GET['profile'])) {
  213. $installationProfile = api_htmlentities($_GET['profile'], ENT_QUOTES);
  214. }
  215. } else {
  216. foreach ($_POST as $key => $val) {
  217. $magic_quotes_gpc = ini_get('magic_quotes_gpc');
  218. if (is_string($val)) {
  219. if ($magic_quotes_gpc) {
  220. $val = stripslashes($val);
  221. }
  222. $val = trim($val);
  223. $_POST[$key] = $val;
  224. } elseif (is_array($val)) {
  225. foreach ($val as $key2 => $val2) {
  226. if ($magic_quotes_gpc) {
  227. $val2 = stripslashes($val2);
  228. }
  229. $val2 = trim($val2);
  230. $_POST[$key][$key2] = $val2;
  231. }
  232. }
  233. $GLOBALS[$key] = $_POST[$key];
  234. }
  235. }
  236. /* NEXT STEPS IMPLEMENTATION */
  237. $total_steps = 7;
  238. if (!$_POST) {
  239. $current_step = 1;
  240. } elseif (!empty($_POST['language_list']) or !empty($_POST['step1']) or ((!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6']))) && ($emptyUpdatePath or $badUpdatePath))) {
  241. $current_step = 2;
  242. } elseif (!empty($_POST['step2']) or (!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6'])))) {
  243. $current_step = 3;
  244. } elseif (!empty($_POST['step3'])) {
  245. $current_step = 4;
  246. } elseif (!empty($_POST['step4'])) {
  247. $current_step = 5;
  248. } elseif (!empty($_POST['step5'])) {
  249. $current_step = 6;
  250. } elseif (@$_POST['step6']) {
  251. $current_step = 7;
  252. }
  253. // Managing the $encryptPassForm
  254. if ($encryptPassForm == '1') {
  255. $encryptPassForm = 'sha1';
  256. } elseif ($encryptPassForm == '0') {
  257. $encryptPassForm = 'none';
  258. }
  259. ?>
  260. <!DOCTYPE html>
  261. <head>
  262. <title>&mdash; <?php echo get_lang('ChamiloInstallation').' &mdash; '.get_lang('Version_').' '.$new_version; ?></title>
  263. <style type="text/css" media="screen, projection">
  264. @import "../../web/assets/bootstrap/dist/css/bootstrap.min.css";
  265. @import "../../web/assets/fontawesome/css/font-awesome.min.css";
  266. @import "../../web/css/base.css";
  267. @import "../../web/css/themes/chamilo/default.css";
  268. </style>
  269. <script type="text/javascript" src="../../web/assets/jquery/dist/jquery.min.js"></script>
  270. <script type="text/javascript">
  271. $(document).ready( function() {
  272. $("#button_please_wait").hide();
  273. $("button").addClass('btn btn-default');
  274. // Allow Chamilo install in IE
  275. $("button").click(function() {
  276. $("#is_executable").attr("value",$(this).attr("name"));
  277. });
  278. //Blocking step6 button
  279. $("#button_step6").click(function() {
  280. $("#button_step6").hide();
  281. $("#button_please_wait").html('<?php echo addslashes(get_lang('PleaseWait'));?>');
  282. $("#button_please_wait").show();
  283. $("#button_please_wait").attr('disabled', true);
  284. $("#is_executable").attr("value",'step6');
  285. });
  286. });
  287. init_visibility=0;
  288. $(document).ready( function() {
  289. $(".advanced_parameters").click(function() {
  290. if ($("#id_contact_form").css("display") == "none") {
  291. $("#id_contact_form").css("display","block");
  292. $("#img_plus_and_minus").html('&nbsp;<img src="<?php echo api_get_path(WEB_IMG_PATH) ?>div_hide.gif" alt="<?php echo get_lang('Hide') ?>" title="<?php echo get_lang('Hide')?>" style ="vertical-align:middle" >&nbsp;<?php echo get_lang('ContactInformation') ?>');
  293. } else {
  294. $("#id_contact_form").css("display","none");
  295. $("#img_plus_and_minus").html('&nbsp;<img src="<?php echo api_get_path(WEB_IMG_PATH) ?>div_show.gif" alt="<?php echo get_lang('Show') ?>" title="<?php echo get_lang('Show') ?>" style ="vertical-align:middle" >&nbsp;<?php echo get_lang('ContactInformation') ?>');
  296. }
  297. });
  298. });
  299. function send_contact_information() {
  300. var data_post = "";
  301. data_post += "person_name="+$("#person_name").val()+"&";
  302. data_post += "person_email="+$("#person_email").val()+"&";
  303. data_post += "company_name="+$("#company_name").val()+"&";
  304. data_post += "company_activity="+$("#company_activity option:selected").val()+"&";
  305. data_post += "person_role="+$("#person_role option:selected").val()+"&";
  306. data_post += "company_country="+$("#country option:selected").val()+"&";
  307. data_post += "company_city="+$("#company_city").val()+"&";
  308. data_post += "language="+$("#language option:selected").val()+"&";
  309. data_post += "financial_decision="+$("input[@name='financial_decision']:checked").val();
  310. $.ajax({
  311. contentType: "application/x-www-form-urlencoded",
  312. beforeSend: function(objeto) {},
  313. type: "POST",
  314. url: "<?php echo api_get_path(WEB_AJAX_PATH) ?>install.ajax.php?a=send_contact_information",
  315. data: data_post,
  316. success: function(datos) {
  317. if (datos == 'required_field_error') {
  318. message = "<?php echo get_lang('FormHasErrorsPleaseComplete') ?>";
  319. } else if (datos == '1') {
  320. message = "<?php echo get_lang('ContactInformationHasBeenSent') ?>";
  321. } else {
  322. message = "<?php echo get_lang('Error').': '.get_lang('ContactInformationHasNotBeenSent') ?>";
  323. }
  324. alert(message);
  325. }
  326. });
  327. }
  328. </script>
  329. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>" />
  330. </head>
  331. <body dir="<?php echo api_get_text_direction(); ?>">
  332. <div id="page-install">
  333. <div id="main" class="container">
  334. <header class="row">
  335. <div class="col-md-12">
  336. <div class="logo">
  337. <img src="<?php echo api_get_path(WEB_CSS_PATH) ?>themes/chamilo/images/header-logo.png" hspace="10" vspace="10" alt="Chamilo" />
  338. </div>
  339. </div>
  340. </header>
  341. <div class="panel panel-default">
  342. <div class="panel-heading">
  343. <?php
  344. echo '<h4>'.get_lang('ChamiloInstallation').' &ndash; '.get_lang('Version_').' '.$new_version.'</h4>';
  345. ?>
  346. </div>
  347. <div class="panel-body">
  348. <div class="row">
  349. <div class="col-md-4">
  350. <div class="well install-steps-menu">
  351. <ol>
  352. <li <?php step_active('1'); ?>><?php echo get_lang('InstallationLanguage'); ?></li>
  353. <li <?php step_active('2'); ?>><?php echo get_lang('Requirements'); ?></li>
  354. <li <?php step_active('3'); ?>><?php echo get_lang('Licence'); ?></li>
  355. <li <?php step_active('4'); ?>><?php echo get_lang('DBSetting'); ?></li>
  356. <li <?php step_active('5'); ?>><?php echo get_lang('CfgSetting'); ?></li>
  357. <li <?php step_active('6'); ?>><?php echo get_lang('PrintOverview'); ?></li>
  358. <li <?php step_active('7'); ?>><?php echo get_lang('Installing'); ?></li>
  359. </ol>
  360. </div>
  361. <div id="note">
  362. <a class="btn btn-default" href="<?php echo $installationGuideLink; ?>" target="_blank">
  363. <i class="fa fa-file-text-o"></i> <?php echo get_lang('ReadTheInstallationGuide'); ?>
  364. </a>
  365. </div>
  366. </div>
  367. <div class="col-md-8">
  368. <form class="form-horizontal" id="install_form" method="post" action="<?php echo api_get_self(); ?>?running=1&amp;installType=<?php echo $installType; ?>&amp;updateFromConfigFile=<?php echo urlencode($updateFromConfigFile); ?>">
  369. <?php
  370. $instalation_type_label = '';
  371. if ($installType == 'new') {
  372. $instalation_type_label = get_lang('NewInstallation');
  373. } elseif ($installType == 'update') {
  374. $update_from_version = isset($update_from_version) ? $update_from_version : null;
  375. $instalation_type_label = get_lang('UpdateFromLMSVersion').(is_array($update_from_version) ? implode('|', $update_from_version) : '');
  376. }
  377. if (!empty($instalation_type_label) && empty($_POST['step6'])) {
  378. echo '<div class="page-header"><h2>'.$instalation_type_label.'</h2></div>';
  379. }
  380. if (empty($installationProfile)) {
  381. $installationProfile = '';
  382. if (!empty($_POST['installationProfile'])) {
  383. $installationProfile = api_htmlentities($_POST['installationProfile']);
  384. }
  385. }
  386. ?>
  387. <input type="hidden" name="updatePath" value="<?php if (!$badUpdatePath) echo api_htmlentities($proposedUpdatePath, ENT_QUOTES); ?>" />
  388. <input type="hidden" name="urlAppendPath" value="<?php echo api_htmlentities($urlAppendPath, ENT_QUOTES); ?>" />
  389. <input type="hidden" name="pathForm" value="<?php echo api_htmlentities($pathForm, ENT_QUOTES); ?>" />
  390. <input type="hidden" name="urlForm" value="<?php echo api_htmlentities($urlForm, ENT_QUOTES); ?>" />
  391. <input type="hidden" name="dbHostForm" value="<?php echo api_htmlentities($dbHostForm, ENT_QUOTES); ?>" />
  392. <input type="hidden" name="dbUsernameForm" value="<?php echo api_htmlentities($dbUsernameForm, ENT_QUOTES); ?>" />
  393. <input type="hidden" name="dbPassForm" value="<?php echo api_htmlentities($dbPassForm, ENT_QUOTES); ?>" />
  394. <input type="hidden" name="dbNameForm" value="<?php echo api_htmlentities($dbNameForm, ENT_QUOTES); ?>" />
  395. <input type="hidden" name="allowSelfReg" value="<?php echo api_htmlentities($allowSelfReg, ENT_QUOTES); ?>" />
  396. <input type="hidden" name="allowSelfRegProf" value="<?php echo api_htmlentities($allowSelfRegProf, ENT_QUOTES); ?>" />
  397. <input type="hidden" name="emailForm" value="<?php echo api_htmlentities($emailForm, ENT_QUOTES); ?>" />
  398. <input type="hidden" name="adminLastName" value="<?php echo api_htmlentities($adminLastName, ENT_QUOTES); ?>" />
  399. <input type="hidden" name="adminFirstName" value="<?php echo api_htmlentities($adminFirstName, ENT_QUOTES); ?>" />
  400. <input type="hidden" name="adminPhoneForm" value="<?php echo api_htmlentities($adminPhoneForm, ENT_QUOTES); ?>" />
  401. <input type="hidden" name="loginForm" value="<?php echo api_htmlentities($loginForm, ENT_QUOTES); ?>" />
  402. <input type="hidden" name="passForm" value="<?php echo api_htmlentities($passForm, ENT_QUOTES); ?>" />
  403. <input type="hidden" name="languageForm" value="<?php echo api_htmlentities($languageForm, ENT_QUOTES); ?>" />
  404. <input type="hidden" name="campusForm" value="<?php echo api_htmlentities($campusForm, ENT_QUOTES); ?>" />
  405. <input type="hidden" name="educationForm" value="<?php echo api_htmlentities($educationForm, ENT_QUOTES); ?>" />
  406. <input type="hidden" name="institutionForm" value="<?php echo api_htmlentities($institutionForm, ENT_QUOTES); ?>" />
  407. <input type="hidden" name="institutionUrlForm" value="<?php echo 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); ?>" />
  408. <input type="hidden" name="checkEmailByHashSent" value="<?php echo api_htmlentities($checkEmailByHashSent, ENT_QUOTES); ?>" />
  409. <input type="hidden" name="ShowEmailNotCheckedToStudent" value="<?php echo api_htmlentities($ShowEmailNotCheckedToStudent, ENT_QUOTES); ?>" />
  410. <input type="hidden" name="userMailCanBeEmpty" value="<?php echo api_htmlentities($userMailCanBeEmpty, ENT_QUOTES); ?>" />
  411. <input type="hidden" name="encryptPassForm" value="<?php echo api_htmlentities($encryptPassForm, ENT_QUOTES); ?>" />
  412. <input type="hidden" name="session_lifetime" value="<?php echo api_htmlentities($session_lifetime, ENT_QUOTES); ?>" />
  413. <input type="hidden" name="old_version" value="<?php echo api_htmlentities($my_old_version, ENT_QUOTES); ?>" />
  414. <input type="hidden" name="new_version" value="<?php echo api_htmlentities($new_version, ENT_QUOTES); ?>" />
  415. <input type="hidden" name="installationProfile" value="<?php echo api_htmlentities($installationProfile, ENT_QUOTES); ?>" />
  416. <?php
  417. if (@$_POST['step2']) {
  418. //STEP 3 : LICENSE
  419. display_license_agreement();
  420. } elseif (@$_POST['step3']) {
  421. //STEP 4 : MYSQL DATABASE SETTINGS
  422. display_database_settings_form(
  423. $installType,
  424. $dbHostForm,
  425. $dbUsernameForm,
  426. $dbPassForm,
  427. $dbNameForm,
  428. $installationProfile
  429. );
  430. } elseif (@$_POST['step4']) {
  431. //STEP 5 : CONFIGURATION SETTINGS
  432. //if update, try getting settings from the database...
  433. if ($installType == 'update') {
  434. $db_name = $dbNameForm;
  435. $manager = connectToDatabase(
  436. $dbHostForm,
  437. $dbUsernameForm,
  438. $dbPassForm,
  439. $dbNameForm
  440. );
  441. $tmp = get_config_param_from_db('platformLanguage');
  442. if (!empty($tmp)) {
  443. $languageForm = $tmp;
  444. }
  445. $tmp = get_config_param_from_db('emailAdministrator');
  446. if (!empty($tmp)) {
  447. $emailForm = $tmp;
  448. }
  449. $tmp = get_config_param_from_db('administratorName');
  450. if (!empty($tmp)) {
  451. $adminFirstName = $tmp;
  452. }
  453. $tmp = get_config_param_from_db('administratorSurname');
  454. if (!empty($tmp)) {
  455. $adminLastName = $tmp;
  456. }
  457. $tmp = get_config_param_from_db('administratorTelephone');
  458. if (!empty($tmp)) {
  459. $adminPhoneForm = $tmp;
  460. }
  461. $tmp = get_config_param_from_db('siteName');
  462. if (!empty($tmp)) {
  463. $campusForm = $tmp;
  464. }
  465. $tmp = get_config_param_from_db('Institution');
  466. if (!empty($tmp)) {
  467. $institutionForm = $tmp;
  468. }
  469. $tmp = get_config_param_from_db('InstitutionUrl');
  470. if (!empty($tmp)) {
  471. $institutionUrlForm = $tmp;
  472. }
  473. // For version 1.9
  474. $urlForm = $_configuration['root_web'];
  475. $encryptPassForm = get_config_param('userPasswordCrypted');
  476. // Managing the $encryptPassForm
  477. if ($encryptPassForm == '1') {
  478. $encryptPassForm = 'sha1';
  479. } elseif ($encryptPassForm == '0') {
  480. $encryptPassForm = 'none';
  481. }
  482. $allowSelfReg = false;
  483. $tmp = get_config_param_from_db('allow_registration');
  484. if (!empty($tmp)) {
  485. $allowSelfReg = $tmp;
  486. }
  487. $allowSelfRegProf = false;
  488. $tmp = get_config_param_from_db('allow_registration_as_teacher');
  489. if (!empty($tmp)) {
  490. $allowSelfRegProf = $tmp;
  491. }
  492. }
  493. display_configuration_settings_form(
  494. $installType,
  495. $urlForm,
  496. $languageForm,
  497. $emailForm,
  498. $adminFirstName,
  499. $adminLastName,
  500. $adminPhoneForm,
  501. $campusForm,
  502. $institutionForm,
  503. $institutionUrlForm,
  504. $encryptPassForm,
  505. $allowSelfReg,
  506. $allowSelfRegProf,
  507. $loginForm,
  508. $passForm
  509. );
  510. } elseif (@$_POST['step5']) {
  511. //STEP 6 : LAST CHECK BEFORE INSTALL
  512. ?>
  513. <div class="RequirementHeading">
  514. <h3><?php echo display_step_sequence().get_lang('LastCheck'); ?></h3>
  515. </div>
  516. <div class="RequirementContent">
  517. <?php echo get_lang('HereAreTheValuesYouEntered'); ?>
  518. </div>
  519. <?php
  520. if ($installType == 'new') {
  521. echo get_lang('AdminLogin') . ' : <strong>' . $loginForm . '</strong><br />';
  522. echo get_lang('AdminPass') . ' : <strong>' . $passForm . '</strong><br /><br />'; /* TODO: Maybe this password should be hidden too? */
  523. }
  524. echo get_lang('AdminFirstName').' : '.$adminFirstName, '<br />', get_lang('AdminLastName').' : '.$adminLastName, '<br />';
  525. echo get_lang('AdminEmail').' : '.$emailForm; ?><br />
  526. <?php echo get_lang('AdminPhone').' : '.$adminPhoneForm; ?><br />
  527. <?php echo get_lang('MainLang').' : '.$languageForm; ?><br /><br />
  528. <?php echo get_lang('DBHost').' : '.$dbHostForm; ?><br />
  529. <?php echo get_lang('DBLogin').' : '.$dbUsernameForm; ?><br />
  530. <?php echo get_lang('DBPassword').' : '.str_repeat('*', api_strlen($dbPassForm)); ?><br />
  531. <?php echo get_lang('MainDB').' : <strong>'.$dbNameForm; ?></strong><br />
  532. <?php echo get_lang('AllowSelfReg').' : '.($allowSelfReg ? get_lang('Yes') : get_lang('No')); ?><br />
  533. <?php echo get_lang('EncryptMethodUserPass').' : ';
  534. echo $encryptPassForm;
  535. ?>
  536. <br /><br />
  537. <?php echo get_lang('CampusName').' : '.$campusForm; ?><br />
  538. <?php echo get_lang('InstituteShortName').' : '.$institutionForm; ?><br />
  539. <?php echo get_lang('InstituteURL').' : '.$institutionUrlForm; ?><br />
  540. <?php echo get_lang('ChamiloURL').' : '.$urlForm; ?><br /><br />
  541. <?php
  542. if ($installType == 'new') {
  543. echo Display::display_warning_message(
  544. '<h4 style="text-align: center">'.get_lang(
  545. 'Warning'
  546. ).'</h4>'.get_lang('TheInstallScriptWillEraseAllTables'),
  547. false
  548. );
  549. }
  550. ?>
  551. <table width="100%">
  552. <tr>
  553. <td>
  554. <button type="submit" class="btn btn-default" name="step4" value="&lt; <?php echo get_lang('Previous'); ?>" >
  555. <i class="fa fa-backward"> </i> <?php echo get_lang('Previous'); ?>
  556. </button>
  557. </td>
  558. <td align="right">
  559. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  560. <input type="hidden" name="step6" value="1" />
  561. <button id="button_step6" class="btn btn-success" type="submit" name="button_step6" value="<?php echo get_lang('InstallChamilo'); ?>">
  562. <i class="fa fa-floppy-o"> </i>
  563. <?php echo get_lang('InstallChamilo'); ?>
  564. </button>
  565. <button class="btn btn-save" id="button_please_wait"></button>
  566. </td>
  567. </tr>
  568. </table>
  569. <?php
  570. } elseif (@$_POST['step6']) {
  571. //STEP 6 : INSTALLATION PROCESS
  572. $current_step = 7;
  573. $msg = get_lang('InstallExecution');
  574. if ($installType == 'update') {
  575. $msg = get_lang('UpdateExecution');
  576. }
  577. echo '<div class="RequirementHeading">
  578. <h3>'.display_step_sequence().$msg.'</h3>';
  579. if (!empty($installationProfile)) {
  580. echo ' <h3>('.$installationProfile.')</h3>';
  581. }
  582. echo ' <div id="pleasewait" class="alert alert-success">'.get_lang('PleaseWaitThisCouldTakeAWhile').'
  583. <div class="progress">
  584. <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
  585. <span class="sr-only">100% Complete</span>
  586. </div>
  587. </div>
  588. </div>
  589. </div>';
  590. // Push the web server to send these strings before we start the real
  591. // installation process
  592. flush();
  593. $f = ob_get_contents();
  594. if (!empty($f)) {
  595. ob_flush(); //#5565
  596. }
  597. if ($installType == 'update') {
  598. remove_memory_and_time_limits();
  599. $manager = connectToDatabase(
  600. $dbHostForm,
  601. $dbUsernameForm,
  602. $dbPassForm,
  603. $dbNameForm
  604. );
  605. $perm = api_get_permissions_for_new_directories();
  606. $perm_file = api_get_permissions_for_new_files();
  607. Log::notice('Starting migration process from '.$my_old_version.' ('.time().')');
  608. switch ($my_old_version) {
  609. case '1.9.0':
  610. case '1.9.2':
  611. case '1.9.4':
  612. case '1.9.6':
  613. case '1.9.6.1':
  614. case '1.9.8':
  615. case '1.9.8.1':
  616. case '1.9.8.2':
  617. case '1.9.10':
  618. case '1.9.10.2':
  619. // Fix type "enum" before running the migration with Doctrine
  620. Database::query("ALTER TABLE course_category MODIFY COLUMN auth_course_child VARCHAR(40) DEFAULT 'TRUE'");
  621. Database::query("ALTER TABLE course_category MODIFY COLUMN auth_cat_child VARCHAR(40) DEFAULT 'TRUE'");
  622. Database::query("ALTER TABLE c_quiz_answer MODIFY COLUMN hotspot_type varchar(40) default NULL");
  623. Database::query("ALTER TABLE c_tool MODIFY COLUMN target varchar(20) NOT NULL default '_self'");
  624. Database::query("ALTER TABLE c_link MODIFY COLUMN on_homepage char(10) NOT NULL default '0'");
  625. Database::query("ALTER TABLE c_blog_rating MODIFY COLUMN rating_type char(40) NOT NULL default 'post'");
  626. Database::query("ALTER TABLE c_survey MODIFY COLUMN anonymous char(10) NOT NULL default '0'");
  627. Database::query("ALTER TABLE c_document MODIFY COLUMN filetype char(10) NOT NULL default 'file'");
  628. Database::query("ALTER TABLE c_student_publication MODIFY COLUMN filetype char(10) NOT NULL default 'file'");
  629. // Migrate using the migration files located in:
  630. // src/Chamilo/CoreBundle/Migrations/Schema/V110
  631. migrate(
  632. 110,
  633. $manager
  634. );
  635. fixIds($manager);
  636. include 'update-files-1.9.0-1.10.0.inc.php';
  637. // Only updates the configuration.inc.php with the new version
  638. include 'update-configuration.inc.php';
  639. $configurationFiles = array(
  640. 'mail.conf.php',
  641. 'profile.conf.php',
  642. 'course_info.conf.php',
  643. 'add_course.conf.php',
  644. 'events.conf.php',
  645. 'auth.conf.php',
  646. 'portfolio.conf.php'
  647. );
  648. foreach ($configurationFiles as $file) {
  649. if (file_exists(api_get_path(SYS_CODE_PATH) . 'inc/conf/'.$file)) {
  650. copy(
  651. api_get_path(SYS_CODE_PATH).'inc/conf/'.$file,
  652. api_get_path(CONFIGURATION_PATH).$file
  653. );
  654. }
  655. }
  656. break;
  657. default:
  658. break;
  659. }
  660. } else {
  661. set_file_folder_permissions();
  662. $manager = connectToDatabase(
  663. $dbHostForm,
  664. $dbUsernameForm,
  665. $dbPassForm,
  666. null
  667. );
  668. $dbNameForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbNameForm);
  669. // Drop and create the database anyways
  670. $manager->getConnection()->getSchemaManager()->dropAndCreateDatabase($dbNameForm);
  671. $manager = connectToDatabase(
  672. $dbHostForm,
  673. $dbUsernameForm,
  674. $dbPassForm,
  675. $dbNameForm
  676. );
  677. $metadataList = $manager->getMetadataFactory()->getAllMetadata();
  678. $schema = $manager->getConnection()->getSchemaManager()->createSchema();
  679. // Create database schema
  680. $tool = new \Doctrine\ORM\Tools\SchemaTool($manager);
  681. $tool->createSchema($metadataList);
  682. $sysPath = api_get_path(SYS_PATH);
  683. finishInstallation(
  684. $manager,
  685. $sysPath,
  686. $encryptPassForm,
  687. $passForm,
  688. $adminLastName,
  689. $adminFirstName,
  690. $loginForm,
  691. $emailForm,
  692. $adminPhoneForm,
  693. $languageForm,
  694. $institutionForm,
  695. $institutionUrlForm,
  696. $campusForm,
  697. $allowSelfReg,
  698. $allowSelfRegProf,
  699. $installationProfile
  700. );
  701. include 'install_files.inc.php';
  702. }
  703. display_after_install_message($installType);
  704. // Hide the "please wait" message sent previously
  705. echo '<script>$(\'#pleasewait\').hide(\'fast\');</script>';
  706. } elseif (@$_POST['step1'] || $badUpdatePath) {
  707. //STEP 1 : REQUIREMENTS
  708. //make sure that proposed path is set, shouldn't be necessary but...
  709. if (empty($proposedUpdatePath)) {
  710. $proposedUpdatePath = $_POST['updatePath'];
  711. }
  712. display_requirements($installType, $badUpdatePath, $proposedUpdatePath, $update_from_version_8);
  713. } else {
  714. // This is the start screen.
  715. display_language_selection();
  716. if (!empty($_GET['profile'])) {
  717. $installationProfile = api_htmlentities($_GET['profile'], ENT_QUOTES);
  718. }
  719. echo '<input type="hidden" name="installationProfile" value="'.api_htmlentities($installationProfile, ENT_QUOTES).'" />';
  720. }
  721. $poweredBy = 'Powered by <a href="http://www.chamilo.org" target="_blank"> Chamilo </a> &copy; '.date('Y');
  722. ?>
  723. </form>
  724. </div>
  725. </div>
  726. </div>
  727. </div>
  728. <footer class="panel panel-default">
  729. <div class="panel-body">
  730. <div style="text-align: center;">
  731. <?php echo $poweredBy; ?>
  732. </div>
  733. </div>
  734. </footer>
  735. </body>
  736. </html>