install_functions.inc.php 48 KB

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