index.php 31 KB

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