index.php 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022
  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. /* CONSTANTS */
  17. use \ChamiloSession as Session;
  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. require_once '../inc/global.inc.php';
  24. require_once __DIR__.'../../../vendor/autoload.php';
  25. require_once 'install.lib.php';
  26. require_once 'i_database.class.php';
  27. // This value is use in database::query in order to prompt errors in the error log (course databases)
  28. Database::$log_queries = true;
  29. // The function api_get_setting() might be called within the installation scripts.
  30. // We need to provide some limited support for it through initialization of the
  31. // global array-type variable $_setting.
  32. $_setting = array(
  33. 'platform_charset' => 'UTF-8',
  34. 'server_type' => 'production', // 'production' | 'test'
  35. 'permissions_for_new_directories' => '0770',
  36. 'permissions_for_new_files' => '0660',
  37. 'stylesheets' => 'chamilo'
  38. );
  39. // Determination of the language during the installation procedure.
  40. if (!empty($_POST['language_list'])) {
  41. $search = array('../', '\\0');
  42. $install_language = str_replace($search, '', urldecode($_POST['language_list']));
  43. Session::write('install_language', $install_language);
  44. } elseif (isset($_SESSION['install_language']) && $_SESSION['install_language']) {
  45. $install_language = $_SESSION['install_language'];
  46. } else {
  47. // Trying to switch to the browser's language, it is covenient for most of the cases.
  48. $install_language = detect_browser_language();
  49. }
  50. // Language validation.
  51. if (!array_key_exists($install_language, get_language_folder_list())) {
  52. $install_language = 'english';
  53. }
  54. // Loading language files.
  55. require api_get_path(SYS_LANG_PATH).'english/trad4all.inc.php';
  56. require api_get_path(SYS_LANG_PATH).'english/admin.inc.php';
  57. require api_get_path(SYS_LANG_PATH).'english/install.inc.php';
  58. if ($install_language != 'english') {
  59. include_once api_get_path(SYS_LANG_PATH).$install_language.'/trad4all.inc.php';
  60. include_once api_get_path(SYS_LANG_PATH).$install_language.'/install.inc.php';
  61. include_once api_get_path(SYS_LANG_PATH).$install_language.'/admin.inc.php';
  62. }
  63. // These global variables must be set for proper working of the function get_lang(...) during the installation.
  64. $language_interface = $install_language;
  65. ///$language_interface_initial_value = $install_language;
  66. // Character set during the installation, it is always to be 'UTF-8'.
  67. $charset = 'UTF-8';
  68. // Initialization of the internationalization library.
  69. api_initialize_internationalization();
  70. // Initialization of the default encoding that will be used by the multibyte string routines in the internationalization library.
  71. api_set_internationalization_default_encoding($charset);
  72. // Page encoding initialization.
  73. header('Content-Type: text/html; charset='.api_get_system_encoding());
  74. // Setting the error reporting levels.
  75. error_reporting(E_ALL);
  76. // Overriding the timelimit (for large campusses that have to be migrated).
  77. @set_time_limit(0);
  78. // Upgrading from any subversion of 1.6 is just like upgrading from 1.6.5
  79. $update_from_version_6 = array('1.6', '1.6.1', '1.6.2', '1.6.3', '1.6.4', '1.6.5');
  80. // Upgrading from any subversion of 1.8 avoids the additional step of upgrading from 1.6
  81. $update_from_version_8 = array(
  82. '1.8',
  83. '1.8.2',
  84. '1.8.3',
  85. '1.8.4',
  86. '1.8.5',
  87. '1.8.6',
  88. '1.8.6.1',
  89. '1.8.6.2',
  90. '1.8.7',
  91. '1.8.7.1',
  92. '1.8.8',
  93. '1.8.8.2',
  94. '1.8.8.4',
  95. '1.8.8.6',
  96. '1.9.0',
  97. '1.9.2',
  98. '1.9.4'
  99. );
  100. $my_old_version = '';
  101. $tmp_version = get_config_param('dokeos_version');
  102. if (empty($tmp_version)) {
  103. $tmp_version = get_config_param('system_version');
  104. }
  105. if (!empty($_POST['old_version'])) {
  106. $my_old_version = $_POST['old_version'];
  107. } elseif (!empty($tmp_version)) {
  108. $my_old_version = $tmp_version;
  109. } elseif (!empty($dokeos_version)) { //variable coming from installedVersion, normally
  110. $my_old_version = $dokeos_version;
  111. }
  112. require_once __DIR__.'/version.php';
  113. // A protection measure for already installed systems.
  114. if (is_already_installed_system()) {
  115. // The system has already been installed, so block re-installation.
  116. header("Location: ".api_get_path(WEB_PATH));
  117. exit;
  118. }
  119. /* STEP 1 : INITIALIZES FORM VARIABLES IF IT IS THE FIRST VISIT */
  120. // Is valid request
  121. $is_valid_request = isset($_REQUEST['is_executable']) ? $_REQUEST['is_executable'] : null;
  122. foreach ($_POST as $request_index => $request_value) {
  123. if (substr($request_index, 0, 4) == 'step') {
  124. if ($request_index != $is_valid_request) {
  125. unset($_POST[$request_index]);
  126. }
  127. }
  128. }
  129. $badUpdatePath = false;
  130. $emptyUpdatePath = true;
  131. $proposedUpdatePath = '';
  132. if (!empty($_POST['updatePath'])) {
  133. $proposedUpdatePath = $_POST['updatePath'];
  134. }
  135. if (@$_POST['step2_install'] || @$_POST['step2_update_8'] || @$_POST['step2_update_6']) {
  136. if (@$_POST['step2_install']) {
  137. $installType = 'new';
  138. $_POST['step2'] = 1;
  139. } else {
  140. $installType = 'update';
  141. if (@$_POST['step2_update_8']) {
  142. $emptyUpdatePath = false;
  143. $proposedUpdatePath = api_add_trailing_slash(
  144. empty($_POST['updatePath']) ? api_get_path(SYS_PATH) : $_POST['updatePath']
  145. );
  146. if (file_exists($proposedUpdatePath)) {
  147. if (in_array($my_old_version, $update_from_version_8)) {
  148. $_POST['step2'] = 1;
  149. } else {
  150. $badUpdatePath = true;
  151. }
  152. } else {
  153. $badUpdatePath = true;
  154. }
  155. } else { //step2_update_6, presumably
  156. if (empty($_POST['updatePath'])) {
  157. $_POST['step1'] = 1;
  158. } else {
  159. $emptyUpdatePath = false;
  160. $_POST['updatePath'] = api_add_trailing_slash($_POST['updatePath']);
  161. if (file_exists($_POST['updatePath'])) {
  162. //1.6.x
  163. $my_old_version = get_config_param('clarolineVersion', $_POST['updatePath']);
  164. if (in_array($my_old_version, $update_from_version_6)) {
  165. $_POST['step2'] = 1;
  166. $proposedUpdatePath = $_POST['updatePath'];
  167. } else {
  168. $badUpdatePath = true;
  169. }
  170. } else {
  171. $badUpdatePath = true;
  172. }
  173. }
  174. }
  175. }
  176. } elseif (@$_POST['step1']) {
  177. $_POST['updatePath'] = '';
  178. $installType = '';
  179. $updateFromConfigFile = '';
  180. unset($_GET['running']);
  181. } else {
  182. $installType = isset($_GET['installType']) ? $_GET['installType'] : null;
  183. $updateFromConfigFile = isset($_GET['updateFromConfigFile']) ? $_GET['updateFromConfigFile'] : false;
  184. }
  185. if ($installType == 'update' && in_array($my_old_version, $update_from_version_8)) {
  186. // This is the main configuration file of the system before the upgrade.
  187. include api_get_path(CONFIGURATION_PATH).'configuration.php'; // Don't change to include_once
  188. }
  189. if (!isset($_GET['running'])) {
  190. $dbHostForm = 'localhost';
  191. $dbUsernameForm = 'root';
  192. $dbPassForm = '';
  193. $dbPrefixForm = '';
  194. $dbNameForm = 'chamilo';
  195. $dbStatsForm = 'chamilo';
  196. $dbScormForm = 'chamilo';
  197. $dbUserForm = 'chamilo';
  198. // Extract the path to append to the url if Chamilo is not installed on the web root directory.
  199. $urlAppendPath = api_remove_trailing_slash(api_get_path(REL_PATH));
  200. $urlForm = api_get_path(WEB_PATH);
  201. $pathForm = api_get_path(SYS_PATH);
  202. $emailForm = $_SERVER['SERVER_ADMIN'];
  203. $email_parts = explode('@', $emailForm);
  204. if (isset($email_parts[1]) && $email_parts[1] == 'localhost') {
  205. $emailForm .= '.localdomain';
  206. }
  207. $adminLastName = 'Doe';
  208. $adminFirstName = 'John';
  209. $loginForm = 'admin';
  210. $passForm = api_generate_password();
  211. $campusForm = 'My campus';
  212. $educationForm = 'Albert Einstein';
  213. $adminPhoneForm = '(000) 001 02 03';
  214. $institutionForm = 'My Organisation';
  215. $institutionUrlForm = 'http://www.chamilo.org';
  216. // TODO: A better choice to be tested:
  217. //$languageForm = 'english';
  218. $languageForm = api_get_interface_language();
  219. $checkEmailByHashSent = 0;
  220. $ShowEmailnotcheckedToStudent = 1;
  221. $userMailCanBeEmpty = 1;
  222. $allowSelfReg = 1;
  223. $allowSelfRegProf = 1;
  224. $enableTrackingForm = 1;
  225. $singleDbForm = 0;
  226. $encryptPassForm = 'sha1';
  227. $session_lifetime = 360000;
  228. } else {
  229. foreach ($_POST as $key => $val) {
  230. $magic_quotes_gpc = ini_get('magic_quotes_gpc');
  231. if (is_string($val)) {
  232. if ($magic_quotes_gpc) {
  233. $val = stripslashes($val);
  234. }
  235. $val = trim($val);
  236. $_POST[$key] = $val;
  237. } elseif (is_array($val)) {
  238. foreach ($val as $key2 => $val2) {
  239. if ($magic_quotes_gpc) {
  240. $val2 = stripslashes($val2);
  241. }
  242. $val2 = trim($val2);
  243. $_POST[$key][$key2] = $val2;
  244. }
  245. }
  246. $GLOBALS[$key] = $_POST[$key];
  247. }
  248. }
  249. /* NEXT STEPS IMPLEMENTATION */
  250. $total_steps = 7;
  251. if (!$_POST) {
  252. $current_step = 1;
  253. } elseif (!empty($_POST['language_list']) or !empty($_POST['step1']) or ((!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6']))) && ($emptyUpdatePath or $badUpdatePath))) {
  254. $current_step = 2;
  255. } elseif (!empty($_POST['step2']) or (!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6'])))) {
  256. $current_step = 3;
  257. } elseif (!empty($_POST['step3'])) {
  258. $current_step = 4;
  259. } elseif (!empty($_POST['step4'])) {
  260. $current_step = 5;
  261. } elseif (!empty($_POST['step5'])) {
  262. $current_step = 6;
  263. }
  264. // Managing the $encryptPassForm
  265. if ($encryptPassForm == '1') {
  266. $encryptPassForm = 'sha1';
  267. } elseif ($encryptPassForm == '0') {
  268. $encryptPassForm = 'none';
  269. }
  270. ?>
  271. <!DOCTYPE html>
  272. <head>
  273. <title>&mdash; <?php echo get_lang('ChamiloInstallation').' &mdash; '.get_lang(
  274. 'Version_'
  275. ).' '.$new_version; ?></title>
  276. <style type="text/css" media="screen, projection">
  277. /*<![CDATA[*/
  278. @import "../css/base.css";
  279. @import "../css/<?php echo api_get_visual_theme(); ?>/default.css";
  280. /*]]>*/
  281. </style>
  282. <script type="text/javascript" src="../inc/lib/javascript/jquery.min.js"></script>
  283. <script type="text/javascript">
  284. $(document).ready(function () {
  285. $("#button_please_wait").hide();
  286. //checked
  287. if ($('#singleDb1').attr('checked') == false) {
  288. //$('#dbStatsForm').removeAttr('disabled');
  289. //$('#dbUserForm').removeAttr('disabled');
  290. $('#dbStatsForm').attr('value', 'chamilo_main');
  291. $('#dbUserForm').attr('value', 'chamilo_main');
  292. } else if ($('#singleDb1').attr('checked') == true) {
  293. //$('#dbStatsForm').attr('disabled','disabled');
  294. //$('#dbUserForm').attr('disabled','disabled');
  295. $('#dbStatsForm').attr('value', 'chamilo_main');
  296. $('#dbUserForm').attr('value', 'chamilo_main');
  297. }
  298. $("button").addClass('btn');
  299. //Allow Chamilo install in IE
  300. $("button").click(function () {
  301. $("#is_executable").attr("value", $(this).attr("name"));
  302. });
  303. //Blocking step6 button
  304. $("#button_step6").click(function () {
  305. $("#button_step6").hide();
  306. $("#button_please_wait").html('<?php echo addslashes(get_lang('PleaseWait'));?>');
  307. $("#button_please_wait").show();
  308. $("#button_please_wait").attr('disabled', true);
  309. $("#is_executable").attr("value", 'step6');
  310. });
  311. });
  312. function show_hide_tracking_and_user_db(my_option) {
  313. if (my_option == 'singleDb1') {
  314. $('#optional_param2').hide();
  315. $('#optional_param4').hide();
  316. $('#dbStatsForm').attr('value', 'chamilo_main');
  317. $('#dbUserForm').attr('value', 'chamilo_main');
  318. } else if (my_option == 'singleDb0') {
  319. $('#optional_param2').show();
  320. $('#optional_param4').show();
  321. $('#dbStatsForm').attr('value', 'chamilo_main');
  322. $('#dbUserForm').attr('value', 'chamilo_main');
  323. }
  324. }
  325. init_visibility = 0;
  326. function show_hide_option() {
  327. if (init_visibility == 0) {
  328. $('#optional_param1').show();
  329. if ($('#singleDb1').attr("checked") == true) {
  330. //$('#optional_param2').hide();
  331. //$('#optional_param4').hide();
  332. $('#optional_param5').hide();
  333. } else {
  334. //$('#optional_param2').show();
  335. //$('#optional_param4').show();
  336. $('#optional_param5').show();
  337. }
  338. //document.getElementById('optional_param2').style.display = '';
  339. if (document.getElementById('optional_param3')) {
  340. document.getElementById('optional_param3').style.display = '';
  341. }
  342. //document.getElementById('optional_param5').style.display = '';
  343. //document.getElementById('optional_param6').style.display = '';
  344. init_visibility = 1;
  345. document.getElementById('optionalparameters').innerHTML = '<img style="vertical-align:middle;" src="../img/div_hide.gif" alt="" /> <?php echo get_lang(
  346. 'OptionalParameters',
  347. ''
  348. ); ?>';
  349. } else {
  350. document.getElementById('optional_param1').style.display = 'none';
  351. /*document.getElementById('optional_param2').style.display = 'none';
  352. if (document.getElementById('optional_param3')) {
  353. document.getElementById('optional_param3').style.display = 'none';
  354. }
  355. document.getElementById('optional_param4').style.display = 'none';
  356. */
  357. document.getElementById('optional_param5').style.display = 'none';
  358. //document.getElementById('optional_param6').style.display = 'none';
  359. document.getElementById('optionalparameters').innerHTML = '<img style="vertical-align:middle;" src="../img/div_show.gif" alt="" /> <?php echo get_lang(
  360. 'OptionalParameters',
  361. ''
  362. ); ?>';
  363. init_visibility = 0;
  364. }
  365. return false;
  366. }
  367. $(document).ready(function () {
  368. $(".advanced_parameters").click(function () {
  369. if ($("#id_contact_form").css("display") == "none") {
  370. $("#id_contact_form").css("display", "block");
  371. $("#img_plus_and_minus").html('&nbsp;<img src="<?php echo api_get_path(
  372. WEB_IMG_PATH
  373. ) ?>div_hide.gif" alt="<?php echo get_lang('Hide') ?>" title="<?php echo get_lang(
  374. 'Hide'
  375. )?>" style ="vertical-align:middle" >&nbsp;<?php echo get_lang('ContactInformation') ?>');
  376. } else {
  377. $("#id_contact_form").css("display", "none");
  378. $("#img_plus_and_minus").html('&nbsp;<img src="<?php echo api_get_path(
  379. WEB_IMG_PATH
  380. ) ?>div_show.gif" alt="<?php echo get_lang('Show') ?>" title="<?php echo get_lang(
  381. 'Show'
  382. ) ?>" style ="vertical-align:middle" >&nbsp;<?php echo get_lang('ContactInformation') ?>');
  383. }
  384. });
  385. });
  386. function send_contact_information() {
  387. var data_post = "";
  388. data_post += "person_name=" + $("#person_name").val() + "&";
  389. data_post += "person_email=" + $("#person_email").val() + "&";
  390. data_post += "company_name=" + $("#company_name").val() + "&";
  391. data_post += "company_activity=" + $("#company_activity option:selected").val() + "&";
  392. data_post += "person_role=" + $("#person_role option:selected").val() + "&";
  393. data_post += "company_country=" + $("#country option:selected").val() + "&";
  394. data_post += "company_city=" + $("#company_city").val() + "&";
  395. data_post += "language=" + $("#language option:selected").val() + "&";
  396. data_post += "financial_decision=" + $("input[@name='financial_decision']:checked").val();
  397. $.ajax({
  398. contentType:"application/x-www-form-urlencoded",
  399. beforeSend:function (objeto) {
  400. },
  401. type:"POST",
  402. url:"<?php echo api_get_path(WEB_AJAX_PATH) ?>install.ajax.php?a=send_contact_information",
  403. data:data_post,
  404. success:function (datos) {
  405. if (datos == 'required_field_error') {
  406. message = "<?php echo get_lang('FormHasErrorsPleaseComplete') ?>";
  407. } else if (datos == '1') {
  408. message = "<?php echo get_lang('ContactInformationHasBeenSent') ?>";
  409. } else {
  410. message = "<?php echo get_lang('Error').': '.get_lang('ContactInformationHasNotBeenSent') ?>";
  411. }
  412. alert(message);
  413. }
  414. });
  415. }
  416. </script>
  417. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>"/>
  418. </head>
  419. <body dir="<?php echo api_get_text_direction(); ?>">
  420. <div id="wrapper">
  421. <div id="main" class="container">
  422. <header>
  423. <div class="row">
  424. <div id="header_left" class="span4">
  425. <div id="logo">
  426. <img src="../css/chamilo/images/header-logo.png" hspace="10" vspace="10" alt="Chamilo"/>
  427. </div>
  428. </div>
  429. </div>
  430. <div class="navbar subnav">
  431. <div class="navbar-inner">
  432. <div class="container">
  433. <div class="nav-collapse">
  434. <ul class="nav nav-pills">
  435. <li id="current" class="active">
  436. <a target="_top" href="index.php"><?php echo get_lang('Homepage'); ?></a>
  437. </li>
  438. </ul>
  439. </div>
  440. </div>
  441. </div>
  442. </div>
  443. </header>
  444. <br/>
  445. <?php
  446. echo '<div class="page-header"><h1>'.get_lang('ChamiloInstallation').' &ndash; '.get_lang(
  447. 'Version_'
  448. ).' '.$new_version.'</h1></div>';
  449. ?>
  450. <div class="row">
  451. <div class="span3">
  452. <div class="well">
  453. <ol>
  454. <li <?php step_active('1'); ?>><?php echo get_lang('InstallationLanguage'); ?></li>
  455. <li <?php step_active('2'); ?>><?php echo get_lang('Requirements'); ?></li>
  456. <li <?php step_active('3'); ?>><?php echo get_lang('Licence'); ?></li>
  457. <li <?php step_active('4'); ?>><?php echo get_lang('DBSetting'); ?></li>
  458. <li <?php step_active('5'); ?>><?php echo get_lang('CfgSetting'); ?></li>
  459. <li <?php step_active('6'); ?>><?php echo get_lang('PrintOverview'); ?></li>
  460. <li <?php step_active('7'); ?>><?php echo get_lang('Installing'); ?></li>
  461. </ol>
  462. </div>
  463. <div id="note">
  464. <a class="btn" href="../../documentation/installation_guide.html" target="_blank">
  465. <?php echo get_lang('ReadTheInstallationGuide'); ?>
  466. </a>
  467. </div>
  468. </div>
  469. <div class="span9">
  470. <form class="form-horizontal" id="install_form" style="padding: 0px; margin: 0px;" method="post"
  471. action="<?php echo api_get_self(
  472. ); ?>?running=1&amp;installType=<?php echo $installType; ?>&amp;updateFromConfigFile=<?php echo urlencode(
  473. $updateFromConfigFile
  474. ); ?>">
  475. <?php
  476. $instalation_type_label = '';
  477. if ($installType == 'new') {
  478. $instalation_type_label = get_lang('NewInstallation');
  479. } elseif ($installType == 'update') {
  480. $update_from_version = isset($update_from_version) ? $update_from_version : null;
  481. $instalation_type_label = get_lang('UpdateFromDokeosVersion').(is_array($update_from_version) ? implode(
  482. '|',
  483. $update_from_version
  484. ) : '');
  485. }
  486. if (!empty($instalation_type_label) && empty($_POST['step6'])) {
  487. echo '<div class="page-header"><h2>'.$instalation_type_label.'</h2></div>';
  488. }
  489. ?>
  490. <input type="hidden" name="updatePath"
  491. value="<?php if (!$badUpdatePath) {
  492. echo api_htmlentities($proposedUpdatePath, ENT_QUOTES);
  493. } ?>"/>
  494. <input type="hidden" name="urlAppendPath" value="<?php echo api_htmlentities($urlAppendPath, ENT_QUOTES); ?>"/>
  495. <input type="hidden" name="pathForm" value="<?php echo api_htmlentities($pathForm, ENT_QUOTES); ?>"/>
  496. <input type="hidden" name="urlForm" value="<?php echo api_htmlentities($urlForm, ENT_QUOTES); ?>"/>
  497. <input type="hidden" name="dbHostForm" value="<?php echo api_htmlentities($dbHostForm, ENT_QUOTES); ?>"/>
  498. <input type="hidden" name="dbUsernameForm" value="<?php echo api_htmlentities($dbUsernameForm, ENT_QUOTES); ?>"/>
  499. <input type="hidden" name="dbPassForm" value="<?php echo api_htmlentities($dbPassForm, ENT_QUOTES); ?>"/>
  500. <input type="hidden" name="singleDbForm" value="<?php echo api_htmlentities($singleDbForm, ENT_QUOTES); ?>"/>
  501. <input type="hidden" name="dbPrefixForm" value="<?php echo api_htmlentities($dbPrefixForm, ENT_QUOTES); ?>"/>
  502. <input type="hidden" name="dbNameForm" value="<?php echo api_htmlentities($dbNameForm, ENT_QUOTES); ?>"/>
  503. <?php
  504. if ($installType == 'update' OR $singleDbForm == 0) {
  505. ?>
  506. <input type="hidden" name="dbStatsForm" value="<?php echo api_htmlentities($dbStatsForm, ENT_QUOTES); ?>"/>
  507. <input type="hidden" name="dbScormForm" value="<?php echo api_htmlentities($dbScormForm, ENT_QUOTES); ?>"/>
  508. <input type="hidden" name="dbUserForm" value="<?php echo api_htmlentities($dbUserForm, ENT_QUOTES); ?>"/>
  509. <?php
  510. } else {
  511. ?>
  512. <input type="hidden" name="dbStatsForm" value="<?php echo api_htmlentities($dbNameForm, ENT_QUOTES); ?>"/>
  513. <input type="hidden" name="dbUserForm" value="<?php echo api_htmlentities($dbNameForm, ENT_QUOTES); ?>"/>
  514. <?php
  515. }
  516. ?>
  517. <input type="hidden" name="enableTrackingForm"
  518. value="<?php echo api_htmlentities($enableTrackingForm, ENT_QUOTES); ?>"/>
  519. <input type="hidden" name="allowSelfReg" value="<?php echo api_htmlentities($allowSelfReg, ENT_QUOTES); ?>"/>
  520. <input type="hidden" name="allowSelfRegProf" value="<?php echo api_htmlentities($allowSelfRegProf, ENT_QUOTES); ?>"/>
  521. <input type="hidden" name="emailForm" value="<?php echo api_htmlentities($emailForm, ENT_QUOTES); ?>"/>
  522. <input type="hidden" name="adminLastName" value="<?php echo api_htmlentities($adminLastName, ENT_QUOTES); ?>"/>
  523. <input type="hidden" name="adminFirstName" value="<?php echo api_htmlentities($adminFirstName, ENT_QUOTES); ?>"/>
  524. <input type="hidden" name="adminPhoneForm" value="<?php echo api_htmlentities($adminPhoneForm, ENT_QUOTES); ?>"/>
  525. <input type="hidden" name="loginForm" value="<?php echo api_htmlentities($loginForm, ENT_QUOTES); ?>"/>
  526. <input type="hidden" name="passForm" value="<?php echo api_htmlentities($passForm, ENT_QUOTES); ?>"/>
  527. <input type="hidden" name="languageForm" value="<?php echo api_htmlentities($languageForm, ENT_QUOTES); ?>"/>
  528. <input type="hidden" name="campusForm" value="<?php echo api_htmlentities($campusForm, ENT_QUOTES); ?>"/>
  529. <input type="hidden" name="educationForm" value="<?php echo api_htmlentities($educationForm, ENT_QUOTES); ?>"/>
  530. <input type="hidden" name="institutionForm" value="<?php echo api_htmlentities($institutionForm, ENT_QUOTES); ?>"/>
  531. <input type="hidden" name="institutionUrlForm"
  532. value="<?php echo api_stristr($institutionUrlForm, 'http://', false) ? api_htmlentities(
  533. $institutionUrlForm,
  534. ENT_QUOTES
  535. ) : api_stristr($institutionUrlForm, 'https://', false) ? api_htmlentities(
  536. $institutionUrlForm,
  537. ENT_QUOTES
  538. ) : 'http://'.api_htmlentities($institutionUrlForm, ENT_QUOTES); ?>"/>
  539. <input type="hidden" name="checkEmailByHashSent"
  540. value="<?php echo api_htmlentities($checkEmailByHashSent, ENT_QUOTES); ?>"/>
  541. <input type="hidden" name="ShowEmailnotcheckedToStudent"
  542. value="<?php echo api_htmlentities($ShowEmailnotcheckedToStudent, ENT_QUOTES); ?>"/>
  543. <input type="hidden" name="userMailCanBeEmpty"
  544. value="<?php echo api_htmlentities($userMailCanBeEmpty, ENT_QUOTES); ?>"/>
  545. <input type="hidden" name="encryptPassForm" value="<?php echo api_htmlentities($encryptPassForm, ENT_QUOTES); ?>"/>
  546. <input type="hidden" name="session_lifetime" value="<?php echo api_htmlentities($session_lifetime, ENT_QUOTES); ?>"/>
  547. <input type="hidden" name="old_version" value="<?php echo api_htmlentities($my_old_version, ENT_QUOTES); ?>"/>
  548. <input type="hidden" name="new_version" value="<?php echo api_htmlentities($new_version, ENT_QUOTES); ?>"/>
  549. <?php
  550. if (@$_POST['step2']) {
  551. //STEP 3 : LICENSE
  552. display_license_agreement();
  553. } elseif (@$_POST['step3']) {
  554. //STEP 4 : MYSQL DATABASE SETTINGS
  555. display_database_settings_form(
  556. $installType,
  557. $dbHostForm,
  558. $dbUsernameForm,
  559. $dbPassForm,
  560. $dbPrefixForm,
  561. $enableTrackingForm,
  562. $singleDbForm,
  563. $dbNameForm,
  564. $dbStatsForm,
  565. $dbScormForm,
  566. $dbUserForm
  567. );
  568. } elseif (@$_POST['step4']) {
  569. //STEP 5 : CONFIGURATION SETTINGS
  570. //if update, try getting settings from the database...
  571. if ($installType == 'update') {
  572. $db_name = $dbNameForm;
  573. $tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'platformLanguage');
  574. if (!empty($tmp)) {
  575. $languageForm = $tmp;
  576. }
  577. $tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'emailAdministrator');
  578. if (!empty($tmp)) {
  579. $emailForm = $tmp;
  580. }
  581. $tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'administratorName');
  582. if (!empty($tmp)) {
  583. $adminFirstName = $tmp;
  584. }
  585. $tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'administratorSurname');
  586. if (!empty($tmp)) {
  587. $adminLastName = $tmp;
  588. }
  589. $tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'administratorTelephone');
  590. if (!empty($tmp)) {
  591. $adminPhoneForm = $tmp;
  592. }
  593. $tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'siteName');
  594. if (!empty($tmp)) {
  595. $campusForm = $tmp;
  596. }
  597. $tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'Institution');
  598. if (!empty($tmp)) {
  599. $institutionForm = $tmp;
  600. }
  601. $tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'InstitutionUrl');
  602. if (!empty($tmp)) {
  603. $institutionUrlForm = $tmp;
  604. }
  605. if (in_array($my_old_version, $update_from_version_6)) { //for version 1.6
  606. $urlForm = get_config_param('rootWeb');
  607. $encryptPassForm = get_config_param('userPasswordCrypted');
  608. if (empty($encryptPassForm)) {
  609. $encryptPassForm = get_config_param('password_encryption');
  610. }
  611. // Managing the $encryptPassForm
  612. if ($encryptPassForm == '1') {
  613. $encryptPassForm = 'sha1';
  614. } elseif ($encryptPassForm == '0') {
  615. $encryptPassForm = 'none';
  616. }
  617. $allowSelfReg = get_config_param('allowSelfReg');
  618. $allowSelfRegProf = get_config_param('allowSelfRegProf');
  619. } else { //for version 1.8
  620. $urlForm = $_configuration['root_web'];
  621. $encryptPassForm = get_config_param('userPasswordCrypted');
  622. // Managing the $encryptPassForm
  623. if ($encryptPassForm == '1') {
  624. $encryptPassForm = 'sha1';
  625. } elseif ($encryptPassForm == '0') {
  626. $encryptPassForm = 'none';
  627. }
  628. $allowSelfReg = false;
  629. $tmp = get_config_param_from_db($dbHostForm, $dbUsernameForm, $dbPassForm, $db_name, 'allow_registration');
  630. if (!empty($tmp)) {
  631. $allowSelfReg = $tmp;
  632. }
  633. $allowSelfRegProf = false;
  634. $tmp = get_config_param_from_db(
  635. $dbHostForm,
  636. $dbUsernameForm,
  637. $dbPassForm,
  638. $db_name,
  639. 'allow_registration_as_teacher'
  640. );
  641. if (!empty($tmp)) {
  642. $allowSelfRegProf = $tmp;
  643. }
  644. }
  645. }
  646. display_configuration_settings_form(
  647. $installType,
  648. $urlForm,
  649. $languageForm,
  650. $emailForm,
  651. $adminFirstName,
  652. $adminLastName,
  653. $adminPhoneForm,
  654. $campusForm,
  655. $institutionForm,
  656. $institutionUrlForm,
  657. $encryptPassForm,
  658. $allowSelfReg,
  659. $allowSelfRegProf,
  660. $loginForm,
  661. $passForm
  662. );
  663. } elseif (@$_POST['step5']) {
  664. //STEP 6 : LAST CHECK BEFORE INSTALL
  665. ?>
  666. <div class="RequirementHeading">
  667. <h2><?php echo display_step_sequence().get_lang('LastCheck'); ?></h2>
  668. </div>
  669. <div class="RequirementContent">
  670. <?php echo get_lang('HereAreTheValuesYouEntered'); ?>
  671. </div><br/>
  672. <blockquote>
  673. <?php if ($installType == 'new'): ?>
  674. <?php echo get_lang('AdminLogin').' : <strong>'.$loginForm; ?></strong><br/>
  675. <?php echo get_lang(
  676. 'AdminPass'
  677. ).' : <strong>'.$passForm; /* TODO: Maybe this password should be hidden too? */ ?></strong><br/><br/>
  678. <?php else: ?>
  679. <?php endif;
  680. if (api_is_western_name_order()) {
  681. echo get_lang('AdminFirstName').' : '.$adminFirstName, '<br />', get_lang(
  682. 'AdminLastName'
  683. ).' : '.$adminLastName, '<br />';
  684. } else {
  685. echo get_lang('AdminLastName').' : '.$adminLastName, '<br />', get_lang(
  686. 'AdminFirstName'
  687. ).' : '.$adminFirstName, '<br />';
  688. }
  689. echo get_lang('AdminEmail').' : '.$emailForm; ?><br/>
  690. <?php echo get_lang('AdminPhone').' : '.$adminPhoneForm; ?><br/>
  691. <?php echo get_lang('MainLang').' : '.$languageForm; ?><br/><br/>
  692. <?php echo get_lang('DBHost').' : '.$dbHostForm; ?><br/>
  693. <?php echo get_lang('DBLogin').' : '.$dbUsernameForm; ?><br/>
  694. <?php echo get_lang('DBPassword').' : '.str_repeat('*', api_strlen($dbPassForm)); ?><br/>
  695. <?php //echo get_lang('DbPrefixForm').' : '.$dbPrefixForm.'<br />'; ?>
  696. <?php echo get_lang('MainDB').' : <strong>'.$dbNameForm; ?></strong>
  697. <?php
  698. if (!$singleDbForm) {
  699. //Showing this data only in case a user migrates from a 3 main databases (main, user, tracking)
  700. //@todo should be removed
  701. if ($installType == 'update') {
  702. echo '<br />';
  703. echo get_lang('StatDB').' : <strong>'.$dbStatsForm.'</strong>';
  704. if ($installType == 'new') {
  705. echo ' (<font color="#cc0033">'.get_lang('ReadWarningBelow').'</font>)';
  706. }
  707. echo '<br />';
  708. echo get_lang('UserDB').' : <strong>'.$dbUserForm.'</strong>';
  709. if ($installType == 'new') {
  710. echo ' (<font color="#cc0033">'.get_lang('ReadWarningBelow').'</font>)';
  711. }
  712. echo '<br />';
  713. }
  714. }
  715. //echo get_lang('EnableTracking').' : '.($enableTrackingForm ? get_lang('Yes') : get_lang('No')); ?>
  716. <?php //echo get_lang('SingleDb').' : '.($singleDbForm ? get_lang('One') : get_lang('Several')); ?><br/><br/>
  717. <?php echo get_lang('AllowSelfReg').' : '.($allowSelfReg ? get_lang('Yes') : get_lang('No')); ?><br/>
  718. <?php echo get_lang('EncryptMethodUserPass').' : ';
  719. echo $encryptPassForm;
  720. ?>
  721. <br/><br/>
  722. <?php echo get_lang('CampusName').' : '.$campusForm; ?><br/>
  723. <?php echo get_lang('InstituteShortName').' : '.$institutionForm; ?><br/>
  724. <?php echo get_lang('InstituteURL').' : '.$institutionUrlForm; ?><br/>
  725. <?php echo get_lang('ChamiloURL').' : '.$urlForm; ?><br/>
  726. </blockquote>
  727. <?php if ($installType == 'new'): ?>
  728. <div style="background-color:#FFFFFF">
  729. <div class="warning-message">
  730. <center>
  731. <h3><?php echo get_lang('Warning'); ?> !</h3>
  732. <?php echo get_lang('TheInstallScriptWillEraseAllTables'); ?>
  733. </center>
  734. </div>
  735. </div>
  736. <?php endif; ?>
  737. <table width="100%">
  738. <tr>
  739. <td>
  740. <button type="submit" class="back" name="step4" value="&lt; <?php echo get_lang('Previous'); ?>"/>
  741. <?php echo get_lang('Previous'); ?></button>
  742. </td>
  743. <td align="right">
  744. <input type="hidden" name="is_executable" id="is_executable" value="-"/>
  745. <input type="hidden" name="step6" value="1"/>
  746. <button id="button_step6" class="save" type="submit" name="button_step6"
  747. value="<?php echo get_lang('InstallChamilo'); ?>" autofocus="autofocus">
  748. <?php echo get_lang('InstallChamilo'); ?>
  749. </button>
  750. <button class="save" id="button_please_wait"></button>
  751. </td>
  752. </tr>
  753. </table>
  754. <?php
  755. } elseif (@$_POST['step6']) {
  756. //STEP 6 : INSTALLATION PROCESS
  757. $current_step = 7;
  758. $msg = get_lang('InstallExecution');
  759. if ($installType == 'update') {
  760. $msg = get_lang('UpdateExecution');
  761. }
  762. echo '<div class="RequirementHeading">
  763. <h2>'.display_step_sequence().$msg.'</h2>
  764. <div id="pleasewait" class="warning-message">'.get_lang('PleaseWaitThisCouldTakeAWhile').'</div>
  765. </div>';
  766. // Push the web server to send these strings before we start the real
  767. // installation process
  768. flush();
  769. ob_flush();
  770. $app['monolog']->addInfo("installType: $installType");
  771. if ($installType == 'update') {
  772. remove_memory_and_time_limits();
  773. database_server_connect();
  774. // Initialization of the database connection encoding intentionaly is not done.
  775. // This is the old style for connecting to the database server, that is implemented here.
  776. // Inializing global variables that are to be used by the included scripts.
  777. $dblist = Database::get_databases();
  778. $perm = api_get_permissions_for_new_directories();
  779. $perm_file = api_get_permissions_for_new_files();
  780. if (empty($my_old_version)) {
  781. $my_old_version = '1.8.6.2';
  782. } //we guess
  783. $_configuration['main_database'] = $dbNameForm;
  784. $app['monolog']->addInfo('Starting migration process from old version: '.$my_old_version.' ('.time().')');
  785. if (isset($userPasswordCrypted)) {
  786. if ($userPasswordCrypted == '1') {
  787. $userPasswordCrypted = 'md5';
  788. } elseif ($userPasswordCrypted == '0') {
  789. $userPasswordCrypted = 'none';
  790. }
  791. }
  792. //Setting the single db form
  793. if (in_array($_POST['old_version'], $update_from_version_6)) {
  794. $singleDbForm = get_config_param('singleDbEnabled');
  795. } else {
  796. $singleDbForm = isset($_configuration['single_database']) ? $_configuration['single_database'] : false;
  797. }
  798. $app['monolog']->addInfo("singledbForm: '$singleDbForm'");
  799. Database::query("SET storage_engine = MYISAM;");
  800. if (version_compare($my_old_version, '1.8.7', '>=')) {
  801. Database::query("SET SESSION character_set_server='utf8';");
  802. Database::query("SET SESSION collation_server='utf8_general_ci';");
  803. //Database::query("SET CHARACTER SET 'utf8';"); // See task #1802.
  804. Database::query("SET NAMES 'utf8';");
  805. }
  806. $app['monolog']->addInfo("my_old_version $my_old_version");
  807. switch ($my_old_version) {
  808. case '1.6':
  809. case '1.6.0':
  810. case '1.6.1':
  811. case '1.6.2':
  812. case '1.6.3':
  813. case '1.6.4':
  814. case '1.6.5':
  815. include 'update-db-1.6.x-1.8.0.inc.php';
  816. include 'update-files-1.6.x-1.8.0.inc.php';
  817. //intentionally no break to continue processing
  818. case '1.8':
  819. case '1.8.0':
  820. include 'update-db-1.8.0-1.8.2.inc.php';
  821. //intentionally no break to continue processing
  822. case '1.8.2':
  823. include 'update-db-1.8.2-1.8.3.inc.php';
  824. //intentionally no break to continue processing
  825. case '1.8.3':
  826. include 'update-db-1.8.3-1.8.4.inc.php';
  827. include 'update-files-1.8.3-1.8.4.inc.php';
  828. case '1.8.4':
  829. include 'update-db-1.8.4-1.8.5.inc.php';
  830. include 'update-files-1.8.4-1.8.5.inc.php';
  831. case '1.8.5':
  832. include 'update-db-1.8.5-1.8.6.inc.php';
  833. include 'update-files-1.8.5-1.8.6.inc.php';
  834. case '1.8.6':
  835. include 'update-db-1.8.6-1.8.6.1.inc.php';
  836. include 'update-files-1.8.6-1.8.6.1.inc.php';
  837. case '1.8.6.1':
  838. include 'update-db-1.8.6.1-1.8.6.2.inc.php';
  839. include 'update-files-1.8.6.1-1.8.6.2.inc.php';
  840. case '1.8.6.2':
  841. include 'update-db-1.8.6.2-1.8.7.inc.php';
  842. include 'update-files-1.8.6.2-1.8.7.inc.php';
  843. // After database conversion to UTF-8, new encoding initialization is necessary
  844. // to be used for the next upgrade 1.8.7[.1] -> 1.8.8.
  845. Database::query("SET SESSION character_set_server='utf8';");
  846. Database::query("SET SESSION collation_server='utf8_general_ci';");
  847. //Database::query("SET CHARACTER SET 'utf8';"); // See task #1802.
  848. Database::query("SET NAMES 'utf8';");
  849. case '1.8.7':
  850. case '1.8.7.1':
  851. include 'update-db-1.8.7-1.8.8.inc.php';
  852. include 'update-files-1.8.7-1.8.8.inc.php';
  853. case '1.8.8':
  854. case '1.8.8.2':
  855. //Only updates the configuration.inc.php with the new version
  856. include 'update-configuration.inc.php';
  857. case '1.8.8.4':
  858. case '1.8.8.6':
  859. include 'update-db-1.8.8-1.9.0.inc.php';
  860. //Only updates the configuration.inc.php with the new version
  861. include 'update-configuration.inc.php';
  862. case '1.9.0':
  863. case '1.9.2':
  864. case '1.9.4':
  865. include 'update-db-1.9.0-1.10.0.inc.php';
  866. include 'update-configuration.inc.php';
  867. break;
  868. default:
  869. break;
  870. }
  871. } else {
  872. set_file_folder_permissions();
  873. database_server_connect();
  874. // Initialization of the database encoding to be used.
  875. Database::query("SET storage_engine = MYISAM;");
  876. Database::query("SET SESSION character_set_server='utf8';");
  877. Database::query("SET SESSION collation_server='utf8_general_ci';");
  878. //Database::query("SET CHARACTER SET 'utf8';"); // See task #1802.
  879. Database::query("SET NAMES 'utf8';");
  880. include 'install_db.inc.php';
  881. include 'install_files.inc.php';
  882. }
  883. display_after_install_message($installType);
  884. //Hide the "please wait" message sent previously
  885. echo '<script>$(\'#pleasewait\').hide(\'fast\');</script>';
  886. } elseif (@$_POST['step1'] || $badUpdatePath) {
  887. //STEP 1 : REQUIREMENTS
  888. //make sure that proposed path is set, shouldn't be necessary but...
  889. if (empty($proposedUpdatePath)) {
  890. $proposedUpdatePath = $_POST['updatePath'];
  891. }
  892. display_requirements(
  893. $installType,
  894. $badUpdatePath,
  895. $proposedUpdatePath,
  896. $update_from_version_8,
  897. $update_from_version_6
  898. );
  899. } else {
  900. // This is the start screen.
  901. display_language_selection();
  902. }
  903. ?>
  904. </form>
  905. </div>
  906. <!-- span9-->
  907. </div>
  908. <!-- row -->
  909. </div>
  910. <!-- main end-->
  911. <div class="push"></div>
  912. </div>
  913. <!-- wrapper end-->
  914. <footer></footer>
  915. </body>
  916. </html>