index.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  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. $dbPortForm = 3306;
  184. // Extract the path to append to the url if Chamilo is not installed on the web root directory.
  185. $urlAppendPath = api_remove_trailing_slash(api_get_path(REL_PATH));
  186. $urlForm = api_get_path(WEB_PATH);
  187. $pathForm = api_get_path(SYS_PATH);
  188. $emailForm = 'webmaster@localhost';
  189. if (!empty($_SERVER['SERVER_ADMIN'])) {
  190. $emailForm = $_SERVER['SERVER_ADMIN'];
  191. }
  192. $email_parts = explode('@', $emailForm);
  193. if (isset($email_parts[1]) && $email_parts[1] == 'localhost') {
  194. $emailForm .= '.localdomain';
  195. }
  196. $adminLastName = get_lang('DefaultInstallAdminLastname');
  197. $adminFirstName = get_lang('DefaultInstallAdminFirstname');
  198. $loginForm = 'admin';
  199. $passForm = api_generate_password();
  200. $campusForm = 'My campus';
  201. $educationForm = 'Albert Einstein';
  202. $adminPhoneForm = '(000) 001 02 03';
  203. $institutionForm = 'My Organisation';
  204. $institutionUrlForm = 'http://www.chamilo.org';
  205. $languageForm = api_get_interface_language();
  206. $checkEmailByHashSent = 0;
  207. $ShowEmailNotCheckedToStudent = 1;
  208. $userMailCanBeEmpty = 1;
  209. $allowSelfReg = 1;
  210. $allowSelfRegProf = 1;
  211. $encryptPassForm = 'sha1';
  212. $session_lifetime = 360000;
  213. if (!empty($_GET['profile'])) {
  214. $installationProfile = api_htmlentities($_GET['profile'], ENT_QUOTES);
  215. }
  216. } else {
  217. foreach ($_POST as $key => $val) {
  218. $magic_quotes_gpc = ini_get('magic_quotes_gpc');
  219. if (is_string($val)) {
  220. if ($magic_quotes_gpc) {
  221. $val = stripslashes($val);
  222. }
  223. $val = trim($val);
  224. $_POST[$key] = $val;
  225. } elseif (is_array($val)) {
  226. foreach ($val as $key2 => $val2) {
  227. if ($magic_quotes_gpc) {
  228. $val2 = stripslashes($val2);
  229. }
  230. $val2 = trim($val2);
  231. $_POST[$key][$key2] = $val2;
  232. }
  233. }
  234. $GLOBALS[$key] = $_POST[$key];
  235. }
  236. }
  237. /* NEXT STEPS IMPLEMENTATION */
  238. $total_steps = 7;
  239. if (!$_POST) {
  240. $current_step = 1;
  241. } elseif (!empty($_POST['language_list']) or !empty($_POST['step1']) or ((!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6']))) && ($emptyUpdatePath or $badUpdatePath))) {
  242. $current_step = 2;
  243. } elseif (!empty($_POST['step2']) or (!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6'])))) {
  244. $current_step = 3;
  245. } elseif (!empty($_POST['step3'])) {
  246. $current_step = 4;
  247. } elseif (!empty($_POST['step4'])) {
  248. $current_step = 5;
  249. } elseif (!empty($_POST['step5'])) {
  250. $current_step = 6;
  251. } elseif (@$_POST['step6']) {
  252. $current_step = 7;
  253. }
  254. // Managing the $encryptPassForm
  255. if ($encryptPassForm == '1') {
  256. $encryptPassForm = 'sha1';
  257. } elseif ($encryptPassForm == '0') {
  258. $encryptPassForm = 'none';
  259. }
  260. ?>
  261. <!DOCTYPE html>
  262. <head>
  263. <title>&mdash; <?php echo get_lang('ChamiloInstallation').' &mdash; '.get_lang('Version_').' '.$new_version; ?></title>
  264. <style type="text/css" media="screen, projection">
  265. @import "../../web/assets/bootstrap/dist/css/bootstrap.min.css";
  266. @import "<?php echo api_get_path(WEB_CSS_PATH)?>bootstrap-select.css";
  267. @import "../../web/assets/fontawesome/css/font-awesome.min.css";
  268. @import "../../web/css/base.css";
  269. @import "../../web/css/themes/chamilo/default.css";
  270. </style>
  271. <script type="text/javascript" src="../../web/assets/jquery/dist/jquery.min.js"></script>
  272. <script type="text/javascript" src="../../web/assets/bootstrap/dist/js/bootstrap.min.js"></script>
  273. <script type="text/javascript" src="<?php echo api_get_path(WEB_LIBRARY_PATH)?>javascript/bootstrap-select.min.js"></script>
  274. <script type="text/javascript">
  275. $(document).ready( function() {
  276. $("#details_button").click(function() {
  277. $( "#details" ).toggle("slow", function() {
  278. });
  279. });
  280. $("#button_please_wait").hide();
  281. $("button").addClass('btn btn-default');
  282. // Allow Chamilo install in IE
  283. $("button").click(function() {
  284. $("#is_executable").attr("value",$(this).attr("name"));
  285. });
  286. //Blocking step6 button
  287. $("#button_step6").click(function() {
  288. $("#button_step6").hide();
  289. $("#button_please_wait").html('<?php echo addslashes(get_lang('PleaseWait'));?>');
  290. $("#button_please_wait").show();
  291. $("#button_please_wait").attr('disabled', true);
  292. $("#is_executable").attr("value",'step6');
  293. });
  294. });
  295. init_visibility=0;
  296. $(document).ready( function() {
  297. $(".advanced_parameters").click(function() {
  298. if ($("#id_contact_form").css("display") == "none") {
  299. $("#id_contact_form").css("display","block");
  300. $("#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') ?>');
  301. } else {
  302. $("#id_contact_form").css("display","none");
  303. $("#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') ?>');
  304. }
  305. });
  306. });
  307. function send_contact_information() {
  308. var data_post = "";
  309. data_post += "person_name="+$("#person_name").val()+"&";
  310. data_post += "person_email="+$("#person_email").val()+"&";
  311. data_post += "company_name="+$("#company_name").val()+"&";
  312. data_post += "company_activity="+$("#company_activity option:selected").val()+"&";
  313. data_post += "person_role="+$("#person_role option:selected").val()+"&";
  314. data_post += "company_country="+$("#country option:selected").val()+"&";
  315. data_post += "company_city="+$("#company_city").val()+"&";
  316. data_post += "language="+$("#language option:selected").val()+"&";
  317. data_post += "financial_decision="+$("input[@name='financial_decision']:checked").val();
  318. $.ajax({
  319. contentType: "application/x-www-form-urlencoded",
  320. beforeSend: function(objeto) {},
  321. type: "POST",
  322. url: "<?php echo api_get_path(WEB_AJAX_PATH) ?>install.ajax.php?a=send_contact_information",
  323. data: data_post,
  324. success: function(datos) {
  325. if (datos == 'required_field_error') {
  326. message = "<?php echo get_lang('FormHasErrorsPleaseComplete') ?>";
  327. } else if (datos == '1') {
  328. message = "<?php echo get_lang('ContactInformationHasBeenSent') ?>";
  329. } else {
  330. message = "<?php echo get_lang('Error').': '.get_lang('ContactInformationHasNotBeenSent') ?>";
  331. }
  332. alert(message);
  333. }
  334. });
  335. }
  336. </script>
  337. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>" />
  338. </head>
  339. <body dir="<?php echo api_get_text_direction(); ?>">
  340. <div id="page-install">
  341. <div id="main" class="container">
  342. <header class="row">
  343. <div class="col-md-12">
  344. <div class="logo">
  345. <img src="<?php echo api_get_path(WEB_CSS_PATH) ?>themes/chamilo/images/header-logo.png" hspace="10" vspace="10" alt="Chamilo" />
  346. </div>
  347. </div>
  348. </header>
  349. <div class="panel panel-default">
  350. <div class="panel-heading">
  351. <?php
  352. echo '<h4>'.get_lang('ChamiloInstallation').' &ndash; '.get_lang('Version_').' '.$new_version.'</h4>';
  353. ?>
  354. </div>
  355. <div class="panel-body">
  356. <div class="row">
  357. <div class="col-md-4">
  358. <div class="well install-steps-menu">
  359. <ol>
  360. <li <?php step_active('1'); ?>><?php echo get_lang('InstallationLanguage'); ?></li>
  361. <li <?php step_active('2'); ?>><?php echo get_lang('Requirements'); ?></li>
  362. <li <?php step_active('3'); ?>><?php echo get_lang('Licence'); ?></li>
  363. <li <?php step_active('4'); ?>><?php echo get_lang('DBSetting'); ?></li>
  364. <li <?php step_active('5'); ?>><?php echo get_lang('CfgSetting'); ?></li>
  365. <li <?php step_active('6'); ?>><?php echo get_lang('PrintOverview'); ?></li>
  366. <li <?php step_active('7'); ?>><?php echo get_lang('Installing'); ?></li>
  367. </ol>
  368. </div>
  369. <div id="note">
  370. <a class="btn btn-default" href="<?php echo $installationGuideLink; ?>" target="_blank">
  371. <i class="fa fa-file-text-o"></i> <?php echo get_lang('ReadTheInstallationGuide'); ?>
  372. </a>
  373. </div>
  374. </div>
  375. <div class="col-md-8">
  376. <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); ?>">
  377. <?php
  378. $instalation_type_label = '';
  379. if ($installType == 'new') {
  380. $instalation_type_label = get_lang('NewInstallation');
  381. } elseif ($installType == 'update') {
  382. $update_from_version = isset($update_from_version) ? $update_from_version : null;
  383. $instalation_type_label = get_lang('UpdateFromLMSVersion').(is_array($update_from_version) ? implode('|', $update_from_version) : '');
  384. }
  385. if (!empty($instalation_type_label) && empty($_POST['step6'])) {
  386. echo '<div class="page-header"><h2>'.$instalation_type_label.'</h2></div>';
  387. }
  388. if (empty($installationProfile)) {
  389. $installationProfile = '';
  390. if (!empty($_POST['installationProfile'])) {
  391. $installationProfile = api_htmlentities($_POST['installationProfile']);
  392. }
  393. }
  394. ?>
  395. <input type="hidden" name="updatePath" value="<?php if (!$badUpdatePath) echo api_htmlentities($proposedUpdatePath, ENT_QUOTES); ?>" />
  396. <input type="hidden" name="urlAppendPath" value="<?php echo api_htmlentities($urlAppendPath, ENT_QUOTES); ?>" />
  397. <input type="hidden" name="pathForm" value="<?php echo api_htmlentities($pathForm, ENT_QUOTES); ?>" />
  398. <input type="hidden" name="urlForm" value="<?php echo api_htmlentities($urlForm, ENT_QUOTES); ?>" />
  399. <input type="hidden" name="dbHostForm" value="<?php echo api_htmlentities($dbHostForm, ENT_QUOTES); ?>" />
  400. <input type="hidden" name="dbPortForm" value="<?php echo api_htmlentities($dbPortForm, ENT_QUOTES); ?>" />
  401. <input type="hidden" name="dbUsernameForm" value="<?php echo api_htmlentities($dbUsernameForm, ENT_QUOTES); ?>" />
  402. <input type="hidden" name="dbPassForm" value="<?php echo api_htmlentities($dbPassForm, ENT_QUOTES); ?>" />
  403. <input type="hidden" name="dbNameForm" value="<?php echo api_htmlentities($dbNameForm, ENT_QUOTES); ?>" />
  404. <input type="hidden" name="allowSelfReg" value="<?php echo api_htmlentities($allowSelfReg, ENT_QUOTES); ?>" />
  405. <input type="hidden" name="allowSelfRegProf" value="<?php echo api_htmlentities($allowSelfRegProf, ENT_QUOTES); ?>" />
  406. <input type="hidden" name="emailForm" value="<?php echo api_htmlentities($emailForm, ENT_QUOTES); ?>" />
  407. <input type="hidden" name="adminLastName" value="<?php echo api_htmlentities($adminLastName, ENT_QUOTES); ?>" />
  408. <input type="hidden" name="adminFirstName" value="<?php echo api_htmlentities($adminFirstName, ENT_QUOTES); ?>" />
  409. <input type="hidden" name="adminPhoneForm" value="<?php echo api_htmlentities($adminPhoneForm, ENT_QUOTES); ?>" />
  410. <input type="hidden" name="loginForm" value="<?php echo api_htmlentities($loginForm, ENT_QUOTES); ?>" />
  411. <input type="hidden" name="passForm" value="<?php echo api_htmlentities($passForm, ENT_QUOTES); ?>" />
  412. <input type="hidden" name="languageForm" value="<?php echo api_htmlentities($languageForm, ENT_QUOTES); ?>" />
  413. <input type="hidden" name="campusForm" value="<?php echo api_htmlentities($campusForm, ENT_QUOTES); ?>" />
  414. <input type="hidden" name="educationForm" value="<?php echo api_htmlentities($educationForm, ENT_QUOTES); ?>" />
  415. <input type="hidden" name="institutionForm" value="<?php echo api_htmlentities($institutionForm, ENT_QUOTES); ?>" />
  416. <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); ?>" />
  417. <input type="hidden" name="checkEmailByHashSent" value="<?php echo api_htmlentities($checkEmailByHashSent, ENT_QUOTES); ?>" />
  418. <input type="hidden" name="ShowEmailNotCheckedToStudent" value="<?php echo api_htmlentities($ShowEmailNotCheckedToStudent, ENT_QUOTES); ?>" />
  419. <input type="hidden" name="userMailCanBeEmpty" value="<?php echo api_htmlentities($userMailCanBeEmpty, ENT_QUOTES); ?>" />
  420. <input type="hidden" name="encryptPassForm" value="<?php echo api_htmlentities($encryptPassForm, ENT_QUOTES); ?>" />
  421. <input type="hidden" name="session_lifetime" value="<?php echo api_htmlentities($session_lifetime, ENT_QUOTES); ?>" />
  422. <input type="hidden" name="old_version" value="<?php echo api_htmlentities($my_old_version, ENT_QUOTES); ?>" />
  423. <input type="hidden" name="new_version" value="<?php echo api_htmlentities($new_version, ENT_QUOTES); ?>" />
  424. <input type="hidden" name="installationProfile" value="<?php echo api_htmlentities($installationProfile, ENT_QUOTES); ?>" />
  425. <?php
  426. if (@$_POST['step2']) {
  427. //STEP 3 : LICENSE
  428. display_license_agreement();
  429. } elseif (@$_POST['step3']) {
  430. //STEP 4 : MYSQL DATABASE SETTINGS
  431. display_database_settings_form(
  432. $installType,
  433. $dbHostForm,
  434. $dbUsernameForm,
  435. $dbPassForm,
  436. $dbNameForm,
  437. $dbPortForm,
  438. $installationProfile
  439. );
  440. } elseif (@$_POST['step4']) {
  441. //STEP 5 : CONFIGURATION SETTINGS
  442. //if update, try getting settings from the database...
  443. if ($installType == 'update') {
  444. $db_name = $dbNameForm;
  445. $manager = connectToDatabase(
  446. $dbHostForm,
  447. $dbUsernameForm,
  448. $dbPassForm,
  449. $dbNameForm,
  450. $dbPortForm
  451. );
  452. $tmp = get_config_param_from_db('platformLanguage');
  453. if (!empty($tmp)) {
  454. $languageForm = $tmp;
  455. }
  456. $tmp = get_config_param_from_db('emailAdministrator');
  457. if (!empty($tmp)) {
  458. $emailForm = $tmp;
  459. }
  460. $tmp = get_config_param_from_db('administratorName');
  461. if (!empty($tmp)) {
  462. $adminFirstName = $tmp;
  463. }
  464. $tmp = get_config_param_from_db('administratorSurname');
  465. if (!empty($tmp)) {
  466. $adminLastName = $tmp;
  467. }
  468. $tmp = get_config_param_from_db('administratorTelephone');
  469. if (!empty($tmp)) {
  470. $adminPhoneForm = $tmp;
  471. }
  472. $tmp = get_config_param_from_db('siteName');
  473. if (!empty($tmp)) {
  474. $campusForm = $tmp;
  475. }
  476. $tmp = get_config_param_from_db('Institution');
  477. if (!empty($tmp)) {
  478. $institutionForm = $tmp;
  479. }
  480. $tmp = get_config_param_from_db('InstitutionUrl');
  481. if (!empty($tmp)) {
  482. $institutionUrlForm = $tmp;
  483. }
  484. // For version 1.9
  485. $urlForm = $_configuration['root_web'];
  486. $encryptPassForm = get_config_param('userPasswordCrypted');
  487. // Managing the $encryptPassForm
  488. if ($encryptPassForm == '1') {
  489. $encryptPassForm = 'sha1';
  490. } elseif ($encryptPassForm == '0') {
  491. $encryptPassForm = 'none';
  492. }
  493. $allowSelfReg = false;
  494. $tmp = get_config_param_from_db('allow_registration');
  495. if (!empty($tmp)) {
  496. $allowSelfReg = $tmp;
  497. }
  498. $allowSelfRegProf = false;
  499. $tmp = get_config_param_from_db('allow_registration_as_teacher');
  500. if (!empty($tmp)) {
  501. $allowSelfRegProf = $tmp;
  502. }
  503. }
  504. display_configuration_settings_form(
  505. $installType,
  506. $urlForm,
  507. $languageForm,
  508. $emailForm,
  509. $adminFirstName,
  510. $adminLastName,
  511. $adminPhoneForm,
  512. $campusForm,
  513. $institutionForm,
  514. $institutionUrlForm,
  515. $encryptPassForm,
  516. $allowSelfReg,
  517. $allowSelfRegProf,
  518. $loginForm,
  519. $passForm
  520. );
  521. } elseif (@$_POST['step5']) {
  522. //STEP 6 : LAST CHECK BEFORE INSTALL
  523. ?>
  524. <div class="RequirementHeading">
  525. <h3><?php echo display_step_sequence().get_lang('LastCheck'); ?></h3>
  526. </div>
  527. <div class="RequirementContent">
  528. <?php echo get_lang('HereAreTheValuesYouEntered'); ?>
  529. </div>
  530. <?php
  531. if ($installType == 'new') {
  532. echo get_lang('AdminLogin') . ' : <strong>' . $loginForm . '</strong><br />';
  533. echo get_lang('AdminPass') . ' : <strong>' . $passForm . '</strong><br /><br />'; /* TODO: Maybe this password should be hidden too? */
  534. }
  535. echo get_lang('AdminFirstName').' : '.$adminFirstName, '<br />', get_lang('AdminLastName').' : '.$adminLastName, '<br />';
  536. echo get_lang('AdminEmail').' : '.$emailForm; ?><br />
  537. <?php echo get_lang('AdminPhone').' : '.$adminPhoneForm; ?><br />
  538. <?php echo get_lang('MainLang').' : '.$languageForm; ?><br /><br />
  539. <?php echo get_lang('DBHost').' : '.$dbHostForm; ?><br />
  540. <?php echo get_lang('DBPort').' : '.$dbPortForm; ?><br />
  541. <?php echo get_lang('DBLogin').' : '.$dbUsernameForm; ?><br />
  542. <?php echo get_lang('DBPassword').' : '.str_repeat('*', api_strlen($dbPassForm)); ?><br />
  543. <?php echo get_lang('MainDB').' : <strong>'.$dbNameForm; ?></strong><br />
  544. <?php echo get_lang('AllowSelfReg').' : '.($allowSelfReg ? get_lang('Yes') : get_lang('No')); ?><br />
  545. <?php echo get_lang('EncryptMethodUserPass').' : ';
  546. echo $encryptPassForm;
  547. ?>
  548. <br /><br />
  549. <?php echo get_lang('CampusName').' : '.$campusForm; ?><br />
  550. <?php echo get_lang('InstituteShortName').' : '.$institutionForm; ?><br />
  551. <?php echo get_lang('InstituteURL').' : '.$institutionUrlForm; ?><br />
  552. <?php echo get_lang('ChamiloURL').' : '.$urlForm; ?><br /><br />
  553. <?php
  554. if ($installType == 'new') {
  555. echo Display::display_warning_message(
  556. '<h4 style="text-align: center">'.get_lang(
  557. 'Warning'
  558. ).'</h4>'.get_lang('TheInstallScriptWillEraseAllTables'),
  559. false
  560. );
  561. }
  562. ?>
  563. <table width="100%">
  564. <tr>
  565. <td>
  566. <button type="submit" class="btn btn-default" name="step4" value="&lt; <?php echo get_lang('Previous'); ?>" >
  567. <i class="fa fa-backward"> </i> <?php echo get_lang('Previous'); ?>
  568. </button>
  569. </td>
  570. <td align="right">
  571. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  572. <input type="hidden" name="step6" value="1" />
  573. <button id="button_step6" class="btn btn-success" type="submit" name="button_step6" value="<?php echo get_lang('InstallChamilo'); ?>">
  574. <i class="fa fa-floppy-o"> </i>
  575. <?php echo get_lang('InstallChamilo'); ?>
  576. </button>
  577. <button class="btn btn-save" id="button_please_wait"></button>
  578. </td>
  579. </tr>
  580. </table>
  581. <?php
  582. } elseif (@$_POST['step6']) {
  583. //STEP 6 : INSTALLATION PROCESS
  584. $current_step = 7;
  585. $msg = get_lang('InstallExecution');
  586. if ($installType == 'update') {
  587. $msg = get_lang('UpdateExecution');
  588. }
  589. echo '<div class="RequirementHeading">
  590. <h3>'.display_step_sequence().$msg.'</h3>';
  591. if (!empty($installationProfile)) {
  592. echo ' <h3>('.$installationProfile.')</h3>';
  593. }
  594. echo ' <div id="pleasewait" class="alert alert-success">'.get_lang('PleaseWaitThisCouldTakeAWhile').'
  595. <div class="progress">
  596. <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
  597. <span class="sr-only">100% Complete</span>
  598. </div>
  599. </div>
  600. </div>
  601. </div>';
  602. // Push the web server to send these strings before we start the real
  603. // installation process
  604. flush();
  605. $f = ob_get_contents();
  606. if (!empty($f)) {
  607. ob_flush(); //#5565
  608. }
  609. if ($installType == 'update') {
  610. remove_memory_and_time_limits();
  611. $manager = connectToDatabase(
  612. $dbHostForm,
  613. $dbUsernameForm,
  614. $dbPassForm,
  615. $dbNameForm,
  616. $dbPortForm
  617. );
  618. $perm = api_get_permissions_for_new_directories();
  619. $perm_file = api_get_permissions_for_new_files();
  620. error_log('Starting migration process from '.$my_old_version.' ('.time().')');
  621. switch ($my_old_version) {
  622. case '1.9.0':
  623. case '1.9.2':
  624. case '1.9.4':
  625. case '1.9.6':
  626. case '1.9.6.1':
  627. case '1.9.8':
  628. case '1.9.8.1':
  629. case '1.9.8.2':
  630. case '1.9.10':
  631. case '1.9.10.2':
  632. // Fix type "enum" before running the migration with Doctrine
  633. Database::query("ALTER TABLE course_category MODIFY COLUMN auth_course_child VARCHAR(40) DEFAULT 'TRUE'");
  634. Database::query("ALTER TABLE course_category MODIFY COLUMN auth_cat_child VARCHAR(40) DEFAULT 'TRUE'");
  635. Database::query("ALTER TABLE c_quiz_answer MODIFY COLUMN hotspot_type varchar(40) default NULL");
  636. Database::query("ALTER TABLE c_tool MODIFY COLUMN target varchar(20) NOT NULL default '_self'");
  637. Database::query("ALTER TABLE c_link MODIFY COLUMN on_homepage char(10) NOT NULL default '0'");
  638. Database::query("ALTER TABLE c_blog_rating MODIFY COLUMN rating_type char(40) NOT NULL default 'post'");
  639. Database::query("ALTER TABLE c_survey MODIFY COLUMN anonymous char(10) NOT NULL default '0'");
  640. Database::query("ALTER TABLE c_document MODIFY COLUMN filetype char(10) NOT NULL default 'file'");
  641. Database::query("ALTER TABLE c_student_publication MODIFY COLUMN filetype char(10) NOT NULL default 'file'");
  642. echo '<a class="btn btn-default" href="javascript:void(0)" id="details_button">'.get_lang('Details').'</a><br />';
  643. echo '<div id="details" style="display:none">';
  644. // Migrate using the migration files located in:
  645. // src/Chamilo/CoreBundle/Migrations/Schema/V110
  646. migrate(
  647. 110,
  648. $manager
  649. );
  650. echo '</div>';
  651. fixIds($manager);
  652. include 'update-files-1.9.0-1.10.0.inc.php';
  653. // Only updates the configuration.inc.php with the new version
  654. include 'update-configuration.inc.php';
  655. $configurationFiles = array(
  656. 'mail.conf.php',
  657. 'profile.conf.php',
  658. 'course_info.conf.php',
  659. 'add_course.conf.php',
  660. 'events.conf.php',
  661. 'auth.conf.php',
  662. 'portfolio.conf.php'
  663. );
  664. foreach ($configurationFiles as $file) {
  665. if (file_exists(api_get_path(SYS_CODE_PATH) . 'inc/conf/'.$file)) {
  666. copy(
  667. api_get_path(SYS_CODE_PATH).'inc/conf/'.$file,
  668. api_get_path(CONFIGURATION_PATH).$file
  669. );
  670. }
  671. }
  672. break;
  673. default:
  674. break;
  675. }
  676. } else {
  677. set_file_folder_permissions();
  678. $manager = connectToDatabase(
  679. $dbHostForm,
  680. $dbUsernameForm,
  681. $dbPassForm,
  682. null,
  683. $dbPortForm
  684. );
  685. $dbNameForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbNameForm);
  686. // Drop and create the database anyways
  687. $manager->getConnection()->getSchemaManager()->dropAndCreateDatabase($dbNameForm);
  688. $manager = connectToDatabase(
  689. $dbHostForm,
  690. $dbUsernameForm,
  691. $dbPassForm,
  692. $dbNameForm,
  693. $dbPortForm
  694. );
  695. $metadataList = $manager->getMetadataFactory()->getAllMetadata();
  696. $schema = $manager->getConnection()->getSchemaManager()->createSchema();
  697. // Create database schema
  698. $tool = new \Doctrine\ORM\Tools\SchemaTool($manager);
  699. $tool->createSchema($metadataList);
  700. $sysPath = api_get_path(SYS_PATH);
  701. finishInstallation(
  702. $manager,
  703. $sysPath,
  704. $encryptPassForm,
  705. $passForm,
  706. $adminLastName,
  707. $adminFirstName,
  708. $loginForm,
  709. $emailForm,
  710. $adminPhoneForm,
  711. $languageForm,
  712. $institutionForm,
  713. $institutionUrlForm,
  714. $campusForm,
  715. $allowSelfReg,
  716. $allowSelfRegProf,
  717. $installationProfile
  718. );
  719. include 'install_files.inc.php';
  720. }
  721. display_after_install_message($installType);
  722. // Hide the "please wait" message sent previously
  723. echo '<script>$(\'#pleasewait\').hide(\'fast\');</script>';
  724. } elseif (@$_POST['step1'] || $badUpdatePath) {
  725. //STEP 1 : REQUIREMENTS
  726. //make sure that proposed path is set, shouldn't be necessary but...
  727. if (empty($proposedUpdatePath)) {
  728. $proposedUpdatePath = $_POST['updatePath'];
  729. }
  730. display_requirements($installType, $badUpdatePath, $proposedUpdatePath, $update_from_version_8);
  731. } else {
  732. // This is the start screen.
  733. display_language_selection();
  734. if (!empty($_GET['profile'])) {
  735. $installationProfile = api_htmlentities($_GET['profile'], ENT_QUOTES);
  736. }
  737. echo '<input type="hidden" name="installationProfile" value="'.api_htmlentities($installationProfile, ENT_QUOTES).'" />';
  738. }
  739. $poweredBy = 'Powered by <a href="http://www.chamilo.org" target="_blank"> Chamilo </a> &copy; '.date('Y');
  740. ?>
  741. </form>
  742. </div>
  743. </div>
  744. </div>
  745. </div>
  746. <footer class="panel panel-default">
  747. <div class="panel-body">
  748. <div style="text-align: center;">
  749. <?php echo $poweredBy; ?>
  750. </div>
  751. </div>
  752. </footer>
  753. </body>
  754. </html>