index.php 31 KB

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