index.php 34 KB

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