install_functions.inc.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958
  1. <?php
  2. /**
  3. * This function prints class=active_step $current_step=$param
  4. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  5. */
  6. function step_active($param)
  7. {
  8. global $current_step;
  9. if ($param==$current_step)
  10. {
  11. echo 'class="current_step" ';
  12. }
  13. }
  14. /**
  15. * This function displays the Step X of Y -
  16. */
  17. function display_step_sequence()
  18. {
  19. global $current_step;
  20. global $total_steps;
  21. return get_lang('Step').' '.$current_step.' '.get_lang('Of').' '.$total_steps.' &ndash; ';
  22. }
  23. /**
  24. * this function checks if a php extension exists or not
  25. *
  26. * @param string $extentionName name of the php extension to be checked
  27. * @param boolean $echoWhenOk true => show ok when the extension exists
  28. * @author Christophe Gesche
  29. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  30. * @version Dokeos 1.8, august 2006
  31. */
  32. function check_extension($extention_name,$return_success=false, $return_failure=false)
  33. {
  34. if(extension_loaded($extention_name))
  35. {
  36. return '<strong><font color="green">'.$return_success.'</font></strong>';
  37. }
  38. else
  39. {
  40. return '<strong><font color="red">'.$return_failure.'</font></strong>';
  41. //echo "\t<li><b>$extentionName</b> <font color=\"red\">is missing (Dokeos can work without it)</font> (<a href=\"http://www.php.net/$extentionName\" target=\"_blank\">$extentionName</a>)</li>\n";
  42. }
  43. }
  44. /**
  45. * This function checks if a php settings matches the recommended value
  46. *
  47. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  48. * @version Dokeos 1.8, august 2006
  49. */
  50. function check_php_setting($php_setting, $recommended_value, $return_success=false, $return_failure=false)
  51. {
  52. $current_php_value = get_php_setting($php_setting);
  53. if ( $current_php_value== $recommended_value)
  54. {
  55. return '<strong><font color="green">'.$current_php_value.' '.$return_success.'</font></strong>';
  56. }
  57. else
  58. {
  59. return '<strong><font color="red">'.$current_php_value.' '.$return_failure.'</font></strong>';
  60. }
  61. }
  62. /**
  63. * Enter description here...
  64. *
  65. * @param string $val a php ini value
  66. * @return boolean: ON or OFF
  67. * @author Joomla <http://www.joomla.org>
  68. */
  69. function get_php_setting($val) {
  70. $r = (ini_get($val) == '1' ? 1 : 0);
  71. return $r ? 'ON' : 'OFF';
  72. }
  73. /**
  74. * This function checks if the given folder is writable
  75. */
  76. function check_writable($folder)
  77. {
  78. if (is_writable('../'.$folder))
  79. {
  80. return '<strong><font color="green">'.get_lang('Writable').'</font></strong>';
  81. }
  82. else
  83. {
  84. return '<strong><font color="red">'.get_lang('NotWritable').'</font></strong>';
  85. }
  86. }
  87. /**
  88. * this function returns a string "FALSE" or "TRUE" according to the variable in parameter
  89. *
  90. * @param integer $var the variable to convert
  91. * @return string the string "FALSE" or "TRUE"
  92. * @author Christophe Gesche
  93. */
  94. function trueFalse($var)
  95. {
  96. return $var?'true':'false';
  97. }
  98. /**
  99. * this function returns a the value of a parameter from the configuration file
  100. *
  101. * WARNING - this function relies heavily on global variables $updateFromConfigFile
  102. * and $configFile, and also changes these globals. This can be rewritten.
  103. *
  104. * @param string $param the parameter which the value is returned for
  105. * @return string the value of the parameter
  106. * @author Olivier Brouckaert
  107. */
  108. function get_config_param($param)
  109. {
  110. global $configFile, $updateFromConfigFile;
  111. if(empty($updateFromConfigFile))
  112. {
  113. if(file_exists($_POST['updatePath'].'main/include/config.inc.php'))
  114. {
  115. $updateFromConfigFile='main/include/config.inc.php';
  116. }
  117. elseif(file_exists($_POST['updatePath'].'main/inc/conf/claro_main.conf.php'))
  118. {
  119. $updateFromConfigFile='main/inc/conf/claro_main.conf.php';
  120. }
  121. else
  122. {
  123. return;
  124. }
  125. }
  126. if(is_array($configFile) && isset($configFile[$param]))
  127. {
  128. return $configFile[$param];
  129. }
  130. elseif(file_exists($_POST['updatePath'].$updateFromConfigFile))
  131. {
  132. $configFile=array();
  133. $temp=file($_POST['updatePath'].$updateFromConfigFile);
  134. $val='';
  135. foreach($temp as $enreg)
  136. {
  137. if(strstr($enreg,'='))
  138. {
  139. $enreg=explode('=',$enreg);
  140. if($enreg[0][0] == '$')
  141. {
  142. list($enreg[1])=explode(' //',$enreg[1]);
  143. $enreg[0]=trim(str_replace('$','',$enreg[0]));
  144. $enreg[1]=str_replace('\"','"',ereg_replace('(^"|"$)','',substr(trim($enreg[1]),0,-1)));
  145. if(strtolower($enreg[1]) == 'true')
  146. {
  147. $enreg[1]=1;
  148. }
  149. if(strtolower($enreg[1]) == 'false')
  150. {
  151. $enreg[1]=0;
  152. }
  153. else
  154. {
  155. $implode_string=' ';
  156. if(!strstr($enreg[1],'." ".') && strstr($enreg[1],'.$'))
  157. {
  158. $enreg[1]=str_replace('.$','." ".$',$enreg[1]);
  159. $implode_string='';
  160. }
  161. $tmp=explode('." ".',$enreg[1]);
  162. foreach($tmp as $tmp_key=>$tmp_val)
  163. {
  164. if(eregi('^\$[a-z_][a-z0-9_]*$',$tmp_val))
  165. {
  166. $tmp[$tmp_key]=get_config_param(str_replace('$','',$tmp_val));
  167. }
  168. }
  169. $enreg[1]=implode($implode_string,$tmp);
  170. }
  171. $configFile[$enreg[0]]=$enreg[1];
  172. if($enreg[0] == $param)
  173. {
  174. $val=$enreg[1];
  175. }
  176. }
  177. }
  178. }
  179. return $val;
  180. }
  181. }
  182. /**
  183. * Return a list of language directories.
  184. * @todo function does not belong here, move to code library,
  185. * also see infocours.php which contains similar function
  186. */
  187. function get_language_folder_list($dirname)
  188. {
  189. if ($dirname[strlen($dirname)-1] != '/') $dirname .= '/';
  190. $handle = opendir($dirname);
  191. $language_list = array();
  192. while ($entries = readdir($handle))
  193. {
  194. if ($entries=='.' || $entries=='..' || $entries=='CVS' || $entries == '.svn') continue;
  195. if (is_dir($dirname.$entries))
  196. {
  197. $language_list[] = $entries;
  198. }
  199. }
  200. closedir($handle);
  201. return $language_list;
  202. }
  203. /*
  204. ==============================================================================
  205. DISPLAY FUNCTIONS
  206. ==============================================================================
  207. */
  208. /**
  209. * Displays a form (drop down menu) so the user can select
  210. * his/her preferred language.
  211. */
  212. function display_language_selection_box()
  213. {
  214. $langNameOfLang = get_lang('NameOfLang');
  215. //get language list
  216. $dirname = '../lang/';
  217. $language_list = get_language_folder_list($dirname);
  218. sort($language_list);
  219. $language_to_display = $language_list;
  220. //display
  221. echo "\t\t<select name=\"language_list\">\n";
  222. $default_language = 'english';
  223. foreach ($language_to_display as $key => $value)
  224. {
  225. if ($value == $default_language) $option_end = ' selected="selected">';
  226. else $option_end = '>';
  227. echo "\t\t\t<option value=\"$value\"$option_end";
  228. echo $value;
  229. echo "</option>\n";
  230. }
  231. echo "\t\t</select>\n";
  232. }
  233. /**
  234. * This function displays a language dropdown box so that the installatioin
  235. * can be done in the language of the user
  236. */
  237. function display_language_selection()
  238. { ?>
  239. <h1>Welcome to the Dokeos installer!</h1>
  240. <h2><?php echo display_step_sequence(); ?>Installation Language</h2>
  241. <p>Please select the language you'd like to use while installing:</p>
  242. <form id="lang_form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  243. <?php display_language_selection_box(); ?>
  244. <input type="submit" name="step1" value="Next &gt;" />
  245. </form>
  246. <?php }
  247. /**
  248. * This function displays the requirements for installing Dokeos.
  249. *
  250. * @param unknown_type $installType
  251. * @param unknown_type $badUpdatePath
  252. * @param unknown_type $update_from_version
  253. *
  254. * @author unknow
  255. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  256. */
  257. function display_requirements($installType, $badUpdatePath, $update_from_version)
  258. {
  259. echo '<h2>'.display_step_sequence().get_lang('Requirements')."</h2>\n";
  260. echo '<strong>'.get_lang('ReadThoroughly').'</strong><br />';
  261. echo get_lang('MoreDetails').' <a href="../../installation_guide.html" target="_blank">read the installation guide</a>.<br />'."\n";
  262. // SERVER REQUIREMENTS
  263. echo '<div class="RequirementHeading"><h1>'.get_lang('ServerRequirements').'</h1>';
  264. echo '<div class="RequirementText">'.get_lang('ServerRequirementsInfo').'</div>';
  265. echo '<div class="RequirementContent">';
  266. echo '<table class="requirements">
  267. <tr>
  268. <td class="requirements-item">'.get_lang('PHPVersion').'>= 4.1.0</td>
  269. <td class="requirements-value">';
  270. if (phpversion() < '4.1')
  271. {
  272. echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>';
  273. }
  274. else
  275. {
  276. echo '<strong><font color="green">'.get_lang('PHPVersionOK'). ' '.phpversion().'</font></strong>';
  277. }
  278. echo ' </td>
  279. </tr>
  280. <tr>
  281. <td class="requirements-item">session '.get_lang('support').'</td>
  282. <td class="requirements-value">'.check_extension('session',get_lang('OK'), get_lang('ExtensionSessionsNotAvailable')).'</td>
  283. </tr>
  284. <tr>
  285. <td class="requirements-item">MySQL '.get_lang('support').'</td>
  286. <td class="requirements-value">'.check_extension('mysql',get_lang('OK'), get_lang('ExtensionMySQLNotAvailable')).'</td>
  287. </tr>
  288. <tr>
  289. <td class="requirements-item">zlib '.get_lang('support').'</td>
  290. <td class="requirements-value">'.check_extension('zlib',get_lang('OK'), get_lang('ExtensionZlibNotAvailable')).'</td>
  291. </tr>
  292. <tr>
  293. <td class="requirements-item">Regular Expressions '.get_lang('support').'</td>
  294. <td class="requirements-value">'.check_extension('pcre',get_lang('OK'), get_lang('ExtensionPCRENotAvailable')).'</td>
  295. </tr>
  296. <tr>
  297. <td class="requirements-item">XML '.get_lang('support').'</td>
  298. <td class="requirements-value">'.check_extension('xml',get_lang('OK'), get_lang('ExtensionZlibNotAvailable')).'</td>
  299. </tr>
  300. <tr>
  301. <td class="requirements-item">LDAP '.get_lang('support').'('.get_lang('Optional').')</td>
  302. <td class="requirements-value">'.check_extension('ldap',get_lang('OK'), get_lang('ExtensionLDAPNotAvailable')).'</td>
  303. </tr>
  304. <tr>
  305. <td class="requirements-item">GD '.get_lang('support').'('.get_lang('Optional').')</td>
  306. <td class="requirements-value">'.check_extension('gd',get_lang('OK'), get_lang('ExtensionGDNotAvailable')).'</td>
  307. </tr>
  308. </table>';
  309. echo ' </div>';
  310. echo '</div>';
  311. // RECOMMENDED SETTINGS
  312. // Note: these are the settings for Joomla, does this also apply for Dokeos?
  313. // Note: also add upload_max_filesize here so that large uploads are possible
  314. echo '<div class="RequirementHeading"><h1>'.get_lang('RecommendedSettings').'</h1>';
  315. echo '<div class="RequirementText">'.get_lang('RecommendedSettingsInfo').'</div>';
  316. echo '<div class="RequirementContent">';
  317. echo '<table class="requirements">
  318. <tr>
  319. <th>'.get_lang('Setting').'</th>
  320. <th>'.get_lang('Recommended').'</th>
  321. <th>'.get_lang('Actual').'</th>
  322. </tr>
  323. <tr>
  324. <td class="requirements-item"><a href="http://php.net/manual/features.safe-mode.php">Safe Mode</a></td>
  325. <td class="requirements-recommended">OFF</td>
  326. <td class="requirements-value">'.check_php_setting('safe_mode','OFF').'</td>
  327. </tr>
  328. <tr>
  329. <td class="requirements-item">Display Errors</td>
  330. <td class="requirements-recommended">ON</td>
  331. <td class="requirements-value">'.check_php_setting('display_errors','ON').'</td>
  332. </tr>
  333. <tr>
  334. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.file-uploads">File Uploads</a></td>
  335. <td class="requirements-recommended">ON</td>
  336. <td class="requirements-value">'.check_php_setting('file_uploads','ON').'</td>
  337. </tr>
  338. <tr>
  339. <td class="requirements-item"><a href="http://php.net/manual/ref.info.php#ini.magic-quotes-gpc">Magic Quotes GPC</a></td>
  340. <td class="requirements-recommended">ON</td>
  341. <td class="requirements-value">'.check_php_setting('magic_quotes_gpc','ON').'</td>
  342. </tr>
  343. <tr>
  344. <td class="requirements-item"><a href="http://php.net/manual/ref.info.php#ini.magic-quotes-runtime">Magic Quotes Runtime</a></td>
  345. <td class="requirements-recommended">OFF</td>
  346. <td class="requirements-value">'.check_php_setting('magic_quotes_runtime','OFF').'</td>
  347. </tr>
  348. <tr>
  349. <td class="requirements-item"><a href="http://php.net/manual/security.globals.php">Register Globals</a></td>
  350. <td class="requirements-recommended">OFF</td>
  351. <td class="requirements-value">'.check_php_setting('register_globals','OFF').'</td>
  352. </tr>
  353. <tr>
  354. <td class="requirements-item">Output Buffering</td>
  355. <td class="requirements-recommended">ON</td>
  356. <td class="requirements-value">'.check_php_setting('output_buffering','ON').'</td>
  357. </tr>
  358. <tr>
  359. <td class="requirements-item">Session auto start</td>
  360. <td class="requirements-recommended">OFF</td>
  361. <td class="requirements-value">'.check_php_setting('session.auto_start','OFF').'</td>
  362. </tr>
  363. <tr>
  364. <td class="requirements-item">Short Open Tag</td>
  365. <td class="requirements-recommended">ON</td>
  366. <td class="requirements-value">'.check_php_setting('short_open_tag','ON').'</td>
  367. </tr>
  368. </table>';
  369. echo ' </div>';
  370. echo '</div>';
  371. // DIRECTORY AND FILE PERMISSIONS
  372. echo '<div class="RequirementHeading"><h1>'.get_lang('DirectoryAndFilePermissions').'</h1>';
  373. echo '<div class="RequirementText">'.get_lang('DirectoryAndFilePermissionsInfo').'</div>';
  374. echo '<div class="RequirementContent">';
  375. echo '<table class="requirements">
  376. <tr>
  377. <td class="requirements-item">dokeos/main/inc/conf/</td>
  378. <td class="requirements-value">'.check_writable('inc/conf/').'</td>
  379. </tr>
  380. <tr>
  381. <td class="requirements-item">dokeos/main/garbage/</td>
  382. <td class="requirements-value">'.check_writable('garbage/').'</td>
  383. </tr>
  384. <tr>
  385. <td class="requirements-item">dokeos/main/upload/</td>
  386. <td class="requirements-value">'.check_writable('upload/').'</td>
  387. </tr>
  388. <tr>
  389. <td class="requirements-item">dokeos/archive/</td>
  390. <td class="requirements-value">'.check_writable('../archive/').'</td>
  391. </tr>
  392. <tr>
  393. <td class="requirements-item">dokeos/courses/</td>
  394. <td class="requirements-value">'.check_writable('../courses/').'</td>
  395. </tr>
  396. <tr>
  397. <td class="requirements-item">dokeos/home/</td>
  398. <td class="requirements-value">'.check_writable('../home/').'</td>
  399. </tr>
  400. ';
  401. echo '</table>';
  402. echo ' </div>';
  403. echo '</div>';
  404. if($installType == 'update' && (empty($_POST['updatePath']) || $badUpdatePath))
  405. {
  406. if($badUpdatePath)
  407. { ?>
  408. <div style="color:red; background-color:white; font-weight:bold; text-align:center;">
  409. Error!<br />
  410. Dokeos <?php echo implode('|',$update_from_version); ?> has not been found in that directory.
  411. </div>
  412. <?php }
  413. else
  414. {
  415. echo '<br />';
  416. }
  417. ?>
  418. <table border="0" cellpadding="5" align="center">
  419. <tr>
  420. <td>Old version root path:</td>
  421. <td><input type="text" name="updatePath" size="50" value="<?php echo $badUpdatePath?htmlentities($_POST['updatePath']):$_SERVER['DOCUMENT_ROOT'].'/old_version/'; ?>" /></td>
  422. </tr>
  423. <tr>
  424. <td colspan="2" align="center">
  425. <input type="submit" name="step1" value="&lt; Back" />
  426. <input type="submit" name="step2_update" value="Next &gt;" />
  427. </td>
  428. </tr>
  429. </table>
  430. <?php
  431. }
  432. else
  433. {
  434. $error=false;
  435. //First, attempt to set writing permissions if we don't have them yet
  436. //0xxx is an octal number, this is the required format
  437. if(!is_writable('../inc/conf'))
  438. {
  439. $notwritable[]='../inc/conf';
  440. @chmod('../inc/conf',0777);
  441. }
  442. if(!is_writable('../garbage'))
  443. {
  444. $notwritable[]='../garbage';
  445. @chmod('../garbage',0777);
  446. }
  447. if(!is_writable('../upload'))
  448. {
  449. $notwritable[]='../upload';
  450. @chmod('../upload', 0777);
  451. }
  452. if(!is_writable('../../archive'))
  453. {
  454. $notwritable[]='../../archive';
  455. @chmod('../../archive',0777);
  456. }
  457. if(!is_writable('../../courses'))
  458. {
  459. $notwritable[]='../../courses';
  460. @chmod('../../courses',0777);
  461. }
  462. if(!is_writable('../../home'))
  463. {
  464. $notwritable[]='../../home';
  465. @chmod('../../home',0777);
  466. }
  467. if(file_exists('../inc/conf/claro_main.conf.php') && !is_writable('../inc/conf/claro_main.conf.php'))
  468. {
  469. $notwritable[]='../inc/conf/claro_main.conf.php';
  470. @chmod('../inc/conf/claro_main.conf.php',0666);
  471. }
  472. //Second, if this fails, report an error
  473. //--> the user will have to adjust the permissions manually
  474. if(!is_writable('../inc/conf') ||
  475. !is_writable('../garbage') ||
  476. !is_writable('../upload') ||
  477. !is_writable('../../archive') ||
  478. !is_writable('../../courses') ||
  479. !is_writable('../../home') ||
  480. (file_exists('../inc/conf/claro_main.conf.php') && !is_writable('../inc/conf/claro_main.conf.php')))
  481. {
  482. $error=true;
  483. ?>
  484. <div style="color:#cc0033; background-color:white; font-weight:bold; text-align:center;">
  485. Warning:<br />
  486. Some files or folders don't have writing permission. To be able to install Dokeos you should first change their permissions (using CHMOD). Please read the</font> <a href="../../installation_guide.html" target="blank">installation guide</a> <font color="#cc0033">.
  487. <?php
  488. if (is_array($notwritable) AND count($notwritable)>0)
  489. {
  490. echo '<ul>';
  491. foreach ($notwritable as $value)
  492. {
  493. echo '<li>'.$value.'</li>';
  494. }
  495. echo '<ul>';
  496. }
  497. ?>
  498. </div>
  499. <?php
  500. }
  501. // check wether a Dokeos configuration file already exists.
  502. elseif(file_exists('../inc/conf/claro_main.conf.php'))
  503. {
  504. echo '<div style="color:#cc0033; background-color:white; font-weight:bold; text-align:center;">';
  505. echo get_lang('WarningExistingDokeosInstallationDetected');
  506. echo '</div>';
  507. }
  508. ?>
  509. <p align="center">
  510. <input type="submit" name="step1" onclick="window.location='index.php';return false;" value="&lt; <?php echo get_lang('Previous'); ?>"/>
  511. <input type="submit" name="step2_install" value="<?php echo get_lang("NewInstallation"); ?>" <?php if($error) echo 'disabled="disabled"'; ?> />
  512. <?php
  513. //real code
  514. /* echo '<input type="submit" name="step2_update" value="Upgrade from Dokeos ' . implode(', ',$update_from_version) . '"';
  515. if($error) echo ' disabled="disabled"';*/
  516. //temporary code for alpha version, disabling upgrade
  517. echo '<input type="submit" name="step2_update" value="Upgrading is not possible in this beta version"';
  518. echo ' disabled="disabled"';
  519. //end temp code
  520. echo ' />';
  521. echo '</p>';
  522. }
  523. }
  524. /**
  525. * Displays the license (GNU GPL) as step 2, with
  526. * - an "I accept" button named step3 to proceed to step 3;
  527. * - a "Back" button named step1 to go back to the first step.
  528. */
  529. function display_license_agreement()
  530. {
  531. echo '<h2>'.display_step_sequence().get_lang('Licence').'</h2>';
  532. echo '<p>'.get_lang('DokeosLicenseInfo').'</p>';
  533. echo '<p><a href="../license/gpl_print.txt">'.get_lang('PrintVers').'</a></p>';
  534. ?>
  535. <table><tr><td>
  536. <p><textarea cols="75" rows="15" wrap="virtual"><?php include('../license/gpl.txt'); ?></textarea></p>
  537. </td>
  538. </tr>
  539. <tr>
  540. <td>
  541. <table width="100%">
  542. <tr>
  543. <td></td>
  544. <td align="right">
  545. <input type="submit" name="step1" value="&lt; <?php echo get_lang('Previous'); ?>" />
  546. <input type="submit" name="step3" value="<?php echo get_lang('IAccept'); ?> &gt;" />
  547. </td>
  548. </tr>
  549. </table>
  550. </td></tr></table>
  551. <?php
  552. }
  553. /**
  554. * Displays a parameter in a table row.
  555. * Used by the display_database_settings_form function.
  556. */
  557. function display_database_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $extra_notice, $display_when_update = 'true')
  558. {
  559. echo "<tr>\n";
  560. echo "<td>$parameter_name&nbsp;&nbsp;</td>\n";
  561. if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update)
  562. {
  563. echo '<td><input type="hidden" name="'.$form_field_name.'" value="'.htmlentities($parameter_value).'" />'.$parameter_value."</td>\n";
  564. }
  565. else
  566. {
  567. echo '<td><input type="text" size="'.DATABASE_FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.MAX_FORM_FIELD_LENGTH.'" name="'.$form_field_name.'" value="'.htmlentities($parameter_value).'" />'."</td>\n";
  568. echo "<td>$extra_notice</td>\n";
  569. }
  570. echo "</tr>\n";
  571. }
  572. /**
  573. * Displays step 3 - a form where the user can enter the installation settings
  574. * regarding the databases - login and password, names, prefixes, single
  575. * or multiple databases, tracking or not...
  576. */
  577. function display_database_settings_form($installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbPrefixForm, $enableTrackingForm, $singleDbForm, $dbNameForm, $dbStatsForm, $dbScormForm, $dbUserForm)
  578. {
  579. if($installType == 'update')
  580. {
  581. $dbHostForm=get_config_param('dbHost');
  582. $dbUsernameForm=get_config_param('dbLogin');
  583. $dbPassForm=get_config_param('dbPass');
  584. $dbPrefixForm=get_config_param('dbNamePrefix');
  585. $enableTrackingForm=get_config_param('is_trackingEnabled');
  586. $singleDbForm=get_config_param('singleDbEnabled');
  587. $dbNameForm=get_config_param('mainDbName');
  588. $dbStatsForm=get_config_param('statsDbName');
  589. $dbScormForm=get_config_param('scormDbName');
  590. $dbScormExists=true;
  591. if(empty($dbScormForm))
  592. {
  593. if($singleDbForm)
  594. {
  595. $dbScormForm=$dbNameForm;
  596. }
  597. else
  598. {
  599. $dbScormForm=$dbPrefixForm.'scorm';
  600. $dbScormExists=false;
  601. }
  602. }
  603. if($singleDbForm)
  604. {
  605. $dbUserForm=$dbNameForm;
  606. }
  607. else
  608. {
  609. $dbUserForm=$dbPrefixForm.'dokeos_user';
  610. }
  611. }
  612. echo "<h2>" . display_step_sequence() .get_lang("DBSetting") . "</h2>";
  613. echo get_lang("DBSettingIntro");
  614. ?>
  615. <br /><br />
  616. </td>
  617. </tr>
  618. <tr>
  619. <td>
  620. <table width="100%">
  621. <tr>
  622. <td width="40%"><?php echo get_lang('DBHost'); ?> </td>
  623. <?php if($installType == 'update'): ?>
  624. <td width="30%"><input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?></td>
  625. <td width="30%">&nbsp;</td>
  626. <?php else: ?>
  627. <td width="30%"><input type="text" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /></td>
  628. <td width="30%"><?php echo get_lang('EG').' localhost'; ?></td>
  629. <?php endif; ?>
  630. </tr>
  631. <?php
  632. //database user username
  633. $example_login = get_lang('EG').' root';
  634. display_database_parameter($installType, get_lang('DBLogin'), 'dbUsernameForm', $dbUsernameForm, $example_login);
  635. //database user password
  636. $example_password = get_lang('EG').' '.api_generate_password();
  637. display_database_parameter($installType, get_lang('DBPassword'), 'dbPassForm', $dbPassForm, $example_password);
  638. //database prefix
  639. display_database_parameter($installType, get_lang('DbPrefixForm'), 'dbPrefixForm', $dbPrefixForm, get_lang('DbPrefixCom'));
  640. //fields for the four standard Dokeos databases
  641. display_database_parameter($installType, get_lang('MainDB'), 'dbNameForm', $dbNameForm, '&nbsp;');
  642. display_database_parameter($installType, get_lang('StatDB'), 'dbStatsForm', $dbStatsForm, '&nbsp;');
  643. display_database_parameter($installType, get_lang('ScormDB'), 'dbScormForm', $dbScormForm, '&nbsp;');
  644. display_database_parameter($installType, get_lang('UserDB'), 'dbUserForm', $dbUserForm, '&nbsp;');
  645. ?>
  646. <tr>
  647. <td><?php echo get_lang('EnableTracking'); ?> </td>
  648. <?php if($installType == 'update'): ?>
  649. <td><input type="hidden" name="enableTrackingForm" value="<?php echo $enableTrackingForm; ?>" /><?php echo $enableTrackingForm? get_lang('Yes') : get_lang('No'); ?></td>
  650. <?php else: ?>
  651. <td>
  652. <input class="checkbox" type="radio" name="enableTrackingForm" value="1" id="enableTracking1" <?php echo $enableTrackingForm?'checked="checked" ':''; ?>/> <label for="enableTracking1"><?php echo get_lang('Yes'); ?></label>
  653. <input class="checkbox" type="radio" name="enableTrackingForm" value="0" id="enableTracking0" <?php echo $enableTrackingForm?'':'checked="checked" '; ?>/> <label for="enableTracking0"><?php echo get_lang('No'); ?></label>
  654. </td>
  655. <?php endif; ?>
  656. <td>&nbsp;</td>
  657. </tr>
  658. <tr>
  659. <td><?php echo get_lang('SingleDb'); ?> </td>
  660. <?php if($installType == 'update'): ?>
  661. <td><input type="hidden" name="singleDbForm" value="<?php echo $singleDbForm; ?>" /><?php echo $singleDbForm? get_lang('One') : get_lang('Several'); ?></td>
  662. <?php else: ?>
  663. <td>
  664. <input class="checkbox" type="radio" name="singleDbForm" value="1" id="singleDb1" <?php echo $singleDbForm?'checked="checked" ':''; ?>/> <label for="singleDb1"><?php echo get_lang('One'); ?></label>
  665. <input class="checkbox" type="radio" name="singleDbForm" value="0" id="singleDb0" <?php echo $singleDbForm?'':'checked="checked" '; ?>/> <label for="singleDb0"><?php echo get_lang('Several'); ?></label>
  666. </td>
  667. <?php endif; ?>
  668. <td>&nbsp;</td>
  669. </tr>
  670. <tr>
  671. <td><input type="submit" name="step3" value="<?php echo get_lang('CheckDatabaseConnection'); ?>" /> </td>
  672. <?php if (mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm) !== false): ?>
  673. <td colspan="2">
  674. <div class="confirmation-message">
  675. <div style="float:left; margin-right:10px;">
  676. <img src="../img/message_confirmation.png" alt="Confirmation" />
  677. </div>
  678. <div style="float:left;">
  679. MySQL host info: <?php echo mysql_get_host_info(); ?><br />
  680. MySQL server version: <?php echo mysql_get_server_info(); ?><br />
  681. MySQL protocol version: <?php echo mysql_get_proto_info(); ?>
  682. </div>
  683. <div style="clear:both;"
  684. </div>
  685. </td>
  686. <?php else: ?>
  687. <td colspan="2">
  688. <div class="error-message">
  689. <div style="float:left; margin-right:10px;">
  690. <img src="../img/message_error.png" alt="Error" />
  691. </div>
  692. <div style="float:left;">
  693. <strong>MySQL error: <?php echo mysql_errno(); ?></strong><br />
  694. <?php echo mysql_error(); ?>
  695. </div>
  696. </div>
  697. </td>
  698. <?php endif; ?>
  699. </tr>
  700. <tr>
  701. <td><input type="submit" name="step2" value="&lt; <?php echo get_lang('Previous'); ?>" /></td>
  702. <td>&nbsp;</td>
  703. <td align="right"><input type="submit" name="step4" value="<?php echo get_lang('Next'); ?> &gt;" /></td>
  704. </tr>
  705. </table>
  706. <?php
  707. }
  708. /**
  709. * Displays a parameter in a table row.
  710. * Used by the display_configuration_settings_form function.
  711. */
  712. function display_configuration_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $display_when_update = 'true')
  713. {
  714. echo "<tr>\n";
  715. echo "<td>$parameter_name&nbsp;&nbsp;</td>\n";
  716. if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update)
  717. {
  718. echo '<td><input type="hidden" name="'.$form_field_name.'" value="'.htmlentities($parameter_value).'" />'.$parameter_value."</td>\n";
  719. }
  720. else
  721. {
  722. echo '<td><input type="text" size="'.FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.MAX_FORM_FIELD_LENGTH.'" name="'.$form_field_name.'" value="'.htmlentities($parameter_value).'" />'."</td>\n";
  723. }
  724. echo "</tr>\n";
  725. }
  726. /**
  727. * Displays step 4 of the installation - configuration settings about Dokeos itself.
  728. */
  729. function display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $loginForm, $passForm)
  730. {
  731. if($installType == 'update')
  732. {
  733. $languageForm=get_config_param('platformLanguage');
  734. $emailForm=get_config_param('emailAdministrator');
  735. list($adminFirstName,$adminLastName)=explode(' ',get_config_param('administrator["name"]'));
  736. $adminPhoneForm=get_config_param('administrator["phone"]');
  737. $campusForm=get_config_param('siteName');
  738. $institutionForm=get_config_param('institution["name"]');
  739. $institutionUrlForm=get_config_param('institution["url"]');
  740. $encryptPassForm=get_config_param('userPasswordCrypted');
  741. $allowSelfReg=get_config_param('allowSelfReg');
  742. }
  743. else
  744. {
  745. $languageForm = $_SESSION['install_language'];
  746. }
  747. echo "<h2>" . display_step_sequence() . get_lang("CfgSetting") . "</h2>";
  748. echo '<p>'.get_lang('ConfigSettingsInfo').'</p>';
  749. echo "</td></tr>\n<tr><td>";
  750. echo "<table width=\"100%\">";
  751. //First parameter: language
  752. echo "<tr>\n";
  753. echo '<td>'.get_lang('MainLang')."&nbsp;&nbsp;</td>\n";
  754. if($installType == 'update')
  755. {
  756. echo '<td><input type="hidden" name="languageForm" value="'.htmlentities($languageForm).'" />'.$languageForm."</td>\n";
  757. }
  758. else // new installation
  759. {
  760. echo '<td>';
  761. echo "<select name=\"languageForm\">\n";
  762. $dirname='../lang/';
  763. if($dir=@opendir($dirname))
  764. {
  765. while($file=readdir($dir))
  766. {
  767. if($file != '.' && $file != '..' && $file != 'CVS' && $file != '.svn' && is_dir($dirname.$file))
  768. {
  769. echo '<option value="'.$file.'"';
  770. if($file == $languageForm) echo ' selected="selected"';
  771. echo ">$file</option>\n";
  772. }
  773. }
  774. closedir($dir);
  775. }
  776. echo '</select>';
  777. echo "</td>\n";
  778. }
  779. echo "</tr>\n";
  780. //Second parameter: Dokeos URL
  781. echo "<tr>\n";
  782. echo '<td>'.get_lang('DokeosURL').' (<font color="#cc0033">'.get_lang('ThisFieldIsRequired')."</font>)&nbsp;&nbsp;</td>\n";
  783. echo '<td><input type="text" size="40" maxlength="100" name="urlForm" value="'.htmlentities($urlForm).'" />'."</td>\n";
  784. echo "</tr>\n";
  785. //Parameter 3: administrator's email
  786. display_configuration_parameter($installType, get_lang("AdminEmail"), "emailForm", $emailForm);
  787. //Parameter 4: administrator's last name
  788. display_configuration_parameter($installType, get_lang("AdminLastName"), "adminLastName", $adminLastName);
  789. //Parameter 5: administrator's first name
  790. display_configuration_parameter($installType, get_lang("AdminFirstName"), "adminFirstName", $adminFirstName);
  791. //Parameter 6: administrator's telephone
  792. display_configuration_parameter($installType, get_lang("AdminPhone"), "adminPhoneForm", $adminPhoneForm);
  793. //Parameter 7: administrator's login
  794. display_configuration_parameter($installType, get_lang("AdminLogin"), "loginForm", $loginForm, false);
  795. //Parameter 8: administrator's password
  796. display_configuration_parameter($installType, get_lang("AdminPass"), "passForm", $passForm, false);
  797. //Parameter 9: campus name
  798. display_configuration_parameter($installType, get_lang("CampusName"), "campusForm", $campusForm);
  799. //Parameter 10: institute (short) name
  800. display_configuration_parameter($installType, get_lang("InstituteShortName"), "institutionForm", $institutionForm);
  801. //Parameter 11: institute (short) name
  802. display_configuration_parameter($installType, get_lang("InstituteURL"), "institutionUrlForm", $institutionUrlForm);
  803. ?>
  804. <tr>
  805. <td><?php echo get_lang("EncryptUserPass"); ?> :</td>
  806. <?php if($installType == 'update'): ?>
  807. <td><input type="hidden" name="encryptPassForm" value="<?php echo $encryptPassForm; ?>" /><?php echo $encryptPassForm? get_lang("Yes") : get_lang("No"); ?></td>
  808. <?php else: ?>
  809. <td>
  810. <input class="checkbox" type="radio" name="encryptPassForm" value="1" id="encryptPass1" <?php echo $encryptPassForm?'checked="checked" ':''; ?>/> <label for="encryptPass1"><?php echo get_lang("Yes"); ?></label>
  811. <input class="checkbox" type="radio" name="encryptPassForm" value="0" id="encryptPass0" <?php echo $encryptPassForm?'':'checked="checked" '; ?>/> <label for="encryptPass0"><?php echo get_lang("No"); ?></label>
  812. </td>
  813. <?php endif; ?>
  814. </tr>
  815. <tr>
  816. <td><?php echo get_lang("AllowSelfReg"); ?> :</td>
  817. <?php if($installType == 'update'): ?>
  818. <td><input type="hidden" name="allowSelfReg" value="<?php echo $allowSelfReg; ?>" /><?php echo $allowSelfReg? get_lang("Yes") : get_lang("No"); ?></td>
  819. <?php else: ?>
  820. <td>
  821. <input class="checkbox" type="radio" name="allowSelfReg" value="1" id="allowSelfReg1" <?php echo $allowSelfReg?'checked="checked" ':''; ?>/> <label for="allowSelfReg1"><?php echo get_lang("Yes").' '.get_lang("Recommended"); ?></label>
  822. <input class="checkbox" type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" <?php echo $allowSelfReg?'':'checked="checked" '; ?>/> <label for="allowSelfReg0"><?php echo get_lang("No"); ?></label>
  823. </td>
  824. <?php endif; ?>
  825. </tr>
  826. <tr>
  827. <td><?php echo get_lang("AllowSelfRegProf"); ?> :</td>
  828. <?php if($installType == 'update'): ?>
  829. <td><input type="hidden" name="allowSelfRegProf" value="<?php echo $allowSelfRegProf; ?>" /><?php echo $allowSelfRegProf? get_lang("Yes") : get_lang("No"); ?></td>
  830. <?php else: ?>
  831. <td>
  832. <input class="checkbox" type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" <?php echo $allowSelfRegProf?'checked="checked" ':''; ?>/> <label for="allowSelfRegProf1"><?php echo get_lang("Yes"); ?></label>
  833. <input class="checkbox" type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" <?php echo $allowSelfRegProf?'':'checked="checked" '; ?>/> <label for="allowSelfRegProf0"><?php echo get_lang("No"); ?></label>
  834. </td>
  835. <?php endif; ?>
  836. </tr>
  837. <tr>
  838. <td><input type="submit" name="step3" value="&lt; <?php echo get_lang('Previous'); ?>" /></td>
  839. <td align="right"><input type="submit" name="step5" value="<?php echo get_lang('Next'); ?> &gt;" /></td>
  840. </tr>
  841. </table>
  842. <?php
  843. }
  844. /**
  845. * After installation is completed (step 6), this message is displayed.
  846. */
  847. function display_after_install_message($installType, $nbr_courses)
  848. {
  849. ?>
  850. <h2><?php echo display_step_sequence() . get_lang("CfgSetting"); ?></h2>
  851. <?php echo get_lang('FirstUseTip'); ?>
  852. <?php if($installType == 'update' && $nbr_courses > MAX_COURSE_TRANSFER): ?>
  853. <br><br>
  854. <font color="red"><b>Warning :</b> You have more than <?php echo MAX_COURSE_TRANSFER; ?> courses on your Dokeos platform ! Only <?php echo MAX_COURSE_TRANSFER; ?> courses have been updated. To update the other courses, <a href="update_courses.php"><font color="red">click here</font></a>.</font>
  855. <?php endif; ?>
  856. <br><br>
  857. <b>Security advice :</b> To protect your site, make read-only (CHMOD 444) 'main/inc/conf/claro_main.conf.php' and 'main/install/index.php'.
  858. <br><br><br><br>
  859. </form>
  860. <a href="../../index.php"><?php echo get_lang('GoToYourNewlyCreatedPortal'); ?></a>
  861. <?php
  862. }
  863. ?>