install_functions.inc.php 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  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='OK',$return_failure='KO',$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. $myconnect = mysql_select_db($db_name);
  255. $sql = "SELECT * FROM settings_current WHERE variable = '$param'";
  256. $res = mysql_query($sql);
  257. if($res===false){return null;}
  258. if(mysql_num_rows($res)>0)
  259. {
  260. $row = mysql_fetch_array($res);
  261. $value = $row['selected_value'];
  262. return $value;
  263. }
  264. return null;
  265. }
  266. /**
  267. * Return a list of language directories.
  268. * @todo function does not belong here, move to code library,
  269. * also see infocours.php which contains similar function
  270. */
  271. function get_language_folder_list($dirname)
  272. {
  273. if ($dirname[strlen($dirname)-1] != '/') $dirname .= '/';
  274. $handle = opendir($dirname);
  275. $language_list = array();
  276. while ($entries = readdir($handle))
  277. {
  278. if ($entries=='.' || $entries=='..' || $entries=='CVS' || $entries == '.svn') continue;
  279. if (is_dir($dirname.$entries))
  280. {
  281. $language_list[] = $entries;
  282. }
  283. }
  284. closedir($handle);
  285. return $language_list;
  286. }
  287. /*
  288. ==============================================================================
  289. DISPLAY FUNCTIONS
  290. ==============================================================================
  291. */
  292. /**
  293. * Displays a form (drop down menu) so the user can select
  294. * his/her preferred language.
  295. */
  296. function display_language_selection_box()
  297. {
  298. //get language list
  299. $dirname = '../lang/';
  300. $language_list = get_language_folder_list($dirname);
  301. sort($language_list);
  302. //Reduce the number of languages shown to only show those with higher than 90% translation in DLTT
  303. //This option can be easily removed later on. The aim is to test people response to less choice
  304. //$language_to_display = $language_list;
  305. $language_to_display = array('brazilian','dutch','english','french','german','hungarian','italian','portuguese','slovenian','spanish');
  306. //display
  307. echo "\t\t<select name=\"language_list\">\n";
  308. $default_language = 'english';
  309. foreach ($language_to_display as $key => $value)
  310. {
  311. if ($value == $default_language) $option_end = ' selected="selected">';
  312. else $option_end = '>';
  313. echo "\t\t\t<option value=\"$value\"$option_end";
  314. echo ucfirst($value);
  315. echo "</option>\n";
  316. }
  317. echo "\t\t</select>\n";
  318. }
  319. /**
  320. * This function displays a language dropdown box so that the installatioin
  321. * can be done in the language of the user
  322. */
  323. function display_language_selection()
  324. { ?>
  325. <h1><?php get_lang('WelcomeToTheDokeosInstaller');?></h1>
  326. <h2><?php echo display_step_sequence(); ?><?php echo get_lang('InstallationLanguage');?></h2>
  327. <p><?php echo get_lang('PleaseSelectInstallationProcessLanguage');?>:</p>
  328. <form id="lang_form" method="post" action="<?php echo api_get_self(); ?>">
  329. <?php display_language_selection_box(); ?>
  330. <input type="submit" name="step1" value="<?php get_lang('Next');?> &gt;" />
  331. </form>
  332. <?php }
  333. /**
  334. * This function displays the requirements for installing Dokeos.
  335. *
  336. * @param string $installType
  337. * @param boolean $badUpdatePath
  338. * @param string The updatePath given (if given)
  339. * @param array $update_from_version_8 The different subversions from version 1.8
  340. * @param array $update_from_version_6 The different subversions from version 1.6
  341. *
  342. * @author unknow
  343. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  344. */
  345. function display_requirements($installType, $badUpdatePath, $updatePath='', $update_from_version_8=array(), $update_from_version_6=array())
  346. {
  347. echo '<h2>'.display_step_sequence().get_lang('Requirements')."</h2>\n";
  348. echo '<strong>'.get_lang('ReadThoroughly').'</strong><br />';
  349. echo get_lang('MoreDetails').' <a href="../../documentation/installation_guide.html" target="_blank">'.get_lang('ReadTheInstallGuide').'</a>.<br />'."\n";
  350. // SERVER REQUIREMENTS
  351. echo '<div class="RequirementHeading"><h1>'.get_lang('ServerRequirements').'</h1>';
  352. echo '<div class="RequirementText">'.get_lang('ServerRequirementsInfo').'</div>';
  353. echo '<div class="RequirementContent">';
  354. echo '<table class="requirements">
  355. <tr>
  356. <td class="requirements-item">'.get_lang('PHPVersion').'>= 5.0</td>
  357. <td class="requirements-value">';
  358. if (phpversion() < '5.0')
  359. {
  360. echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>';
  361. }
  362. else
  363. {
  364. echo '<strong><font color="green">'.get_lang('PHPVersionOK'). ' '.phpversion().'</font></strong>';
  365. }
  366. echo ' </td>
  367. </tr>
  368. <tr>
  369. <td class="requirements-item">session '.get_lang('support').'</td>
  370. <td class="requirements-value">'.check_extension('session',get_lang('OK'), get_lang('ExtensionSessionsNotAvailable')).'</td>
  371. </tr>
  372. <tr>
  373. <td class="requirements-item">MySQL '.get_lang('support').'</td>
  374. <td class="requirements-value">'.check_extension('mysql',get_lang('OK'), get_lang('ExtensionMySQLNotAvailable')).'</td>
  375. </tr>
  376. <tr>
  377. <td class="requirements-item">zlib '.get_lang('support').'</td>
  378. <td class="requirements-value">'.check_extension('zlib',get_lang('OK'), get_lang('ExtensionZlibNotAvailable')).'</td>
  379. </tr>
  380. <tr>
  381. <td class="requirements-item">Regular Expressions '.get_lang('support').'</td>
  382. <td class="requirements-value">'.check_extension('pcre',get_lang('OK'), get_lang('ExtensionPCRENotAvailable')).'</td>
  383. </tr>
  384. <tr>
  385. <td class="requirements-item">XML '.get_lang('support').'</td>
  386. <td class="requirements-value">'.check_extension('xml',get_lang('OK'), get_lang('ExtensionZlibNotAvailable')).'</td>
  387. </tr>
  388. <tr>
  389. <td class="requirements-item">MultiByteString '.get_lang('support').'</td>
  390. <td class="requirements-value">'.check_extension('mbstring',get_lang('OK'), get_lang('ExtensionMBStringNotAvailable')).'</td>
  391. </tr>
  392. <tr>
  393. <td class="requirements-item">GD '.get_lang('support').'</td>
  394. <td class="requirements-value">'.check_extension('gd',get_lang('OK'), get_lang('ExtensionGDNotAvailable')).'</td>
  395. </tr>
  396. <tr>
  397. <td class="requirements-item">LDAP '.get_lang('support').' ('.get_lang('Optional').')</td>
  398. <td class="requirements-value">'.check_extension('ldap',get_lang('OK'), get_lang('ExtensionLDAPNotAvailable'),true).'</td>
  399. </tr>
  400. </table>';
  401. echo ' </div>';
  402. echo '</div>';
  403. // RECOMMENDED SETTINGS
  404. // Note: these are the settings for Joomla, does this also apply for Dokeos?
  405. // Note: also add upload_max_filesize here so that large uploads are possible
  406. echo '<div class="RequirementHeading"><h1>'.get_lang('RecommendedSettings').'</h1>';
  407. echo '<div class="RequirementText">'.get_lang('RecommendedSettingsInfo').'</div>';
  408. echo '<div class="RequirementContent">';
  409. echo '<table class="requirements">
  410. <tr>
  411. <th>'.get_lang('Setting').'</th>
  412. <th>'.get_lang('Recommended').'</th>
  413. <th>'.get_lang('Actual').'</th>
  414. </tr>
  415. <tr>
  416. <td class="requirements-item"><a href="http://php.net/manual/features.safe-mode.php">Safe Mode</a></td>
  417. <td class="requirements-recommended">OFF</td>
  418. <td class="requirements-value">'.check_php_setting('safe_mode','OFF').'</td>
  419. </tr>
  420. <tr>
  421. <td class="requirements-item"><a href="http://php.net/manual/ref.errorfunc.php#ini.display-errors">Display Errors</a></td>
  422. <td class="requirements-recommended">OFF</td>
  423. <td class="requirements-value">'.check_php_setting('display_errors','OFF').'</td>
  424. </tr>
  425. <tr>
  426. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.file-uploads">File Uploads</a></td>
  427. <td class="requirements-recommended">ON</td>
  428. <td class="requirements-value">'.check_php_setting('file_uploads','ON').'</td>
  429. </tr>
  430. <tr>
  431. <td class="requirements-item"><a href="http://php.net/manual/ref.info.php#ini.magic-quotes-gpc">Magic Quotes GPC</a></td>
  432. <td class="requirements-recommended">ON</td>
  433. <td class="requirements-value">'.check_php_setting('magic_quotes_gpc','ON').'</td>
  434. </tr>
  435. <tr>
  436. <td class="requirements-item"><a href="http://php.net/manual/ref.info.php#ini.magic-quotes-runtime">Magic Quotes Runtime</a></td>
  437. <td class="requirements-recommended">OFF</td>
  438. <td class="requirements-value">'.check_php_setting('magic_quotes_runtime','OFF').'</td>
  439. </tr>
  440. <tr>
  441. <td class="requirements-item"><a href="http://php.net/manual/security.globals.php">Register Globals</a></td>
  442. <td class="requirements-recommended">OFF</td>
  443. <td class="requirements-value">'.check_php_setting('register_globals','OFF').'</td>
  444. </tr>
  445. <tr>
  446. <td class="requirements-item"><a href="http://php.net/manual/ref.session.php#ini.session.auto-start">Session auto start</a></td>
  447. <td class="requirements-recommended">OFF</td>
  448. <td class="requirements-value">'.check_php_setting('session.auto_start','OFF').'</td>
  449. </tr>
  450. <tr>
  451. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.short-open-tag">Short Open Tag</a></td>
  452. <td class="requirements-recommended">ON</td>
  453. <td class="requirements-value">'.check_php_setting('short_open_tag','ON').'</td>
  454. </tr>
  455. <tr>
  456. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.upload-max-filesize">Maximum upload file size</a></td>
  457. <td class="requirements-recommended">10M-100M</td>
  458. <td class="requirements-value">'.ini_get('upload_max_filesize').'</td>
  459. </tr>
  460. <tr>
  461. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.post-max-size">Maximum post size</a></td>
  462. <td class="requirements-recommended">10M-100M</td>
  463. <td class="requirements-value">'.ini_get('post_max_size').'</td>
  464. </tr>
  465. </table>';
  466. echo ' </div>';
  467. echo '</div>';
  468. // DIRECTORY AND FILE PERMISSIONS
  469. echo '<div class="RequirementHeading"><h1>'.get_lang('DirectoryAndFilePermissions').'</h1>';
  470. echo '<div class="RequirementText">'.get_lang('DirectoryAndFilePermissionsInfo').'</div>';
  471. echo '<div class="RequirementContent">';
  472. echo '<table class="requirements">
  473. <tr>
  474. <td class="requirements-item">dokeos/main/inc/conf/</td>
  475. <td class="requirements-value">'.check_writable('inc/conf/').'</td>
  476. </tr>
  477. <tr>
  478. <td class="requirements-item">dokeos/main/garbage/</td>
  479. <td class="requirements-value">'.check_writable('garbage/').'</td>
  480. </tr>
  481. <tr>
  482. <td class="requirements-item">dokeos/main/upload/users/</td>
  483. <td class="requirements-value">'.check_writable('upload/users/').'</td>
  484. </tr>
  485. <tr>
  486. <td class="requirements-item">dokeos/main/default_course_document/images/</td>
  487. <td class="requirements-value">'.check_writable('default_course_document/images/').'</td>
  488. </tr>
  489. <tr>
  490. <td class="requirements-item">dokeos/archive/</td>
  491. <td class="requirements-value">'.check_writable('../archive/').'</td>
  492. </tr>
  493. <tr>
  494. <td class="requirements-item">dokeos/courses/</td>
  495. <td class="requirements-value">'.check_writable('../courses/').'</td>
  496. </tr>
  497. <tr>
  498. <td class="requirements-item">dokeos/home/</td>
  499. <td class="requirements-value">'.check_writable('../home/').'</td>
  500. </tr>
  501. <tr>
  502. <td class="requirements-item">dokeos/searchdb/</td>
  503. <td class="requirements-value">'.check_writable('../searchdb/').'</td>
  504. </tr>
  505. ';
  506. echo '</table>';
  507. echo ' </div>';
  508. echo '</div>';
  509. if($installType == 'update' && (empty($updatePath) || $badUpdatePath))
  510. {
  511. if($badUpdatePath)
  512. { ?>
  513. <div style="color:red; background-color:white; font-weight:bold; text-align:center;">
  514. <?php echo get_lang('Error');?>!<br />
  515. Dokeos <?php echo (isset($_POST['step2_update_6'])?implode('|',$update_from_version_6):implode('|',$update_from_version_8)).' '.get_lang('HasNotBeenFoundInThatDir'); ?>.
  516. </div>
  517. <?php }
  518. else
  519. {
  520. echo '<br />';
  521. }
  522. ?>
  523. <table border="0" cellpadding="5" align="center">
  524. <tr>
  525. <td><?php echo get_lang('OldVersionRootPath');?>:</td>
  526. <td><input type="text" name="updatePath" size="50" value="<?php echo ($badUpdatePath && !empty($updatePath))?htmlentities($updatePath):$_SERVER['DOCUMENT_ROOT'].'/old_version/'; ?>" /></td>
  527. </tr>
  528. <tr>
  529. <td colspan="2" align="center">
  530. <input type="submit" name="step1" value="&lt; <?php echo get_lang('Back');?>" />
  531. <input type="submit" name="<?php echo (isset($_POST['step2_update_6'])?'step2_update_6':'step2_update_8');?>" value="<?php echo get_lang('Next');?> &gt;" />
  532. </td>
  533. </tr>
  534. </table>
  535. <?php
  536. }
  537. else
  538. {
  539. $error=false;
  540. $perm = api_get_setting('permissions_for_new_directories');
  541. $perm = octdec(!empty($perm)?$perm:'0770');
  542. $perm_file = api_get_setting('permissions_for_new_files');
  543. $perm_file = octdec(!empty($perm_file)?$perm_file:'0660');
  544. //First, attempt to set writing permissions if we don't have them yet
  545. //0xxx is an octal number, this is the required format
  546. $notwritable = array();
  547. $curdir = getcwd();
  548. if(!is_writable('../inc/conf'))
  549. {
  550. $notwritable[] = realpath($curdir.'/../inc/conf');
  551. @chmod('../inc/conf',$perm);
  552. }
  553. if(!is_writable('../garbage'))
  554. {
  555. $notwritable[] = realpath($curdir.'/../garbage');
  556. @chmod('../garbage',$perm);
  557. }
  558. if(!is_writable('../upload'))
  559. {
  560. $notwritable[] = realpath($curdir.'/../upload');
  561. @chmod('../upload', $perm);
  562. }
  563. if(!is_writable('../default_course_document/images/'))
  564. {
  565. $notwritable[] = realpath($curdir.'/../default_course_document/images/');
  566. @chmod('../default_course_document/images/', $perm);
  567. }
  568. if(!is_writable('../../archive'))
  569. {
  570. $notwritable[] = realpath($curdir.'/../../archive');
  571. @chmod('../../archive',$perm);
  572. }
  573. if(!is_writable('../../courses'))
  574. {
  575. $notwritable[] = realpath($curdir.'/../../courses');
  576. @chmod('../../courses',$perm);
  577. }
  578. if(!is_writable('../../home'))
  579. {
  580. $notwritable[] = realpath($curdir.'/../../home');
  581. @chmod('../../home',$perm);
  582. }
  583. if(file_exists('../inc/conf/configuration.php') && !is_writable('../inc/conf/configuration.php'))
  584. {
  585. $notwritable[]= realpath($curdir.'/../inc/conf/configuration.php');
  586. @chmod('../inc/conf/configuration.php',$perm_file);
  587. }
  588. //Second, if this fails, report an error
  589. //--> the user will have to adjust the permissions manually
  590. if(count($notwritable)>0)
  591. {
  592. $error=true;
  593. echo '<div style="color:red; background-color:white; font-weight:bold; text-align:center;">';
  594. echo get_lang('Warning').':<br />';
  595. printf(get_lang('NoWritePermissionPleaseReadInstallGuide'),'</font><a href="../../documentation/installation_guide.html" target="blank">','</a> <font color="red">');
  596. echo '<ul>';
  597. foreach ($notwritable as $value)
  598. {
  599. echo '<li>'.$value.'</li>';
  600. }
  601. echo '</ul>';
  602. echo '</div>';
  603. }
  604. // check wether a Dokeos configuration file already exists.
  605. elseif(file_exists('../inc/conf/configuration.php'))
  606. {
  607. echo '<div style="color:red; background-color:white; font-weight:bold; text-align:center;">';
  608. echo get_lang('WarningExistingDokeosInstallationDetected');
  609. echo '</div>';
  610. }
  611. //and now display the choice buttons (go back or install)
  612. ?>
  613. <p align="center">
  614. <input type="submit" name="step1" onclick="window.location='index.php';return false;" value="&lt; <?php echo get_lang('Previous'); ?>"/>
  615. <input type="submit" name="step2_install" value="<?php echo get_lang("NewInstallation"); ?>" <?php if($error) echo 'disabled="disabled"'; ?> />
  616. <?php
  617. //real code
  618. echo '<input type="submit" name="step2_update_8" value="Upgrade from Dokeos 1.8.x"';
  619. if($error) echo ' disabled="disabled"';
  620. //temporary code for alpha version, disabling upgrade
  621. //echo '<input type="submit" name="step2_update" value="Upgrading is not possible in this beta version"';
  622. //echo ' disabled="disabled"';
  623. //end temp code
  624. echo ' />';
  625. echo '<input type="submit" name="step2_update_6" value="Upgrade from Dokeos 1.6.x"';
  626. if($error) echo ' disabled="disabled"';
  627. echo ' />';
  628. echo '</p>';
  629. }
  630. }
  631. /**
  632. * Displays the license (GNU GPL) as step 2, with
  633. * - an "I accept" button named step3 to proceed to step 3;
  634. * - a "Back" button named step1 to go back to the first step.
  635. */
  636. function display_license_agreement()
  637. {
  638. echo '<h2>'.display_step_sequence().get_lang('Licence').'</h2>';
  639. echo '<p>'.get_lang('DokeosLicenseInfo').'</p>';
  640. echo '<p><a href="../../documentation/license.html">'.get_lang('PrintVers').'</a></p>';
  641. ?>
  642. <table><tr><td>
  643. <p><textarea cols="75" rows="15" ><?php htmlentities(include('../../documentation/license.txt')); ?></textarea></p>
  644. </td>
  645. </tr>
  646. <tr>
  647. <td>
  648. <p><?php echo get_lang('DokeosArtLicense');?></p>
  649. </td>
  650. </tr>
  651. <td>
  652. <table width="100%">
  653. <tr>
  654. <td></td>
  655. <td align="center">
  656. <input type="submit" name="step1" value="&lt; <?php echo get_lang('Previous'); ?>" />
  657. <input type="submit" name="step3" value="<?php echo get_lang('IAccept'); ?> &gt;" />
  658. </td>
  659. </tr>
  660. </table>
  661. </td></tr></table>
  662. <?php
  663. }
  664. /**
  665. * Displays a parameter in a table row.
  666. * Used by the display_database_settings_form function.
  667. * @param string Type of install
  668. * @param string Name of parameter
  669. * @param string Field name (in the HTML form)
  670. * @param string Field value
  671. * @param string Extra notice (to show on the right side)
  672. * @param boolean Whether to display in update mode
  673. * @param string Additional attribute for the <tr> element
  674. * @return void Direct output
  675. */
  676. function display_database_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $extra_notice, $display_when_update = true, $tr_attribute='')
  677. {
  678. echo "<tr ".$tr_attribute.">\n";
  679. echo "<td>$parameter_name&nbsp;&nbsp;</td>\n";
  680. if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update)
  681. {
  682. echo '<td><input type="hidden" name="'.$form_field_name.'" id="'.$form_field_name.'" value="'.htmlentities($parameter_value).'" />'.$parameter_value."</td>\n";
  683. }
  684. else
  685. {
  686. if ($form_field_name=='dbPassForm') {
  687. $inputtype = 'password';
  688. } else {
  689. $inputtype = 'text';
  690. }
  691. //Slightly limit the length of the database prefix to avoid
  692. //having to cut down the databases names later on
  693. if ($form_field_name=='dbPrefixForm') {
  694. $maxlength = '15';
  695. } else {
  696. $maxlength = MAX_FORM_FIELD_LENGTH;
  697. }
  698. 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";
  699. echo "<td>$extra_notice</td>\n";
  700. }
  701. echo "</tr>\n";
  702. }
  703. /**
  704. * Displays step 3 - a form where the user can enter the installation settings
  705. * regarding the databases - login and password, names, prefixes, single
  706. * or multiple databases, tracking or not...
  707. */
  708. function display_database_settings_form($installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbPrefixForm, $enableTrackingForm, $singleDbForm, $dbNameForm, $dbStatsForm, $dbScormForm, $dbUserForm)
  709. {
  710. if($installType == 'update')
  711. {
  712. global $_configuration, $update_from_version_6;
  713. if(in_array($_POST['old_version'],$update_from_version_6))
  714. {
  715. $dbHostForm=get_config_param('dbHost');
  716. $dbUsernameForm=get_config_param('dbLogin');
  717. $dbPassForm=get_config_param('dbPass');
  718. $dbPrefixForm=get_config_param('dbNamePrefix');
  719. $enableTrackingForm=get_config_param('is_trackingEnabled');
  720. $singleDbForm=get_config_param('singleDbEnabled');
  721. $dbNameForm=get_config_param('mainDbName');
  722. $dbStatsForm=get_config_param('statsDbName');
  723. $dbScormForm=get_config_param('scormDbName');
  724. $dbUserForm=get_config_param('user_personal_database');
  725. $dbScormExists=true;
  726. }
  727. else
  728. {
  729. $dbHostForm=$_configuration['db_host'];
  730. $dbUsernameForm=$_configuration['db_user'];
  731. $dbPassForm=$_configuration['db_password'];
  732. $dbPrefixForm=$_configuration['db_prefix'];
  733. $enableTrackingForm=$_configuration['tracking_enabled'];
  734. $singleDbForm=$_configuration['single_database'];
  735. $dbNameForm=$_configuration['main_database'];
  736. $dbStatsForm=$_configuration['statistics_database'];
  737. $dbScormForm=$_configuration['scorm_database'];
  738. $dbUserForm=$_configuration['user_personal_database'];
  739. $dbScormExists=true;
  740. }
  741. if(empty($dbScormForm))
  742. {
  743. if($singleDbForm)
  744. {
  745. $dbScormForm=$dbNameForm;
  746. }
  747. else
  748. {
  749. $dbScormForm=$dbPrefixForm.'scorm';
  750. $dbScormExists=false;
  751. }
  752. }
  753. if(empty($dbUserForm))
  754. {
  755. if($singleDbForm)
  756. {
  757. $dbUserForm=$dbNameForm;
  758. }
  759. else
  760. {
  761. $dbUserForm=$dbPrefixForm.'dokeos_user';
  762. }
  763. }
  764. echo "<h2>" . display_step_sequence() .get_lang("DBSetting") . "</h2>";
  765. echo get_lang("DBSettingUpgradeIntro");
  766. }else{
  767. if(empty($dbPrefixForm)) //make sure there is a default value for db prefix
  768. {
  769. $dbPrefixForm = 'dokeos_';
  770. }
  771. echo "<h2>" . display_step_sequence() .get_lang("DBSetting") . "</h2>";
  772. echo get_lang("DBSettingIntro");
  773. }
  774. ?>
  775. <br /><br />
  776. </td>
  777. </tr>
  778. <tr>
  779. <td>
  780. <table width="100%">
  781. <tr>
  782. <td width="40%"><?php echo get_lang('DBHost'); ?> </td>
  783. <?php if($installType == 'update'): ?>
  784. <td width="30%"><input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?></td>
  785. <td width="30%">&nbsp;</td>
  786. <?php else: ?>
  787. <td width="30%"><input type="text" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /></td>
  788. <td width="30%"><?php echo get_lang('EG').' localhost'; ?></td>
  789. <?php endif; ?>
  790. </tr>
  791. <?php
  792. //database user username
  793. $example_login = get_lang('EG').' root';
  794. display_database_parameter($installType, get_lang('DBLogin'), 'dbUsernameForm', $dbUsernameForm, $example_login);
  795. //database user password
  796. $example_password = get_lang('EG').' '.api_generate_password();
  797. display_database_parameter($installType, get_lang('DBPassword'), 'dbPassForm', $dbPassForm, $example_password);
  798. //database prefix
  799. display_database_parameter($installType, get_lang('DbPrefixForm'), 'dbPrefixForm', $dbPrefixForm, get_lang('DbPrefixCom'));
  800. //fields for the four standard Dokeos databases
  801. echo '<tr><td colspan="3"><a href="" onclick="show_hide_option();return false;"><img src="../img/add_na.gif" alt="show-hide" />'.get_lang('OptionalParameters','').'</a></td></tr>';
  802. display_database_parameter($installType, get_lang('MainDB'), 'dbNameForm', $dbNameForm, '&nbsp;',null,'id="optional_param1" style="display:none;"');
  803. display_database_parameter($installType, get_lang('StatDB'), 'dbStatsForm', $dbStatsForm, '&nbsp;',null,'id="optional_param2" style="display:none;"');
  804. if($installType == 'update' && in_array($_POST['old_version'],$update_from_version_6))
  805. {
  806. display_database_parameter($installType, get_lang('ScormDB'), 'dbScormForm', $dbScormForm, '&nbsp;',null,'id="optional_param3" style="display:none;"');
  807. }
  808. display_database_parameter($installType, get_lang('UserDB'), 'dbUserForm', $dbUserForm, '&nbsp;',null,'id="optional_param4" style="display:none;"');
  809. ?>
  810. <tr id="optional_param5" style="display:none;">
  811. <td><?php echo get_lang('EnableTracking'); ?> </td>
  812. <?php if($installType == 'update'): ?>
  813. <td><input type="hidden" name="enableTrackingForm" value="<?php echo $enableTrackingForm; ?>" /><?php echo $enableTrackingForm? get_lang('Yes') : get_lang('No'); ?></td>
  814. <?php else: ?>
  815. <td>
  816. <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>
  817. <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>
  818. </td>
  819. <?php endif; ?>
  820. <td>&nbsp;</td>
  821. </tr>
  822. <tr id="optional_param6" style="display:none;">
  823. <td><?php echo get_lang('SingleDb'); ?> </td>
  824. <?php if($installType == 'update'): ?>
  825. <td><input type="hidden" name="singleDbForm" value="<?php echo $singleDbForm; ?>" /><?php echo $singleDbForm? get_lang('One') : get_lang('Several'); ?></td>
  826. <?php else: ?>
  827. <td>
  828. <input class="checkbox" type="radio" name="singleDbForm" value="1" id="singleDb1" <?php echo $singleDbForm?'checked="checked" ':''; ?> onclick="document.getElementById('dbStatsForm').disabled='true'; document.getElementById('dbUserForm').disabled='true';" /> <label for="singleDb1"><?php echo get_lang('One'); ?></label>
  829. <input class="checkbox" type="radio" name="singleDbForm" value="0" id="singleDb0" <?php echo $singleDbForm?'':'checked="checked" '; ?> onclick="document.getElementById('dbStatsForm').disabled='false'; document.getElementById('dbUserForm').disabled='false';" /> <label for="singleDb0"><?php echo get_lang('Several'); ?></label>
  830. </td>
  831. <?php endif; ?>
  832. <td>&nbsp;</td>
  833. </tr>
  834. </div>
  835. <tr>
  836. <td><input type="submit" name="step3" value="<?php echo get_lang('CheckDatabaseConnection'); ?>" /> </td>
  837. <?php $dbConnect = test_db_connect ($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm);
  838. if($dbConnect==1): ?>
  839. <td colspan="2">
  840. <div class="confirmation-message">
  841. <div style="float:left; margin-right:10px;">
  842. <img src="../img/message_confirmation.png" alt="Confirmation" />
  843. </div>
  844. <div style="float:left;">
  845. MySQL host info: <?php echo mysql_get_host_info(); ?><br />
  846. MySQL server version: <?php echo mysql_get_server_info(); ?><br />
  847. MySQL protocol version: <?php echo mysql_get_proto_info(); ?>
  848. </div>
  849. <div style="clear:both;"></div>
  850. </div>
  851. </td>
  852. <?php else: ?>
  853. <td colspan="2">
  854. <div class="error-message">
  855. <div style="float:left; margin-right:10px;">
  856. <img src="../img/message_error.png" alt="Error" />
  857. </div>
  858. <div style="float:left;">
  859. <strong>MySQL error: <?php echo mysql_errno(); ?></strong><br />
  860. <?php echo mysql_error(); ?>
  861. </div>
  862. </div>
  863. </td>
  864. <?php endif; ?>
  865. </tr>
  866. <tr>
  867. <td><input type="submit" name="step2" value="&lt; <?php echo get_lang('Previous'); ?>" /></td>
  868. <td>&nbsp;</td>
  869. <td align="right"><input type="submit" name="step4" value="<?php echo get_lang('Next'); ?> &gt;" /></td>
  870. </tr>
  871. </table>
  872. <?php
  873. }
  874. /**
  875. * Displays a parameter in a table row.
  876. * Used by the display_configuration_settings_form function.
  877. */
  878. function display_configuration_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $display_when_update = 'true')
  879. {
  880. echo "<tr>\n";
  881. echo "<td>$parameter_name&nbsp;&nbsp;</td>\n";
  882. if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update)
  883. {
  884. echo '<td><input type="hidden" name="'.$form_field_name.'" value="'.htmlentities($parameter_value).'" />'.$parameter_value."</td>\n";
  885. }
  886. else
  887. {
  888. echo '<td><input type="text" size="'.FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.MAX_FORM_FIELD_LENGTH.'" name="'.$form_field_name.'" value="'.htmlentities($parameter_value).'" />'."</td>\n";
  889. }
  890. echo "</tr>\n";
  891. }
  892. /**
  893. * Displays step 4 of the installation - configuration settings about Dokeos itself.
  894. */
  895. function display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $allowSelfRegProf, $loginForm, $passForm)
  896. {
  897. if($installType != 'update' && empty($languageForm))
  898. {
  899. $languageForm = $_SESSION['install_language'];
  900. }
  901. echo "<h2>" . display_step_sequence() . get_lang("CfgSetting") . "</h2>";
  902. echo '<p>'.get_lang('ConfigSettingsInfo').' <b>main/inc/conf/configuration.php</b></p>';
  903. echo "</td></tr>\n<tr><td>";
  904. echo "<table width=\"100%\">";
  905. //First parameter: language
  906. echo "<tr>\n";
  907. echo '<td>'.get_lang('MainLang')."&nbsp;&nbsp;</td>\n";
  908. if($installType == 'update')
  909. {
  910. echo '<td><input type="hidden" name="languageForm" value="'.htmlentities($languageForm).'" />'.$languageForm."</td>\n";
  911. }
  912. else // new installation
  913. {
  914. echo '<td>';
  915. echo "<select name=\"languageForm\">\n";
  916. $dirname='../lang/';
  917. if ($dir=@opendir($dirname)) {
  918. $lang_files = array();
  919. while (($file = readdir($dir)) !== false) {
  920. if($file != '.' && $file != '..' && $file != 'CVS' && $file != '.svn' && is_dir($dirname.$file)){
  921. array_push($lang_files, $file);
  922. }
  923. }
  924. closedir($dir);
  925. }
  926. sort($lang_files);
  927. foreach ($lang_files as $file) {
  928. echo '<option value="'.$file.'"';
  929. if($file == $languageForm) echo ' selected="selected"';
  930. echo ">$file</option>\n";
  931. }
  932. echo '</select>';
  933. echo "</td>\n";
  934. }
  935. echo "</tr>\n";
  936. //Second parameter: Dokeos URL
  937. echo "<tr>\n";
  938. echo '<td>'.get_lang('DokeosURL').' (<font color="#cc0033">'.get_lang('ThisFieldIsRequired')."</font>)&nbsp;&nbsp;</td>\n";
  939. if($installType == 'update') echo '<td>'.htmlentities($urlForm)."</td>\n";
  940. else echo '<td><input type="text" size="40" maxlength="100" name="urlForm" value="'.htmlentities($urlForm).'" />'."</td>\n";
  941. echo "</tr>\n";
  942. //Parameter 3: administrator's email
  943. display_configuration_parameter($installType, get_lang("AdminEmail"), "emailForm", $emailForm);
  944. //Parameter 4: administrator's last name
  945. display_configuration_parameter($installType, get_lang("AdminLastName"), "adminLastName", $adminLastName);
  946. //Parameter 5: administrator's first name
  947. display_configuration_parameter($installType, get_lang("AdminFirstName"), "adminFirstName", $adminFirstName);
  948. //Parameter 6: administrator's telephone
  949. display_configuration_parameter($installType, get_lang("AdminPhone"), "adminPhoneForm", $adminPhoneForm);
  950. //Parameter 7: administrator's login
  951. display_configuration_parameter($installType, get_lang("AdminLogin"), "loginForm", $loginForm, ($installType == 'update' ? true : false));
  952. //Parameter 8: administrator's password
  953. if($installType != 'update')
  954. display_configuration_parameter($installType, get_lang("AdminPass"), "passForm", $passForm, false);
  955. //Parameter 9: campus name
  956. display_configuration_parameter($installType, get_lang("CampusName"), "campusForm", $campusForm);
  957. //Parameter 10: institute (short) name
  958. display_configuration_parameter($installType, get_lang("InstituteShortName"), "institutionForm", $institutionForm);
  959. //Parameter 11: institute (short) name
  960. display_configuration_parameter($installType, get_lang("InstituteURL"), "institutionUrlForm", $institutionUrlForm);
  961. ?>
  962. <tr>
  963. <td><?php echo get_lang("EncryptUserPass"); ?> :</td>
  964. <?php if($installType == 'update'): ?>
  965. <td><input type="hidden" name="encryptPassForm" value="<?php echo $encryptPassForm; ?>" /><?php echo $encryptPassForm? get_lang("Yes") : get_lang("No"); ?></td>
  966. <?php else: ?>
  967. <td>
  968. <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>
  969. <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>
  970. </td>
  971. <?php endif; ?>
  972. </tr>
  973. <tr>
  974. <td><?php echo get_lang("AllowSelfReg"); ?> :</td>
  975. <?php if($installType == 'update'): ?>
  976. <td><input type="hidden" name="allowSelfReg" value="<?php echo $allowSelfReg; ?>" /><?php echo $allowSelfReg? get_lang("Yes") : get_lang("No"); ?></td>
  977. <?php else: ?>
  978. <td>
  979. <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>
  980. <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>
  981. </td>
  982. <?php endif; ?>
  983. </tr>
  984. <tr>
  985. <td><?php echo get_lang("AllowSelfRegProf"); ?> :</td>
  986. <?php if($installType == 'update'): ?>
  987. <td><input type="hidden" name="allowSelfRegProf" value="<?php echo $allowSelfRegProf; ?>" /><?php echo $allowSelfRegProf? get_lang("Yes") : get_lang("No"); ?></td>
  988. <?php else: ?>
  989. <td>
  990. <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>
  991. <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>
  992. </td>
  993. <?php endif; ?>
  994. </tr>
  995. <tr>
  996. <td><input type="submit" name="step3" value="&lt; <?php echo get_lang('Previous'); ?>" /></td>
  997. <td align="right"><input type="submit" name="step5" value="<?php echo get_lang('Next'); ?> &gt;" /></td>
  998. </tr>
  999. </table>
  1000. <?php
  1001. }
  1002. /**
  1003. * After installation is completed (step 6), this message is displayed.
  1004. */
  1005. function display_after_install_message($installType, $nbr_courses)
  1006. {
  1007. ?>
  1008. <h2><?php echo display_step_sequence() . get_lang("CfgSetting"); ?></h2>
  1009. <?php echo get_lang('FirstUseTip'); ?>
  1010. <?php if($installType == 'update' && $nbr_courses > MAX_COURSE_TRANSFER): ?>
  1011. <br /><br />
  1012. <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>
  1013. <?php endif; ?>
  1014. <br /><br />
  1015. <?php
  1016. echo '<div class="warning-message">';
  1017. echo '<img src="../img/message_warning.png" style="float:left; margin-right:10px;" alt="'.get_lang('Warning').'"/>';
  1018. echo '<b>'.get_lang('SecurityAdvice').'</b>';
  1019. echo ': ';
  1020. printf(get_lang('ToProtectYourSiteMakeXAndYReadOnly'),'main/inc/conf/configuration.php','main/install/index.php');
  1021. echo '</div>';
  1022. ?>
  1023. </form>
  1024. <a href="../../index.php"><?php echo get_lang('GoToYourNewlyCreatedPortal'); ?></a>
  1025. <?php
  1026. }
  1027. /**
  1028. * In step 3. Test the connection to the DB in case of single or multy DB.
  1029. * 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.
  1030. */
  1031. function test_db_connect ($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm)
  1032. {
  1033. $dbConnect = -1;
  1034. if($singleDbForm == 1)
  1035. {
  1036. if(mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm) !== false)
  1037. {
  1038. $dbConnect = 1;
  1039. }
  1040. else
  1041. {
  1042. $dbConnect = -1;
  1043. }
  1044. }
  1045. elseif($singleDbForm == 0)
  1046. {
  1047. if(mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm) !== false)
  1048. {
  1049. $multipleDbCheck = @mysql_query("CREATE DATABASE ".$dbPrefixForm."test_dokeos_connection");
  1050. if($multipleDbCheck !== false)
  1051. {
  1052. $multipleDbCheck = @mysql_query("DROP DATABASE IF EXISTS ".$dbPrefixForm."test_dokeos_connection");
  1053. if($multipleDbCheck !== false)
  1054. {
  1055. $dbConnect = 1;
  1056. }
  1057. else
  1058. {
  1059. $dbConnect = 0;
  1060. }
  1061. }
  1062. else
  1063. {
  1064. $dbConnect = 0;
  1065. }
  1066. }
  1067. else
  1068. {
  1069. $dbConnect = -1;
  1070. }
  1071. }
  1072. 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.
  1073. }
  1074. ?>