index.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  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'; // TODO: This should be UTF-8 for some languages.
  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. document.getElementById('optionalparameters').innerHTML='<img src="../img/div_show.gif" alt="" /> <?php echo get_lang('OptionalParameters'); ?>';
  373. } else {
  374. document.getElementById('optional_param1').style.display = 'none';
  375. document.getElementById('optional_param2').style.display = 'none';
  376. if(document.getElementById('optional_param3')) {
  377. document.getElementById('optional_param3').style.display = 'none';
  378. }
  379. document.getElementById('optional_param4').style.display = 'none';
  380. document.getElementById('optional_param5').style.display = 'none';
  381. document.getElementById('optional_param6').style.display = 'none';
  382. document.getElementById('optionalparameters').innerHTML='<img src="../img/div_hide.gif" alt="" /> <?php echo get_lang('OptionalParameters'); ?>';
  383. init_visibility = 0;
  384. }
  385. }
  386. </script>
  387. <?php if(!empty($charset)){ ?>
  388. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset ?>" />
  389. <?php } ?>
  390. </head>
  391. <body dir="<?php echo $text_dir ?>">
  392. <div id="header">
  393. <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>
  394. <div id="header2">&nbsp;</div>
  395. <div id="header3">
  396. <ul>
  397. <li id="current"><a href="#"><span>Installation</span></a></li>
  398. </ul>
  399. </div>
  400. </div>
  401. <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); ?>">
  402. <div id="installation_steps">
  403. <img src="../img/bluelogo.gif" hspace="10" vspace="10" alt="Dokeos logo" />
  404. <ol>
  405. <li <?php step_active('1'); ?>><?php echo get_lang('InstallationLanguage'); ?></li>
  406. <li <?php step_active('2'); ?>><?php echo get_lang('Requirements'); ?></li>
  407. <li <?php step_active('3'); ?>><?php echo get_lang('Licence'); ?></li>
  408. <li <?php step_active('4'); ?>><?php echo get_lang('DBSetting'); ?></li>
  409. <li <?php step_active('5'); ?>><?php echo get_lang('CfgSetting'); ?></li>
  410. <li <?php step_active('6'); ?>><?php echo get_lang('PrintOverview'); ?></li>
  411. <li <?php step_active('7'); ?>><?php echo get_lang('Installing'); ?></li>
  412. </ol>
  413. </div>
  414. <table cellpadding="6" cellspacing="0" border="0" width="75%" align="center">
  415. <tr>
  416. <td>
  417. <input type="hidden" name="updatePath" value="<?php if(!$badUpdatePath) echo api_htmlentities($proposedUpdatePath, ENT_QUOTES, $charset); ?>" />
  418. <input type="hidden" name="urlAppendPath" value="<?php echo api_htmlentities($urlAppendPath, ENT_QUOTES, $charset); ?>" />
  419. <input type="hidden" name="pathForm" value="<?php echo api_htmlentities($pathForm, ENT_QUOTES, $charset); ?>" />
  420. <input type="hidden" name="urlForm" value="<?php echo api_htmlentities($urlForm, ENT_QUOTES, $charset); ?>" />
  421. <input type="hidden" name="dbHostForm" value="<?php echo api_htmlentities($dbHostForm, ENT_QUOTES, $charset); ?>" />
  422. <input type="hidden" name="dbUsernameForm" value="<?php echo api_htmlentities($dbUsernameForm, ENT_QUOTES, $charset); ?>" />
  423. <input type="hidden" name="dbPassForm" value="<?php echo api_htmlentities($dbPassForm, ENT_QUOTES, $charset); ?>" />
  424. <input type="hidden" name="singleDbForm" value="<?php echo api_htmlentities($singleDbForm, ENT_QUOTES, $charset); ?>" />
  425. <input type="hidden" name="dbPrefixForm" value="<?php echo api_htmlentities($dbPrefixForm, ENT_QUOTES, $charset); ?>" />
  426. <input type="hidden" name="dbNameForm" value="<?php echo api_htmlentities($dbNameForm, ENT_QUOTES, $charset); ?>" />
  427. <?php
  428. if($installType == 'update' OR $singleDbForm == 0)
  429. {
  430. ?>
  431. <input type="hidden" name="dbStatsForm" value="<?php echo api_htmlentities($dbStatsForm, ENT_QUOTES, $charset); ?>" />
  432. <input type="hidden" name="dbScormForm" value="<?php echo api_htmlentities($dbScormForm, ENT_QUOTES, $charset); ?>" />
  433. <input type="hidden" name="dbUserForm" value="<?php echo api_htmlentities($dbUserForm, ENT_QUOTES, $charset); ?>" />
  434. <?php
  435. }
  436. else
  437. {
  438. ?>
  439. <input type="hidden" name="dbStatsForm" value="<?php echo api_htmlentities($dbNameForm, ENT_QUOTES, $charset); ?>" />
  440. <input type="hidden" name="dbUserForm" value="<?php echo api_htmlentities($dbNameForm, ENT_QUOTES, $charset); ?>" />
  441. <?php
  442. }
  443. ?>
  444. <input type="hidden" name="enableTrackingForm" value="<?php echo api_htmlentities($enableTrackingForm, ENT_QUOTES, $charset); ?>" />
  445. <input type="hidden" name="allowSelfReg" value="<?php echo api_htmlentities($allowSelfReg, ENT_QUOTES, $charset); ?>" />
  446. <input type="hidden" name="allowSelfRegProf" value="<?php echo api_htmlentities($allowSelfRegProf, ENT_QUOTES, $charset); ?>" />
  447. <input type="hidden" name="emailForm" value="<?php echo api_htmlentities($emailForm, ENT_QUOTES, $charset); ?>" />
  448. <input type="hidden" name="adminLastName" value="<?php echo api_htmlentities($adminLastName, ENT_QUOTES, $charset); ?>" />
  449. <input type="hidden" name="adminFirstName" value="<?php echo api_htmlentities($adminFirstName, ENT_QUOTES, $charset); ?>" />
  450. <input type="hidden" name="adminPhoneForm" value="<?php echo api_htmlentities($adminPhoneForm, ENT_QUOTES, $charset); ?>" />
  451. <input type="hidden" name="loginForm" value="<?php echo api_htmlentities($loginForm, ENT_QUOTES, $charset); ?>" />
  452. <input type="hidden" name="passForm" value="<?php echo api_htmlentities($passForm, ENT_QUOTES, $charset); ?>" />
  453. <input type="hidden" name="languageForm" value="<?php echo api_htmlentities($languageForm, ENT_QUOTES, $charset); ?>" />
  454. <input type="hidden" name="campusForm" value="<?php echo api_htmlentities($campusForm, ENT_QUOTES, $charset); ?>" />
  455. <input type="hidden" name="educationForm" value="<?php echo api_htmlentities($educationForm, ENT_QUOTES, $charset); ?>" />
  456. <input type="hidden" name="institutionForm" value="<?php echo api_htmlentities($institutionForm, ENT_QUOTES, $charset); ?>" />
  457. <input type="hidden" name="institutionUrlForm" value="<?php echo api_stristr($institutionUrlForm, 'http://', false, $charset) ? api_htmlentities($institutionUrlForm, ENT_QUOTES, $charset) : api_stristr($institutionUrlForm, 'https://', false, $charset) ? api_htmlentities($institutionUrlForm, ENT_QUOTES, $charset) : 'http://'.api_htmlentities($institutionUrlForm, ENT_QUOTES, $charset); ?>" />
  458. <input type="hidden" name="checkEmailByHashSent" value="<?php echo api_htmlentities($checkEmailByHashSent, ENT_QUOTES, $charset); ?>" />
  459. <input type="hidden" name="ShowEmailnotcheckedToStudent" value="<?php echo api_htmlentities($ShowEmailnotcheckedToStudent, ENT_QUOTES, $charset); ?>" />
  460. <input type="hidden" name="userMailCanBeEmpty" value="<?php echo api_htmlentities($userMailCanBeEmpty, ENT_QUOTES, $charset); ?>" />
  461. <input type="hidden" name="encryptPassForm" value="<?php echo api_htmlentities($encryptPassForm, ENT_QUOTES, $charset); ?>" />
  462. <input type="hidden" name="session_lifetime" value="<?php echo api_htmlentities($session_lifetime, ENT_QUOTES, $charset); ?>" />
  463. <input type="hidden" name="old_version" value="<?php echo api_htmlentities($my_old_version, ENT_QUOTES, $charset); ?>" />
  464. <input type="hidden" name="new_version" value="<?php echo api_htmlentities($new_version, ENT_QUOTES, $charset); ?>" />
  465. <?php
  466. if($_POST['step2'])
  467. {
  468. //STEP 3 : LICENSE
  469. display_license_agreement();
  470. }
  471. elseif($_POST['step3'])
  472. {
  473. //STEP 4 : MYSQL DATABASE SETTINGS
  474. display_database_settings_form($installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbPrefixForm, $enableTrackingForm, $singleDbForm, $dbNameForm, $dbStatsForm, $dbScormForm, $dbUserForm);
  475. }
  476. elseif($_POST['step4'])
  477. {
  478. //STEP 5 : CONFIGURATION SETTINGS
  479. //if update, try getting settings from the database...
  480. if($installType == 'update')
  481. {
  482. $db_name = $dbNameForm;
  483. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'platformLanguage');
  484. if(!empty($tmp)) $languageForm = $tmp;
  485. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'emailAdministrator');
  486. if(!empty($tmp)) $emailForm = $tmp;
  487. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'administratorName');
  488. if(!empty($tmp)) $adminFirstName = $tmp;
  489. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'administratorSurname');
  490. if(!empty($tmp)) $adminLastName = $tmp;
  491. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'administratorTelephone');
  492. if(!empty($tmp)) $adminPhoneForm = $tmp;
  493. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'siteName');
  494. if(!empty($tmp)) $campusForm = $tmp;
  495. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'Institution');
  496. if(!empty($tmp)) $institutionForm = $tmp;
  497. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'InstitutionUrl');
  498. if(!empty($tmp)) $institutionUrlForm = $tmp;
  499. if(in_array($my_old_version,$update_from_version_6))
  500. { //for version 1.6
  501. $urlForm = get_config_param('rootWeb');
  502. $encryptPassForm = get_config_param('userPasswordCrypted');
  503. // Managing the $encryptPassForm
  504. if ($encryptPassForm=='1' ) {
  505. $encryptPassForm = 'md5';
  506. } elseif ($encryptPassForm=='0') {
  507. $encryptPassForm = 'none';
  508. }
  509. $allowSelfReg = get_config_param('allowSelfReg');
  510. $allowSelfRegProf = get_config_param('allowSelfRegProf');
  511. }
  512. else
  513. { //for version 1.8
  514. $urlForm = $_configuration['root_web'];
  515. $encryptPassForm = get_config_param('userPasswordCrypted');
  516. // Managing the $encryptPassForm
  517. if ($encryptPassForm=='1' ) {
  518. $encryptPassForm = 'md5';
  519. } elseif ($encryptPassForm=='0') {
  520. $encryptPassForm = 'none';
  521. }
  522. $allowSelfReg = false;
  523. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'allow_registration');
  524. if(!empty($tmp)) $allowSelfReg = $tmp;
  525. $allowSelfRegProf = false;
  526. $tmp = get_config_param_from_db($dbHostForm,$dbUsernameForm,$dbPassForm,$db_name,'allow_registration_as_teacher');
  527. if(!empty($tmp)) $allowSelfRegProf = $tmp;
  528. }
  529. }
  530. display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $allowSelfRegProf, $loginForm, $passForm);
  531. }
  532. elseif($_POST['step5'])
  533. {
  534. //STEP 6 : LAST CHECK BEFORE INSTALL
  535. ?>
  536. <h2><?php echo display_step_sequence().get_lang('LastCheck'); ?></h2>
  537. <?php echo get_lang('HereAreTheValuesYouEntered');?>
  538. <br />
  539. <b><?php echo get_lang('PrintThisPageToRememberPassAndOthers');?></b>
  540. <blockquote>
  541. <?php echo get_lang('MainLang').' : '.$languageForm; ?><br /><br />
  542. <?php echo get_lang('DBHost').' : '.$dbHostForm; ?><br />
  543. <?php echo get_lang('DBLogin').' : '.$dbUsernameForm; ?><br />
  544. <?php echo get_lang('DBPassword').' : '.str_repeat('*',strlen($dbPassForm)); ?><br />
  545. <?php if(!empty($dbPrefixForm)) echo get_lang('DbPrefixForm').' : '.$dbPrefixForm.'<br />'; ?>
  546. <?php echo get_lang('MainDB').' : <b>'.$dbNameForm; ?></b><?php if($installType == 'new') echo ' (<font color="#cc0033">'.get_lang('ReadWarningBelow').'</font>)'; ?><br />
  547. <?php
  548. if(!$singleDbForm)
  549. {
  550. echo get_lang('StatDB').' : <b>'.$dbStatsForm.'</b>';
  551. if($installType == 'new')
  552. {
  553. echo ' (<font color="#cc0033">'.get_lang('ReadWarningBelow').'</font>)';
  554. }
  555. echo '<br />';
  556. echo get_lang('ScormDB').' : <b>'.$dbScormForm.'</b>';
  557. if($installType == 'new')
  558. {
  559. echo ' (<font color="#cc0033">'.get_lang('ReadWarningBelow').'</font>)';
  560. }
  561. echo '<br />';
  562. echo get_lang('UserDB').' : <b>'.$dbUserForm.'</b>';
  563. if($installType == 'new')
  564. {
  565. echo ' (<font color="#cc0033">'.get_lang('ReadWarningBelow').'</font>)';
  566. }
  567. echo '<br />';
  568. }
  569. ?>
  570. <?php echo get_lang('EnableTracking').' : '.($enableTrackingForm?get_lang('Yes'):get_lang('No')); ?><br />
  571. <?php echo get_lang('SingleDb').' : '.($singleDbForm?get_lang('One'):get_lang('Several')); ?><br /><br />
  572. <?php echo get_lang('AllowSelfReg').' : '.($allowSelfReg?get_lang('Yes'):get_lang('No')); ?><br />
  573. <?php echo get_lang('EncryptMethodUserPass').' : ';
  574. echo $encryptPassForm;
  575. ?><br /><br/>
  576. <?php echo get_lang('AdminEmail').' : '.$emailForm; ?><br />
  577. <?php echo get_lang('AdminLastName').' : '.$adminLastName; ?><br />
  578. <?php echo get_lang('AdminFirstName').' : '.$adminFirstName; ?><br />
  579. <?php echo get_lang('AdminPhone').' : '.$adminPhoneForm; ?><br />
  580. <?php if($installType == 'new'): ?>
  581. <?php echo get_lang('AdminLogin').' : <b>'.$loginForm; ?></b><br />
  582. <?php echo get_lang('AdminPass').' : <b>'.$passForm; ?></b><br /><br />
  583. <?php else: ?>
  584. <br />
  585. <?php endif; ?>
  586. <?php echo get_lang('CampusName').' : '.$campusForm; ?><br />
  587. <?php echo get_lang('InstituteShortName').' : '.$institutionForm; ?><br />
  588. <?php echo get_lang('InstituteURL').' : '.$institutionUrlForm; ?><br />
  589. <?php echo get_lang('DokeosURL').' : '.$urlForm; ?><br />
  590. </blockquote>
  591. <?php if($installType == 'new'): ?>
  592. <div style="background-color:#FFFFFF">
  593. <p align="center"><b><font color="red">
  594. <?php echo get_lang('Warning');?> !<br />
  595. <?php echo get_lang('TheInstallScriptWillEraseAllTables');?>
  596. </font></b></p>
  597. </div>
  598. <?php endif; ?>
  599. <table width="100%">
  600. <tr>
  601. <td><button type="submit" class="back" name="step4" value="&lt; <?php echo get_lang('Previous'); ?>" /><?php echo get_lang('Previous'); ?></button></td>
  602. <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>
  603. </tr>
  604. </table>
  605. <?php
  606. }
  607. elseif($_POST['step6'])
  608. {
  609. //STEP 6 : INSTALLATION PROCESS
  610. if($installType == 'update')
  611. {
  612. if(empty($my_old_version)){$my_old_version='1.8.5';} //we guess
  613. $_configuration['main_database'] = $dbNameForm;
  614. //$urlAppendPath = get_config_param('urlAppend');
  615. error_log('Starting migration process from '.$my_old_version.' ('.time().')',0);
  616. if ($userPasswordCrypted=='1' ) {
  617. $userPasswordCrypted = 'md5';
  618. } elseif ($userPasswordCrypted=='0') {
  619. $userPasswordCrypted = 'none';
  620. }
  621. switch($my_old_version)
  622. {
  623. case '1.6':
  624. case '1.6.0':
  625. case '1.6.1':
  626. case '1.6.2':
  627. case '1.6.3':
  628. case '1.6.4':
  629. case '1.6.5':
  630. include('update-db-1.6.x-1.8.0.inc.php');
  631. include('update-files-1.6.x-1.8.0.inc.php');
  632. //intentionally no break to continue processing
  633. case '1.8':
  634. case '1.8.0':
  635. include('update-db-1.8.0-1.8.2.inc.php');
  636. //intentionally no break to continue processing
  637. case '1.8.2':
  638. include('update-db-1.8.2-1.8.3.inc.php');
  639. //intentionally no break to continue processing
  640. case '1.8.3':
  641. include('update-db-1.8.3-1.8.4.inc.php');
  642. include('update-files-1.8.3-1.8.4.inc.php');
  643. case '1.8.4':
  644. include('update-db-1.8.4-1.8.5.inc.php');
  645. include('update-files-1.8.4-1.8.5.inc.php');
  646. case '1.8.5':
  647. include('update-db-1.8.5-1.8.6.inc.php');
  648. include('update-files-1.8.5-1.8.6.inc.php');
  649. default:
  650. break;
  651. }
  652. }
  653. else
  654. {
  655. include('install_db.inc.php');
  656. include('install_files.inc.php');
  657. }
  658. display_after_install_message($installType, $nbr_courses);
  659. }
  660. elseif($_POST['step1'] || $badUpdatePath)
  661. {
  662. //STEP 1 : REQUIREMENTS
  663. //make sure that proposed path is set, shouldn't be necessary but...
  664. if(empty($proposedUpdatePath)){$proposedUpdatePath = $_POST['updatePath'];}
  665. display_requirements($installType, $badUpdatePath, $proposedUpdatePath, $update_from_version_8, $update_from_version_6);
  666. }
  667. else
  668. {
  669. //start screen
  670. display_language_selection();
  671. }
  672. ?>
  673. </td>
  674. </tr>
  675. </table>
  676. </form>
  677. <br style="clear:both;" />
  678. <div id="footer">
  679. <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>
  680. &nbsp;
  681. </div>
  682. </body>
  683. </html>