index.php 34 KB

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