index.php 37 KB

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