index.php 29 KB

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