index.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2008 Dokeos SPRL
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Olivier Brouckaert
  9. Copyright (c) Roan Embrechts, Vrije Universiteit Brussel
  10. For a full list of contributors, see "credits.txt".
  11. The full license can be read in "license.txt".
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. See the GNU General Public License for more details.
  17. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  18. Mail: info@dokeos.com
  19. ==============================================================================
  20. */
  21. /**
  22. ==============================================================================
  23. * GOAL : Dokeos installation
  24. * As seen from the user, the installation proceeds in 6 steps.
  25. * The user is presented with several webpages where he/she has to make choices
  26. * and/or fill in data.
  27. *
  28. * The aim is, as always, to have good default settings and suggestions.
  29. *
  30. * @todo reduce high level of duplication in this code
  31. * @todo (busy) organise code into functions
  32. * @package dokeos.install
  33. ==============================================================================
  34. */
  35. /*
  36. ==============================================================================
  37. INIT SECTION
  38. ==============================================================================
  39. */
  40. session_start();
  41. // Including necessary files
  42. @include('../inc/installedVersion.inc.php');
  43. require('../inc/lib/main_api.lib.php');
  44. require('../lang/english/trad4all.inc.php');
  45. require('../lang/english/install.inc.php');
  46. if (!empty($_POST['language_list']))
  47. {
  48. $search = array('../','\\0');
  49. $install_language = str_replace($search,'',urldecode($_POST['language_list']));
  50. if(!is_dir('../lang/'.$install_language)){$install_language = 'english';}
  51. include_once("../lang/$install_language/trad4all.inc.php");
  52. include_once("../lang/$install_language/install.inc.php");
  53. api_session_register('install_language');
  54. }
  55. elseif ( isset($_SESSION['install_language']) && $_SESSION['install_language'] )
  56. {
  57. $install_language = $_SESSION['install_language'];
  58. include_once("../lang/$install_language/trad4all.inc.php");
  59. include_once("../lang/$install_language/install.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. $charset = '';
  65. //force ISO-8859-15 for European languages. Leave Apache determine the encoding for others (HTML declaring UTF-8)
  66. $euro_langs = array('english','french','french_KM','french_corporate','french_org','dutch','spanish','german','italian','greek','danish','swedish','norwegian','polish','galician','catalan','czech','finnish');
  67. if (isset($install_language))
  68. {
  69. if(in_array($install_language,$euro_langs))
  70. {
  71. $charset = 'ISO-8859-15';
  72. header('Content-Type: text/html; charset='. $charset);
  73. }
  74. }
  75. require_once('install_upgrade.lib.php'); //also defines constants
  76. require_once('install_functions.inc.php');
  77. // Some constants
  78. define('DOKEOS_INSTALL',1);
  79. define('MAX_COURSE_TRANSFER',100);
  80. define('INSTALL_TYPE_UPDATE', 'update');
  81. define('FORM_FIELD_DISPLAY_LENGTH', 40);
  82. define('DATABASE_FORM_FIELD_DISPLAY_LENGTH', 25);
  83. define('MAX_FORM_FIELD_LENGTH', 80);
  84. define('DEFAULT_LANGUAGE', 'english');
  85. // setting the error reporting
  86. error_reporting(E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR);
  87. // overriding the timelimit (for large campusses that have to be migrated)
  88. @set_time_limit(0);
  89. //upgrading from any subversion of 1.6 is just like upgrading from 1.6.5
  90. $update_from_version_6=array('1.6','1.6.1','1.6.2','1.6.3','1.6.4','1.6.5');
  91. //upgrading from any subversion of 1.8 avoids the additional step of upgrading from 1.6
  92. $update_from_version_8=array('1.8','1.8.2','1.8.3','1.8.4','1.8.5');
  93. $my_old_version = '';
  94. $tmp_version = get_config_param('dokeos_version');
  95. if(!empty($_POST['old_version']))
  96. {
  97. $my_old_version = $_POST['old_version'];
  98. }
  99. elseif(!empty($tmp_version))
  100. {
  101. $my_old_version = $tmp_version;
  102. }
  103. elseif(!empty($dokeos_version)) //variable coming from installedVersion, normally
  104. {
  105. $my_old_version = $dokeos_version;
  106. }
  107. $new_version = '1.8.6';
  108. $new_version_stable = true;
  109. /*
  110. ==============================================================================
  111. STEP 1 : INITIALIZES FORM VARIABLES IF IT IS THE FIRST VISIT
  112. ==============================================================================
  113. */
  114. $badUpdatePath=false;
  115. $emptyUpdatePath=true;
  116. $proposedUpdatePath = '';
  117. if(!empty($_POST['updatePath']))
  118. {
  119. $proposedUpdatePath = $_POST['updatePath'];
  120. }
  121. if($_POST['step2_install'] || $_POST['step2_update_8'] || $_POST['step2_update_6'])
  122. {
  123. if($_POST['step2_install'])
  124. {
  125. $installType='new';
  126. $_POST['step2']=1;
  127. }
  128. else
  129. {
  130. $installType='update';
  131. if($_POST['step2_update_8'])
  132. {
  133. $emptyUpdatePath = false;
  134. if(empty($_POST['updatePath']))
  135. {
  136. $proposedUpdatePath = $_SERVER['DOCUMENT_ROOT'];
  137. }
  138. else
  139. {
  140. $proposedUpdatePath = $_POST['updatePath'];
  141. }
  142. if(substr($proposedUpdatePath,-1) != '/')
  143. {
  144. $proposedUpdatePath.='/';
  145. }
  146. if(file_exists($proposedUpdatePath))
  147. {
  148. if(in_array($my_old_version,$update_from_version_8))
  149. {
  150. $_POST['step2']=1;
  151. }
  152. else
  153. {
  154. $badUpdatePath=true;
  155. }
  156. }
  157. else
  158. {
  159. $badUpdatePath=true;
  160. }
  161. }
  162. else //step2_update_6, presumably
  163. {
  164. if(empty($_POST['updatePath']))
  165. {
  166. $_POST['step1']=1;
  167. }
  168. else
  169. {
  170. $emptyUpdatePath = false;
  171. if(substr($_POST['updatePath'],-1) != '/')
  172. {
  173. $_POST['updatePath'].='/';
  174. }
  175. if(file_exists($_POST['updatePath']))
  176. {
  177. //1.6.x
  178. $my_old_version = get_config_param('clarolineVersion',$_POST['updatePath']);
  179. if(in_array($my_old_version,$update_from_version_6))
  180. {
  181. $_POST['step2']=1;
  182. $proposedUpdatePath = $_POST['updatePath'];
  183. }
  184. else
  185. {
  186. $badUpdatePath=true;
  187. }
  188. }
  189. else
  190. {
  191. $badUpdatePath=true;
  192. }
  193. }
  194. }
  195. }
  196. }
  197. elseif($_POST['step1'])
  198. {
  199. $_POST['updatePath']='';
  200. $installType='';
  201. $updateFromConfigFile='';
  202. unset($_GET['running']);
  203. }
  204. else
  205. {
  206. $installType=$_GET['installType'];
  207. $updateFromConfigFile=$_GET['updateFromConfigFile'];
  208. }
  209. if($installType=='update' && in_array($my_old_version,$update_from_version_8))
  210. {
  211. include_once('../inc/conf/configuration.php');
  212. }
  213. if(!isset($_GET['running']))
  214. {
  215. $dbHostForm='localhost';
  216. $dbUsernameForm='root';
  217. $dbPassForm='';
  218. $dbPrefixForm='';
  219. $dbNameForm='dokeos_main';
  220. $dbStatsForm='dokeos_stats';
  221. $dbScormForm='dokeos_scorm';
  222. $dbUserForm='dokeos_user';
  223. // extract the path to append to the url if Dokeos is not installed on the web root directory
  224. $urlAppendPath=str_replace('/main/install/index.php','',api_get_self());
  225. $urlForm='http://'.$_SERVER['HTTP_HOST'].$urlAppendPath.'/';
  226. $pathForm=str_replace('\\','/',realpath('../..')).'/';
  227. $emailForm=$_SERVER['SERVER_ADMIN'];
  228. $email_parts = explode('@',$emailForm);
  229. if($email_parts[1] == 'localhost')
  230. {
  231. $emailForm .= '.localdomain';
  232. }
  233. $adminLastName='Doe';
  234. $adminFirstName='John';
  235. $loginForm='admin';
  236. $passForm=api_generate_password();
  237. $campusForm='My campus';
  238. $educationForm='Albert Einstein';
  239. $adminPhoneForm='(000) 001 02 03';
  240. $institutionForm='My Organisation';
  241. $institutionUrlForm='http://www.dokeos.com';
  242. $languageForm='english';
  243. $checkEmailByHashSent=0;
  244. $ShowEmailnotcheckedToStudent=1;
  245. $userMailCanBeEmpty=1;
  246. $allowSelfReg=1;
  247. $allowSelfRegProf=1;
  248. $enableTrackingForm=1;
  249. $singleDbForm=0;
  250. $encryptPassForm='md5';
  251. $session_lifetime=360000;
  252. }
  253. else
  254. {
  255. foreach($_POST as $key=>$val)
  256. {
  257. $magic_quotes_gpc=ini_get('magic_quotes_gpc')?true:false;
  258. if(is_string($val))
  259. {
  260. if($magic_quotes_gpc)
  261. {
  262. $val=stripslashes($val);
  263. }
  264. $val=trim($val);
  265. $_POST[$key]=$val;
  266. }
  267. elseif(is_array($val))
  268. {
  269. foreach($val as $key2=>$val2)
  270. {
  271. if($magic_quotes_gpc)
  272. {
  273. $val2=stripslashes($val2);
  274. }
  275. $val2=trim($val2);
  276. $_POST[$key][$key2]=$val2;
  277. }
  278. }
  279. $GLOBALS[$key]=$_POST[$key];
  280. }
  281. }
  282. // The Steps
  283. $total_steps=7;
  284. if (!$_POST)
  285. {
  286. $current_step=1;
  287. }
  288. elseif (!empty($_POST['language_list']) or !empty($_POST['step1']) or ((!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6']))) && ($emptyUpdatePath or $badUpdatePath)))
  289. {
  290. $current_step=2;
  291. }
  292. elseif (!empty($_POST['step2']) or (!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6'])) ))
  293. {
  294. $current_step=3;
  295. }
  296. elseif (!empty($_POST['step3']))
  297. {
  298. $current_step=4;
  299. }
  300. elseif (!empty($_POST['step4']))
  301. {
  302. $current_step=5;
  303. }
  304. elseif (!empty($_POST['step5']))
  305. {
  306. $current_step=6;
  307. }
  308. // Managing the $encryptPassForm
  309. if ($encryptPassForm=='1' ) {
  310. $encryptPassForm = 'md5';
  311. } elseif ($encryptPassForm=='0') {
  312. $encryptPassForm = 'none';
  313. }
  314. ?>
  315. <!DOCTYPE html
  316. PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  317. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  318. <html xmlns="http://www.w3.org/1999/xhtml">
  319. <head>
  320. <title>&mdash; <?php echo get_lang('DokeosInstallation').' &mdash; '.get_lang('Version_').' '.$new_version; ?></title>
  321. <style type="text/css" media="screen, projection">
  322. /*<![CDATA[*/
  323. @import "../css/public_admin/default.css";
  324. /*]]>*/
  325. </style>
  326. <script type="text/javascript" src="../inc/lib/javascript/jquery.js"></script>
  327. <script type="text/javascript" >
  328. $(document).ready( function() {
  329. //checked
  330. if ($('#singleDb1').attr('checked')==false) {
  331. $('#dbStatsForm').removeAttr('disabled');
  332. $('#dbUserForm').removeAttr('disabled');
  333. $('#dbStatsForm').attr('value','dokeos_stats');
  334. $('#dbUserForm').attr('value','dokeos_user');
  335. } else if($('#singleDb1').attr('checked')==true){
  336. $('#dbStatsForm').attr('disabled','disabled');
  337. $('#dbUserForm').attr('disabled','disabled');
  338. $('#dbStatsForm').attr('value','dokeos_main');
  339. $('#dbUserForm').attr('value','dokeos_main');
  340. }
  341. } );
  342. </script>
  343. <script type="text/javascript">
  344. function show_hide_tracking_and_user_db (my_option) {
  345. if (my_option=='singleDb1') {
  346. $('#dbStatsForm').attr('disabled','true');
  347. $('#dbUserForm').attr('disabled','true');
  348. $('#dbStatsForm').attr('value','dokeos_main');
  349. $('#dbUserForm').attr('value','dokeos_main');
  350. } else if (my_option=='singleDb0') {
  351. $('#dbStatsForm').removeAttr('disabled');
  352. $('#dbUserForm').removeAttr('disabled');
  353. $('#dbStatsForm').attr('value','dokeos_stats');
  354. $('#dbUserForm').attr('value','dokeos_user');
  355. }
  356. }
  357. </script>
  358. <script language="javascript">
  359. init_visibility=0;
  360. function show_hide_option() {
  361. if(init_visibility == 0) {
  362. document.getElementById('optional_param1').style.display = '';
  363. document.getElementById('optional_param2').style.display = '';
  364. if(document.getElementById('optional_param3'))
  365. {
  366. document.getElementById('optional_param3').style.display = '';
  367. }
  368. document.getElementById('optional_param4').style.display = '';
  369. document.getElementById('optional_param5').style.display = '';
  370. document.getElementById('optional_param6').style.display = '';
  371. init_visibility = 1;
  372. } else {
  373. document.getElementById('optional_param1').style.display = 'none';
  374. document.getElementById('optional_param2').style.display = 'none';
  375. if(document.getElementById('optional_param3')) {
  376. document.getElementById('optional_param3').style.display = 'none';
  377. }
  378. document.getElementById('optional_param4').style.display = 'none';
  379. document.getElementById('optional_param5').style.display = 'none';
  380. document.getElementById('optional_param6').style.display = 'none';
  381. init_visibility = 0;
  382. }
  383. }
  384. </script>
  385. <?php if(!empty($charset)){ ?>
  386. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset ?>" />
  387. <?php } ?>
  388. </head>
  389. <body dir="<?php echo $text_dir ?>">
  390. <div id="header">
  391. <div id="header1"><?php echo get_lang('DokeosInstallation').' &mdash; '.get_lang('Version_').' '.$new_version; ?><?php if($installType == 'new') echo ' &ndash; '.get_lang('NewInstallation'); else if($installType == 'update') echo ' &ndash; '.get_lang('UpdateFromDokeosVersion').(is_array($update_from_version)?implode('|',$update_from_version):''); ?></div>
  392. <div id="header2">&nbsp;</div>
  393. <div id="header3">&nbsp;</div>
  394. </div>
  395. <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); ?>">
  396. <div id="installation_steps">
  397. <img src="../img/bluelogo.gif" hspace="10" vspace="10" alt="Dokeos logo" />
  398. <ol>
  399. <li <?php step_active('1'); ?>><?php echo get_lang('InstallationLanguage'); ?></li>
  400. <li <?php step_active('2'); ?>><?php echo get_lang('Requirements'); ?></li>
  401. <li <?php step_active('3'); ?>><?php echo get_lang('Licence'); ?></li>
  402. <li <?php step_active('4'); ?>><?php echo get_lang('DBSetting'); ?></li>
  403. <li <?php step_active('5'); ?>><?php echo get_lang('CfgSetting'); ?></li>
  404. <li <?php step_active('6'); ?>><?php echo get_lang('PrintOverview'); ?></li>
  405. <li <?php step_active('7'); ?>><?php echo get_lang('Installing'); ?></li>
  406. </ol>
  407. </div>
  408. <table cellpadding="6" cellspacing="0" border="0" width="75%" align="center">
  409. <tr>
  410. <td>
  411. <input type="hidden" name="updatePath" value="<?php if(!$badUpdatePath) echo htmlentities($proposedUpdatePath); ?>" />
  412. <input type="hidden" name="urlAppendPath" value="<?php echo htmlentities($urlAppendPath); ?>" />
  413. <input type="hidden" name="pathForm" value="<?php echo htmlentities($pathForm); ?>" />
  414. <input type="hidden" name="urlForm" value="<?php echo htmlentities($urlForm); ?>" />
  415. <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" />
  416. <input type="hidden" name="dbUsernameForm" value="<?php echo htmlentities($dbUsernameForm); ?>" />
  417. <input type="hidden" name="dbPassForm" value="<?php echo htmlentities($dbPassForm); ?>" />
  418. <input type="hidden" name="singleDbForm" value="<?php echo htmlentities($singleDbForm); ?>" />
  419. <input type="hidden" name="dbPrefixForm" value="<?php echo htmlentities($dbPrefixForm); ?>" />
  420. <input type="hidden" name="dbNameForm" value="<?php echo htmlentities($dbNameForm); ?>" />
  421. <?php
  422. if($installType == 'update' OR $singleDbForm == 0)
  423. {
  424. ?>
  425. <input type="hidden" name="dbStatsForm" value="<?php echo htmlentities($dbStatsForm); ?>" />
  426. <input type="hidden" name="dbScormForm" value="<?php echo htmlentities($dbScormForm); ?>" />
  427. <input type="hidden" name="dbUserForm" value="<?php echo htmlentities($dbUserForm); ?>" />
  428. <?php
  429. }
  430. else
  431. {
  432. ?>
  433. <input type="hidden" name="dbStatsForm" value="<?php echo htmlentities($dbNameForm); ?>" />
  434. <input type="hidden" name="dbUserForm" value="<?php echo htmlentities($dbNameForm); ?>" />
  435. <?php
  436. }
  437. ?>
  438. <input type="hidden" name="enableTrackingForm" value="<?php echo htmlentities($enableTrackingForm); ?>" />
  439. <input type="hidden" name="allowSelfReg" value="<?php echo htmlentities($allowSelfReg); ?>" />
  440. <input type="hidden" name="allowSelfRegProf" value="<?php echo htmlentities($allowSelfRegProf); ?>" />
  441. <input type="hidden" name="emailForm" value="<?php echo htmlentities($emailForm); ?>" />
  442. <input type="hidden" name="adminLastName" value="<?php echo htmlentities($adminLastName); ?>" />
  443. <input type="hidden" name="adminFirstName" value="<?php echo htmlentities($adminFirstName); ?>" />
  444. <input type="hidden" name="adminPhoneForm" value="<?php echo htmlentities($adminPhoneForm); ?>" />
  445. <input type="hidden" name="loginForm" value="<?php echo htmlentities($loginForm); ?>" />
  446. <input type="hidden" name="passForm" value="<?php echo htmlentities($passForm); ?>" />
  447. <input type="hidden" name="languageForm" value="<?php echo htmlentities($languageForm); ?>" />
  448. <input type="hidden" name="campusForm" value="<?php echo htmlentities($campusForm); ?>" />
  449. <input type="hidden" name="educationForm" value="<?php echo htmlentities($educationForm); ?>" />
  450. <input type="hidden" name="institutionForm" value="<?php echo htmlentities($institutionForm); ?>" />
  451. <input type="hidden" name="institutionUrlForm" value="<?php echo stristr($institutionUrlForm,'http://')?htmlentities($institutionUrlForm):'http://'.htmlentities($institutionUrlForm); ?>" />
  452. <input type="hidden" name="checkEmailByHashSent" value="<?php echo htmlentities($checkEmailByHashSent); ?>" />
  453. <input type="hidden" name="ShowEmailnotcheckedToStudent" value="<?php echo htmlentities($ShowEmailnotcheckedToStudent); ?>" />
  454. <input type="hidden" name="userMailCanBeEmpty" value="<?php echo htmlentities($userMailCanBeEmpty); ?>" />
  455. <input type="hidden" name="encryptPassForm" value="<?php echo htmlentities($encryptPassForm); ?>" />
  456. <input type="hidden" name="session_lifetime" value="<?php echo htmlentities($session_lifetime); ?>" />
  457. <input type="hidden" name="old_version" value="<?php echo htmlentities($my_old_version); ?>" />
  458. <input type="hidden" name="new_version" value="<?php echo htmlentities($new_version); ?>" />
  459. <?php
  460. if($_POST['step2'])
  461. {
  462. //STEP 3 : LICENSE
  463. display_license_agreement();
  464. }
  465. elseif($_POST['step3'])
  466. {
  467. //STEP 4 : MYSQL DATABASE SETTINGS
  468. display_database_settings_form($installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbPrefixForm, $enableTrackingForm, $singleDbForm, $dbNameForm, $dbStatsForm, $dbScormForm, $dbUserForm);
  469. }
  470. elseif($_POST['step4'])
  471. {
  472. //STEP 5 : CONFIGURATION SETTINGS
  473. //if update, try getting settings from the database...
  474. if($installType == 'update')
  475. {
  476. $db_name = $dbNameForm;
  477. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'platformLanguage');
  478. if(!empty($tmp)) $languageForm = $tmp;
  479. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'emailAdministrator');
  480. if(!empty($tmp)) $emailForm = $tmp;
  481. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'administratorName');
  482. if(!empty($tmp)) $adminFirstName = $tmp;
  483. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'administratorSurname');
  484. if(!empty($tmp)) $adminLastName = $tmp;
  485. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'administratorTelephone');
  486. if(!empty($tmp)) $adminPhoneForm = $tmp;
  487. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'siteName');
  488. if(!empty($tmp)) $campusForm = $tmp;
  489. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'Institution');
  490. if(!empty($tmp)) $institutionForm = $tmp;
  491. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'InstitutionUrl');
  492. if(!empty($tmp)) $institutionUrlForm = $tmp;
  493. if(in_array($my_old_version,$update_from_version_6))
  494. { //for version 1.6
  495. $urlForm = get_config_param('rootWeb');
  496. $encryptPassForm = get_config_param('userPasswordCrypted');
  497. // Managing the $encryptPassForm
  498. if ($encryptPassForm=='1' ) {
  499. $encryptPassForm = 'md5';
  500. } elseif ($encryptPassForm=='0') {
  501. $encryptPassForm = 'none';
  502. }
  503. $allowSelfReg = get_config_param('allowSelfReg');
  504. $allowSelfRegProf = get_config_param('allowSelfRegProf');
  505. }
  506. else
  507. { //for version 1.8
  508. $urlForm = $_configuration['root_web'];
  509. $encryptPassForm = get_config_param('userPasswordCrypted');
  510. // Managing the $encryptPassForm
  511. if ($encryptPassForm=='1' ) {
  512. $encryptPassForm = 'md5';
  513. } elseif ($encryptPassForm=='0') {
  514. $encryptPassForm = 'none';
  515. }
  516. $allowSelfReg = false;
  517. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'allow_registration');
  518. if(!empty($tmp)) $allowSelfReg = $tmp;
  519. $allowSelfRegProf = false;
  520. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'allow_registration_as_teacher');
  521. if(!empty($tmp)) $allowSelfRegProf = $tmp;
  522. }
  523. }
  524. display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $allowSelfRegProf, $loginForm, $passForm);
  525. }
  526. elseif($_POST['step5'])
  527. {
  528. //STEP 6 : LAST CHECK BEFORE INSTALL
  529. ?>
  530. <h2><?php echo display_step_sequence().get_lang('LastCheck'); ?></h2>
  531. <?php echo get_lang('HereAreTheValuesYouEntered');?>
  532. <br />
  533. <b><?php echo get_lang('PrintThisPageToRememberPassAndOthers');?></b>
  534. <blockquote>
  535. <?php echo get_lang('MainLang').' : '.$languageForm; ?><br /><br />
  536. <?php echo get_lang('DBHost').' : '.$dbHostForm; ?><br />
  537. <?php echo get_lang('DBLogin').' : '.$dbUsernameForm; ?><br />
  538. <?php echo get_lang('DBPassword').' : '.str_repeat('*',strlen($dbPassForm)); ?><br />
  539. <?php if(!empty($dbPrefixForm)) echo get_lang('DbPrefixForm').' : '.$dbPrefixForm.'<br />'; ?>
  540. <?php echo get_lang('MainDB').' : <b>'.$dbNameForm; ?></b><?php if($installType == 'new') echo ' (<font color="#cc0033">'.get_lang('ReadWarningBelow').'</font>)'; ?><br />
  541. <?php
  542. if(!$singleDbForm)
  543. {
  544. echo get_lang('StatDB').' : <b>'.$dbStatsForm.'</b>';
  545. if($installType == 'new')
  546. {
  547. echo ' (<font color="#cc0033">'.get_lang('ReadWarningBelow').'</font>)';
  548. }
  549. echo '<br />';
  550. echo get_lang('ScormDB').' : <b>'.$dbScormForm.'</b>';
  551. if($installType == 'new')
  552. {
  553. echo ' (<font color="#cc0033">'.get_lang('ReadWarningBelow').'</font>)';
  554. }
  555. echo '<br />';
  556. echo get_lang('UserDB').' : <b>'.$dbUserForm.'</b>';
  557. if($installType == 'new')
  558. {
  559. echo ' (<font color="#cc0033">'.get_lang('ReadWarningBelow').'</font>)';
  560. }
  561. echo '<br />';
  562. }
  563. ?>
  564. <?php echo get_lang('EnableTracking').' : '.($enableTrackingForm?$langYes:$langNo); ?><br />
  565. <?php echo get_lang('SingleDb').' : '.($singleDbForm?$langOne:$langSeveral); ?><br /><br />
  566. <?php echo get_lang('AllowSelfReg').' : '.($allowSelfReg?$langYes:$langNo); ?><br />
  567. <?php echo get_lang('EncryptMethodUserPass').' : ';
  568. echo $encryptPassForm;
  569. ?><br /><br/>
  570. <?php echo get_lang('AdminEmail').' : '.$emailForm; ?><br />
  571. <?php echo get_lang('AdminLastName').' : '.$adminLastName; ?><br />
  572. <?php echo get_lang('AdminFirstName').' : '.$adminFirstName; ?><br />
  573. <?php echo get_lang('AdminPhone').' : '.$adminPhoneForm; ?><br />
  574. <?php if($installType == 'new'): ?>
  575. <?php echo get_lang('AdminLogin').' : <b>'.$loginForm; ?></b><br />
  576. <?php echo get_lang('AdminPass').' : <b>'.$passForm; ?></b><br /><br />
  577. <?php else: ?>
  578. <br />
  579. <?php endif; ?>
  580. <?php echo get_lang('CampusName').' : '.$campusForm; ?><br />
  581. <?php echo get_lang('InstituteShortName').' : '.$institutionForm; ?><br />
  582. <?php echo get_lang('InstituteURL').' : '.$institutionUrlForm; ?><br />
  583. <?php echo get_lang('DokeosURL').' : '.$urlForm; ?><br />
  584. </blockquote>
  585. <?php if($installType == 'new'): ?>
  586. <div style="background-color:#FFFFFF">
  587. <p align="center"><b><font color="red">
  588. <?php echo get_lang('Warning');?> !<br />
  589. <?php echo get_lang('TheInstallScriptWillEraseAllTables');?>
  590. </font></b></p>
  591. </div>
  592. <?php endif; ?>
  593. <table width="100%">
  594. <tr>
  595. <td><button type="submit" class="back" name="step4" value="&lt; <?php echo get_lang('Previous'); ?>" /><?php echo get_lang('Previous'); ?></button></td>
  596. <td align="right"><button class="save" type="submit" name="step6" value="<?php echo get_lang('InstallDokeos'); ?> &gt;" onclick="javascript:if(this.value == '<?php $msg = get_lang('PleaseWait');?>...') return false; else this.value='<?php $msg = get_lang('InstallDokeos');?>...';" ><?php echo $msg; ?></button></td>
  597. </tr>
  598. </table>
  599. <?php
  600. }
  601. elseif($_POST['step6'])
  602. {
  603. //STEP 6 : INSTALLATION PROCESS
  604. if($installType == 'update')
  605. {
  606. if(empty($my_old_version)){$my_old_version='1.8.5';} //we guess
  607. $_configuration['main_database'] = $dbNameForm;
  608. //$urlAppendPath = get_config_param('urlAppend');
  609. error_log('Starting migration process from '.$my_old_version.' ('.time().')',0);
  610. if ($userPasswordCrypted=='1' ) {
  611. $userPasswordCrypted = 'md5';
  612. } elseif ($userPasswordCrypted=='0') {
  613. $userPasswordCrypted = 'none';
  614. }
  615. switch($my_old_version)
  616. {
  617. case '1.6':
  618. case '1.6.0':
  619. case '1.6.1':
  620. case '1.6.2':
  621. case '1.6.3':
  622. case '1.6.4':
  623. case '1.6.5':
  624. include('update-db-1.6.x-1.8.0.inc.php');
  625. include('update-files-1.6.x-1.8.0.inc.php');
  626. //intentionally no break to continue processing
  627. case '1.8':
  628. case '1.8.0':
  629. include('update-db-1.8.0-1.8.2.inc.php');
  630. //intentionally no break to continue processing
  631. case '1.8.2':
  632. include('update-db-1.8.2-1.8.3.inc.php');
  633. //intentionally no break to continue processing
  634. case '1.8.3':
  635. include('update-db-1.8.3-1.8.4.inc.php');
  636. include('update-files-1.8.3-1.8.4.inc.php');
  637. case '1.8.4':
  638. include('update-db-1.8.4-1.8.5.inc.php');
  639. include('update-files-1.8.4-1.8.5.inc.php');
  640. case '1.8.5':
  641. include('update-db-1.8.5-1.8.6.inc.php');
  642. include('update-files-1.8.5-1.8.6.inc.php');
  643. default:
  644. break;
  645. }
  646. }
  647. else
  648. {
  649. include('install_db.inc.php');
  650. include('install_files.inc.php');
  651. }
  652. display_after_install_message($installType, $nbr_courses);
  653. }
  654. elseif($_POST['step1'] || $badUpdatePath)
  655. {
  656. //STEP 1 : REQUIREMENTS
  657. //make sure that proposed path is set, shouldn't be necessary but...
  658. if(empty($proposedUpdatePath)){$proposedUpdatePath = $_POST['updatePath'];}
  659. display_requirements($installType, $badUpdatePath, $proposedUpdatePath, $update_from_version_8, $update_from_version_6);
  660. }
  661. else
  662. {
  663. //start screen
  664. display_language_selection();
  665. }
  666. ?>
  667. </td>
  668. </tr>
  669. </table>
  670. </form>
  671. <br style="clear:both;" />
  672. <div id="footer">
  673. <div class="copyright"><?php echo get_lang('Platform');?> <a href="http://www.dokeos.com"> Dokeos <?php echo $new_version ?></a> &copy; <?php echo date('Y'); ?> </div>
  674. &nbsp;
  675. </div>
  676. </body>
  677. </html>