index.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  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. use ChamiloSession as Session;
  17. require_once __DIR__.'/../../vendor/autoload.php';
  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. // Including necessary libraries.
  24. require_once '../inc/lib/api.lib.php';
  25. api_check_php_version('../inc/');
  26. /* INITIALIZATION SECTION */
  27. ob_implicit_flush(true);
  28. session_start();
  29. require_once api_get_path(LIBRARY_PATH).'database.constants.inc.php';
  30. require_once 'install.lib.php';
  31. // The function api_get_setting() might be called within the installation scripts.
  32. // We need to provide some limited support for it through initialization of the
  33. // global array-type variable $_setting.
  34. $_setting = array(
  35. 'platform_charset' => 'UTF-8',
  36. 'server_type' => 'production', // 'production' | 'test'
  37. 'permissions_for_new_directories' => '0770',
  38. 'permissions_for_new_files' => '0660',
  39. 'stylesheets' => 'chamilo'
  40. );
  41. // Determination of the language during the installation procedure.
  42. if (!empty($_POST['language_list'])) {
  43. $search = array('../', '\\0');
  44. $install_language = str_replace($search, '', urldecode($_POST['language_list']));
  45. Session::write('install_language', $install_language);
  46. } elseif (isset($_SESSION['install_language']) && $_SESSION['install_language']) {
  47. $install_language = $_SESSION['install_language'];
  48. } else {
  49. // Trying to switch to the browser's language, it is covenient for most of the cases.
  50. $install_language = detect_browser_language();
  51. }
  52. // Language validation.
  53. if (!array_key_exists($install_language, get_language_folder_list())) {
  54. $install_language = 'english';
  55. }
  56. // Loading language files.
  57. require api_get_path(SYS_LANG_PATH).'english/trad4all.inc.php';
  58. if ($install_language != 'english') {
  59. include_once api_get_path(SYS_LANG_PATH).$install_language.'/trad4all.inc.php';
  60. }
  61. // These global variables must be set for proper working of the function get_lang(...) during the installation.
  62. $language_interface = $install_language;
  63. $language_interface_initial_value = $install_language;
  64. // Character set during the installation, it is always to be 'UTF-8'.
  65. $charset = 'UTF-8';
  66. // Initialization of the internationalization library.
  67. api_initialize_internationalization();
  68. // Initialization of the default encoding that will be used by the multibyte
  69. // 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.9
  78. $update_from_version_8 = array(
  79. '1.9.0',
  80. '1.9.2',
  81. '1.9.4',
  82. '1.9.6',
  83. '1.9.6.1',
  84. '1.9.8',
  85. '1.9.8.1',
  86. '1.9.8.2',
  87. '1.9.10',
  88. '1.9.10.2'
  89. );
  90. $my_old_version = '';
  91. if (empty($tmp_version)) {
  92. $tmp_version = get_config_param('system_version');
  93. }
  94. if (!empty($_POST['old_version'])) {
  95. $my_old_version = $_POST['old_version'];
  96. } elseif (!empty($tmp_version)) {
  97. $my_old_version = $tmp_version;
  98. }
  99. require_once __DIR__.'/version.php';
  100. // A protection measure for already installed systems.
  101. if (isAlreadyInstalledSystem()) {
  102. // The system has already been installed, so block re-installation.
  103. $global_error_code = 6;
  104. // @todo uncomment this.
  105. require '../inc/global_error_message.inc.php';
  106. die();
  107. }
  108. /* STEP 1 : INITIALIZES FORM VARIABLES IF IT IS THE FIRST VISIT */
  109. // Is valid request
  110. $is_valid_request = isset($_REQUEST['is_executable']) ? $_REQUEST['is_executable'] : null;
  111. /*foreach ($_POST as $request_index => $request_value) {
  112. if (substr($request_index, 0, 4) == 'step') {
  113. if ($request_index != $is_valid_request) {
  114. unset($_POST[$request_index]);
  115. }
  116. }
  117. }*/
  118. $badUpdatePath = false;
  119. $emptyUpdatePath = true;
  120. $proposedUpdatePath = '';
  121. if (!empty($_POST['updatePath'])) {
  122. $proposedUpdatePath = $_POST['updatePath'];
  123. }
  124. if (@$_POST['step2_install'] || @$_POST['step2_update_8'] || @$_POST['step2_update_6']) {
  125. if (@$_POST['step2_install']) {
  126. $installType = 'new';
  127. $_POST['step2'] = 1;
  128. } else {
  129. $installType = 'update';
  130. if (@$_POST['step2_update_8']) {
  131. $emptyUpdatePath = false;
  132. $proposedUpdatePath = api_add_trailing_slash(empty($_POST['updatePath']) ? api_get_path(SYS_PATH) : $_POST['updatePath']);
  133. if (file_exists($proposedUpdatePath)) {
  134. if (in_array($my_old_version, $update_from_version_8)) {
  135. $_POST['step2'] = 1;
  136. } else {
  137. $badUpdatePath = true;
  138. }
  139. } else {
  140. $badUpdatePath = true;
  141. }
  142. }
  143. }
  144. } elseif (@$_POST['step1']) {
  145. $_POST['updatePath'] = '';
  146. $installType = '';
  147. $updateFromConfigFile = '';
  148. unset($_GET['running']);
  149. } else {
  150. $installType = isset($_GET['installType']) ? $_GET['installType'] : null;
  151. $updateFromConfigFile = isset($_GET['updateFromConfigFile']) ? $_GET['updateFromConfigFile'] : false;
  152. }
  153. if ($installType == 'update' && in_array($my_old_version, $update_from_version_8)) {
  154. // This is the main configuration file of the system before the upgrade.
  155. include api_get_path(CONFIGURATION_PATH) . 'configuration.php'; // Don't change to include_once
  156. }
  157. if (!isset($_GET['running'])) {
  158. $dbHostForm = 'localhost';
  159. $dbUsernameForm = 'root';
  160. $dbPassForm = '';
  161. $dbNameForm = 'chamilo';
  162. // Extract the path to append to the url if Chamilo is not installed on the web root directory.
  163. $urlAppendPath = api_remove_trailing_slash(api_get_path(REL_PATH));
  164. $urlForm = api_get_path(WEB_PATH);
  165. $pathForm = api_get_path(SYS_PATH);
  166. $emailForm = 'webmaster@localhost';
  167. if (!empty($_SERVER['SERVER_ADMIN'])) {
  168. $emailForm = $_SERVER['SERVER_ADMIN'];
  169. }
  170. $email_parts = explode('@', $emailForm);
  171. if (isset($email_parts[1]) && $email_parts[1] == 'localhost') {
  172. $emailForm .= '.localdomain';
  173. }
  174. $adminLastName = 'Doe';
  175. $adminFirstName = 'John';
  176. $loginForm = 'admin';
  177. $passForm = api_generate_password();
  178. $campusForm = 'My campus';
  179. $educationForm = 'Albert Einstein';
  180. $adminPhoneForm = '(000) 001 02 03';
  181. $institutionForm = 'My Organisation';
  182. $institutionUrlForm = 'http://www.chamilo.org';
  183. $languageForm = api_get_interface_language();
  184. $checkEmailByHashSent = 0;
  185. $ShowEmailNotCheckedToStudent = 1;
  186. $userMailCanBeEmpty = 1;
  187. $allowSelfReg = 1;
  188. $allowSelfRegProf = 1;
  189. $encryptPassForm = 'sha1';
  190. $session_lifetime = 360000;
  191. } else {
  192. foreach ($_POST as $key => $val) {
  193. $magic_quotes_gpc = ini_get('magic_quotes_gpc');
  194. if (is_string($val)) {
  195. if ($magic_quotes_gpc) {
  196. $val = stripslashes($val);
  197. }
  198. $val = trim($val);
  199. $_POST[$key] = $val;
  200. } elseif (is_array($val)) {
  201. foreach ($val as $key2 => $val2) {
  202. if ($magic_quotes_gpc) {
  203. $val2 = stripslashes($val2);
  204. }
  205. $val2 = trim($val2);
  206. $_POST[$key][$key2] = $val2;
  207. }
  208. }
  209. $GLOBALS[$key] = $_POST[$key];
  210. }
  211. }
  212. /* NEXT STEPS IMPLEMENTATION */
  213. $total_steps = 7;
  214. if (!$_POST) {
  215. $current_step = 1;
  216. } elseif (!empty($_POST['language_list']) or !empty($_POST['step1']) or ((!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6']))) && ($emptyUpdatePath or $badUpdatePath))) {
  217. $current_step = 2;
  218. } elseif (!empty($_POST['step2']) or (!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6'])))) {
  219. $current_step = 3;
  220. } elseif (!empty($_POST['step3'])) {
  221. $current_step = 4;
  222. } elseif (!empty($_POST['step4'])) {
  223. $current_step = 5;
  224. } elseif (!empty($_POST['step5'])) {
  225. $current_step = 6;
  226. }
  227. // Managing the $encryptPassForm
  228. if ($encryptPassForm == '1') {
  229. $encryptPassForm = 'sha1';
  230. } elseif ($encryptPassForm == '0') {
  231. $encryptPassForm = 'none';
  232. }
  233. ?>
  234. <!DOCTYPE html>
  235. <head>
  236. <title>&mdash; <?php echo get_lang('ChamiloInstallation').' &mdash; '.get_lang('Version_').' '.$new_version; ?></title>
  237. <style type="text/css" media="screen, projection">
  238. /*<![CDATA[*/
  239. @import "../../web/assets/bootstrap/dist/css/bootstrap.min.css";
  240. @import "../../web/assets/fontawesome/css/font-awesome.min.css";
  241. @import "../css/base.css";
  242. @import "../css/<?php echo api_get_visual_theme(); ?>/default.css";
  243. /*]]>*/
  244. </style>
  245. <script type="text/javascript" src="../../web/assets/jquery/dist/jquery.min.js"></script>
  246. <script type="text/javascript">
  247. $(document).ready( function() {
  248. $("#button_please_wait").hide();
  249. $("button").addClass('btn btn-default');
  250. // Allow Chamilo install in IE
  251. $("button").click(function() {
  252. $("#is_executable").attr("value",$(this).attr("name"));
  253. });
  254. //Blocking step6 button
  255. $("#button_step6").click(function() {
  256. $("#button_step6").hide();
  257. $("#button_please_wait").html('<?php echo addslashes(get_lang('PleaseWait'));?>');
  258. $("#button_please_wait").show();
  259. $("#button_please_wait").attr('disabled', true);
  260. $("#is_executable").attr("value",'step6');
  261. });
  262. });
  263. init_visibility=0;
  264. $(document).ready( function() {
  265. $(".advanced_parameters").click(function() {
  266. if ($("#id_contact_form").css("display") == "none") {
  267. $("#id_contact_form").css("display","block");
  268. $("#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') ?>');
  269. } else {
  270. $("#id_contact_form").css("display","none");
  271. $("#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') ?>');
  272. }
  273. });
  274. });
  275. function send_contact_information() {
  276. var data_post = "";
  277. data_post += "person_name="+$("#person_name").val()+"&";
  278. data_post += "person_email="+$("#person_email").val()+"&";
  279. data_post += "company_name="+$("#company_name").val()+"&";
  280. data_post += "company_activity="+$("#company_activity option:selected").val()+"&";
  281. data_post += "person_role="+$("#person_role option:selected").val()+"&";
  282. data_post += "company_country="+$("#country option:selected").val()+"&";
  283. data_post += "company_city="+$("#company_city").val()+"&";
  284. data_post += "language="+$("#language option:selected").val()+"&";
  285. data_post += "financial_decision="+$("input[@name='financial_decision']:checked").val();
  286. $.ajax({
  287. contentType: "application/x-www-form-urlencoded",
  288. beforeSend: function(objeto) {},
  289. type: "POST",
  290. url: "<?php echo api_get_path(WEB_AJAX_PATH) ?>install.ajax.php?a=send_contact_information",
  291. data: data_post,
  292. success: function(datos) {
  293. if (datos == 'required_field_error') {
  294. message = "<?php echo get_lang('FormHasErrorsPleaseComplete') ?>";
  295. } else if (datos == '1') {
  296. message = "<?php echo get_lang('ContactInformationHasBeenSent') ?>";
  297. } else {
  298. message = "<?php echo get_lang('Error').': '.get_lang('ContactInformationHasNotBeenSent') ?>";
  299. }
  300. alert(message);
  301. }
  302. });
  303. }
  304. </script>
  305. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>" />
  306. </head>
  307. <body dir="<?php echo api_get_text_direction(); ?>" class="install-chamilo">
  308. <div id="page-wrap">
  309. <div id="main" class="container well-install">
  310. <header>
  311. <div class="row">
  312. <div id="header_left" class="col-md-4">
  313. <div id="logo">
  314. <img src="../css/chamilo/images/header-logo.png" hspace="10" vspace="10" alt="Chamilo" />
  315. </div>
  316. </div>
  317. </div>
  318. <div class="navbar subnav">
  319. <div class="navbar-inner">
  320. <div class="container">
  321. <div class="nav-collapse">
  322. <ul class="nav nav-pills">
  323. <li id="current" class="active">
  324. <a target="_top" href="index.php"><?php echo get_lang('Homepage'); ?></a>
  325. </li>
  326. </ul>
  327. </div>
  328. </div>
  329. </div>
  330. </div>
  331. </header>
  332. <?php
  333. echo '<div class="page-header"><h1>'.get_lang('ChamiloInstallation').' &ndash; '.get_lang('Version_').' '.$new_version.'</h1></div>';
  334. ?>
  335. <div class="row">
  336. <div class="col-md-3">
  337. <div class="well">
  338. <ol>
  339. <li <?php step_active('1'); ?>><?php echo get_lang('InstallationLanguage'); ?></li>
  340. <li <?php step_active('2'); ?>><?php echo get_lang('Requirements'); ?></li>
  341. <li <?php step_active('3'); ?>><?php echo get_lang('Licence'); ?></li>
  342. <li <?php step_active('4'); ?>><?php echo get_lang('DBSetting'); ?></li>
  343. <li <?php step_active('5'); ?>><?php echo get_lang('CfgSetting'); ?></li>
  344. <li <?php step_active('6'); ?>><?php echo get_lang('PrintOverview'); ?></li>
  345. <li <?php step_active('7'); ?>><?php echo get_lang('Installing'); ?></li>
  346. </ol>
  347. </div>
  348. <div id="note">
  349. <a class="btn btn-default" href="../../documentation/installation_guide.html" target="_blank">
  350. <?php echo get_lang('ReadTheInstallationGuide'); ?>
  351. </a>
  352. </div>
  353. </div>
  354. <div class="col-md-9">
  355. <form class="form-horizontal" id="install_form" method="post" action="<?php echo api_get_self(); ?>?running=1&amp;installType=<?php echo $installType; ?>&amp;updateFromConfigFile=<?php echo urlencode($updateFromConfigFile); ?>">
  356. <?php
  357. $instalation_type_label = '';
  358. if ($installType == 'new') {
  359. $instalation_type_label = get_lang('NewInstallation');
  360. } elseif ($installType == 'update') {
  361. $update_from_version = isset($update_from_version) ? $update_from_version : null;
  362. $instalation_type_label = get_lang('UpdateFromLMSVersion').(is_array($update_from_version) ? implode('|', $update_from_version) : '');
  363. }
  364. if (!empty($instalation_type_label) && empty($_POST['step6'])) {
  365. echo '<div class="page-header"><h2>'.$instalation_type_label.'</h2></div>';
  366. }
  367. ?>
  368. <input type="hidden" name="updatePath" value="<?php if (!$badUpdatePath) echo api_htmlentities($proposedUpdatePath, ENT_QUOTES); ?>" />
  369. <input type="hidden" name="urlAppendPath" value="<?php echo api_htmlentities($urlAppendPath, ENT_QUOTES); ?>" />
  370. <input type="hidden" name="pathForm" value="<?php echo api_htmlentities($pathForm, ENT_QUOTES); ?>" />
  371. <input type="hidden" name="urlForm" value="<?php echo api_htmlentities($urlForm, ENT_QUOTES); ?>" />
  372. <input type="hidden" name="dbHostForm" value="<?php echo api_htmlentities($dbHostForm, ENT_QUOTES); ?>" />
  373. <input type="hidden" name="dbUsernameForm" value="<?php echo api_htmlentities($dbUsernameForm, ENT_QUOTES); ?>" />
  374. <input type="hidden" name="dbPassForm" value="<?php echo api_htmlentities($dbPassForm, ENT_QUOTES); ?>" />
  375. <input type="hidden" name="dbNameForm" value="<?php echo api_htmlentities($dbNameForm, ENT_QUOTES); ?>" />
  376. <input type="hidden" name="allowSelfReg" value="<?php echo api_htmlentities($allowSelfReg, ENT_QUOTES); ?>" />
  377. <input type="hidden" name="allowSelfRegProf" value="<?php echo api_htmlentities($allowSelfRegProf, ENT_QUOTES); ?>" />
  378. <input type="hidden" name="emailForm" value="<?php echo api_htmlentities($emailForm, ENT_QUOTES); ?>" />
  379. <input type="hidden" name="adminLastName" value="<?php echo api_htmlentities($adminLastName, ENT_QUOTES); ?>" />
  380. <input type="hidden" name="adminFirstName" value="<?php echo api_htmlentities($adminFirstName, ENT_QUOTES); ?>" />
  381. <input type="hidden" name="adminPhoneForm" value="<?php echo api_htmlentities($adminPhoneForm, ENT_QUOTES); ?>" />
  382. <input type="hidden" name="loginForm" value="<?php echo api_htmlentities($loginForm, ENT_QUOTES); ?>" />
  383. <input type="hidden" name="passForm" value="<?php echo api_htmlentities($passForm, ENT_QUOTES); ?>" />
  384. <input type="hidden" name="languageForm" value="<?php echo api_htmlentities($languageForm, ENT_QUOTES); ?>" />
  385. <input type="hidden" name="campusForm" value="<?php echo api_htmlentities($campusForm, ENT_QUOTES); ?>" />
  386. <input type="hidden" name="educationForm" value="<?php echo api_htmlentities($educationForm, ENT_QUOTES); ?>" />
  387. <input type="hidden" name="institutionForm" value="<?php echo api_htmlentities($institutionForm, ENT_QUOTES); ?>" />
  388. <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); ?>" />
  389. <input type="hidden" name="checkEmailByHashSent" value="<?php echo api_htmlentities($checkEmailByHashSent, ENT_QUOTES); ?>" />
  390. <input type="hidden" name="ShowEmailNotCheckedToStudent" value="<?php echo api_htmlentities($ShowEmailNotCheckedToStudent, ENT_QUOTES); ?>" />
  391. <input type="hidden" name="userMailCanBeEmpty" value="<?php echo api_htmlentities($userMailCanBeEmpty, ENT_QUOTES); ?>" />
  392. <input type="hidden" name="encryptPassForm" value="<?php echo api_htmlentities($encryptPassForm, ENT_QUOTES); ?>" />
  393. <input type="hidden" name="session_lifetime" value="<?php echo api_htmlentities($session_lifetime, ENT_QUOTES); ?>" />
  394. <input type="hidden" name="old_version" value="<?php echo api_htmlentities($my_old_version, ENT_QUOTES); ?>" />
  395. <input type="hidden" name="new_version" value="<?php echo api_htmlentities($new_version, ENT_QUOTES); ?>" />
  396. <?php
  397. if (@$_POST['step2']) {
  398. //STEP 3 : LICENSE
  399. display_license_agreement();
  400. } elseif (@$_POST['step3']) {
  401. //STEP 4 : MYSQL DATABASE SETTINGS
  402. display_database_settings_form(
  403. $installType,
  404. $dbHostForm,
  405. $dbUsernameForm,
  406. $dbPassForm,
  407. $dbNameForm
  408. );
  409. } elseif (@$_POST['step4']) {
  410. //STEP 5 : CONFIGURATION SETTINGS
  411. //if update, try getting settings from the database...
  412. if ($installType == 'update') {
  413. $db_name = $dbNameForm;
  414. $manager = testDbConnect(
  415. $dbHostForm,
  416. $dbUsernameForm,
  417. $dbPassForm,
  418. $dbNameForm
  419. );
  420. $tmp = get_config_param_from_db('platformLanguage');
  421. if (!empty($tmp)) {
  422. $languageForm = $tmp;
  423. }
  424. $tmp = get_config_param_from_db('emailAdministrator');
  425. if (!empty($tmp)) {
  426. $emailForm = $tmp;
  427. }
  428. $tmp = get_config_param_from_db('administratorName');
  429. if (!empty($tmp)) {
  430. $adminFirstName = $tmp;
  431. }
  432. $tmp = get_config_param_from_db('administratorSurname');
  433. if (!empty($tmp)) {
  434. $adminLastName = $tmp;
  435. }
  436. $tmp = get_config_param_from_db('administratorTelephone');
  437. if (!empty($tmp)) {
  438. $adminPhoneForm = $tmp;
  439. }
  440. $tmp = get_config_param_from_db('siteName');
  441. if (!empty($tmp)) {
  442. $campusForm = $tmp;
  443. }
  444. $tmp = get_config_param_from_db('Institution');
  445. if (!empty($tmp)) {
  446. $institutionForm = $tmp;
  447. }
  448. $tmp = get_config_param_from_db('InstitutionUrl');
  449. if (!empty($tmp)) {
  450. $institutionUrlForm = $tmp;
  451. }
  452. // For version 1.9
  453. $urlForm = $_configuration['root_web'];
  454. $encryptPassForm = get_config_param('userPasswordCrypted');
  455. // Managing the $encryptPassForm
  456. if ($encryptPassForm == '1') {
  457. $encryptPassForm = 'sha1';
  458. } elseif ($encryptPassForm == '0') {
  459. $encryptPassForm = 'none';
  460. }
  461. $allowSelfReg = false;
  462. $tmp = get_config_param_from_db('allow_registration');
  463. if (!empty($tmp)) {
  464. $allowSelfReg = $tmp;
  465. }
  466. $allowSelfRegProf = false;
  467. $tmp = get_config_param_from_db('allow_registration_as_teacher');
  468. if (!empty($tmp)) {
  469. $allowSelfRegProf = $tmp;
  470. }
  471. }
  472. display_configuration_settings_form(
  473. $installType,
  474. $urlForm,
  475. $languageForm,
  476. $emailForm,
  477. $adminFirstName,
  478. $adminLastName,
  479. $adminPhoneForm,
  480. $campusForm,
  481. $institutionForm,
  482. $institutionUrlForm,
  483. $encryptPassForm,
  484. $allowSelfReg,
  485. $allowSelfRegProf,
  486. $loginForm,
  487. $passForm
  488. );
  489. } elseif (@$_POST['step5']) {
  490. //STEP 6 : LAST CHECK BEFORE INSTALL
  491. ?>
  492. <div class="RequirementHeading">
  493. <h2><?php echo display_step_sequence().get_lang('LastCheck'); ?></h2>
  494. </div>
  495. <div class="RequirementContent">
  496. <?php echo get_lang('HereAreTheValuesYouEntered'); ?>
  497. </div><br />
  498. <?php
  499. if ($installType == 'new') {
  500. echo get_lang('AdminLogin') . ' : <strong>' . $loginForm . '</strong><br />';
  501. echo get_lang('AdminPass') . ' : <strong>' . $passForm . '</strong><br /><br />'; /* TODO: Maybe this password should be hidden too? */
  502. }
  503. if (api_is_western_name_order()) {
  504. echo get_lang('AdminFirstName').' : '.$adminFirstName, '<br />', get_lang('AdminLastName').' : '.$adminLastName, '<br />';
  505. } else {
  506. echo get_lang('AdminLastName').' : '.$adminLastName, '<br />', get_lang('AdminFirstName').' : '.$adminFirstName, '<br />';
  507. }
  508. echo get_lang('AdminEmail').' : '.$emailForm; ?><br />
  509. <?php echo get_lang('AdminPhone').' : '.$adminPhoneForm; ?><br />
  510. <?php echo get_lang('MainLang').' : '.$languageForm; ?><br /><br />
  511. <?php echo get_lang('DBHost').' : '.$dbHostForm; ?><br />
  512. <?php echo get_lang('DBLogin').' : '.$dbUsernameForm; ?><br />
  513. <?php echo get_lang('DBPassword').' : '.str_repeat('*', api_strlen($dbPassForm)); ?><br />
  514. <?php echo get_lang('MainDB').' : <strong>'.$dbNameForm; ?></strong><br />
  515. <?php echo get_lang('AllowSelfReg').' : '.($allowSelfReg ? get_lang('Yes') : get_lang('No')); ?><br />
  516. <?php echo get_lang('EncryptMethodUserPass').' : ';
  517. echo $encryptPassForm;
  518. ?>
  519. <br /><br />
  520. <?php echo get_lang('CampusName').' : '.$campusForm; ?><br />
  521. <?php echo get_lang('InstituteShortName').' : '.$institutionForm; ?><br />
  522. <?php echo get_lang('InstituteURL').' : '.$institutionUrlForm; ?><br />
  523. <?php echo get_lang('ChamiloURL').' : '.$urlForm; ?><br />
  524. <?php
  525. if ($installType == 'new') {
  526. echo Display::display_warning_message(
  527. '<h3 style="text-align: center">'.get_lang(
  528. 'Warning'
  529. ).'</h3><br />'.get_lang('TheInstallScriptWillEraseAllTables'),
  530. false
  531. );
  532. }
  533. ?>
  534. <table width="100%">
  535. <tr>
  536. <td>
  537. <button type="submit" class="btn btn-default" name="step4" value="&lt; <?php echo get_lang('Previous'); ?>" >
  538. <i class="fa fa-backward"> </i> <?php echo get_lang('Previous'); ?>
  539. </button>
  540. </td>
  541. <td align="right">
  542. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  543. <input type="hidden" name="step6" value="1" />
  544. <button id="button_step6" class="btn btn-success" type="submit" name="button_step6" value="<?php echo get_lang('InstallChamilo'); ?>">
  545. <i class="fa fa-floppy-o"> </i>
  546. <?php echo get_lang('InstallChamilo'); ?>
  547. </button>
  548. <button class="btn btn-save" id="button_please_wait"></button>
  549. </td>
  550. </tr>
  551. </table>
  552. <?php
  553. } elseif (@$_POST['step6']) {
  554. //STEP 6 : INSTALLATION PROCESS
  555. $current_step = 7;
  556. $msg = get_lang('InstallExecution');
  557. if ($installType == 'update') {
  558. $msg = get_lang('UpdateExecution');
  559. }
  560. echo '<div class="RequirementHeading">
  561. <h2>'.display_step_sequence().$msg.'</h2>
  562. <div id="pleasewait" class="warning-message">'.get_lang('PleaseWaitThisCouldTakeAWhile').'</div>
  563. </div>';
  564. // Push the web server to send these strings before we start the real
  565. // installation process
  566. flush();
  567. $f = ob_get_contents();
  568. if (!empty($f)) {
  569. ob_flush(); //#5565
  570. }
  571. if ($installType == 'update') {
  572. remove_memory_and_time_limits();
  573. $manager = testDbConnect(
  574. $dbHostForm,
  575. $dbUsernameForm,
  576. $dbPassForm,
  577. $dbNameForm
  578. );
  579. $perm = api_get_permissions_for_new_directories();
  580. $perm_file = api_get_permissions_for_new_files();
  581. Log::notice('Starting migration process from '.$my_old_version.' ('.time().')');
  582. switch ($my_old_version) {
  583. case '1.9.0':
  584. case '1.9.2':
  585. case '1.9.4':
  586. case '1.9.6':
  587. case '1.9.6.1':
  588. case '1.9.8':
  589. case '1.9.8.1':
  590. case '1.9.8.2':
  591. case '1.9.10':
  592. case '1.9.10.2':
  593. // Fix type "enum" before running the migration with Doctrine
  594. Database::query("ALTER TABLE course_category MODIFY COLUMN auth_course_child VARCHAR(40) DEFAULT 'TRUE'");
  595. Database::query("ALTER TABLE course_category MODIFY COLUMN auth_cat_child VARCHAR(40) DEFAULT 'TRUE'");
  596. Database::query("ALTER TABLE c_quiz_answer MODIFY COLUMN hotspot_type varchar(40) default NULL");
  597. Database::query("ALTER TABLE c_tool MODIFY COLUMN target varchar(20) NOT NULL default '_self'");
  598. Database::query("ALTER TABLE c_link MODIFY COLUMN on_homepage char(10) NOT NULL default '0'");
  599. Database::query("ALTER TABLE c_blog_rating MODIFY COLUMN rating_type char(40) NOT NULL default 'post'");
  600. Database::query("ALTER TABLE c_survey MODIFY COLUMN anonymous char(10) NOT NULL default '0'");
  601. // Migrate using the file Version110.php
  602. migrate('110', 1, $dbNameForm, $dbUsernameForm, $dbPassForm, $dbHostForm, $manager);
  603. include 'update-files-1.9.0-1.10.0.inc.php';
  604. // Only updates the configuration.inc.php with the new version
  605. include 'update-configuration.inc.php';
  606. break;
  607. default:
  608. break;
  609. }
  610. } else {
  611. set_file_folder_permissions();
  612. $manager = testDbConnect(
  613. $dbHostForm,
  614. $dbUsernameForm,
  615. $dbPassForm,
  616. null
  617. );
  618. $dbNameForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbNameForm);
  619. // Drop and create the database anyways
  620. $manager->getConnection()->getSchemaManager()->dropAndCreateDatabase($dbNameForm);
  621. $manager = testDbConnect(
  622. $dbHostForm,
  623. $dbUsernameForm,
  624. $dbPassForm,
  625. $dbNameForm
  626. );
  627. $metadataList = $manager->getMetadataFactory()->getAllMetadata();
  628. $schema = $manager->getConnection()->getSchemaManager()->createSchema();
  629. // Create database schema
  630. $tool = new \Doctrine\ORM\Tools\SchemaTool($manager);
  631. $tool->createSchema($metadataList);
  632. $sysPath = api_get_path(SYS_PATH);
  633. finishInstallation(
  634. $manager,
  635. $sysPath,
  636. $encryptPassForm,
  637. $passForm,
  638. $adminLastName,
  639. $adminFirstName,
  640. $loginForm,
  641. $emailForm,
  642. $adminPhoneForm,
  643. $languageForm,
  644. $institutionForm,
  645. $institutionUrlForm,
  646. $campusForm,
  647. $allowSelfReg,
  648. $allowSelfRegProf
  649. );
  650. include 'install_files.inc.php';
  651. }
  652. display_after_install_message($installType);
  653. // Hide the "please wait" message sent previously
  654. echo '<script>$(\'#pleasewait\').hide(\'fast\');</script>';
  655. } elseif (@$_POST['step1'] || $badUpdatePath) {
  656. //STEP 1 : REQUIREMENTS
  657. //make sure that proposed path is set, shouldn't be necessary but...
  658. if (empty($proposedUpdatePath)) {
  659. $proposedUpdatePath = $_POST['updatePath'];
  660. }
  661. display_requirements($installType, $badUpdatePath, $proposedUpdatePath, $update_from_version_8);
  662. } else {
  663. // This is the start screen.
  664. display_language_selection();
  665. }
  666. ?>
  667. </form>
  668. </div> <!-- col-md-9-->
  669. </div> <!-- row -->
  670. </div> <!-- main end-->
  671. <div class="push"></div>
  672. </div><!-- wrapper end-->
  673. <footer></footer>
  674. </body>
  675. </html>