index.php 34 KB

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