index.php 34 KB

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