index.php 37 KB

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