index.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  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, 44 rue des palais, 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. require('../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 ( isset($_POST['language_list']) && $_POST['language_list'] )
  47. {
  48. $install_language = $_POST['language_list'];
  49. include_once("../lang/$install_language/trad4all.inc.php");
  50. include_once("../lang/$install_language/install.inc.php");
  51. api_session_register('install_language');
  52. }
  53. elseif ( isset($_SESSION['install_language']) && $_SESSION['install_language'] )
  54. {
  55. $install_language = $_SESSION['install_language'];
  56. include_once("../lang/$install_language/trad4all.inc.php");
  57. include_once("../lang/$install_language/install.inc.php");
  58. }
  59. require_once('install_upgrade.lib.php');
  60. require_once('install_functions.inc.php');
  61. // Some constants
  62. define('DOKEOS_INSTALL',1);
  63. define('MAX_COURSE_TRANSFER',100);
  64. define("INSTALL_TYPE_UPDATE", "update");
  65. define("FORM_FIELD_DISPLAY_LENGTH", 40);
  66. define("DATABASE_FORM_FIELD_DISPLAY_LENGTH", 25);
  67. define("MAX_FORM_FIELD_LENGTH", 50);
  68. define("DEFAULT_LANGUAGE", "english");
  69. // setting the error reporting
  70. error_reporting(E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR);
  71. // overriding the timelimit (for large campusses that have to be migrated)
  72. @set_time_limit(0);
  73. //we hope in the future to add the ability to upgrade from 1.5.x versions
  74. //to 1.8 as well.
  75. $old_update_from_version=array('1.5','1.5.4','1.5.5','1.6');
  76. $update_from_version=array('1.6','1.6.1','1.6.2','1.6.3');
  77. /*
  78. ==============================================================================
  79. STEP 1 : INITIALIZES FORM VARIABLES IF IT IS THE FIRST VISIT
  80. ==============================================================================
  81. */
  82. $badUpdatePath=false;
  83. if($_POST['step2_install'] || $_POST['step2_update'])
  84. {
  85. if($_POST['step2_install'])
  86. {
  87. $installType='new';
  88. $_POST['step2']=1;
  89. }
  90. else
  91. {
  92. $installType='update';
  93. if(empty($_POST['updatePath']))
  94. {
  95. $_POST['step1']=1;
  96. }
  97. else
  98. {
  99. if($_POST['updatePath'][strlen($_POST['updatePath'])-1] != '/')
  100. {
  101. $_POST['updatePath'].='/';
  102. }
  103. if(file_exists($_POST['updatePath']))
  104. {
  105. if(in_array(get_config_param('clarolineVersion'),$update_from_version))
  106. {
  107. $_POST['step2']=1;
  108. }
  109. else
  110. {
  111. $badUpdatePath=true;
  112. }
  113. }
  114. else
  115. {
  116. $badUpdatePath=true;
  117. }
  118. }
  119. }
  120. }
  121. elseif($_POST['step1'])
  122. {
  123. $_POST['updatePath']='';
  124. $installType='';
  125. $updateFromConfigFile='';
  126. unset($_GET['running']);
  127. }
  128. else
  129. {
  130. $installType=$_GET['installType'];
  131. $updateFromConfigFile=$_GET['updateFromConfigFile'];
  132. }
  133. if(!isset($_GET['running']))
  134. {
  135. $dbHostForm='localhost';
  136. $dbUsernameForm='root';
  137. $dbPassForm='';
  138. $dbPrefixForm='';
  139. $dbNameForm='dokeos_main';
  140. $dbStatsForm='dokeos_stats';
  141. $dbScormForm='dokeos_scorm';
  142. $dbUserForm='dokeos_user';
  143. // extract the path to append to the url if Dokeos is not installed on the web root directory
  144. $urlAppendPath=str_replace('/main/install/index.php','',$_SERVER['PHP_SELF']);
  145. $urlForm='http://'.$_SERVER['HTTP_HOST'].$urlAppendPath.'/';
  146. $pathForm=str_replace('\\','/',realpath('../..')).'/';
  147. $emailForm=$_SERVER['SERVER_ADMIN'];
  148. $email_parts = explode('@',$emailForm);
  149. if($email_parts[1] == 'localhost')
  150. {
  151. $emailForm .= '.localdomain';
  152. }
  153. $adminLastName='Doe';
  154. $adminFirstName='John';
  155. $loginForm='admin';
  156. $passForm=api_generate_password();
  157. $campusForm='My campus';
  158. $educationForm='Albert Einstein';
  159. $adminPhoneForm='(000) 001 02 03';
  160. $institutionForm='My Organisation';
  161. $institutionUrlForm='http://www.dokeos.com';
  162. $languageForm='english';
  163. $checkEmailByHashSent=0;
  164. $ShowEmailnotcheckedToStudent=1;
  165. $userMailCanBeEmpty=1;
  166. $allowSelfReg=1;
  167. $allowSelfRegProf=1;
  168. $enableTrackingForm=1;
  169. $singleDbForm=0;
  170. $encryptPassForm=1;
  171. }
  172. else
  173. {
  174. foreach($_POST as $key=>$val)
  175. {
  176. $magic_quotes_gpc=ini_get('magic_quotes_gpc')?true:false;
  177. if(is_string($val))
  178. {
  179. if($magic_quotes_gpc)
  180. {
  181. $val=stripslashes($val);
  182. }
  183. $val=trim($val);
  184. $_POST[$key]=$val;
  185. }
  186. elseif(is_array($val))
  187. {
  188. foreach($val as $key2=>$val2)
  189. {
  190. if($magic_quotes_gpc)
  191. {
  192. $val2=stripslashes($val2);
  193. }
  194. $val2=trim($val2);
  195. $_POST[$key][$key2]=$val2;
  196. }
  197. }
  198. $GLOBALS[$key]=$_POST[$key];
  199. }
  200. }
  201. // The Steps
  202. $total_steps=7;
  203. if (!$_POST)
  204. {
  205. $current_step=1;
  206. }
  207. elseif ($_POST['language_list'])
  208. {
  209. $current_step=2;
  210. }
  211. elseif ($_POST['step2'])
  212. {
  213. $current_step=3;
  214. }
  215. elseif ($_POST['step3'])
  216. {
  217. $current_step=4;
  218. }
  219. elseif ($_POST['step4'])
  220. {
  221. $current_step=5;
  222. }
  223. elseif ($_POST['step5'])
  224. {
  225. $current_step=6;
  226. }
  227. ?>
  228. <!DOCTYPE html
  229. PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  230. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  231. <html xmlns="http://www.w3.org/1999/xhtml">
  232. <head>
  233. <title>&mdash; Dokeos installation &mdash; version <?php echo $dokeos_version; ?></title>
  234. <style type="text/css" media="screen, projection">
  235. /*<![CDATA[*/
  236. @import "../css/default/default.css";
  237. /*]]>*/
  238. </style>
  239. </head>
  240. <body dir="<?php echo $text_dir ?>">
  241. <div id="header">
  242. <div id="header1">Dokeos installation &ndash; version <?php echo $dokeos_version; ?><?php if($installType == 'new') echo ' &ndash; New installation'; else if($installType == 'update') echo ' &ndash; Update from Dokeos '.implode('|',$updateFromVersion); ?></div>
  243. <div class="clear"></div>
  244. <div id="header2">&nbsp;</div>
  245. <div id="header3">&nbsp;</div>
  246. </div>
  247. <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?running=1&amp;installType=<?php echo $installType; ?>&amp;updateFromConfigFile=<?php echo urlencode($updateFromConfigFile); ?>" autocomplete="off">
  248. <div id="installation_steps">
  249. <img src="../img/bluelogo.gif" hspace="10" vspace="10" alt="Dokeos logo" />
  250. <ol>
  251. <li <?php step_active('1'); ?>><?php echo get_lang('InstallationLanguage'); ?></li>
  252. <li <?php step_active('2'); ?>><?php echo get_lang('Requirements'); ?></li>
  253. <li <?php step_active('3'); ?>><?php echo get_lang('Licence'); ?></li>
  254. <li <?php step_active('4'); ?>><?php echo get_lang('DBSetting'); ?></li>
  255. <li <?php step_active('5'); ?>><?php echo get_lang('CfgSetting'); ?></li>
  256. <li <?php step_active('6'); ?>><?php echo get_lang('PrintOverview'); ?></li>
  257. <li <?php step_active('7'); ?>><?php echo get_lang('Installing'); ?></li>
  258. </ol>
  259. </div>
  260. <table cellpadding="6" cellspacing="0" border="0" width="80%" align="center">
  261. <tr>
  262. <td>
  263. <input type="hidden" name="updatePath" value="<?php if(!$badUpdatePath) echo htmlentities($_POST['updatePath']); ?>" />
  264. <input type="hidden" name="urlAppendPath" value="<?php echo htmlentities($urlAppendPath); ?>" />
  265. <input type="hidden" name="pathForm" value="<?php echo htmlentities($pathForm); ?>" />
  266. <input type="hidden" name="urlForm" value="<?php echo htmlentities($urlForm); ?>" />
  267. <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" />
  268. <input type="hidden" name="dbUsernameForm" value="<?php echo htmlentities($dbUsernameForm); ?>" />
  269. <input type="hidden" name="dbPassForm" value="<?php echo htmlentities($dbPassForm); ?>" />
  270. <input type="hidden" name="singleDbForm" value="<?php echo htmlentities($singleDbForm); ?>" />
  271. <input type="hidden" name="dbPrefixForm" value="<?php echo htmlentities($dbPrefixForm); ?>" />
  272. <input type="hidden" name="dbNameForm" value="<?php echo htmlentities($dbNameForm); ?>" />
  273. <input type="hidden" name="dbStatsForm" value="<?php echo htmlentities($dbStatsForm); ?>" />
  274. <input type="hidden" name="dbScormForm" value="<?php echo htmlentities($dbScormForm); ?>" />
  275. <input type="hidden" name="dbUserForm" value="<?php echo htmlentities($dbUserForm); ?>" />
  276. <input type="hidden" name="enableTrackingForm" value="<?php echo htmlentities($enableTrackingForm); ?>" />
  277. <input type="hidden" name="allowSelfReg" value="<?php echo htmlentities($allowSelfReg); ?>" />
  278. <input type="hidden" name="allowSelfRegProf" value="<?php echo htmlentities($allowSelfRegProf); ?>" />
  279. <input type="hidden" name="emailForm" value="<?php echo htmlentities($emailForm); ?>" />
  280. <input type="hidden" name="adminLastName" value="<?php echo htmlentities($adminLastName); ?>" />
  281. <input type="hidden" name="adminFirstName" value="<?php echo htmlentities($adminFirstName); ?>" />
  282. <input type="hidden" name="adminPhoneForm" value="<?php echo htmlentities($adminPhoneForm); ?>" />
  283. <input type="hidden" name="loginForm" value="<?php echo htmlentities($loginForm); ?>" />
  284. <input type="hidden" name="passForm" value="<?php echo htmlentities($passForm); ?>" />
  285. <input type="hidden" name="languageForm" value="<?php echo htmlentities($languageForm); ?>" />
  286. <input type="hidden" name="campusForm" value="<?php echo htmlentities($campusForm); ?>" />
  287. <input type="hidden" name="educationForm" value="<?php echo htmlentities($educationForm); ?>" />
  288. <input type="hidden" name="institutionForm" value="<?php echo htmlentities($institutionForm); ?>" />
  289. <input type="hidden" name="institutionUrlForm" value="<?php echo stristr($institutionUrlForm,'http://')?htmlentities($institutionUrlForm):'http://'.htmlentities($institutionUrlForm); ?>" />
  290. <input type="hidden" name="checkEmailByHashSent" value="<?php echo htmlentities($checkEmailByHashSent); ?>" />
  291. <input type="hidden" name="ShowEmailnotcheckedToStudent" value="<?php echo htmlentities($ShowEmailnotcheckedToStudent); ?>" />
  292. <input type="hidden" name="userMailCanBeEmpty" value="<?php echo htmlentities($userMailCanBeEmpty); ?>" />
  293. <input type="hidden" name="encryptPassForm" value="<?php echo htmlentities($encryptPassForm); ?>" />
  294. <?php
  295. if($_POST['step2'])
  296. {
  297. //STEP 3 : LICENSE
  298. display_license_agreement();
  299. }
  300. elseif($_POST['step3'])
  301. {
  302. //STEP 4 : MYSQL DATABASE SETTINGS
  303. display_database_settings_form($installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbPrefixForm, $enableTrackingForm, $singleDbForm, $dbNameForm, $dbStatsForm, $dbScormForm, $dbUserForm);
  304. }
  305. elseif($_POST['step4'])
  306. {
  307. //STEP 5 : CONFIGURATION SETTINGS
  308. display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $loginForm, $passForm);
  309. }
  310. elseif($_POST['step5'])
  311. {
  312. //STEP 6 : LAST CHECK BEFORE INSTALL
  313. ?>
  314. <h2><?php echo display_step_sequence().get_lang('LastCheck'); ?></h2>
  315. Here are the values you entered
  316. <br>
  317. <b>Print this page to remember your password and other settings</b>
  318. <blockquote>
  319. <?php echo $langMainLang.' : '.$languageForm; ?><br><br>
  320. <?php echo $langDBHost.' : '.$dbHostForm; ?><br>
  321. <?php echo $langDBLogin.' : '.$dbUsernameForm; ?><br>
  322. <?php echo $langDBPassword.' : '.$dbPassForm; ?><br>
  323. <?php if(!empty($dbPrefixForm)) echo $langDbPrefixForm.' : '.$dbPrefixForm.'<br>'; ?>
  324. <?php echo $langMainDB.' : <b>'.$dbNameForm; ?></b><?php if($installType == 'new') echo ' (<font color="#cc0033">read warning below</font>)'; ?><br>
  325. <?php if(!$singleDbForm) { ?>
  326. <?php echo $langStatDB.' : <b>'.$dbStatsForm; ?></b><?php if($installType == 'new') echo ' (<font color="#cc0033">read warning below</font>)'; ?><br>
  327. <?php echo $langScormDB.' : <b>'.$dbScormForm; ?></b><?php if($installType == 'new') echo ' (<font color="#cc0033">read warning below</font>)'; ?><br>
  328. <?php echo $langUserDB.' : <b>'.$dbUserForm; ?></b><?php if($installType == 'new') echo ' (<font color="#cc0033">read warning below</font>)'; ?><br>
  329. <?php } ?>
  330. <?php echo $langEnableTracking.' : '.($enableTrackingForm?$langYes:$langNo); ?><br>
  331. <?php echo $langSingleDb.' : '.($singleDbForm?$langOne:$langSeveral); ?><br><br>
  332. <?php echo $langAllowSelfReg.' : '.($allowSelfReg?$langYes:$langNo); ?><br>
  333. <?php echo $langEncryptUserPass.' : '.($encryptPassForm?$langYes:$langNo); ?><br><br>
  334. <?php echo $langAdminEmail.' : '.$emailForm; ?><br>
  335. <?php echo $langAdminLastName.' : '.$adminLastName; ?><br>
  336. <?php echo $langAdminFirstName.' : '.$adminFirstName; ?><br>
  337. <?php echo $langAdminPhone.' : '.$adminPhoneForm; ?><br>
  338. <?php if($installType == 'new'): ?>
  339. <?php echo $langAdminLogin.' : <b>'.$loginForm; ?></b><br>
  340. <?php echo $langAdminPass.' : <b>'.$passForm; ?></b><br><br>
  341. <?php else: ?>
  342. <br>
  343. <?php endif; ?>
  344. <?php echo $langCampusName.' : '.$campusForm; ?><br>
  345. <?php echo $langInstituteShortName.' : '.$institutionForm; ?><br>
  346. <?php echo $langInstituteURL.' : '.$institutionUrlForm; ?><br>
  347. <?php echo $langDokeosURL.' : '.$urlForm; ?><br>
  348. </blockquote>
  349. <?php if($installType == 'new'): ?>
  350. <div style="background-color:#FFFFFF">
  351. <p align="center"><b><font color="red">
  352. Warning !<br>
  353. The install script will erase all tables of the selected databases. We heavily recommend you do a full backup of them before confirming this last install step.
  354. </font></b></p>
  355. </div>
  356. <?php endif; ?>
  357. <table width="100%">
  358. <tr>
  359. <td><input type="submit" name="step4" value="&lt; <?php echo get_lang('Previous'); ?>" /></td>
  360. <td align="right"><input type="submit" name="step6" value="<?php echo get_lang('InstallDokeos'); ?> &gt;" onclick="javascript:if(this.value == 'Please Wait...') return false; else this.value='Please Wait...';" /></td>
  361. </tr>
  362. </table>
  363. <?php
  364. }
  365. elseif($_POST['step6'])
  366. {
  367. //STEP 6 : INSTALLATION PROCESS
  368. if($installType == 'update')
  369. {
  370. include('update_db.inc.php');
  371. include('update_files.inc.php');
  372. }
  373. else
  374. {
  375. include('install_db.inc.php');
  376. include('install_files.inc.php');
  377. }
  378. display_after_install_message($installType, $nbr_courses);
  379. }
  380. elseif($_POST['step1'] || $badUpdatePath)
  381. {
  382. //STEP 1 : REQUIREMENTS
  383. display_requirements($installType, $badUpdatePath, $update_from_version);
  384. }
  385. else
  386. {
  387. //start screen
  388. display_language_selection();
  389. }
  390. ?>
  391. </td>
  392. </tr>
  393. </table>
  394. </form>
  395. <br style="clear:both;" />
  396. <div id="footer">
  397. <div class="copyright">Platform <a href="http://www.dokeos.com"> Dokeos <?php echo $dokeos_version ?></a> &copy; 2006 </div>
  398. &nbsp;
  399. </div>
  400. </body>
  401. </html>