index.php 31 KB

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