index.php 39 KB

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