install_functions.inc.php 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229
  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. Chamilo <?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. global $_configuration, $update_from_version_6;
  731. if(in_array($_POST['old_version'],$update_from_version_6)) {
  732. $dbHostForm = get_config_param('dbHost');
  733. $dbUsernameForm = get_config_param('dbLogin');
  734. $dbPassForm = get_config_param('dbPass');
  735. $dbPrefixForm = get_config_param('dbNamePrefix');
  736. $enableTrackingForm=get_config_param('is_trackingEnabled');
  737. $singleDbForm =get_config_param('singleDbEnabled');
  738. $dbNameForm =get_config_param('mainDbName');
  739. $dbStatsForm =get_config_param('statsDbName');
  740. $dbScormForm =get_config_param('scormDbName');
  741. $dbUserForm =get_config_param('user_personal_database');
  742. $dbScormExists=true;
  743. }
  744. else
  745. {
  746. $dbHostForm=$_configuration['db_host'];
  747. $dbUsernameForm=$_configuration['db_user'];
  748. $dbPassForm=$_configuration['db_password'];
  749. $dbPrefixForm=$_configuration['db_prefix'];
  750. $enableTrackingForm=$_configuration['tracking_enabled'];
  751. $singleDbForm=$_configuration['single_database'];
  752. $dbNameForm=$_configuration['main_database'];
  753. $dbStatsForm=$_configuration['statistics_database'];
  754. $dbScormForm=$_configuration['scorm_database'];
  755. $dbUserForm=$_configuration['user_personal_database'];
  756. $dbScormExists=true;
  757. }
  758. if(empty($dbScormForm))
  759. {
  760. if($singleDbForm)
  761. {
  762. $dbScormForm=$dbNameForm;
  763. }
  764. else
  765. {
  766. $dbScormForm=$dbPrefixForm.'scorm';
  767. $dbScormExists=false;
  768. }
  769. }
  770. if(empty($dbUserForm))
  771. {
  772. if($singleDbForm)
  773. {
  774. $dbUserForm=$dbNameForm;
  775. }
  776. else
  777. {
  778. $dbUserForm=$dbPrefixForm.'chamilo_user';
  779. }
  780. }
  781. echo "<h2>" . display_step_sequence() .get_lang("DBSetting") . "</h2>";
  782. echo get_lang("DBSettingUpgradeIntro");
  783. }else{
  784. if(empty($dbPrefixForm)) //make sure there is a default value for db prefix
  785. {
  786. $dbPrefixForm = 'chamilo_';
  787. }
  788. echo "<h2>" . display_step_sequence() .get_lang("DBSetting") . "</h2>";
  789. echo get_lang("DBSettingIntro");
  790. }
  791. ?>
  792. <br /><br />
  793. </td>
  794. </tr>
  795. <tr>
  796. <td>
  797. <table width="100%">
  798. <tr>
  799. <td width="40%"><?php echo get_lang('DBHost'); ?> </td>
  800. <?php if($installType == 'update'): ?>
  801. <td width="30%"><input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?></td>
  802. <td width="30%">&nbsp;</td>
  803. <?php else: ?>
  804. <td width="30%"><input type="text" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /></td>
  805. <td width="30%"><?php echo get_lang('EG').' localhost'; ?></td>
  806. <?php endif; ?>
  807. </tr>
  808. <?php
  809. //database user username
  810. $example_login = get_lang('EG').' root';
  811. display_database_parameter($installType, get_lang('DBLogin'), 'dbUsernameForm', $dbUsernameForm, $example_login);
  812. //database user password
  813. $example_password = get_lang('EG').' '.api_generate_password();
  814. display_database_parameter($installType, get_lang('DBPassword'), 'dbPassForm', $dbPassForm, $example_password);
  815. //database prefix
  816. display_database_parameter($installType, get_lang('DbPrefixForm'), 'dbPrefixForm', $dbPrefixForm, get_lang('DbPrefixCom'));
  817. //fields for the four standard Chamilo databases
  818. 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>';
  819. display_database_parameter($installType, get_lang('MainDB'), 'dbNameForm', $dbNameForm, '&nbsp;',null,'id="optional_param1" style="display:none;"');
  820. display_database_parameter($installType, get_lang('StatDB'), 'dbStatsForm', $dbStatsForm, '&nbsp;',null,'id="optional_param2" style="display:none;"');
  821. if($installType == 'update' && in_array($_POST['old_version'],$update_from_version_6))
  822. {
  823. display_database_parameter($installType, get_lang('ScormDB'), 'dbScormForm', $dbScormForm, '&nbsp;',null,'id="optional_param3" style="display:none;"');
  824. }
  825. display_database_parameter($installType, get_lang('UserDB'), 'dbUserForm', $dbUserForm, '&nbsp;',null,'id="optional_param4" style="display:none;"');
  826. ?>
  827. <tr id="optional_param5" style="display:none;">
  828. <td><?php echo get_lang('EnableTracking'); ?> </td>
  829. <?php if($installType == 'update'): ?>
  830. <td><input type="hidden" name="enableTrackingForm" value="<?php echo $enableTrackingForm; ?>" /><?php echo $enableTrackingForm? get_lang('Yes') : get_lang('No'); ?></td>
  831. <?php else: ?>
  832. <td>
  833. <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>
  834. <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>
  835. </td>
  836. <?php endif; ?>
  837. <td>&nbsp;</td>
  838. </tr>
  839. <tr id="optional_param6" style="display:none;">
  840. <td><?php echo get_lang('SingleDb'); ?> </td>
  841. <?php if($installType == 'update'): ?>
  842. <td><input type="hidden" name="singleDbForm" value="<?php echo $singleDbForm; ?>" /><?php echo $singleDbForm? get_lang('One') : get_lang('Several'); ?></td>
  843. <?php else: ?>
  844. <td>
  845. <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>
  846. <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>
  847. </td>
  848. <?php endif; ?>
  849. <td>&nbsp;</td>
  850. </tr>
  851. </div>
  852. <tr>
  853. <td><button type="submit" class="login" name="step3" value="<?php echo get_lang('CheckDatabaseConnection'); ?>" ><?php echo get_lang('CheckDatabaseConnection'); ?></button></td>
  854. <?php $dbConnect = test_db_connect ($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm);
  855. if($dbConnect==1): ?>
  856. <td colspan="2">
  857. <div class="confirmation-message">
  858. <!--<div style="float:left; margin-right:10px;">
  859. <img src="../img/message_confirmation.png" alt="Confirmation" />
  860. </div>-->
  861. <!--<div style="float:left;">-->
  862. MySQL host info: <?php echo mysql_get_host_info(); ?><br />
  863. MySQL server version: <?php echo mysql_get_server_info(); ?><br />
  864. MySQL protocol version: <?php echo mysql_get_proto_info(); ?>
  865. <!--</div>-->
  866. <div style="clear:both;"></div>
  867. </div>
  868. </td>
  869. <?php else: ?>
  870. <td colspan="2">
  871. <div style="float:left;" class="error-message">
  872. <!--<div style="float:left; margin-right:10px;">
  873. <img src="../img/message_error.png" alt="Error" />
  874. </div>-->
  875. <div style="float:left;">
  876. <strong>MySQL error: <?php echo mysql_errno(); ?></strong><br />
  877. <?php echo mysql_error().'<br/>'; ?>
  878. <strong><?php echo get_lang('Details').': '. get_lang('FailedConectionDatabase'); ?></strong><br />
  879. </div>
  880. </div>
  881. </td>
  882. <?php endif; ?>
  883. </tr>
  884. <tr>
  885. <td><button type="submit" name="step2" class="back" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button></td>
  886. <td>&nbsp;</td>
  887. <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>
  888. </tr>
  889. </table>
  890. <?php
  891. }
  892. /**
  893. * Displays a parameter in a table row.
  894. * Used by the display_configuration_settings_form function.
  895. */
  896. function display_configuration_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $display_when_update = 'true')
  897. {
  898. global $charset;
  899. echo "<tr>\n";
  900. echo "<td>$parameter_name&nbsp;&nbsp;</td>\n";
  901. if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update)
  902. {
  903. echo '<td><input type="hidden" name="'.$form_field_name.'" value="'.api_htmlentities($parameter_value, ENT_QUOTES, $charset).'" />'.$parameter_value."</td>\n";
  904. }
  905. else
  906. {
  907. 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";
  908. }
  909. echo "</tr>\n";
  910. }
  911. /**
  912. * Displays step 4 of the installation - configuration settings about Chamilo itself.
  913. */
  914. function display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $allowSelfRegProf, $loginForm, $passForm)
  915. {
  916. global $charset;
  917. if($installType != 'update' && empty($languageForm))
  918. {
  919. $languageForm = $_SESSION['install_language'];
  920. }
  921. echo "<h2>" . display_step_sequence() . get_lang("CfgSetting") . "</h2>";
  922. echo '<p>'.get_lang('ConfigSettingsInfo').' <b>main/inc/conf/configuration.php</b></p>';
  923. echo "</td></tr>\n<tr><td>";
  924. echo "<table width=\"100%\">";
  925. //First parameter: language
  926. echo "<tr>\n";
  927. echo '<td>'.get_lang('MainLang')."&nbsp;&nbsp;</td>\n";
  928. if($installType == 'update')
  929. {
  930. echo '<td><input type="hidden" name="languageForm" value="'.api_htmlentities($languageForm, ENT_QUOTES, $charset).'" />'.$languageForm."</td>\n";
  931. }
  932. else // new installation
  933. {
  934. echo '<td>';
  935. $array_lang = array('asturian','english','italian','french','slovenian','spanish');
  936. ////Only display Language have 90% +
  937. echo "\t\t<select name=\"languageForm\">\n";
  938. foreach ($array_lang as $key => $value) {
  939. echo '<option value="'.$value.'"';
  940. if($value == $languageForm) echo ' selected="selected"';
  941. echo ">$value</option>\n";
  942. }
  943. echo "\t\t</select>\n";
  944. //Display all language
  945. /*echo "<select name=\"languageForm\">\n";
  946. $dirname='../lang/';
  947. if ($dir=@opendir($dirname)) {
  948. $lang_files = array();
  949. while (($file = readdir($dir)) !== false) {
  950. if($file != '.' && $file != '..' && $file != 'CVS' && $file != '.svn' && is_dir($dirname.$file)){
  951. array_push($lang_files, $file);
  952. }
  953. }
  954. closedir($dir);
  955. }
  956. sort($lang_files);
  957. foreach ($lang_files as $file) {
  958. echo '<option value="'.$file.'"';
  959. if($file == $languageForm) echo ' selected="selected"';
  960. echo ">$file</option>\n";
  961. }
  962. echo '</select>';*/
  963. echo "</td>\n";
  964. }
  965. echo "</tr>\n";
  966. //Second parameter: Chamilo URL
  967. echo "<tr>\n";
  968. echo '<td>'.get_lang('ChamiloURL').' (<font color="red">'.get_lang('ThisFieldIsRequired')."</font>)&nbsp;&nbsp;</td>\n";
  969. if($installType == 'update') echo '<td>'.api_htmlentities($urlForm, ENT_QUOTES, $charset)."</td>\n";
  970. else echo '<td><input type="text" size="40" maxlength="100" name="urlForm" value="'.api_htmlentities($urlForm, ENT_QUOTES, $charset).'" />'."</td>\n";
  971. echo "</tr>\n";
  972. //Parameter 3: administrator's email
  973. display_configuration_parameter($installType, get_lang("AdminEmail"), "emailForm", $emailForm);
  974. //Parameters 4 and 5: administrator's names
  975. if (api_is_western_name_order()) {
  976. display_configuration_parameter($installType, get_lang("AdminFirstName"), "adminFirstName", $adminFirstName);
  977. display_configuration_parameter($installType, get_lang("AdminLastName"), "adminLastName", $adminLastName);
  978. } else {
  979. display_configuration_parameter($installType, get_lang("AdminLastName"), "adminLastName", $adminLastName);
  980. display_configuration_parameter($installType, get_lang("AdminFirstName"), "adminFirstName", $adminFirstName);
  981. }
  982. //Parameter 6: administrator's telephone
  983. display_configuration_parameter($installType, get_lang("AdminPhone"), "adminPhoneForm", $adminPhoneForm);
  984. //Parameter 7: administrator's login
  985. display_configuration_parameter($installType, get_lang("AdminLogin"), "loginForm", $loginForm, ($installType == 'update' ? true : false));
  986. //Parameter 8: administrator's password
  987. if($installType != 'update')
  988. display_configuration_parameter($installType, get_lang("AdminPass"), "passForm", $passForm, false);
  989. //Parameter 9: campus name
  990. display_configuration_parameter($installType, get_lang("CampusName"), "campusForm", $campusForm);
  991. //Parameter 10: institute (short) name
  992. display_configuration_parameter($installType, get_lang("InstituteShortName"), "institutionForm", $institutionForm);
  993. //Parameter 11: institute (short) name
  994. display_configuration_parameter($installType, get_lang("InstituteURL"), "institutionUrlForm", $institutionUrlForm);
  995. /*
  996. //old method
  997. <tr>
  998. <td><?php echo get_lang("EncryptUserPass"); ?> :</td>
  999. <?php if($installType == 'update'): ?>
  1000. <td><input type="hidden" name="encryptPassForm" value="<?php echo $encryptPassForm; ?>" /><?php echo $encryptPassForm? get_lang("Yes") : get_lang("No"); ?></td>
  1001. <?php else: ?>
  1002. <td>
  1003. <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>
  1004. <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>
  1005. </td>
  1006. <?php endif; ?>
  1007. </tr>
  1008. */
  1009. ?>
  1010. <tr>
  1011. <td><?php echo get_lang("EncryptMethodUserPass"); ?> :</td>
  1012. <?php if($installType == 'update'): ?>
  1013. <td><input type="hidden" name="encryptPassForm" value="<?php echo $encryptPassForm; ?>" /><?php echo $encryptPassForm; ?></td>
  1014. <?php else: ?>
  1015. <td>
  1016. <input class="checkbox" type="radio" name="encryptPassForm" value="md5" id="encryptPass0" <?php echo $encryptPassForm?'checked="checked" ':''; ?>/> <label for="encryptPass0"><?php echo "md5"; ?></label>
  1017. <input class="checkbox" type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" <?php echo $encryptPassForm?'':'checked="checked" '; ?>/> <label for="encryptPass1"><?php echo "sha1"; ?></label>
  1018. <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>
  1019. </td>
  1020. <?php endif; ?>
  1021. </tr>
  1022. <tr>
  1023. <td><?php echo get_lang("AllowSelfReg"); ?> :</td>
  1024. <?php if($installType == 'update'): ?>
  1025. <td><input type="hidden" name="allowSelfReg" value="<?php echo $allowSelfReg; ?>" /><?php echo $allowSelfReg? get_lang("Yes") : get_lang("No"); ?></td>
  1026. <?php else: ?>
  1027. <td>
  1028. <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>
  1029. <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>
  1030. </td>
  1031. <?php endif; ?>
  1032. </tr>
  1033. <tr>
  1034. <td><?php echo get_lang("AllowSelfRegProf"); ?> :</td>
  1035. <?php if($installType == 'update'): ?>
  1036. <td><input type="hidden" name="allowSelfRegProf" value="<?php echo $allowSelfRegProf; ?>" /><?php echo $allowSelfRegProf? get_lang("Yes") : get_lang("No"); ?></td>
  1037. <?php else: ?>
  1038. <td>
  1039. <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>
  1040. <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>
  1041. </td>
  1042. <?php endif; ?>
  1043. </tr>
  1044. <tr>
  1045. <td><button type="submit" class="back" name="step3" value="&lt; <?php echo get_lang('Previous'); ?>" /><?php echo get_lang('Previous'); ?></button></td>
  1046. <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>
  1047. </tr>
  1048. </table>
  1049. <?php
  1050. }
  1051. /**
  1052. * After installation is completed (step 6), this message is displayed.
  1053. */
  1054. function display_after_install_message($installType, $nbr_courses)
  1055. {
  1056. ?>
  1057. <h2><?php echo display_step_sequence() . get_lang("CfgSetting"); ?></h2>
  1058. <?php echo get_lang('FirstUseTip'); ?>
  1059. <?php if($installType == 'update' && $nbr_courses > MAX_COURSE_TRANSFER): ?>
  1060. <br /><br />
  1061. <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>
  1062. <?php endif; ?>
  1063. <br /><br />
  1064. <?php
  1065. echo '<div class="warning-message">';
  1066. //echo '<img src="../img/message_warning.png" style="float:left; margin-right:10px;" alt="'.get_lang('Warning').'"/>';
  1067. echo '<b>'.get_lang('SecurityAdvice').'</b>';
  1068. echo ': ';
  1069. printf(get_lang('ToProtectYourSiteMakeXAndYReadOnly'),'main/inc/conf/configuration.php','main/install/index.php');
  1070. echo '</div>';
  1071. ?>
  1072. </form>
  1073. <a class="portal" href="../../index.php"><?php echo get_lang('GoToYourNewlyCreatedPortal'); ?></a>
  1074. <?php
  1075. }
  1076. /**
  1077. * In step 3. Test the connection to the DB in case of single or multy DB.
  1078. * 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.
  1079. */
  1080. function test_db_connect ($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm) {
  1081. $dbConnect = -1;
  1082. if ($singleDbForm == 1) {
  1083. if(@mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm) !== false) {
  1084. $dbConnect = 1;
  1085. } else {
  1086. $dbConnect = -1;
  1087. }
  1088. } elseif ($singleDbForm == 0) {
  1089. $res=@mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
  1090. if ($res===false) {
  1091. return $res;
  1092. }
  1093. if ($res !== false) {
  1094. // The Dokeos system has not been designed to use special SQL modes that were introduced since MySQL 5
  1095. @mysql_query("set session sql_mode='';");
  1096. $multipleDbCheck = @mysql_query("CREATE DATABASE ".$dbPrefixForm."test_dokeos_connection");
  1097. if ($multipleDbCheck !== false) {
  1098. $multipleDbCheck = @mysql_query("DROP DATABASE IF EXISTS ".$dbPrefixForm."test_dokeos_connection");
  1099. if ($multipleDbCheck !== false) {
  1100. $dbConnect = 1;
  1101. } else {
  1102. $dbConnect = 0;
  1103. }
  1104. } else {
  1105. $dbConnect = 0;
  1106. }
  1107. } else {
  1108. $dbConnect = -1;
  1109. }
  1110. }
  1111. 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.
  1112. }
  1113. ?>