index.php 29 KB

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