install_functions.inc.php 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231
  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. * @return string String that says 'Step X of Y' with the right values
  17. */
  18. function display_step_sequence()
  19. {
  20. global $current_step;
  21. global $total_steps;
  22. return get_lang('Step'.$current_step).' &ndash; ';
  23. }
  24. /**
  25. * This function checks if a php extension exists or not and returns an HTML
  26. * status string.
  27. *
  28. * @param string Name of the PHP extension to be checked
  29. * @param string Text to show when extension is available (defaults to 'OK')
  30. * @param string Text to show when extension is available (defaults to 'KO')
  31. * @param boolean Whether this extension is optional (in this case show unavailable text in orange rather than red)
  32. * @return string HTML string reporting the status of this extension. Language-aware.
  33. * @author Christophe Gesche
  34. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  35. * @author Yannick Warnier <yannick.warnier@dokeos.com>
  36. * @version Dokeos 1.8.1, May 2007
  37. */
  38. function check_extension($extension_name,$return_success='Yes',$return_failure='No',$optional=false)
  39. {
  40. if(extension_loaded($extension_name))
  41. {
  42. return '<strong><font color="green">'.$return_success.'</font></strong>';
  43. }
  44. else
  45. {
  46. if($optional===true)
  47. {
  48. return '<strong><font color="#ff9900">'.$return_failure.'</font></strong>';
  49. }
  50. else
  51. {
  52. return '<strong><font color="red">'.$return_failure.'</font></strong>';
  53. }
  54. }
  55. }
  56. /**
  57. * This function checks whether a php setting matches the recommended value
  58. *
  59. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  60. * @version Dokeos 1.8, august 2006
  61. */
  62. function check_php_setting($php_setting, $recommended_value, $return_success=false, $return_failure=false)
  63. {
  64. $current_php_value = get_php_setting($php_setting);
  65. if ( $current_php_value== $recommended_value)
  66. {
  67. return '<strong><font color="green">'.$current_php_value.' '.$return_success.'</font></strong>';
  68. }
  69. else
  70. {
  71. return '<strong><font color="red">'.$current_php_value.' '.$return_failure.'</font></strong>';
  72. }
  73. }
  74. /**
  75. * Enter description here...
  76. *
  77. * @param string $val a php ini value
  78. * @return boolean: ON or OFF
  79. * @author Joomla <http://www.joomla.org>
  80. */
  81. function get_php_setting($val) {
  82. $r = (ini_get($val) == '1' ? 1 : 0);
  83. return $r ? 'ON' : 'OFF';
  84. }
  85. /**
  86. * This function checks if the given folder is writable
  87. */
  88. function check_writable($folder)
  89. {
  90. if (is_writable('../'.$folder))
  91. {
  92. return '<strong><font color="green">'.get_lang('Writable').'</font></strong>';
  93. }
  94. else
  95. {
  96. return '<strong><font color="red">'.get_lang('NotWritable').'</font></strong>';
  97. }
  98. }
  99. /**
  100. * this function returns a string "FALSE" or "TRUE" according to the variable in parameter
  101. *
  102. * @param integer $var the variable to convert
  103. * @return string the string "FALSE" or "TRUE"
  104. * @author Christophe Gesche
  105. */
  106. function trueFalse($var)
  107. {
  108. return $var?'true':'false';
  109. }
  110. /**
  111. * This function is similar to the core file() function, except that it
  112. * works with line endings in Windows (which is not the case of file())
  113. * @param string File path
  114. * @return array The lines of the file returned as an array
  115. */
  116. function file_to_array($filename)
  117. {
  118. $fp = fopen($filename, "rb");
  119. $buffer = fread($fp, filesize($filename));
  120. fclose($fp);
  121. $result = explode('<br />',nl2br($buffer));
  122. return $result;
  123. }
  124. /**
  125. * This function returns the value of a parameter from the configuration file
  126. *
  127. * WARNING - this function relies heavily on global variables $updateFromConfigFile
  128. * and $configFile, and also changes these globals. This can be rewritten.
  129. *
  130. * @param string $param the parameter of which the value is returned
  131. * @param string If we want to give the path rather than take it from POST
  132. * @return string the value of the parameter
  133. * @author Olivier Brouckaert
  134. */
  135. function get_config_param($param,$updatePath='')
  136. {
  137. global $configFile, $updateFromConfigFile;
  138. //look if we already have the queried param
  139. if(is_array($configFile) && isset($configFile[$param]))
  140. {
  141. return $configFile[$param];
  142. }
  143. if(empty($updatePath) && !empty($_POST['updatePath']))
  144. {
  145. $updatePath = $_POST['updatePath'];
  146. }
  147. $updatePath = realpath($updatePath).'/';
  148. $updateFromInstalledVersionFile = '';
  149. if(empty($updateFromConfigFile)) //if update from previous install was requested
  150. {
  151. //try to recover old config file from dokeos 1.8.x
  152. if(file_exists($updatePath.'main/inc/conf/configuration.php'))
  153. {
  154. $updateFromConfigFile='main/inc/conf/configuration.php';
  155. }
  156. elseif(file_exists($updatePath.'claroline/inc/conf/claro_main.conf.php'))
  157. {
  158. $updateFromConfigFile='claroline/inc/conf/claro_main.conf.php';
  159. }
  160. //give up recovering
  161. else
  162. {
  163. error_log('Could not find config file in '.$updatePath.' in get_config_param()',0);
  164. return null;
  165. }
  166. }
  167. if(file_exists($updatePath.'main/inc/installedVersion.inc.php'))
  168. {
  169. $updateFromInstalledVersionFile = $updatePath.'main/inc/installedVersion.inc.php';
  170. }
  171. //the param was not found in global vars, so look into the old config file
  172. elseif(file_exists($updatePath.$updateFromConfigFile))
  173. {
  174. //make sure the installedVersion file is read first so it is overwritten
  175. //by the config file if the config file contains the version (from 1.8.4)
  176. $temp2 = array();
  177. if(file_exists($updatePath.$updateFromInstalledVersionFile))
  178. {
  179. $temp2 = file_to_array($updatePath.$updateFromInstalledVersionFile);
  180. }
  181. $configFile=array();
  182. $temp=file_to_array($updatePath.$updateFromConfigFile);
  183. $temp = array_merge($temp,$temp2);
  184. $val='';
  185. //parse the config file (TODO clarify why it has to be so complicated)
  186. foreach($temp as $enreg)
  187. {
  188. if(strstr($enreg,'='))
  189. {
  190. $enreg=explode('=',$enreg);
  191. $enreg[0] = trim($enreg[0]);
  192. if($enreg[0][0] == '$')
  193. {
  194. list($enreg[1])=explode(' //',$enreg[1]);
  195. $enreg[0]=trim(str_replace('$','',$enreg[0]));
  196. $enreg[1]=str_replace('\"','"',ereg_replace('(^"|"$)','',substr(trim($enreg[1]),0,-1)));
  197. $enreg[1]=str_replace('\'','"',ereg_replace('(^\'|\'$)','',$enreg[1]));
  198. if(strtolower($enreg[1]) == 'true')
  199. {
  200. $enreg[1]=1;
  201. }
  202. if(strtolower($enreg[1]) == 'false')
  203. {
  204. $enreg[1]=0;
  205. }
  206. else
  207. {
  208. $implode_string=' ';
  209. if(!strstr($enreg[1],'." ".') && strstr($enreg[1],'.$'))
  210. {
  211. $enreg[1]=str_replace('.$','." ".$',$enreg[1]);
  212. $implode_string='';
  213. }
  214. $tmp=explode('." ".',$enreg[1]);
  215. foreach($tmp as $tmp_key=>$tmp_val)
  216. {
  217. if(eregi('^\$[a-z_][a-z0-9_]*$',$tmp_val))
  218. {
  219. $tmp[$tmp_key]=get_config_param(str_replace('$','',$tmp_val));
  220. }
  221. }
  222. $enreg[1]=implode($implode_string,$tmp);
  223. }
  224. $configFile[$enreg[0]]=$enreg[1];
  225. $a=explode("'",$enreg[0]);
  226. $key_tmp=$a[1];
  227. if($key_tmp== $param)
  228. {
  229. $val=$enreg[1];
  230. }
  231. }
  232. }
  233. }
  234. return $val;
  235. }
  236. else
  237. {
  238. error_log('Config array could not be found in get_config_param()',0);
  239. return null;
  240. }
  241. }
  242. /**
  243. * Get the config param from the database. If not found, return null
  244. * @param string DB Host
  245. * @param string DB login
  246. * @param string DB pass
  247. * @param string DB name
  248. * @param string Name of param we want
  249. * @return mixed The parameter value or null if not found
  250. */
  251. function get_config_param_from_db($host,$login,$pass,$db_name,$param='')
  252. {
  253. $mydb = mysql_connect($host,$login,$pass);
  254. // The Dokeos system has not been designed to use special SQL modes that were introduced since MySQL 5
  255. @mysql_query("set session sql_mode='';");
  256. $myconnect = mysql_select_db($db_name);
  257. $sql = "SELECT * FROM settings_current WHERE variable = '$param'";
  258. $res = mysql_query($sql);
  259. if($res===false){return null;}
  260. if(mysql_num_rows($res)>0)
  261. {
  262. $row = mysql_fetch_array($res);
  263. $value = $row['selected_value'];
  264. return $value;
  265. }
  266. return null;
  267. }
  268. /**
  269. * Return a list of language directories.
  270. * @todo function does not belong here, move to code library,
  271. * also see infocours.php which contains similar function
  272. */
  273. function get_language_folder_list($dirname)
  274. {
  275. if ($dirname[strlen($dirname)-1] != '/') $dirname .= '/';
  276. $handle = opendir($dirname);
  277. $language_list = array();
  278. while ($entries = readdir($handle))
  279. {
  280. if ($entries=='.' || $entries=='..' || $entries=='CVS' || $entries == '.svn') continue;
  281. if (is_dir($dirname.$entries))
  282. {
  283. $language_list[] = $entries;
  284. }
  285. }
  286. closedir($handle);
  287. return $language_list;
  288. }
  289. /*
  290. ==============================================================================
  291. DISPLAY FUNCTIONS
  292. ==============================================================================
  293. */
  294. /**
  295. * Displays a form (drop down menu) so the user can select
  296. * his/her preferred language.
  297. */
  298. function display_language_selection_box()
  299. {
  300. //get language list
  301. $dirname = '../lang/';
  302. $language_list = get_language_folder_list($dirname);
  303. sort($language_list);
  304. //Reduce the number of languages shown to only show those with higher than 90% translation in DLTT
  305. //This option can be easily removed later on. The aim is to test people response to less choice
  306. //$language_to_display = $language_list;
  307. $language_to_display = array('asturian','english','italian','french','slovenian','slovenian_unicode','spanish');
  308. //display
  309. echo "\t\t<select name=\"language_list\">\n";
  310. $default_language = 'english';
  311. foreach ($language_to_display as $key => $value)
  312. {
  313. if ($value == $default_language) $option_end = ' selected="selected">';
  314. else $option_end = '>';
  315. echo "\t\t\t<option value=\"$value\"$option_end";
  316. echo api_ucfirst($value);
  317. echo "</option>\n";
  318. }
  319. echo "\t\t</select>\n";
  320. }
  321. /**
  322. * This function displays a language dropdown box so that the installatioin
  323. * can be done in the language of the user
  324. */
  325. function display_language_selection()
  326. { ?>
  327. <h1><?php get_lang('WelcomeToTheDokeosInstaller');?></h1>
  328. <h2><?php echo display_step_sequence(); ?><?php echo get_lang('InstallationLanguage');?></h2>
  329. <p><?php echo get_lang('PleaseSelectInstallationProcessLanguage');?>:</p>
  330. <form id="lang_form" method="post" action="<?php echo api_get_self(); ?>">
  331. <?php display_language_selection_box(); ?>
  332. <button type="submit" name="step1" class="next" value="<?php get_lang('Next');?> &gt;"><?php echo get_lang('Next');?></button>
  333. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  334. </form>
  335. <?php }
  336. /**
  337. * This function displays the requirements for installing Dokeos.
  338. *
  339. * @param string $installType
  340. * @param boolean $badUpdatePath
  341. * @param string The updatePath given (if given)
  342. * @param array $update_from_version_8 The different subversions from version 1.8
  343. * @param array $update_from_version_6 The different subversions from version 1.6
  344. *
  345. * @author unknow
  346. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  347. */
  348. function display_requirements($installType, $badUpdatePath, $updatePath='', $update_from_version_8=array(), $update_from_version_6=array())
  349. {
  350. echo '<h2>'.display_step_sequence().get_lang('Requirements')."</h2>\n";
  351. echo '<strong>'.get_lang('ReadThoroughly').'</strong><br />';
  352. echo get_lang('MoreDetails').' <a href="../../documentation/installation_guide.html" target="_blank">'.get_lang('ReadTheInstallGuide').'</a>.<br />'."\n";
  353. // SERVER REQUIREMENTS
  354. echo '<div class="RequirementHeading"><h1>'.get_lang('ServerRequirements').'</h1>';
  355. echo '<div class="RequirementText">'.get_lang('ServerRequirementsInfo').'</div>';
  356. echo '<div class="RequirementContent">';
  357. echo '<table class="requirements">
  358. <tr>
  359. <td class="requirements-item">'.get_lang('PHPVersion').'>= 5.0</td>
  360. <td class="requirements-value">';
  361. if (phpversion() < '5.0')
  362. {
  363. echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>';
  364. }
  365. else
  366. {
  367. echo '<strong><font color="green">'.get_lang('PHPVersionOK'). ' '.phpversion().'</font></strong>';
  368. }
  369. echo ' </td>
  370. </tr>
  371. <tr>
  372. <td class="requirements-item"><a href="http://php.net/manual/en/book.session.php" target="_blank">Session</a> '.get_lang('support').'</td>
  373. <td class="requirements-value">'.check_extension('session', get_lang('Yes'), get_lang('ExtensionSessionsNotAvailable')).'</td>
  374. </tr>
  375. <tr>
  376. <td class="requirements-item"><a href="http://php.net/manual/en/book.mysql.php" target="_blank">MySQL</a> '.get_lang('support').'</td>
  377. <td class="requirements-value">'.check_extension('mysql', get_lang('Yes'), get_lang('ExtensionMySQLNotAvailable')).'</td>
  378. </tr>
  379. <tr>
  380. <td class="requirements-item"><a href="http://php.net/manual/en/book.zlib.php" target="_blank">Zlib</a> '.get_lang('support').'</td>
  381. <td class="requirements-value">'.check_extension('zlib', get_lang('Yes'), get_lang('ExtensionZlibNotAvailable')).'</td>
  382. </tr>
  383. <tr>
  384. <td class="requirements-item"><a href="http://php.net/manual/en/book.pcre.php" target="_blank">Perl-compatible regular expressions</a> '.get_lang('support').'</td>
  385. <td class="requirements-value">'.check_extension('pcre', get_lang('Yes'), get_lang('ExtensionPCRENotAvailable')).'</td>
  386. </tr>
  387. <tr>
  388. <td class="requirements-item"><a href="http://php.net/manual/en/book.xml.php" target="_blank">XML</a> '.get_lang('support').'</td>
  389. <td class="requirements-value">'.check_extension('xml', get_lang('Yes'), get_lang('No')).'</td>
  390. </tr>
  391. <tr>
  392. <td class="requirements-item"><a href="http://php.net/manual/en/book.mbstring.php" target="_blank">Multibyte string</a> '.get_lang('support').' ('.get_lang('Optional').')</td>
  393. <td class="requirements-value">'.check_extension('mbstring', get_lang('Yes'), get_lang('ExtensionMBStringNotAvailable'), true).'</td>
  394. </tr>
  395. <tr>
  396. <td class="requirements-item"><a href="http://php.net/manual/en/book.iconv.php" target="_blank">Iconv</a> '.get_lang('support').' ('.get_lang('Optional').')</td>
  397. <td class="requirements-value">'.check_extension('iconv', get_lang('Yes'), get_lang('No'), true).'</td>
  398. </tr>
  399. <tr>
  400. <td class="requirements-item"><a href="http://php.net/manual/en/book.intl.php" target="_blank">Internationalization</a> '.get_lang('support').' ('.get_lang('Optional').')</td>
  401. <td class="requirements-value">'.check_extension('intl', get_lang('Yes'), get_lang('No'), true).'</td>
  402. </tr>
  403. <tr>
  404. <td class="requirements-item"><a href="http://php.net/manual/en/book.image.php" target="_blank">GD</a> '.get_lang('support').'</td>
  405. <td class="requirements-value">'.check_extension('gd', get_lang('Yes'), get_lang('ExtensionGDNotAvailable')).'</td>
  406. </tr>
  407. <tr>
  408. <td class="requirements-item"><a href="http://php.net/manual/en/book.json.php" target="_blank">JSON</a> '.get_lang('support').'</td>
  409. <td class="requirements-value">'.check_extension('json', get_lang('Yes'), get_lang('No')).'</td>
  410. </tr>
  411. <tr>
  412. <td class="requirements-item"><a href="http://php.net/manual/en/book.ldap.php" target="_blank">LDAP</a> '.get_lang('support').' ('.get_lang('Optional').')</td>
  413. <td class="requirements-value">'.check_extension('ldap', get_lang('Yes'), get_lang('ExtensionLDAPNotAvailable'), true).'</td>
  414. </tr>
  415. <tr>
  416. <td class="requirements-item"><a href="http://xapian.org/" target="_blank">Xapian</a> '.get_lang('support').' ('.get_lang('Optional').')</td>
  417. <td class="requirements-value">'.check_extension('xapian', get_lang('Yes'), get_lang('No'), true).'</td>
  418. </tr>
  419. </table>';
  420. echo ' </div>';
  421. echo '</div>';
  422. // RECOMMENDED SETTINGS
  423. // Note: these are the settings for Joomla, does this also apply for Dokeos?
  424. // Note: also add upload_max_filesize here so that large uploads are possible
  425. echo '<div class="RequirementHeading"><h1>'.get_lang('RecommendedSettings').'</h1>';
  426. echo '<div class="RequirementText">'.get_lang('RecommendedSettingsInfo').'</div>';
  427. echo '<div class="RequirementContent">';
  428. echo '<table class="requirements">
  429. <tr>
  430. <th>'.get_lang('Setting').'</th>
  431. <th>'.get_lang('Recommended').'</th>
  432. <th>'.get_lang('Actual').'</th>
  433. </tr>
  434. <tr>
  435. <td class="requirements-item"><a href="http://php.net/manual/features.safe-mode.php">Safe Mode</a></td>
  436. <td class="requirements-recommended">OFF</td>
  437. <td class="requirements-value">'.check_php_setting('safe_mode','OFF').'</td>
  438. </tr>
  439. <tr>
  440. <td class="requirements-item"><a href="http://php.net/manual/ref.errorfunc.php#ini.display-errors">Display Errors</a></td>
  441. <td class="requirements-recommended">OFF</td>
  442. <td class="requirements-value">'.check_php_setting('display_errors','OFF').'</td>
  443. </tr>
  444. <tr>
  445. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.file-uploads">File Uploads</a></td>
  446. <td class="requirements-recommended">ON</td>
  447. <td class="requirements-value">'.check_php_setting('file_uploads','ON').'</td>
  448. </tr>
  449. <tr>
  450. <td class="requirements-item"><a href="http://php.net/manual/ref.info.php#ini.magic-quotes-gpc">Magic Quotes GPC</a></td>
  451. <td class="requirements-recommended">OFF</td>
  452. <td class="requirements-value">'.check_php_setting('magic_quotes_gpc','OFF').'</td>
  453. </tr>
  454. <tr>
  455. <td class="requirements-item"><a href="http://php.net/manual/ref.info.php#ini.magic-quotes-runtime">Magic Quotes Runtime</a></td>
  456. <td class="requirements-recommended">OFF</td>
  457. <td class="requirements-value">'.check_php_setting('magic_quotes_runtime','OFF').'</td>
  458. </tr>
  459. <tr>
  460. <td class="requirements-item"><a href="http://php.net/manual/security.globals.php">Register Globals</a></td>
  461. <td class="requirements-recommended">OFF</td>
  462. <td class="requirements-value">'.check_php_setting('register_globals','OFF').'</td>
  463. </tr>
  464. <tr>
  465. <td class="requirements-item"><a href="http://php.net/manual/ref.session.php#ini.session.auto-start">Session auto start</a></td>
  466. <td class="requirements-recommended">OFF</td>
  467. <td class="requirements-value">'.check_php_setting('session.auto_start','OFF').'</td>
  468. </tr>
  469. <tr>
  470. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.short-open-tag">Short Open Tag</a></td>
  471. <td class="requirements-recommended">OFF</td>
  472. <td class="requirements-value">'.check_php_setting('short_open_tag','OFF').'</td>
  473. </tr>
  474. <tr>
  475. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.upload-max-filesize">Maximum upload file size</a></td>
  476. <td class="requirements-recommended">10M-100M</td>
  477. <td class="requirements-value">'.ini_get('upload_max_filesize').'</td>
  478. </tr>
  479. <tr>
  480. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.post-max-size">Maximum post size</a></td>
  481. <td class="requirements-recommended">10M-100M</td>
  482. <td class="requirements-value">'.ini_get('post_max_size').'</td>
  483. </tr>
  484. </table>';
  485. echo ' </div>';
  486. echo '</div>';
  487. // DIRECTORY AND FILE PERMISSIONS
  488. echo '<div class="RequirementHeading"><h1>'.get_lang('DirectoryAndFilePermissions').'</h1>';
  489. echo '<div class="RequirementText">'.get_lang('DirectoryAndFilePermissionsInfo').'</div>';
  490. echo '<div class="RequirementContent">';
  491. echo '<table class="requirements">
  492. <tr>
  493. <td class="requirements-item">dokeos/main/inc/conf/</td>
  494. <td class="requirements-value">'.check_writable('inc/conf/').'</td>
  495. </tr>
  496. <tr>
  497. <td class="requirements-item">dokeos/main/upload/users/</td>
  498. <td class="requirements-value">'.check_writable('upload/users/').'</td>
  499. </tr>
  500. <tr>
  501. <td class="requirements-item">dokeos/main/default_course_document/images/</td>
  502. <td class="requirements-value">'.check_writable('default_course_document/images/').'</td>
  503. </tr>
  504. <tr>
  505. <td class="requirements-item">dokeos/archive/</td>
  506. <td class="requirements-value">'.check_writable('../archive/').'</td>
  507. </tr>
  508. <tr>
  509. <td class="requirements-item">dokeos/courses/</td>
  510. <td class="requirements-value">'.check_writable('../courses/').'</td>
  511. </tr>
  512. <tr>
  513. <td class="requirements-item">dokeos/home/</td>
  514. <td class="requirements-value">'.check_writable('../home/').'</td>
  515. </tr>'.
  516. //'<tr>
  517. // <td class="requirements-item">dokeos/searchdb/</td>
  518. // <td class="requirements-value">'.check_writable('../searchdb/').'</td>
  519. //</tr>'.
  520. //'<tr>
  521. // <td class="requirements-item">'.session_save_path().'</td>
  522. // <td class="requirements-value">'.(is_writable(session_save_path())
  523. // ? '<strong><font color="green">'.get_lang('Writable').'</font></strong>'
  524. // : '<strong><font color="red">'.get_lang('NotWritable').'</font></strong>').'</td>
  525. //</tr>'.
  526. '';
  527. echo ' </table>';
  528. echo ' </div>';
  529. echo '</div>';
  530. if($installType == 'update' && (empty($updatePath) || $badUpdatePath))
  531. {
  532. if($badUpdatePath)
  533. { ?>
  534. <div style="color:red; background-color:white; font-weight:bold; text-align:center;">
  535. <?php echo get_lang('Error');?>!<br />
  536. Dokeos <?php echo (isset($_POST['step2_update_6'])?implode('|',$update_from_version_6):implode('|',$update_from_version_8)).' '.get_lang('HasNotBeenFoundInThatDir'); ?>.
  537. </div>
  538. <?php }
  539. else
  540. {
  541. echo '<br />';
  542. }
  543. ?>
  544. <table border="0" cellpadding="5" align="center">
  545. <tr>
  546. <td><?php echo get_lang('OldVersionRootPath');?>:</td>
  547. <td><input type="text" name="updatePath" size="50" value="<?php echo ($badUpdatePath && !empty($updatePath))?htmlentities($updatePath):$_SERVER['DOCUMENT_ROOT'].'/old_version/'; ?>" /></td>
  548. </tr>
  549. <tr>
  550. <td colspan="2" align="center">
  551. <button type="submit" class="back" name="step1" value="&lt; <?php echo get_lang('Back');?>" ><?php echo get_lang('Back');?></button>
  552. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  553. <button type="submit" class="next" name="<?php echo (isset($_POST['step2_update_6'])?'step2_update_6':'step2_update_8');?>" value="<?php echo get_lang('Next');?> &gt;" ><?php echo get_lang('Next');?></button>
  554. </td>
  555. </tr>
  556. </table>
  557. <?php
  558. }
  559. else
  560. {
  561. $error=false;
  562. $perm = api_get_setting('permissions_for_new_directories');
  563. $perm = octdec(!empty($perm)?$perm:'0770');
  564. $perm_file = api_get_setting('permissions_for_new_files');
  565. $perm_file = octdec(!empty($perm_file)?$perm_file:'0660');
  566. //First, attempt to set writing permissions if we don't have them yet
  567. //0xxx is an octal number, this is the required format
  568. $notwritable = array();
  569. $curdir = getcwd();
  570. if(!is_writable('../inc/conf'))
  571. {
  572. $notwritable[] = realpath($curdir.'/../inc/conf');
  573. @chmod('../inc/conf',$perm);
  574. }
  575. if(!is_writable('../upload/users'))
  576. {
  577. $notwritable[] = realpath($curdir.'/../upload/users');
  578. @chmod('../upload/users', $perm);
  579. }
  580. if(!is_writable('../default_course_document/images/'))
  581. {
  582. $notwritable[] = realpath($curdir.'/../default_course_document/images/');
  583. @chmod('../default_course_document/images/', $perm);
  584. }
  585. if(!is_writable('../../archive'))
  586. {
  587. $notwritable[] = realpath($curdir.'/../../archive');
  588. @chmod('../../archive',$perm);
  589. }
  590. if(!is_writable('../../courses'))
  591. {
  592. $notwritable[] = realpath($curdir.'/../../courses');
  593. @chmod('../../courses',$perm);
  594. }
  595. if(!is_writable('../../home'))
  596. {
  597. $notwritable[] = realpath($curdir.'/../../home');
  598. @chmod('../../home',$perm);
  599. }
  600. if(file_exists('../inc/conf/configuration.php') && !is_writable('../inc/conf/configuration.php'))
  601. {
  602. $notwritable[]= realpath($curdir.'/../inc/conf/configuration.php');
  603. @chmod('../inc/conf/configuration.php',$perm_file);
  604. }
  605. //Second, if this fails, report an error
  606. //--> the user will have to adjust the permissions manually
  607. if(count($notwritable)>0)
  608. {
  609. $error=true;
  610. echo '<div style="color:red; background-color:white; font-weight:bold; text-align:center;">';
  611. echo get_lang('Warning').':<br />';
  612. printf(get_lang('NoWritePermissionPleaseReadInstallGuide'),'</font><a href="../../documentation/installation_guide.html" target="blank">','</a> <font color="red">');
  613. echo '<ul>';
  614. foreach ($notwritable as $value)
  615. {
  616. echo '<li>'.$value.'</li>';
  617. }
  618. echo '</ul>';
  619. echo '</div>';
  620. }
  621. // check wether a Dokeos configuration file already exists.
  622. elseif(file_exists('../inc/conf/configuration.php'))
  623. {
  624. echo '<div style="color:red; background-color:white; font-weight:bold; text-align:center;">';
  625. echo get_lang('WarningExistingDokeosInstallationDetected');
  626. echo '</div>';
  627. }
  628. //and now display the choice buttons (go back or install)
  629. ?>
  630. <p align="center">
  631. <button type="submit" name="step1" class="back" onclick="window.location='index.php';return false;" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button>
  632. <button type="submit" name="step2_install" class="add" value="<?php echo get_lang("NewInstallation"); ?>" <?php if($error) if($error)echo 'disabled="disabled"'; ?> ><?php echo get_lang('NewInstallation'); ?></button>
  633. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  634. <?php
  635. //real code
  636. echo '<button type="submit" class="save" name="step2_update_8" value="Upgrade from Dokeos 1.8.x"';
  637. if($error) echo ' disabled="disabled"';
  638. //temporary code for alpha version, disabling upgrade
  639. //echo '<input type="submit" name="step2_update" value="Upgrading is not possible in this beta version"';
  640. //echo ' disabled="disabled"';
  641. //end temp code
  642. echo ' >'.get_lang('UpgradeFromDokeos18x').'</button>';
  643. echo '<button type="submit" class="save" name="step2_update_6" value="Upgrade from Dokeos 1.6.x"';
  644. if($error) echo ' disabled="disabled"';
  645. echo ' >'.get_lang('UpgradeFromDokeos16x').'</button>';
  646. echo '</p>';
  647. }
  648. }
  649. /**
  650. * Displays the license (GNU GPL) as step 2, with
  651. * - an "I accept" button named step3 to proceed to step 3;
  652. * - a "Back" button named step1 to go back to the first step.
  653. */
  654. function display_license_agreement()
  655. {
  656. echo '<h2>'.display_step_sequence().get_lang('Licence').'</h2>';
  657. echo '<p>'.get_lang('DokeosLicenseInfo').'</p>';
  658. echo '<p><a href="../../documentation/license.html" target="_blank">'.get_lang('PrintVers').'</a></p>';
  659. ?>
  660. <table><tr><td>
  661. <p><textarea cols="75" rows="15" ><?php htmlentities(include('../../documentation/license.txt')); ?></textarea></p>
  662. </td>
  663. </tr>
  664. <tr>
  665. <td>
  666. <p><?php echo get_lang('DokeosArtLicense');?></p>
  667. </td>
  668. </tr>
  669. <td>
  670. <table width="100%">
  671. <tr>
  672. <td></td>
  673. <td align="center">
  674. <button type="submit" class="back" name="step1" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button>
  675. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  676. <button type="submit" class="next" name="step3" value="<?php echo get_lang('IAccept'); ?> &gt;" ><?php echo get_lang('IAccept'); ?></button>
  677. </td>
  678. </tr>
  679. </table>
  680. </td></tr></table>
  681. <?php
  682. }
  683. /**
  684. * Displays a parameter in a table row.
  685. * Used by the display_database_settings_form function.
  686. * @param string Type of install
  687. * @param string Name of parameter
  688. * @param string Field name (in the HTML form)
  689. * @param string Field value
  690. * @param string Extra notice (to show on the right side)
  691. * @param boolean Whether to display in update mode
  692. * @param string Additional attribute for the <tr> element
  693. * @return void Direct output
  694. */
  695. function display_database_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $extra_notice, $display_when_update = true, $tr_attribute='')
  696. {
  697. echo "<tr ".$tr_attribute.">\n";
  698. echo "<td>$parameter_name&nbsp;&nbsp;</td>\n";
  699. if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update)
  700. {
  701. echo '<td><input type="hidden" name="'.$form_field_name.'" id="'.$form_field_name.'" value="'.htmlentities($parameter_value).'" />'.$parameter_value."</td>\n";
  702. }
  703. else
  704. {
  705. if ($form_field_name=='dbPassForm') {
  706. $inputtype = 'password';
  707. } else {
  708. $inputtype = 'text';
  709. }
  710. //Slightly limit the length of the database prefix to avoid
  711. //having to cut down the databases names later on
  712. if ($form_field_name=='dbPrefixForm') {
  713. $maxlength = '15';
  714. } else {
  715. $maxlength = MAX_FORM_FIELD_LENGTH;
  716. }
  717. echo '<td><input type="'.$inputtype.'" size="'.DATABASE_FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.$maxlength.'" name="'.$form_field_name.'" id="'.$form_field_name.'" value="'.htmlentities($parameter_value).'" />'."</td>\n";
  718. echo "<td>$extra_notice</td>\n";
  719. }
  720. echo "</tr>\n";
  721. }
  722. /**
  723. * Displays step 3 - a form where the user can enter the installation settings
  724. * regarding the databases - login and password, names, prefixes, single
  725. * or multiple databases, tracking or not...
  726. */
  727. function display_database_settings_form($installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbPrefixForm, $enableTrackingForm, $singleDbForm, $dbNameForm, $dbStatsForm, $dbScormForm, $dbUserForm)
  728. {
  729. if($installType == 'update')
  730. {
  731. global $_configuration, $update_from_version_6;
  732. if(in_array($_POST['old_version'],$update_from_version_6))
  733. {
  734. $dbHostForm=get_config_param('dbHost');
  735. $dbUsernameForm=get_config_param('dbLogin');
  736. $dbPassForm=get_config_param('dbPass');
  737. $dbPrefixForm=get_config_param('dbNamePrefix');
  738. $enableTrackingForm=get_config_param('is_trackingEnabled');
  739. $singleDbForm=get_config_param('singleDbEnabled');
  740. $dbNameForm=get_config_param('mainDbName');
  741. $dbStatsForm=get_config_param('statsDbName');
  742. $dbScormForm=get_config_param('scormDbName');
  743. $dbUserForm=get_config_param('user_personal_database');
  744. $dbScormExists=true;
  745. }
  746. else
  747. {
  748. $dbHostForm=$_configuration['db_host'];
  749. $dbUsernameForm=$_configuration['db_user'];
  750. $dbPassForm=$_configuration['db_password'];
  751. $dbPrefixForm=$_configuration['db_prefix'];
  752. $enableTrackingForm=$_configuration['tracking_enabled'];
  753. $singleDbForm=$_configuration['single_database'];
  754. $dbNameForm=$_configuration['main_database'];
  755. $dbStatsForm=$_configuration['statistics_database'];
  756. $dbScormForm=$_configuration['scorm_database'];
  757. $dbUserForm=$_configuration['user_personal_database'];
  758. $dbScormExists=true;
  759. }
  760. if(empty($dbScormForm))
  761. {
  762. if($singleDbForm)
  763. {
  764. $dbScormForm=$dbNameForm;
  765. }
  766. else
  767. {
  768. $dbScormForm=$dbPrefixForm.'scorm';
  769. $dbScormExists=false;
  770. }
  771. }
  772. if(empty($dbUserForm))
  773. {
  774. if($singleDbForm)
  775. {
  776. $dbUserForm=$dbNameForm;
  777. }
  778. else
  779. {
  780. $dbUserForm=$dbPrefixForm.'dokeos_user';
  781. }
  782. }
  783. echo "<h2>" . display_step_sequence() .get_lang("DBSetting") . "</h2>";
  784. echo get_lang("DBSettingUpgradeIntro");
  785. }else{
  786. if(empty($dbPrefixForm)) //make sure there is a default value for db prefix
  787. {
  788. $dbPrefixForm = 'dokeos_';
  789. }
  790. echo "<h2>" . display_step_sequence() .get_lang("DBSetting") . "</h2>";
  791. echo get_lang("DBSettingIntro");
  792. }
  793. ?>
  794. <br /><br />
  795. </td>
  796. </tr>
  797. <tr>
  798. <td>
  799. <table width="100%">
  800. <tr>
  801. <td width="40%"><?php echo get_lang('DBHost'); ?> </td>
  802. <?php if($installType == 'update'): ?>
  803. <td width="30%"><input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?></td>
  804. <td width="30%">&nbsp;</td>
  805. <?php else: ?>
  806. <td width="30%"><input type="text" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /></td>
  807. <td width="30%"><?php echo get_lang('EG').' localhost'; ?></td>
  808. <?php endif; ?>
  809. </tr>
  810. <?php
  811. //database user username
  812. $example_login = get_lang('EG').' root';
  813. display_database_parameter($installType, get_lang('DBLogin'), 'dbUsernameForm', $dbUsernameForm, $example_login);
  814. //database user password
  815. $example_password = get_lang('EG').' '.api_generate_password();
  816. display_database_parameter($installType, get_lang('DBPassword'), 'dbPassForm', $dbPassForm, $example_password);
  817. //database prefix
  818. display_database_parameter($installType, get_lang('DbPrefixForm'), 'dbPrefixForm', $dbPrefixForm, get_lang('DbPrefixCom'));
  819. //fields for the four standard Dokeos databases
  820. echo '<tr><td colspan="3"><a href="" onclick="javascript: show_hide_option();return false;" id="optionalparameters"><img style="vertical-align:middle;" src="../img/div_show.gif" alt="show-hide" /> '.get_lang('OptionalParameters','').'</a></td></tr>';
  821. display_database_parameter($installType, get_lang('MainDB'), 'dbNameForm', $dbNameForm, '&nbsp;',null,'id="optional_param1" style="display:none;"');
  822. display_database_parameter($installType, get_lang('StatDB'), 'dbStatsForm', $dbStatsForm, '&nbsp;',null,'id="optional_param2" style="display:none;"');
  823. if($installType == 'update' && in_array($_POST['old_version'],$update_from_version_6))
  824. {
  825. display_database_parameter($installType, get_lang('ScormDB'), 'dbScormForm', $dbScormForm, '&nbsp;',null,'id="optional_param3" style="display:none;"');
  826. }
  827. display_database_parameter($installType, get_lang('UserDB'), 'dbUserForm', $dbUserForm, '&nbsp;',null,'id="optional_param4" style="display:none;"');
  828. ?>
  829. <tr id="optional_param5" style="display:none;">
  830. <td><?php echo get_lang('EnableTracking'); ?> </td>
  831. <?php if($installType == 'update'): ?>
  832. <td><input type="hidden" name="enableTrackingForm" value="<?php echo $enableTrackingForm; ?>" /><?php echo $enableTrackingForm? get_lang('Yes') : get_lang('No'); ?></td>
  833. <?php else: ?>
  834. <td>
  835. <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>
  836. <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>
  837. </td>
  838. <?php endif; ?>
  839. <td>&nbsp;</td>
  840. </tr>
  841. <tr id="optional_param6" style="display:none;">
  842. <td><?php echo get_lang('SingleDb'); ?> </td>
  843. <?php if($installType == 'update'): ?>
  844. <td><input type="hidden" name="singleDbForm" value="<?php echo $singleDbForm; ?>" /><?php echo $singleDbForm? get_lang('One') : get_lang('Several'); ?></td>
  845. <?php else: ?>
  846. <td>
  847. <input class="checkbox" type="radio" name="singleDbForm" value="1" id="singleDb1" <?php echo $singleDbForm?'checked="checked" ':''; ?> onclick="show_hide_tracking_and_user_db(this.id);" /> <label for="singleDb1"><?php echo get_lang('One'); ?></label>
  848. <input class="checkbox" type="radio" name="singleDbForm" value="0" id="singleDb0" <?php echo $singleDbForm?'':'checked="checked" '; ?> onclick="show_hide_tracking_and_user_db(this.id);" /> <label for="singleDb0"><?php echo get_lang('Several'); ?></label>
  849. </td>
  850. <?php endif; ?>
  851. <td>&nbsp;</td>
  852. </tr>
  853. </div>
  854. <tr>
  855. <td><button type="submit" class="login" name="step3" value="<?php echo get_lang('CheckDatabaseConnection'); ?>" ><?php echo get_lang('CheckDatabaseConnection'); ?></button></td>
  856. <?php $dbConnect = test_db_connect ($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm);
  857. if($dbConnect==1): ?>
  858. <td colspan="2">
  859. <div class="confirmation-message">
  860. <!--<div style="float:left; margin-right:10px;">
  861. <img src="../img/message_confirmation.png" alt="Confirmation" />
  862. </div>-->
  863. <!--<div style="float:left;">-->
  864. MySQL host info: <?php echo mysql_get_host_info(); ?><br />
  865. MySQL server version: <?php echo mysql_get_server_info(); ?><br />
  866. MySQL protocol version: <?php echo mysql_get_proto_info(); ?>
  867. <!--</div>-->
  868. <div style="clear:both;"></div>
  869. </div>
  870. </td>
  871. <?php else: ?>
  872. <td colspan="2">
  873. <div style="float:left;" class="error-message">
  874. <!--<div style="float:left; margin-right:10px;">
  875. <img src="../img/message_error.png" alt="Error" />
  876. </div>-->
  877. <div style="float:left;">
  878. <strong>MySQL error: <?php echo mysql_errno(); ?></strong><br />
  879. <?php echo mysql_error().'<br/>'; ?>
  880. <strong><?php echo get_lang('Details').': '. get_lang('FailedConectionDatabase'); ?></strong><br />
  881. </div>
  882. </div>
  883. </td>
  884. <?php endif; ?>
  885. </tr>
  886. <tr>
  887. <td><button type="submit" name="step2" class="back" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button></td>
  888. <td>&nbsp;</td>
  889. <td align="right"><input type="hidden" name="is_executable" id="is_executable" value="-" /><button type="submit" class="next" name="step4" value="<?php echo get_lang('Next'); ?> &gt;" /><?php echo get_lang('Next'); ?></button></td>
  890. </tr>
  891. </table>
  892. <?php
  893. }
  894. /**
  895. * Displays a parameter in a table row.
  896. * Used by the display_configuration_settings_form function.
  897. */
  898. function display_configuration_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $display_when_update = 'true')
  899. {
  900. global $charset;
  901. echo "<tr>\n";
  902. echo "<td>$parameter_name&nbsp;&nbsp;</td>\n";
  903. if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update)
  904. {
  905. echo '<td><input type="hidden" name="'.$form_field_name.'" value="'.api_htmlentities($parameter_value, ENT_QUOTES, $charset).'" />'.$parameter_value."</td>\n";
  906. }
  907. else
  908. {
  909. echo '<td><input type="text" size="'.FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.MAX_FORM_FIELD_LENGTH.'" name="'.$form_field_name.'" value="'.api_htmlentities($parameter_value, ENT_QUOTES, $charset).'" />'."</td>\n";
  910. }
  911. echo "</tr>\n";
  912. }
  913. /**
  914. * Displays step 4 of the installation - configuration settings about Dokeos itself.
  915. */
  916. function display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $allowSelfRegProf, $loginForm, $passForm)
  917. {
  918. global $charset;
  919. if($installType != 'update' && empty($languageForm))
  920. {
  921. $languageForm = $_SESSION['install_language'];
  922. }
  923. echo "<h2>" . display_step_sequence() . get_lang("CfgSetting") . "</h2>";
  924. echo '<p>'.get_lang('ConfigSettingsInfo').' <b>main/inc/conf/configuration.php</b></p>';
  925. echo "</td></tr>\n<tr><td>";
  926. echo "<table width=\"100%\">";
  927. //First parameter: language
  928. echo "<tr>\n";
  929. echo '<td>'.get_lang('MainLang')."&nbsp;&nbsp;</td>\n";
  930. if($installType == 'update')
  931. {
  932. echo '<td><input type="hidden" name="languageForm" value="'.api_htmlentities($languageForm, ENT_QUOTES, $charset).'" />'.$languageForm."</td>\n";
  933. }
  934. else // new installation
  935. {
  936. echo '<td>';
  937. $array_lang = array('asturian','english','italian','french','slovenian','spanish');
  938. ////Only display Language have 90% +
  939. echo "\t\t<select name=\"languageForm\">\n";
  940. foreach ($array_lang as $key => $value) {
  941. echo '<option value="'.$value.'"';
  942. if($value == $languageForm) echo ' selected="selected"';
  943. echo ">$value</option>\n";
  944. }
  945. echo "\t\t</select>\n";
  946. //Display all language
  947. /*echo "<select name=\"languageForm\">\n";
  948. $dirname='../lang/';
  949. if ($dir=@opendir($dirname)) {
  950. $lang_files = array();
  951. while (($file = readdir($dir)) !== false) {
  952. if($file != '.' && $file != '..' && $file != 'CVS' && $file != '.svn' && is_dir($dirname.$file)){
  953. array_push($lang_files, $file);
  954. }
  955. }
  956. closedir($dir);
  957. }
  958. sort($lang_files);
  959. foreach ($lang_files as $file) {
  960. echo '<option value="'.$file.'"';
  961. if($file == $languageForm) echo ' selected="selected"';
  962. echo ">$file</option>\n";
  963. }
  964. echo '</select>';*/
  965. echo "</td>\n";
  966. }
  967. echo "</tr>\n";
  968. //Second parameter: Dokeos URL
  969. echo "<tr>\n";
  970. echo '<td>'.get_lang('DokeosURL').' (<font color="red">'.get_lang('ThisFieldIsRequired')."</font>)&nbsp;&nbsp;</td>\n";
  971. if($installType == 'update') echo '<td>'.api_htmlentities($urlForm, ENT_QUOTES, $charset)."</td>\n";
  972. else echo '<td><input type="text" size="40" maxlength="100" name="urlForm" value="'.api_htmlentities($urlForm, ENT_QUOTES, $charset).'" />'."</td>\n";
  973. echo "</tr>\n";
  974. //Parameter 3: administrator's email
  975. display_configuration_parameter($installType, get_lang("AdminEmail"), "emailForm", $emailForm);
  976. //Parameters 4 and 5: administrator's names
  977. if (api_is_western_name_order()) {
  978. display_configuration_parameter($installType, get_lang("AdminFirstName"), "adminFirstName", $adminFirstName);
  979. display_configuration_parameter($installType, get_lang("AdminLastName"), "adminLastName", $adminLastName);
  980. } else {
  981. display_configuration_parameter($installType, get_lang("AdminLastName"), "adminLastName", $adminLastName);
  982. display_configuration_parameter($installType, get_lang("AdminFirstName"), "adminFirstName", $adminFirstName);
  983. }
  984. //Parameter 6: administrator's telephone
  985. display_configuration_parameter($installType, get_lang("AdminPhone"), "adminPhoneForm", $adminPhoneForm);
  986. //Parameter 7: administrator's login
  987. display_configuration_parameter($installType, get_lang("AdminLogin"), "loginForm", $loginForm, ($installType == 'update' ? true : false));
  988. //Parameter 8: administrator's password
  989. if($installType != 'update')
  990. display_configuration_parameter($installType, get_lang("AdminPass"), "passForm", $passForm, false);
  991. //Parameter 9: campus name
  992. display_configuration_parameter($installType, get_lang("CampusName"), "campusForm", $campusForm);
  993. //Parameter 10: institute (short) name
  994. display_configuration_parameter($installType, get_lang("InstituteShortName"), "institutionForm", $institutionForm);
  995. //Parameter 11: institute (short) name
  996. display_configuration_parameter($installType, get_lang("InstituteURL"), "institutionUrlForm", $institutionUrlForm);
  997. /*
  998. //old method
  999. <tr>
  1000. <td><?php echo get_lang("EncryptUserPass"); ?> :</td>
  1001. <?php if($installType == 'update'): ?>
  1002. <td><input type="hidden" name="encryptPassForm" value="<?php echo $encryptPassForm; ?>" /><?php echo $encryptPassForm? get_lang("Yes") : get_lang("No"); ?></td>
  1003. <?php else: ?>
  1004. <td>
  1005. <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>
  1006. <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>
  1007. </td>
  1008. <?php endif; ?>
  1009. </tr>
  1010. */
  1011. ?>
  1012. <tr>
  1013. <td><?php echo get_lang("EncryptMethodUserPass"); ?> :</td>
  1014. <?php if($installType == 'update'): ?>
  1015. <td><input type="hidden" name="encryptPassForm" value="<?php echo $encryptPassForm; ?>" /><?php echo $encryptPassForm; ?></td>
  1016. <?php else: ?>
  1017. <td>
  1018. <input class="checkbox" type="radio" name="encryptPassForm" value="md5" id="encryptPass0" <?php echo $encryptPassForm?'checked="checked" ':''; ?>/> <label for="encryptPass0"><?php echo "md5"; ?></label>
  1019. <input class="checkbox" type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" <?php echo $encryptPassForm?'':'checked="checked" '; ?>/> <label for="encryptPass1"><?php echo "sha1"; ?></label>
  1020. <input class="checkbox" type="radio" name="encryptPassForm" value="none" id="encryptPass2" <?php echo $encryptPassForm?'':'checked="checked" '; ?>/> <label for="encryptPass2"><?php echo get_lang("None"); ?></label>
  1021. </td>
  1022. <?php endif; ?>
  1023. </tr>
  1024. <tr>
  1025. <td><?php echo get_lang("AllowSelfReg"); ?> :</td>
  1026. <?php if($installType == 'update'): ?>
  1027. <td><input type="hidden" name="allowSelfReg" value="<?php echo $allowSelfReg; ?>" /><?php echo $allowSelfReg? get_lang("Yes") : get_lang("No"); ?></td>
  1028. <?php else: ?>
  1029. <td>
  1030. <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>
  1031. <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>
  1032. </td>
  1033. <?php endif; ?>
  1034. </tr>
  1035. <tr>
  1036. <td><?php echo get_lang("AllowSelfRegProf"); ?> :</td>
  1037. <?php if($installType == 'update'): ?>
  1038. <td><input type="hidden" name="allowSelfRegProf" value="<?php echo $allowSelfRegProf; ?>" /><?php echo $allowSelfRegProf? get_lang("Yes") : get_lang("No"); ?></td>
  1039. <?php else: ?>
  1040. <td>
  1041. <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>
  1042. <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>
  1043. </td>
  1044. <?php endif; ?>
  1045. </tr>
  1046. <tr>
  1047. <td><button type="submit" class="back" name="step3" value="&lt; <?php echo get_lang('Previous'); ?>" /><?php echo get_lang('Previous'); ?></button></td>
  1048. <td align="right"><input type="hidden" name="is_executable" id="is_executable" value="-" /><button class="next" type="submit" name="step5" value="<?php echo get_lang('Next'); ?> &gt;" /><?php echo get_lang('Next'); ?></button></td>
  1049. </tr>
  1050. </table>
  1051. <?php
  1052. }
  1053. /**
  1054. * After installation is completed (step 6), this message is displayed.
  1055. */
  1056. function display_after_install_message($installType, $nbr_courses)
  1057. {
  1058. ?>
  1059. <h2><?php echo display_step_sequence() . get_lang("CfgSetting"); ?></h2>
  1060. <?php echo get_lang('FirstUseTip'); ?>
  1061. <?php if($installType == 'update' && $nbr_courses > MAX_COURSE_TRANSFER): ?>
  1062. <br /><br />
  1063. <font color="red"><b><?php echo get_lang('Warning');?> :</b> <?php printf(get_lang('YouHaveMoreThanXCourses'),MAX_COURSE_TRANSFER,MAX_COURSE_TRANSFER,'<a href="update_courses.php"><font color="red">','</font></a>');?></font>
  1064. <?php endif; ?>
  1065. <br /><br />
  1066. <?php
  1067. echo '<div class="warning-message">';
  1068. //echo '<img src="../img/message_warning.png" style="float:left; margin-right:10px;" alt="'.get_lang('Warning').'"/>';
  1069. echo '<b>'.get_lang('SecurityAdvice').'</b>';
  1070. echo ': ';
  1071. printf(get_lang('ToProtectYourSiteMakeXAndYReadOnly'),'main/inc/conf/configuration.php','main/install/index.php');
  1072. echo '</div>';
  1073. ?>
  1074. </form>
  1075. <a class="portal" href="../../index.php"><?php echo get_lang('GoToYourNewlyCreatedPortal'); ?></a>
  1076. <?php
  1077. }
  1078. /**
  1079. * In step 3. Test the connection to the DB in case of single or multy DB.
  1080. * Return "1"if no problems, "0" if, in case of multiDB we can't create a new DB and "-1" if there is no connection.
  1081. */
  1082. function test_db_connect ($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm) {
  1083. $dbConnect = -1;
  1084. if ($singleDbForm == 1) {
  1085. if(@mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm) !== false) {
  1086. $dbConnect = 1;
  1087. } else {
  1088. $dbConnect = -1;
  1089. }
  1090. } elseif ($singleDbForm == 0) {
  1091. $res=@mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
  1092. if ($res===false) {
  1093. return $res;
  1094. }
  1095. if ($res !== false) {
  1096. // The Dokeos system has not been designed to use special SQL modes that were introduced since MySQL 5
  1097. @mysql_query("set session sql_mode='';");
  1098. $multipleDbCheck = @mysql_query("CREATE DATABASE ".$dbPrefixForm."test_dokeos_connection");
  1099. if ($multipleDbCheck !== false) {
  1100. $multipleDbCheck = @mysql_query("DROP DATABASE IF EXISTS ".$dbPrefixForm."test_dokeos_connection");
  1101. if ($multipleDbCheck !== false) {
  1102. $dbConnect = 1;
  1103. } else {
  1104. $dbConnect = 0;
  1105. }
  1106. } else {
  1107. $dbConnect = 0;
  1108. }
  1109. } else {
  1110. $dbConnect = -1;
  1111. }
  1112. }
  1113. return($dbConnect); //return "1"if no problems, "0" if, in case of multiDB we can't create a new DB and "-1" if there is no connection.
  1114. }
  1115. ?>