install_functions.inc.php 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209
  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 api_ucfirst($value);
  317. echo "</option>\n";
  318. }
  319. echo "\t\t</select>\n";
  320. }
  321. /**
  322. * This function displays a language dropdown box so that the installatioin
  323. * can be done in the language of the user
  324. */
  325. function display_language_selection()
  326. { ?>
  327. <h1><?php get_lang('WelcomeToTheDokeosInstaller');?></h1>
  328. <h2><?php echo display_step_sequence(); ?><?php echo get_lang('InstallationLanguage');?></h2>
  329. <p><?php echo get_lang('PleaseSelectInstallationProcessLanguage');?>:</p>
  330. <form id="lang_form" method="post" action="<?php echo api_get_self(); ?>">
  331. <?php display_language_selection_box(); ?>
  332. <button type="submit" name="step1" class="next" value="<?php get_lang('Next');?> &gt;"><?php echo get_lang('Next');?></button>
  333. </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">OFF</td>
  435. <td class="requirements-value">'.check_php_setting('magic_quotes_gpc','OFF').'</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">OFF</td>
  455. <td class="requirements-value">'.check_php_setting('short_open_tag','OFF').'</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/upload/users/</td>
  481. <td class="requirements-value">'.check_writable('upload/users/').'</td>
  482. </tr>
  483. <tr>
  484. <td class="requirements-item">dokeos/main/default_course_document/images/</td>
  485. <td class="requirements-value">'.check_writable('default_course_document/images/').'</td>
  486. </tr>
  487. <tr>
  488. <td class="requirements-item">dokeos/archive/</td>
  489. <td class="requirements-value">'.check_writable('../archive/').'</td>
  490. </tr>
  491. <tr>
  492. <td class="requirements-item">dokeos/courses/</td>
  493. <td class="requirements-value">'.check_writable('../courses/').'</td>
  494. </tr>
  495. <tr>
  496. <td class="requirements-item">dokeos/home/</td>
  497. <td class="requirements-value">'.check_writable('../home/').'</td>
  498. </tr>'.
  499. //'<tr>
  500. // <td class="requirements-item">dokeos/searchdb/</td>
  501. // <td class="requirements-value">'.check_writable('../searchdb/').'</td>
  502. //</tr>'.
  503. //'<tr>
  504. // <td class="requirements-item">'.session_save_path().'</td>
  505. // <td class="requirements-value">'.(is_writable(session_save_path())
  506. // ? '<strong><font color="green">'.get_lang('Writable').'</font></strong>'
  507. // : '<strong><font color="red">'.get_lang('NotWritable').'</font></strong>').'</td>
  508. //</tr>'.
  509. '';
  510. echo ' </table>';
  511. echo ' </div>';
  512. echo '</div>';
  513. if($installType == 'update' && (empty($updatePath) || $badUpdatePath))
  514. {
  515. if($badUpdatePath)
  516. { ?>
  517. <div style="color:red; background-color:white; font-weight:bold; text-align:center;">
  518. <?php echo get_lang('Error');?>!<br />
  519. Dokeos <?php echo (isset($_POST['step2_update_6'])?implode('|',$update_from_version_6):implode('|',$update_from_version_8)).' '.get_lang('HasNotBeenFoundInThatDir'); ?>.
  520. </div>
  521. <?php }
  522. else
  523. {
  524. echo '<br />';
  525. }
  526. ?>
  527. <table border="0" cellpadding="5" align="center">
  528. <tr>
  529. <td><?php echo get_lang('OldVersionRootPath');?>:</td>
  530. <td><input type="text" name="updatePath" size="50" value="<?php echo ($badUpdatePath && !empty($updatePath))?htmlentities($updatePath):$_SERVER['DOCUMENT_ROOT'].'/old_version/'; ?>" /></td>
  531. </tr>
  532. <tr>
  533. <td colspan="2" align="center">
  534. <button type="submit" class="back" name="step1" value="&lt; <?php echo get_lang('Back');?>" ><?php echo get_lang('Back');?></button>
  535. <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>
  536. </td>
  537. </tr>
  538. </table>
  539. <?php
  540. }
  541. else
  542. {
  543. $error=false;
  544. $perm = api_get_setting('permissions_for_new_directories');
  545. $perm = octdec(!empty($perm)?$perm:'0770');
  546. $perm_file = api_get_setting('permissions_for_new_files');
  547. $perm_file = octdec(!empty($perm_file)?$perm_file:'0660');
  548. //First, attempt to set writing permissions if we don't have them yet
  549. //0xxx is an octal number, this is the required format
  550. $notwritable = array();
  551. $curdir = getcwd();
  552. if(!is_writable('../inc/conf'))
  553. {
  554. $notwritable[] = realpath($curdir.'/../inc/conf');
  555. @chmod('../inc/conf',$perm);
  556. }
  557. if(!is_writable('../upload/users'))
  558. {
  559. $notwritable[] = realpath($curdir.'/../upload/users');
  560. @chmod('../upload/users', $perm);
  561. }
  562. if(!is_writable('../default_course_document/images/'))
  563. {
  564. $notwritable[] = realpath($curdir.'/../default_course_document/images/');
  565. @chmod('../default_course_document/images/', $perm);
  566. }
  567. if(!is_writable('../../archive'))
  568. {
  569. $notwritable[] = realpath($curdir.'/../../archive');
  570. @chmod('../../archive',$perm);
  571. }
  572. if(!is_writable('../../courses'))
  573. {
  574. $notwritable[] = realpath($curdir.'/../../courses');
  575. @chmod('../../courses',$perm);
  576. }
  577. if(!is_writable('../../home'))
  578. {
  579. $notwritable[] = realpath($curdir.'/../../home');
  580. @chmod('../../home',$perm);
  581. }
  582. if(file_exists('../inc/conf/configuration.php') && !is_writable('../inc/conf/configuration.php'))
  583. {
  584. $notwritable[]= realpath($curdir.'/../inc/conf/configuration.php');
  585. @chmod('../inc/conf/configuration.php',$perm_file);
  586. }
  587. //Second, if this fails, report an error
  588. //--> the user will have to adjust the permissions manually
  589. if(count($notwritable)>0)
  590. {
  591. $error=true;
  592. echo '<div style="color:red; background-color:white; font-weight:bold; text-align:center;">';
  593. echo get_lang('Warning').':<br />';
  594. printf(get_lang('NoWritePermissionPleaseReadInstallGuide'),'</font><a href="../../documentation/installation_guide.html" target="blank">','</a> <font color="red">');
  595. echo '<ul>';
  596. foreach ($notwritable as $value)
  597. {
  598. echo '<li>'.$value.'</li>';
  599. }
  600. echo '</ul>';
  601. echo '</div>';
  602. }
  603. // check wether a Dokeos configuration file already exists.
  604. elseif(file_exists('../inc/conf/configuration.php'))
  605. {
  606. echo '<div style="color:red; background-color:white; font-weight:bold; text-align:center;">';
  607. echo get_lang('WarningExistingDokeosInstallationDetected');
  608. echo '</div>';
  609. }
  610. //and now display the choice buttons (go back or install)
  611. ?>
  612. <p align="center">
  613. <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>
  614. <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>
  615. <?php
  616. //real code
  617. echo '<button type="submit" class="save" name="step2_update_8" value="Upgrade from Dokeos 1.8.x"';
  618. if($error) echo ' disabled="disabled"';
  619. //temporary code for alpha version, disabling upgrade
  620. //echo '<input type="submit" name="step2_update" value="Upgrading is not possible in this beta version"';
  621. //echo ' disabled="disabled"';
  622. //end temp code
  623. echo ' >Upgrade from Dokeos 1.8.x</button>';
  624. echo '<button type="submit" class="save" name="step2_update_6" value="Upgrade from Dokeos 1.6.x"';
  625. if($error) echo ' disabled="disabled"';
  626. echo ' >Upgrade from Dokeos 1.6.x</button>';
  627. echo '</p>';
  628. }
  629. }
  630. /**
  631. * Displays the license (GNU GPL) as step 2, with
  632. * - an "I accept" button named step3 to proceed to step 3;
  633. * - a "Back" button named step1 to go back to the first step.
  634. */
  635. function display_license_agreement()
  636. {
  637. echo '<h2>'.display_step_sequence().get_lang('Licence').'</h2>';
  638. echo '<p>'.get_lang('DokeosLicenseInfo').'</p>';
  639. echo '<p><a href="../../documentation/license.html">'.get_lang('PrintVers').'</a></p>';
  640. ?>
  641. <table><tr><td>
  642. <p><textarea cols="75" rows="15" ><?php htmlentities(include('../../documentation/license.txt')); ?></textarea></p>
  643. </td>
  644. </tr>
  645. <tr>
  646. <td>
  647. <p><?php echo get_lang('DokeosArtLicense');?></p>
  648. </td>
  649. </tr>
  650. <td>
  651. <table width="100%">
  652. <tr>
  653. <td></td>
  654. <td align="center">
  655. <button type="submit" class="back" name="step1" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button>
  656. <button type="submit" class="next" name="step3" value="<?php echo get_lang('IAccept'); ?> &gt;" ><?php echo get_lang('IAccept'); ?></button>
  657. </td>
  658. </tr>
  659. </table>
  660. </td></tr></table>
  661. <?php
  662. }
  663. /**
  664. * Displays a parameter in a table row.
  665. * Used by the display_database_settings_form function.
  666. * @param string Type of install
  667. * @param string Name of parameter
  668. * @param string Field name (in the HTML form)
  669. * @param string Field value
  670. * @param string Extra notice (to show on the right side)
  671. * @param boolean Whether to display in update mode
  672. * @param string Additional attribute for the <tr> element
  673. * @return void Direct output
  674. */
  675. function display_database_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $extra_notice, $display_when_update = true, $tr_attribute='')
  676. {
  677. echo "<tr ".$tr_attribute.">\n";
  678. echo "<td>$parameter_name&nbsp;&nbsp;</td>\n";
  679. if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update)
  680. {
  681. echo '<td><input type="hidden" name="'.$form_field_name.'" id="'.$form_field_name.'" value="'.htmlentities($parameter_value).'" />'.$parameter_value."</td>\n";
  682. }
  683. else
  684. {
  685. if ($form_field_name=='dbPassForm') {
  686. $inputtype = 'password';
  687. } else {
  688. $inputtype = 'text';
  689. }
  690. //Slightly limit the length of the database prefix to avoid
  691. //having to cut down the databases names later on
  692. if ($form_field_name=='dbPrefixForm') {
  693. $maxlength = '15';
  694. } else {
  695. $maxlength = MAX_FORM_FIELD_LENGTH;
  696. }
  697. 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";
  698. echo "<td>$extra_notice</td>\n";
  699. }
  700. echo "</tr>\n";
  701. }
  702. /**
  703. * Displays step 3 - a form where the user can enter the installation settings
  704. * regarding the databases - login and password, names, prefixes, single
  705. * or multiple databases, tracking or not...
  706. */
  707. function display_database_settings_form($installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbPrefixForm, $enableTrackingForm, $singleDbForm, $dbNameForm, $dbStatsForm, $dbScormForm, $dbUserForm)
  708. {
  709. if($installType == 'update')
  710. {
  711. global $_configuration, $update_from_version_6;
  712. if(in_array($_POST['old_version'],$update_from_version_6))
  713. {
  714. $dbHostForm=get_config_param('dbHost');
  715. $dbUsernameForm=get_config_param('dbLogin');
  716. $dbPassForm=get_config_param('dbPass');
  717. $dbPrefixForm=get_config_param('dbNamePrefix');
  718. $enableTrackingForm=get_config_param('is_trackingEnabled');
  719. $singleDbForm=get_config_param('singleDbEnabled');
  720. $dbNameForm=get_config_param('mainDbName');
  721. $dbStatsForm=get_config_param('statsDbName');
  722. $dbScormForm=get_config_param('scormDbName');
  723. $dbUserForm=get_config_param('user_personal_database');
  724. $dbScormExists=true;
  725. }
  726. else
  727. {
  728. $dbHostForm=$_configuration['db_host'];
  729. $dbUsernameForm=$_configuration['db_user'];
  730. $dbPassForm=$_configuration['db_password'];
  731. $dbPrefixForm=$_configuration['db_prefix'];
  732. $enableTrackingForm=$_configuration['tracking_enabled'];
  733. $singleDbForm=$_configuration['single_database'];
  734. $dbNameForm=$_configuration['main_database'];
  735. $dbStatsForm=$_configuration['statistics_database'];
  736. $dbScormForm=$_configuration['scorm_database'];
  737. $dbUserForm=$_configuration['user_personal_database'];
  738. $dbScormExists=true;
  739. }
  740. if(empty($dbScormForm))
  741. {
  742. if($singleDbForm)
  743. {
  744. $dbScormForm=$dbNameForm;
  745. }
  746. else
  747. {
  748. $dbScormForm=$dbPrefixForm.'scorm';
  749. $dbScormExists=false;
  750. }
  751. }
  752. if(empty($dbUserForm))
  753. {
  754. if($singleDbForm)
  755. {
  756. $dbUserForm=$dbNameForm;
  757. }
  758. else
  759. {
  760. $dbUserForm=$dbPrefixForm.'dokeos_user';
  761. }
  762. }
  763. echo "<h2>" . display_step_sequence() .get_lang("DBSetting") . "</h2>";
  764. echo get_lang("DBSettingUpgradeIntro");
  765. }else{
  766. if(empty($dbPrefixForm)) //make sure there is a default value for db prefix
  767. {
  768. $dbPrefixForm = 'dokeos_';
  769. }
  770. echo "<h2>" . display_step_sequence() .get_lang("DBSetting") . "</h2>";
  771. echo get_lang("DBSettingIntro");
  772. }
  773. ?>
  774. <br /><br />
  775. </td>
  776. </tr>
  777. <tr>
  778. <td>
  779. <table width="100%">
  780. <tr>
  781. <td width="40%"><?php echo get_lang('DBHost'); ?> </td>
  782. <?php if($installType == 'update'): ?>
  783. <td width="30%"><input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?></td>
  784. <td width="30%">&nbsp;</td>
  785. <?php else: ?>
  786. <td width="30%"><input type="text" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /></td>
  787. <td width="30%"><?php echo get_lang('EG').' localhost'; ?></td>
  788. <?php endif; ?>
  789. </tr>
  790. <?php
  791. //database user username
  792. $example_login = get_lang('EG').' root';
  793. display_database_parameter($installType, get_lang('DBLogin'), 'dbUsernameForm', $dbUsernameForm, $example_login);
  794. //database user password
  795. $example_password = get_lang('EG').' '.api_generate_password();
  796. display_database_parameter($installType, get_lang('DBPassword'), 'dbPassForm', $dbPassForm, $example_password);
  797. //database prefix
  798. display_database_parameter($installType, get_lang('DbPrefixForm'), 'dbPrefixForm', $dbPrefixForm, get_lang('DbPrefixCom'));
  799. //fields for the four standard Dokeos databases
  800. echo '<tr><td colspan="3"><a href="" onclick="javascript: show_hide_option();return false;" id="optionalparameters"><img src="../img/div_hide.gif" alt="show-hide" /> '.get_lang('OptionalParameters','').'</a></td></tr>';
  801. display_database_parameter($installType, get_lang('MainDB'), 'dbNameForm', $dbNameForm, '&nbsp;',null,'id="optional_param1" style="display:none;"');
  802. display_database_parameter($installType, get_lang('StatDB'), 'dbStatsForm', $dbStatsForm, '&nbsp;',null,'id="optional_param2" style="display:none;"');
  803. if($installType == 'update' && in_array($_POST['old_version'],$update_from_version_6))
  804. {
  805. display_database_parameter($installType, get_lang('ScormDB'), 'dbScormForm', $dbScormForm, '&nbsp;',null,'id="optional_param3" style="display:none;"');
  806. }
  807. display_database_parameter($installType, get_lang('UserDB'), 'dbUserForm', $dbUserForm, '&nbsp;',null,'id="optional_param4" style="display:none;"');
  808. ?>
  809. <tr id="optional_param5" style="display:none;">
  810. <td><?php echo get_lang('EnableTracking'); ?> </td>
  811. <?php if($installType == 'update'): ?>
  812. <td><input type="hidden" name="enableTrackingForm" value="<?php echo $enableTrackingForm; ?>" /><?php echo $enableTrackingForm? get_lang('Yes') : get_lang('No'); ?></td>
  813. <?php else: ?>
  814. <td>
  815. <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>
  816. <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>
  817. </td>
  818. <?php endif; ?>
  819. <td>&nbsp;</td>
  820. </tr>
  821. <tr id="optional_param6" style="display:none;">
  822. <td><?php echo get_lang('SingleDb'); ?> </td>
  823. <?php if($installType == 'update'): ?>
  824. <td><input type="hidden" name="singleDbForm" value="<?php echo $singleDbForm; ?>" /><?php echo $singleDbForm? get_lang('One') : get_lang('Several'); ?></td>
  825. <?php else: ?>
  826. <td>
  827. <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>
  828. <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>
  829. </td>
  830. <?php endif; ?>
  831. <td>&nbsp;</td>
  832. </tr>
  833. </div>
  834. <tr>
  835. <td><button type="submit" class="login" name="step3" value="<?php echo get_lang('CheckDatabaseConnection'); ?>" ><?php echo get_lang('CheckDatabaseConnection'); ?></button></td>
  836. <?php $dbConnect = test_db_connect ($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm);
  837. if($dbConnect==1): ?>
  838. <td colspan="2">
  839. <div class="confirmation-message">
  840. <!--<div style="float:left; margin-right:10px;">
  841. <img src="../img/message_confirmation.png" alt="Confirmation" />
  842. </div>-->
  843. <div style="float:left;">
  844. MySQL host info: <?php echo mysql_get_host_info(); ?><br />
  845. MySQL server version: <?php echo mysql_get_server_info(); ?><br />
  846. MySQL protocol version: <?php echo mysql_get_proto_info(); ?>
  847. </div>
  848. <div style="clear:both;"></div>
  849. </div>
  850. </td>
  851. <?php else: ?>
  852. <td colspan="2">
  853. <div style="float:left;" class="error-message">
  854. <!--<div style="float:left; margin-right:10px;">
  855. <img src="../img/message_error.png" alt="Error" />
  856. </div>-->
  857. <div style="float:left;">
  858. <strong>MySQL error: <?php echo mysql_errno(); ?></strong><br />
  859. <?php echo mysql_error().'<br/>'; ?>
  860. <strong><?php echo get_lang('Details').': '. get_lang('FailedConectionDatabase'); ?></strong><br />
  861. </div>
  862. </div>
  863. </td>
  864. <?php endif; ?>
  865. </tr>
  866. <tr>
  867. <td><button type="submit" name="step2" class="back" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button></td>
  868. <td>&nbsp;</td>
  869. <td align="right"><button type="submit" class="next" name="step4" value="<?php echo get_lang('Next'); ?> &gt;" /><?php echo get_lang('Next'); ?></button></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. global $charset;
  881. echo "<tr>\n";
  882. echo "<td>$parameter_name&nbsp;&nbsp;</td>\n";
  883. if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update)
  884. {
  885. echo '<td><input type="hidden" name="'.$form_field_name.'" value="'.api_htmlentities($parameter_value, ENT_QUOTES, $charset).'" />'.$parameter_value."</td>\n";
  886. }
  887. else
  888. {
  889. echo '<td><input type="text" size="'.FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.MAX_FORM_FIELD_LENGTH.'" name="'.$form_field_name.'" value="'.api_htmlentities($parameter_value, ENT_QUOTES, $charset).'" />'."</td>\n";
  890. }
  891. echo "</tr>\n";
  892. }
  893. /**
  894. * Displays step 4 of the installation - configuration settings about Dokeos itself.
  895. */
  896. function display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $allowSelfRegProf, $loginForm, $passForm)
  897. {
  898. global $charset;
  899. if($installType != 'update' && empty($languageForm))
  900. {
  901. $languageForm = $_SESSION['install_language'];
  902. }
  903. echo "<h2>" . display_step_sequence() . get_lang("CfgSetting") . "</h2>";
  904. echo '<p>'.get_lang('ConfigSettingsInfo').' <b>main/inc/conf/configuration.php</b></p>';
  905. echo "</td></tr>\n<tr><td>";
  906. echo "<table width=\"100%\">";
  907. //First parameter: language
  908. echo "<tr>\n";
  909. echo '<td>'.get_lang('MainLang')."&nbsp;&nbsp;</td>\n";
  910. if($installType == 'update')
  911. {
  912. echo '<td><input type="hidden" name="languageForm" value="'.api_htmlentities($languageForm, ENT_QUOTES, $charset).'" />'.$languageForm."</td>\n";
  913. }
  914. else // new installation
  915. {
  916. echo '<td>';
  917. $array_lang = array('asturian','english','italian','french','slovenian','slovenian_unicode','spanish');
  918. ////Only display Language have 90% +
  919. echo "\t\t<select name=\"languageForm\">\n";
  920. foreach ($array_lang as $key => $value) {
  921. echo '<option value="'.$value.'"';
  922. if($value == $languageForm) echo ' selected="selected"';
  923. echo ">$value</option>\n";
  924. }
  925. echo "\t\t</select>\n";
  926. //Display all language
  927. /*echo "<select name=\"languageForm\">\n";
  928. $dirname='../lang/';
  929. if ($dir=@opendir($dirname)) {
  930. $lang_files = array();
  931. while (($file = readdir($dir)) !== false) {
  932. if($file != '.' && $file != '..' && $file != 'CVS' && $file != '.svn' && is_dir($dirname.$file)){
  933. array_push($lang_files, $file);
  934. }
  935. }
  936. closedir($dir);
  937. }
  938. sort($lang_files);
  939. foreach ($lang_files as $file) {
  940. echo '<option value="'.$file.'"';
  941. if($file == $languageForm) echo ' selected="selected"';
  942. echo ">$file</option>\n";
  943. }
  944. echo '</select>';*/
  945. echo "</td>\n";
  946. }
  947. echo "</tr>\n";
  948. //Second parameter: Dokeos URL
  949. echo "<tr>\n";
  950. echo '<td>'.get_lang('DokeosURL').' (<font color="red">'.get_lang('ThisFieldIsRequired')."</font>)&nbsp;&nbsp;</td>\n";
  951. if($installType == 'update') echo '<td>'.api_htmlentities($urlForm, ENT_QUOTES, $charset)."</td>\n";
  952. else echo '<td><input type="text" size="40" maxlength="100" name="urlForm" value="'.api_htmlentities($urlForm, ENT_QUOTES, $charset).'" />'."</td>\n";
  953. echo "</tr>\n";
  954. //Parameter 3: administrator's email
  955. display_configuration_parameter($installType, get_lang("AdminEmail"), "emailForm", $emailForm);
  956. //Parameter 4: administrator's last name
  957. display_configuration_parameter($installType, get_lang("AdminLastName"), "adminLastName", $adminLastName);
  958. //Parameter 5: administrator's first name
  959. display_configuration_parameter($installType, get_lang("AdminFirstName"), "adminFirstName", $adminFirstName);
  960. //Parameter 6: administrator's telephone
  961. display_configuration_parameter($installType, get_lang("AdminPhone"), "adminPhoneForm", $adminPhoneForm);
  962. //Parameter 7: administrator's login
  963. display_configuration_parameter($installType, get_lang("AdminLogin"), "loginForm", $loginForm, ($installType == 'update' ? true : false));
  964. //Parameter 8: administrator's password
  965. if($installType != 'update')
  966. display_configuration_parameter($installType, get_lang("AdminPass"), "passForm", $passForm, false);
  967. //Parameter 9: campus name
  968. display_configuration_parameter($installType, get_lang("CampusName"), "campusForm", $campusForm);
  969. //Parameter 10: institute (short) name
  970. display_configuration_parameter($installType, get_lang("InstituteShortName"), "institutionForm", $institutionForm);
  971. //Parameter 11: institute (short) name
  972. display_configuration_parameter($installType, get_lang("InstituteURL"), "institutionUrlForm", $institutionUrlForm);
  973. /*
  974. //old method
  975. <tr>
  976. <td><?php echo get_lang("EncryptUserPass"); ?> :</td>
  977. <?php if($installType == 'update'): ?>
  978. <td><input type="hidden" name="encryptPassForm" value="<?php echo $encryptPassForm; ?>" /><?php echo $encryptPassForm? get_lang("Yes") : get_lang("No"); ?></td>
  979. <?php else: ?>
  980. <td>
  981. <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>
  982. <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>
  983. </td>
  984. <?php endif; ?>
  985. </tr>
  986. */
  987. ?>
  988. <tr>
  989. <td><?php echo get_lang("EncryptMethodUserPass"); ?> :</td>
  990. <?php if($installType == 'update'): ?>
  991. <td><input type="hidden" name="encryptPassForm" value="<?php echo $encryptPassForm; ?>" /><?php echo $encryptPassForm; ?></td>
  992. <?php else: ?>
  993. <td>
  994. <input class="checkbox" type="radio" name="encryptPassForm" value="md5" id="encryptPass0" <?php echo $encryptPassForm?'checked="checked" ':''; ?>/> <label for="encryptPass0"><?php echo "md5"; ?></label>
  995. <input class="checkbox" type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" <?php echo $encryptPassForm?'':'checked="checked" '; ?>/> <label for="encryptPass1"><?php echo "sha1"; ?></label>
  996. <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>
  997. </td>
  998. <?php endif; ?>
  999. </tr>
  1000. <tr>
  1001. <td><?php echo get_lang("AllowSelfReg"); ?> :</td>
  1002. <?php if($installType == 'update'): ?>
  1003. <td><input type="hidden" name="allowSelfReg" value="<?php echo $allowSelfReg; ?>" /><?php echo $allowSelfReg? get_lang("Yes") : get_lang("No"); ?></td>
  1004. <?php else: ?>
  1005. <td>
  1006. <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>
  1007. <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>
  1008. </td>
  1009. <?php endif; ?>
  1010. </tr>
  1011. <tr>
  1012. <td><?php echo get_lang("AllowSelfRegProf"); ?> :</td>
  1013. <?php if($installType == 'update'): ?>
  1014. <td><input type="hidden" name="allowSelfRegProf" value="<?php echo $allowSelfRegProf; ?>" /><?php echo $allowSelfRegProf? get_lang("Yes") : get_lang("No"); ?></td>
  1015. <?php else: ?>
  1016. <td>
  1017. <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>
  1018. <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>
  1019. </td>
  1020. <?php endif; ?>
  1021. </tr>
  1022. <tr>
  1023. <td><button type="submit" class="back" name="step3" value="&lt; <?php echo get_lang('Previous'); ?>" /><?php echo get_lang('Previous'); ?></button></td>
  1024. <td align="right"><button class="next" type="submit" name="step5" value="<?php echo get_lang('Next'); ?> &gt;" /><?php echo get_lang('Next'); ?></button></td>
  1025. </tr>
  1026. </table>
  1027. <?php
  1028. }
  1029. /**
  1030. * After installation is completed (step 6), this message is displayed.
  1031. */
  1032. function display_after_install_message($installType, $nbr_courses)
  1033. {
  1034. ?>
  1035. <h2><?php echo display_step_sequence() . get_lang("CfgSetting"); ?></h2>
  1036. <?php echo get_lang('FirstUseTip'); ?>
  1037. <?php if($installType == 'update' && $nbr_courses > MAX_COURSE_TRANSFER): ?>
  1038. <br /><br />
  1039. <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>
  1040. <?php endif; ?>
  1041. <br /><br />
  1042. <?php
  1043. echo '<div class="warning-message">';
  1044. //echo '<img src="../img/message_warning.png" style="float:left; margin-right:10px;" alt="'.get_lang('Warning').'"/>';
  1045. echo '<b>'.get_lang('SecurityAdvice').'</b>';
  1046. echo ': ';
  1047. printf(get_lang('ToProtectYourSiteMakeXAndYReadOnly'),'main/inc/conf/configuration.php','main/install/index.php');
  1048. echo '</div>';
  1049. ?>
  1050. </form>
  1051. <a href="../../index.php"><?php echo get_lang('GoToYourNewlyCreatedPortal'); ?></a>
  1052. <?php
  1053. }
  1054. /**
  1055. * In step 3. Test the connection to the DB in case of single or multy DB.
  1056. * 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.
  1057. */
  1058. function test_db_connect ($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm) {
  1059. $dbConnect = -1;
  1060. if ($singleDbForm == 1) {
  1061. if(@mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm) !== false) {
  1062. $dbConnect = 1;
  1063. } else {
  1064. $dbConnect = -1;
  1065. }
  1066. } elseif ($singleDbForm == 0) {
  1067. $res=@mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
  1068. if ($res===false) {
  1069. return $res;
  1070. }
  1071. if ($res !== false) {
  1072. // The Dokeos system has not been designed to use special SQL modes that were introduced since MySQL 5
  1073. @mysql_query("set session sql_mode='';");
  1074. $multipleDbCheck = @mysql_query("CREATE DATABASE ".$dbPrefixForm."test_dokeos_connection");
  1075. if ($multipleDbCheck !== false) {
  1076. $multipleDbCheck = @mysql_query("DROP DATABASE IF EXISTS ".$dbPrefixForm."test_dokeos_connection");
  1077. if ($multipleDbCheck !== false) {
  1078. $dbConnect = 1;
  1079. } else {
  1080. $dbConnect = 0;
  1081. }
  1082. } else {
  1083. $dbConnect = 0;
  1084. }
  1085. } else {
  1086. $dbConnect = -1;
  1087. }
  1088. }
  1089. 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.
  1090. }
  1091. ?>