install_functions.inc.php 46 KB

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