index.php 30 KB

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