index.php 35 KB

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