index.php 34 KB

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