install.lib.php 92 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Chamilo LMS
  5. * This file contains functions used by the install and upgrade scripts.
  6. *
  7. * Ideas for future additions:
  8. * - a function get_old_version_settings to retrieve the config file settings
  9. * of older versions before upgrading.
  10. */
  11. /* CONSTANTS */
  12. define('SYSTEM_MAIN_DATABASE_FILE', 'db_main.sql');
  13. define('COUNTRY_DATA_FILENAME', 'country_data.csv');
  14. define('COURSES_HTACCESS_FILENAME', 'htaccess.dist');
  15. define('SYSTEM_CONFIG_FILENAME', 'configuration.dist.php');
  16. /* COMMON PURPOSE FUNCTIONS */
  17. /**
  18. * This function detects whether the system has been already installed.
  19. * It should be used for prevention from second running the installation
  20. * script and as a result - destroying a production system.
  21. * @return bool The detected result;
  22. * @author Ivan Tcholakov, 2010;
  23. */
  24. function is_already_installed_system() {
  25. global $new_version, $_configuration;
  26. if (empty($new_version)) {
  27. return true; // Must be initialized.
  28. }
  29. $current_config_file = api_get_path(CONFIGURATION_PATH).'configuration.php';
  30. if (!file_exists($current_config_file)) {
  31. return false; // Configuration file does not exist, install the system.
  32. }
  33. require $current_config_file;
  34. $current_version = trim($_configuration['dokeos_version']);
  35. if (empty($current_version)) {
  36. $current_version = trim($_configuration['system_version']);
  37. }
  38. // If the current version is old, upgrading is assumed, the installer goes ahead.
  39. return empty($current_version) ? false : version_compare($current_version, $new_version, '>=');
  40. }
  41. /**
  42. * This function checks if a php extension exists or not and returns an HTML status string.
  43. *
  44. * @param string Name of the PHP extension to be checked
  45. * @param string Text to show when extension is available (defaults to 'Yes')
  46. * @param string Text to show when extension is available (defaults to 'No')
  47. * @param boolean Whether this extension is optional (in this case show unavailable text in orange rather than red)
  48. * @return string HTML string reporting the status of this extension. Language-aware.
  49. * @author Christophe Gesch??
  50. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  51. * @author Yannick Warnier <yannick.warnier@dokeos.com>
  52. * @version Dokeos 1.8.1, May 2007
  53. */
  54. function check_extension($extension_name, $return_success = 'Yes', $return_failure = 'No', $optional = false) {
  55. if (extension_loaded($extension_name)) {
  56. return '<strong><font color="green">'.$return_success.'</font></strong>';
  57. } else {
  58. if ($optional) {
  59. return '<strong><font color="#ff9900">'.$return_failure.'</font></strong>';
  60. } else {
  61. return '<strong><font color="red">'.$return_failure.'</font></strong>';
  62. }
  63. }
  64. }
  65. /**
  66. * This function checks whether a php setting matches the recommended value
  67. *
  68. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  69. * @version Dokeos 1.8, august 2006
  70. */
  71. function check_php_setting($php_setting, $recommended_value, $return_success = false, $return_failure = false) {
  72. $current_php_value = get_php_setting($php_setting);
  73. if ($current_php_value == $recommended_value) {
  74. return '<strong><font color="green">'.$current_php_value.' '.$return_success.'</font></strong>';
  75. } else {
  76. return '<strong><font color="red">'.$current_php_value.' '.$return_failure.'</font></strong>';
  77. }
  78. }
  79. /**
  80. * Returns a textual value ('ON' or 'OFF') based on a requester 2-state ini- configuration setting.
  81. *
  82. * @param string $val a php ini value
  83. * @return boolean: ON or OFF
  84. * @author Joomla <http://www.joomla.org>
  85. */
  86. function get_php_setting($val) {
  87. return ini_get($val) == '1' ? 'ON' : 'OFF';
  88. }
  89. /**
  90. * This function returns a string "true" or "false" according to the passed parameter.
  91. *
  92. * @param integer $var The variable to present as text
  93. * @return string the string "true" or "false"
  94. * @author Christophe Gesch??
  95. */
  96. function true_false($var) {
  97. return $var ? 'true' : 'false';
  98. }
  99. /**
  100. * Removes memory and time limits as much as possible.
  101. */
  102. function remove_memory_and_time_limits() {
  103. if (function_exists('ini_set')) {
  104. ini_set('memory_limit', -1);
  105. ini_set('max_execution_time', 0);
  106. } else {
  107. error_log('Update-db script: could not change memory and time limits', 0);
  108. }
  109. }
  110. /**
  111. * Detects browser's language.
  112. * @return string Returns a language identificator, i.e. 'english', 'spanish', ...
  113. * @author Ivan Tcholakov, 2010
  114. */
  115. function detect_browser_language() {
  116. static $language_index = array(
  117. 'ar' => 'arabic',
  118. 'ast' => 'asturian',
  119. 'bg' => 'bulgarian',
  120. 'bs' => 'bosnian',
  121. 'ca' => 'catalan',
  122. 'zh' => 'simpl_chinese',
  123. 'zh-tw' => 'trad_chinese',
  124. 'cs' => 'czech',
  125. 'da' => 'danish',
  126. 'prs' => 'dari',
  127. 'de' => 'german',
  128. 'el' => 'greek',
  129. 'en' => 'english',
  130. 'es' => 'spanish',
  131. 'eo' => 'esperanto',
  132. 'eu' => 'euskera',
  133. 'fa' => 'persian',
  134. 'fr' => 'french',
  135. 'fur' => 'friulian',
  136. 'gl' => 'galician',
  137. 'ka' => 'georgian',
  138. 'hr' => 'croatian',
  139. 'he' => 'hebrew',
  140. 'hi' => 'hindi',
  141. 'id' => 'indonesian',
  142. 'it' => 'italian',
  143. 'ko' => 'korean',
  144. 'lv' => 'latvian',
  145. 'lt' => 'lithuanian',
  146. 'mk' => 'macedonian',
  147. 'hu' => 'hungarian',
  148. 'ms' => 'malay',
  149. 'nl' => 'dutch',
  150. 'ja' => 'japanese',
  151. 'no' => 'norwegian',
  152. 'oc' => 'occitan',
  153. 'ps' => 'pashto',
  154. 'pl' => 'polish',
  155. 'pt' => 'portuguese',
  156. 'pt-br' => 'brazilian',
  157. 'ro' => 'romanian',
  158. 'qu' => 'quechua_cusco',
  159. 'ru' => 'russian',
  160. 'sk' => 'slovak',
  161. 'sl' => 'slovenian',
  162. 'sr' => 'serbian',
  163. 'fi' => 'finnish',
  164. 'sv' => 'swedish',
  165. 'th' => 'thai',
  166. 'tr' => 'turkce',
  167. 'uk' => 'ukrainian',
  168. 'vi' => 'vietnamese',
  169. 'sw' => 'swahili',
  170. 'yo' => 'yoruba'
  171. );
  172. $system_available_languages = & get_language_folder_list();
  173. $accept_languages = strtolower(str_replace('_', '-', $_SERVER['HTTP_ACCEPT_LANGUAGE']));
  174. foreach ($language_index as $code => $language) {
  175. if (strpos($accept_languages, $code) === 0) {
  176. if (!empty($system_available_languages[$language])) {
  177. return $language;
  178. }
  179. }
  180. }
  181. $user_agent = strtolower(str_replace('_', '-', $_SERVER['HTTP_USER_AGENT']));
  182. foreach ($language_index as $code => $language) {
  183. if (@preg_match("/[\[\( ]{$code}[;,_\-\)]/", $user_agent)) {
  184. if (!empty($system_available_languages[$language])) {
  185. return $language;
  186. }
  187. }
  188. }
  189. return 'english';
  190. }
  191. /* FILESYSTEM RELATED FUNCTIONS */
  192. /**
  193. * This function checks if the given folder is writable
  194. */
  195. function check_writable($folder, $suggestion = false) {
  196. if (is_writable(api_get_path(SYS_CODE_PATH).$folder)) {
  197. return '<strong><font color="green">'.get_lang('Writable').'</font></strong>';
  198. } else {
  199. if ($suggestion) {
  200. return '<strong><font color="#ff9900">'.get_lang('NotWritable').'</font></strong>';
  201. } else {
  202. return '<strong><font color="red">'.get_lang('NotWritable').'</font></strong>';
  203. }
  204. }
  205. }
  206. /**
  207. * This function is similar to the core file() function, except that it
  208. * works with line endings in Windows (which is not the case of file())
  209. * @param string File path
  210. * @return array The lines of the file returned as an array
  211. */
  212. function file_to_array($filename) {
  213. $fp = fopen($filename, 'rb');
  214. $buffer = fread($fp, filesize($filename));
  215. fclose($fp);
  216. return explode('<br />', nl2br($buffer));
  217. }
  218. /**
  219. * We assume this function is called from install scripts that reside inside the install folder.
  220. */
  221. function set_file_folder_permissions() {
  222. @chmod('.', 0755); //set permissions on install dir
  223. @chmod('..', 0755); //set permissions on parent dir of install dir
  224. @chmod('country_data.csv.csv', 0755);
  225. }
  226. /**
  227. * Add's a .htaccess file to the courses directory
  228. * @param string $url_append The path from your webroot to your chamilo root
  229. */
  230. function write_courses_htaccess_file($url_append) {
  231. $content = file_get_contents(dirname(__FILE__).'/'.COURSES_HTACCESS_FILENAME);
  232. $content = str_replace('{CHAMILO_URL_APPEND_PATH}', $url_append, $content);
  233. $fp = @ fopen(api_get_path(SYS_PATH).'courses/.htaccess', 'w');
  234. if ($fp) {
  235. fwrite($fp, $content);
  236. return fclose($fp);
  237. }
  238. return false;
  239. }
  240. /**
  241. * Write the main system config file
  242. * @param string $path Path to the config file
  243. */
  244. function write_system_config_file($path) {
  245. global $dbHostForm;
  246. global $dbUsernameForm;
  247. global $dbPassForm;
  248. global $enableTrackingForm;
  249. global $singleDbForm;
  250. global $dbPrefixForm;
  251. global $dbNameForm;
  252. global $dbStatsForm;
  253. global $dbScormForm;
  254. global $dbUserForm;
  255. global $urlForm;
  256. global $pathForm;
  257. global $urlAppendPath;
  258. global $languageForm;
  259. global $encryptPassForm;
  260. global $installType;
  261. global $updatePath;
  262. global $session_lifetime;
  263. global $new_version;
  264. global $new_version_stable;
  265. $root_sys = api_add_trailing_slash(str_replace('\\', '/', realpath($pathForm)));
  266. $content = file_get_contents(dirname(__FILE__).'/'.SYSTEM_CONFIG_FILENAME);
  267. $config['{DATE_GENERATED}'] = date('r');
  268. $config['{DATABASE_HOST}'] = $dbHostForm;
  269. $config['{DATABASE_USER}'] = $dbUsernameForm;
  270. $config['{DATABASE_PASSWORD}'] = $dbPassForm;
  271. $config['TRACKING_ENABLED'] = true_false($enableTrackingForm);
  272. $config['SINGLE_DATABASE'] = true_false($singleDbForm);
  273. $config['{COURSE_TABLE_PREFIX}'] = ($singleDbForm ? 'crs_' : '');
  274. $config['{DATABASE_GLUE}'] = ($singleDbForm ? '_' : '`.`');
  275. $config['{DATABASE_PREFIX}'] = $dbPrefixForm;
  276. $config['{DATABASE_MAIN}'] = $dbNameForm;
  277. $config['{DATABASE_STATS}'] = (($singleDbForm && empty($dbStatsForm)) ? $dbNameForm : $dbStatsForm);
  278. $config['{DATABASE_SCORM}'] = (($singleDbForm && empty($dbScormForm)) ? $dbNameForm : $dbScormForm);
  279. $config['{DATABASE_PERSONAL}'] = (($singleDbForm && empty($dbUserForm)) ? $dbNameForm : $dbUserForm);
  280. $config['{ROOT_WEB}'] = $urlForm;
  281. $config['{ROOT_SYS}'] = $root_sys;
  282. $config['{URL_APPEND_PATH}'] = $urlAppendPath;
  283. $config['{PLATFORM_LANGUAGE}'] = $languageForm;
  284. $config['{SECURITY_KEY}'] = md5(uniqid(rand().time()));
  285. $config['{ENCRYPT_PASSWORD}'] = $encryptPassForm;
  286. $config['SESSION_LIFETIME'] = $session_lifetime;
  287. $config['{NEW_VERSION}'] = $new_version;
  288. $config['NEW_VERSION_STABLE'] = true_false($new_version_stable);
  289. foreach ($config as $key => $value) {
  290. $content = str_replace($key, $value, $content);
  291. }
  292. $fp = @ fopen($path, 'w');
  293. if (!$fp) {
  294. echo '<strong><font color="red">Your script doesn\'t have write access to the config directory</font></strong><br />
  295. <em>('.str_replace('\\', '/', realpath($path)).')</em><br /><br />
  296. You probably do not have write access on Chamilo root directory,
  297. i.e. you should <em>CHMOD 777</em> or <em>755</em> or <em>775</em>.<br /><br />
  298. Your problems can be related on two possible causes:<br />
  299. <ul>
  300. <li>Permission problems.<br />Try initially with <em>chmod -R 777</em> and increase restrictions gradually.</li>
  301. <li>PHP is running in <a href="http://www.php.net/manual/en/features.safe-mode.php" target="_blank">Safe-Mode</a>. If possible, try to switch it off.</li>
  302. </ul>
  303. <a href="http://forum.chamilo.org/" target="_blank">Read about this problem in Support Forum</a><br /><br />
  304. Please go back to step 5.
  305. <p><input type="submit" name="step5" value="&lt; Back" /></p>
  306. </td></tr></table></form></body></html>';
  307. exit;
  308. }
  309. fwrite($fp, $content);
  310. fclose($fp);
  311. }
  312. /**
  313. * Returns a list of language directories.
  314. */
  315. function & get_language_folder_list() {
  316. static $result;
  317. if (!is_array($result)) {
  318. $result = array();
  319. $exceptions = array('.', '..', 'CVS', '.svn');
  320. $search = array('_latin', '_unicode', '_corporate', '_org' , '_KM', '_');
  321. $replace_with = array(' (Latin)', ' (unicode)', ' (corporate)', ' (org)', ' (KM)', ' ');
  322. $dirname = api_get_path(SYS_LANG_PATH);
  323. $handle = opendir($dirname);
  324. while ($entries = readdir($handle)) {
  325. if (in_array($entries, $exceptions)) {
  326. continue;
  327. }
  328. if (is_dir($dirname.$entries)) {
  329. $result[$entries] = ucwords(str_replace($search, $replace_with, $entries));
  330. }
  331. }
  332. closedir($handle);
  333. asort($result);
  334. }
  335. return $result;
  336. }
  337. /**
  338. * TODO: my_directory_to_array() - maybe within the main API there is already a suitable function?
  339. */
  340. function my_directory_to_array($directory) {
  341. $array_items = array();
  342. if ($handle = opendir($directory)) {
  343. while (false !== ($file = readdir($handle))) {
  344. if ($file != "." && $file != "..") {
  345. if (is_dir($directory. "/" . $file)) {
  346. $array_items = array_merge($array_items, my_directory_to_array($directory. '/' . $file));
  347. $file = $directory . "/" . $file;
  348. $array_items[] = preg_replace("/\/\//si", '/', $file);
  349. }
  350. }
  351. }
  352. closedir($handle);
  353. }
  354. return $array_items;
  355. }
  356. /**
  357. * This function returns the value of a parameter from the configuration file
  358. *
  359. * WARNING - this function relies heavily on global variables $updateFromConfigFile
  360. * and $configFile, and also changes these globals. This can be rewritten.
  361. *
  362. * @param string $param the parameter of which the value is returned
  363. * @param string If we want to give the path rather than take it from POST
  364. * @return string the value of the parameter
  365. * @author Olivier Brouckaert
  366. * @author Reworked by Ivan Tcholakov, 2010
  367. */
  368. function get_config_param($param, $updatePath = '') {
  369. global $configFile, $updateFromConfigFile;
  370. // Look if we already have the queried parameter.
  371. if (is_array($configFile) && isset($configFile[$param])) {
  372. return $configFile[$param];
  373. }
  374. if (empty($updatePath) && !empty($_POST['updatePath'])) {
  375. $updatePath = $_POST['updatePath'];
  376. }
  377. if (empty($updatePath)) {
  378. $updatePath = api_get_path(SYS_PATH);
  379. }
  380. $updatePath = api_add_trailing_slash(str_replace('\\', '/', realpath($updatePath)));
  381. $updateFromInstalledVersionFile = '';
  382. if (empty($updateFromConfigFile)) {
  383. // If update from previous install was requested,
  384. // try to recover old config file from dokeos 1.8.x.
  385. if (file_exists($updatePath.'main/inc/conf/configuration.php')) {
  386. $updateFromConfigFile = 'main/inc/conf/configuration.php';
  387. } elseif (file_exists($updatePath.'claroline/inc/conf/claro_main.conf.php')) {
  388. $updateFromConfigFile = 'claroline/inc/conf/claro_main.conf.php';
  389. } else {
  390. // Give up recovering.
  391. error_log('Notice: Could not find previous config file at '.$updatePath.'main/inc/conf/configuration.php nor at '.$updatePath.'claroline/inc/conf/claro_main.conf.php in get_config_param(). Will start new config (in '.__FILE__.', line '.__LINE__.')', 0);
  392. return null;
  393. }
  394. }
  395. if (file_exists($updatePath.$updateFromConfigFile)) {
  396. // The parameter was not found among the global variables, so look into the old configuration file.
  397. // Make sure the installedVersion file is read first so it is overwritten
  398. // by the config file if the config file contains the version (from 1.8.4).
  399. $config_data_2 = array();
  400. if (file_exists($updatePath.$updateFromInstalledVersionFile)) {
  401. $config_data_2 = file_to_array($updatePath.$updateFromInstalledVersionFile);
  402. }
  403. $configFile = array();
  404. $config_data = file_to_array($updatePath.$updateFromConfigFile);
  405. $config_data = array_merge($config_data, $config_data_2);
  406. $val = '';
  407. // Parse the configuration file, statement by statement (line by line, actually).
  408. foreach ($config_data as $php_statement) {
  409. if (strpos($php_statement, '=') !== false) {
  410. // Variable assignment statement have been detected (probably).
  411. // It is expected to be as follows:
  412. // $variable = 'some_value'; // A comment that is not mandatory.
  413. // Split the statement into its left and right sides.
  414. $php_statement = explode('=', $php_statement);
  415. $variable = trim($php_statement[0]);
  416. $value = $php_statement[1];
  417. if (substr($variable, 0, 1) == '$') {
  418. // We have for sure a php variable assignment detected.
  419. // On the left side: Retrieve the pure variable's name
  420. $variable = trim(str_replace('$', '', $variable));
  421. // On the right side: Remove the comment, if it exists.
  422. list($value) = explode(' //', $value);
  423. // Remove extra whitespace, if any. Remove the trailing semicolon (;).
  424. $value = substr(trim($value), 0, -1);
  425. // Remove surroundig quotes, restore escaped quotes.
  426. $value = str_replace('\"', '"', preg_replace('/^"|"$/', '', $value));
  427. $value = str_replace('\'', '"', preg_replace('/^\'|\'$/', '', $value));
  428. if (strtolower($value) == 'true') {
  429. // A boolean true value have been recognized.
  430. $value = 1;
  431. } elseif (strtolower($value) == 'false') {
  432. // A boolean false value have been recognized.
  433. $value = 0;
  434. } else {
  435. // Probably we have a string value, but also we have to check
  436. // possible string concatenations that may include string values
  437. // and other configuration variables. I this case we have to
  438. // get the calculated result of the concatenation.
  439. $implode_string = ' ';
  440. if (!strstr($value, '." ".') && strstr($value, '.$')) {
  441. // Yes, there is concatenation, insert a special separator string.
  442. $value = str_replace('.$', '." ".$', $value);
  443. $implode_string = '';
  444. }
  445. // Split the concatenated values, if they are more than one.
  446. $sub_strings = explode('." ".', $value);
  447. // Seek for variables and retrieve their values.
  448. foreach ($sub_strings as $key => & $sub_string) {
  449. if (preg_match('/^\$[a-zA-Z_][a-zA-Z0-9_]*$/', $sub_string)) {
  450. // A variable has been detected, read it by recursive call.
  451. $sub_string = get_config_param(str_replace('$', '', $sub_string));
  452. }
  453. }
  454. // Concatenate everything into the final, the calculated string value.
  455. $value = implode($implode_string, $sub_strings);
  456. }
  457. // Cache the result value.
  458. $configFile[$variable] = $value;
  459. $a = explode("'", $variable);
  460. $key_tmp = $a[1];
  461. if ($key_tmp == $param) {
  462. $val = $value;
  463. }
  464. }
  465. }
  466. }
  467. }
  468. //Special treatment for dokeos_version parameter due to Dokeos 1.8.3 have the dokeos_version in the main/inc/installedVersion.inc.php file
  469. if ($param == 'dokeos_version') {
  470. //dokeos_version from configuration.php if empty
  471. $dokeos_version = $val;
  472. if (empty($dokeos_version)) {
  473. //checking the dokeos_version value exists in main/inc/installedVersion.inc.php
  474. if (file_exists($updatePath.'main/inc/installedVersion.inc.php')) {
  475. $updateFromInstalledVersionFile = $updatePath.'main/inc/installedVersion.inc.php';
  476. require ($updateFromInstalledVersionFile); //there are only 2 variables here: $stable & $dokeos_version
  477. $stable = false;
  478. }
  479. }
  480. return $dokeos_version;
  481. } else {
  482. if (file_exists($updatePath.$updateFromConfigFile)) {
  483. return $val;
  484. } else {
  485. error_log('Config array could not be found in get_config_param()', 0);
  486. return null;
  487. }
  488. }
  489. }
  490. /* DATABASE RELATED FUNCTIONS */
  491. /**
  492. * Gets a configuration parameter from the database. Returns returns null on failure.
  493. * @param string DB Host
  494. * @param string DB login
  495. * @param string DB pass
  496. * @param string DB name
  497. * @param string Name of param we want
  498. * @return mixed The parameter value or null if not found
  499. */
  500. function get_config_param_from_db($host, $login, $pass, $db_name, $param = '') {
  501. Database::connect(array('server' => $host, 'username' => $login, 'password' => $pass));
  502. Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
  503. Database::select_db($db_name);
  504. if (($res = Database::query("SELECT * FROM settings_current WHERE variable = '$param'")) !== false) {
  505. if (Database::num_rows($res) > 0) {
  506. $row = Database::fetch_array($res);
  507. return $row['selected_value'];
  508. }
  509. }
  510. return null;
  511. }
  512. /**
  513. * Connects to the database server.
  514. */
  515. function database_server_connect() {
  516. global $dbHostForm, $dbUsernameForm, $dbPassForm;
  517. if (($res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm))) === false) {
  518. $no = Database::errno();
  519. $msg = Database::error();
  520. echo '<hr />#'.$no.': '.$msg.'<hr />';
  521. echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />'.
  522. get_lang('PleaseCheckTheseValues').' :<br /><br />'.
  523. '<strong>'.get_lang('DBHost').'</strong> : '.$dbHostForm.'<br />'.
  524. '<strong>'.get_lang('DBLogin').'</strong> : '.$dbUsernameForm.'<br />'.
  525. '<strong>'.get_lang('DBPassword').'</strong> : '.$dbPassForm.'<br /><br />'.
  526. get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'.'.
  527. '<p><button type="submit" class="back" name="step'. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'" value="&lt; '.get_lang('Back').'">'.get_lang('Back').'</button></p>'.
  528. '</td></tr></table></form></body></html>';
  529. exit ();
  530. }
  531. @Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
  532. }
  533. function database_exists($database_name) {
  534. $result = @Database::query("SHOW DATABASES LIKE '".Database::escape_string($database_name)."' ");
  535. if (Database::num_rows($result)) {
  536. return true;
  537. }
  538. return false;
  539. }
  540. /**
  541. * In step 3. Tests establishing connection to the database server.
  542. * If it's a single database environment the function checks if the database exist.
  543. * If the database doesn't exist we check the creation permissions.
  544. *
  545. * @return int 1 when there is no problem;
  546. * 0 when a new database is impossible to be created, then the single/multiple database configuration is impossible too
  547. * -1 when there is no connection established.
  548. */
  549. function test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm, $dbNameForm) {
  550. $dbConnect = -1;
  551. //Checking user credentials
  552. if (@Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)) !== false) {
  553. $check_user_can_create_databases = true;
  554. //Checking if single database exist
  555. if ($singleDbForm) {
  556. if (database_exists($dbPrefixForm.$dbNameForm)) {
  557. $check_user_can_create_databases = false;
  558. $dbConnect = 1;
  559. }
  560. }
  561. //Checking database creation
  562. if ($check_user_can_create_databases) {
  563. @Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
  564. $multipleDbCheck = @Database::query("CREATE DATABASE ".$dbPrefixForm."test_chamilo_connection");
  565. if ($multipleDbCheck !== false) {
  566. $multipleDbCheck = @Database::query("DROP DATABASE IF EXISTS ".$dbPrefixForm."test_chamilo_connection");
  567. if ($multipleDbCheck !== false) {
  568. $dbConnect = 1;
  569. } else {
  570. $dbConnect = 0;
  571. }
  572. } else {
  573. $dbConnect = 0;
  574. }
  575. }
  576. } else {
  577. $dbConnect = -1;
  578. }
  579. return $dbConnect; //return "1"if no problems, "0" if, in case we can't create a new DB and "-1" if there is no connection.
  580. }
  581. /**
  582. * Fills the countries table with a list of countries.
  583. */
  584. function fill_track_countries_table($track_countries_table) {
  585. $file_path = dirname(__FILE__).'/'.COUNTRY_DATA_FILENAME;
  586. $add_country_sql = "LOAD DATA INFILE '".Database::escape_string($file_path)."' INTO TABLE $track_countries_table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\'';";
  587. @ Database::query($add_country_sql);
  588. }
  589. /**
  590. * Creates the structure of the main database and fills it
  591. * with data. Placeholder symbols in the main database file
  592. * have to be replaced by the settings entered by the user during installation.
  593. *
  594. * @param array $installation_settings list of settings entered by the user
  595. * @param string optional path about the script for database
  596. * @return void
  597. */
  598. function load_main_database($installation_settings, $db_script = '') {
  599. if (!empty($db_script)) {
  600. if (file_exists($db_script)) {
  601. $sql_text = file_get_contents($db_script);
  602. }
  603. } else {
  604. $db_script = api_get_path(SYS_CODE_PATH).'install/'.SYSTEM_MAIN_DATABASE_FILE;
  605. if (file_exists($db_script)) {
  606. $sql_text = file_get_contents($db_script);
  607. }
  608. }
  609. //replace symbolic parameters with user-specified values
  610. foreach ($installation_settings as $key => $value) {
  611. $sql_text = str_replace($key, Database::escape_string($value), $sql_text);
  612. }
  613. //split in array of sql strings
  614. $sql_instructions = array();
  615. $success = split_sql_file($sql_instructions, $sql_text);
  616. //execute the sql instructions
  617. $count = count($sql_instructions);
  618. for ($i = 0; $i < $count; $i++) {
  619. $this_sql_query = $sql_instructions[$i]['query'];
  620. Database::query($this_sql_query);
  621. }
  622. }
  623. /**
  624. * Creates the structure of the stats database
  625. * @param string Name of the file containing the SQL script inside the install directory
  626. */
  627. function load_database_script($db_script) {
  628. $db_script = api_get_path(SYS_CODE_PATH).'install/'.$db_script;
  629. if (file_exists($db_script)) {
  630. $sql_text = file_get_contents($db_script);
  631. }
  632. //split in array of sql strings
  633. $sql_instructions = array();
  634. $success = split_sql_file($sql_instructions, $sql_text);
  635. //execute the sql instructions
  636. $count = count($sql_instructions);
  637. for ($i = 0; $i < $count; $i++) {
  638. $this_sql_query = $sql_instructions[$i]['query'];
  639. Database::query($this_sql_query);
  640. }
  641. }
  642. /**
  643. * Function copied and adapted from phpMyAdmin 2.6.0 PMA_splitSqlFile (also GNU GPL)
  644. * Removes comment lines and splits up large sql files into individual queries
  645. * Last revision: September 23, 2001 - gandon
  646. * @param array the splitted sql commands
  647. * @param string the sql commands
  648. * @param integer the MySQL release number (because certains php3 versions
  649. * can't get the value of a constant from within a function)
  650. * @return boolean always true
  651. */
  652. function split_sql_file(&$ret, $sql) {
  653. // do not trim, see bug #1030644
  654. //$sql = trim($sql);
  655. $sql = rtrim($sql, "\n\r");
  656. $sql_len = strlen($sql);
  657. $char = '';
  658. $string_start = '';
  659. $in_string = false;
  660. $nothing = true;
  661. $time0 = time();
  662. for ($i = 0; $i < $sql_len; ++$i) {
  663. $char = $sql[$i];
  664. // We are in a string, check for not escaped end of strings except for
  665. // backquotes that can't be escaped
  666. if ($in_string) {
  667. for (;;) {
  668. $i = strpos($sql, $string_start, $i);
  669. // No end of string found -> add the current substring to the
  670. // returned array
  671. if (!$i) {
  672. $ret[] = $sql;
  673. return true;
  674. }
  675. // Backquotes or no backslashes before quotes: it's indeed the
  676. // end of the string -> exit the loop
  677. elseif ($string_start == '`' || $sql[$i - 1] != '\\') {
  678. $string_start = '';
  679. $in_string = false;
  680. break;
  681. }
  682. // one or more Backslashes before the presumed end of string...
  683. else {
  684. // ... first checks for escaped backslashes
  685. $j = 2;
  686. $escaped_backslash = false;
  687. while ($i - $j > 0 && $sql[$i - $j] == '\\') {
  688. $escaped_backslash = !$escaped_backslash;
  689. $j++;
  690. }
  691. // ... if escaped backslashes: it's really the end of the
  692. // string -> exit the loop
  693. if ($escaped_backslash) {
  694. $string_start = '';
  695. $in_string = false;
  696. break;
  697. }
  698. // ... else loop
  699. else {
  700. $i++;
  701. }
  702. } // end if...elseif...else
  703. } // end for
  704. } // end if (in string)
  705. // lets skip comments (/*, -- and #)
  706. elseif (($char == '-' && $sql_len > $i + 2 && $sql[$i + 1] == '-' && $sql[$i + 2] <= ' ') || $char == '#' || ($char == '/' && $sql_len > $i + 1 && $sql[$i + 1] == '*')) {
  707. $i = strpos($sql, $char == '/' ? '*/' : "\n", $i);
  708. // didn't we hit end of string?
  709. if ($i === false) {
  710. break;
  711. }
  712. if ($char == '/') $i++;
  713. }
  714. // We are not in a string, first check for delimiter...
  715. elseif ($char == ';') {
  716. // if delimiter found, add the parsed part to the returned array
  717. $ret[] = array('query' => substr($sql, 0, $i), 'empty' => $nothing);
  718. $nothing = true;
  719. $sql = ltrim(substr($sql, min($i + 1, $sql_len)));
  720. $sql_len = strlen($sql);
  721. if ($sql_len) {
  722. $i = -1;
  723. } else {
  724. // The submited statement(s) end(s) here
  725. return true;
  726. }
  727. } // end elseif (is delimiter)
  728. // ... then check for start of a string,...
  729. elseif (($char == '"') || ($char == '\'') || ($char == '`')) {
  730. $in_string = true;
  731. $nothing = false;
  732. $string_start = $char;
  733. } // end elseif (is start of string)
  734. elseif ($nothing) {
  735. $nothing = false;
  736. }
  737. // loic1: send a fake header each 30 sec. to bypass browser timeout
  738. $time1 = time();
  739. if ($time1 >= $time0 + 30) {
  740. $time0 = $time1;
  741. header('X-pmaPing: Pong');
  742. } // end if
  743. } // end for
  744. // add any rest to the returned array
  745. if (!empty($sql) && preg_match('@[^[:space:]]+@', $sql)) {
  746. $ret[] = array('query' => $sql, 'empty' => $nothing);
  747. }
  748. return true;
  749. } // end of the 'split_sql_file()' function
  750. /**
  751. * Get an SQL file's contents
  752. *
  753. * This function bases its parsing on the pre-set format of the specific SQL files in
  754. * the install/upgrade procedure:
  755. * Lines starting with "--" are comments (but need to be taken into account as they also hold sections names)
  756. * Other lines are considered to be one-line-per-query lines (this is checked quickly by this function)
  757. * @param string File to parse (in the current directory)
  758. * @param string Section to return
  759. * @param boolean Print (true) or hide (false) error texts when they occur
  760. */
  761. function get_sql_file_contents($file, $section, $print_errors = true) {
  762. //check given parameters
  763. if (empty($file)) {
  764. $error = "Missing name of file to parse in get_sql_file_contents()";
  765. if ($print_errors) echo $error;
  766. return false;
  767. }
  768. if (!in_array($section, array('main', 'user', 'stats', 'scorm', 'course'))) {
  769. $error = "Section '$section' is not authorized in get_sql_file_contents()";
  770. if ($print_errors) echo $error;
  771. return false;
  772. }
  773. $filepath = getcwd().'/'.$file;
  774. if (!is_file($filepath) or !is_readable($filepath)) {
  775. $error = "File $filepath not found or not readable in get_sql_file_contents()";
  776. if ($print_errors) echo $error;
  777. return false;
  778. }
  779. //read the file in an array
  780. // Empty lines should not be executed as SQL statements, because errors occur, see Task #2167.
  781. $file_contents = file($filepath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  782. if (!is_array($file_contents) or count($file_contents) < 1) {
  783. $error = "File $filepath looks empty in get_sql_file_contents()";
  784. if ($print_errors) echo $error;
  785. return false;
  786. }
  787. //prepare the resulting array
  788. $section_contents = array();
  789. $record = false;
  790. foreach ($file_contents as $index => $line) {
  791. if (substr($line, 0, 2) == '--') {
  792. //This is a comment. Check if section name, otherwise ignore
  793. $result = array();
  794. if (preg_match('/^-- xx([A-Z]*)xx/', $line, $result)) { //we got a section name here
  795. if ($result[1] == strtoupper($section)) {
  796. //we have the section we are looking for, start recording
  797. $record = true;
  798. } else {
  799. //we have another section's header. If we were recording, stop now and exit loop
  800. if ($record) {
  801. break;
  802. }
  803. $record = false;
  804. }
  805. }
  806. } else {
  807. if ($record) {
  808. if (!empty($line)) {
  809. $section_contents[] = $line;
  810. }
  811. }
  812. }
  813. }
  814. //now we have our section's SQL statements group ready, return
  815. return $section_contents;
  816. }
  817. /**
  818. * Adds a new document to the database - specific to version 1.8.0
  819. *
  820. * @param array $_course
  821. * @param string $path
  822. * @param string $filetype
  823. * @param int $filesize
  824. * @param string $title
  825. * @return id if inserted document
  826. */
  827. function add_document_180($_course, $path, $filetype, $filesize, $title, $comment = null) {
  828. $table_document = Database::get_course_table(TABLE_DOCUMENT, $_course['dbName']);
  829. $sql = "INSERT INTO $table_document
  830. (`path`,`filetype`,`size`,`title`, `comment`)
  831. VALUES ('$path','$filetype','$filesize','".
  832. Database::escape_string($title)."', '$comment')";
  833. if (Database::query($sql)) {
  834. //display_message("Added to database (id ".Database::insert_id().")!");
  835. return Database::insert_id();
  836. } else {
  837. //display_error("The uploaded file could not be added to the database (".Database::error().")!");
  838. return false;
  839. }
  840. }
  841. /* DISPLAY FUNCTIONS */
  842. /**
  843. * This function prints class=active_step $current_step=$param
  844. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  845. */
  846. function step_active($param) {
  847. global $current_step;
  848. if ($param == $current_step) {
  849. echo 'class="current_step" ';
  850. }
  851. }
  852. /**
  853. * This function displays the Step X of Y -
  854. * @return string String that says 'Step X of Y' with the right values
  855. */
  856. function display_step_sequence() {
  857. global $current_step;
  858. global $total_steps;
  859. return get_lang('Step'.$current_step).' &ndash; ';
  860. }
  861. /**
  862. * Displays a drop down box for selection the preferred language.
  863. */
  864. function display_language_selection_box($name = 'language_list', $default_language = 'english') {
  865. // Reading language list.
  866. $language_list = get_language_folder_list();
  867. /*
  868. // Reduction of the number of languages shown. Enable this fragment of code for customization purposes.
  869. // Modify the language list according to your preference. Don't exclude the 'english' item.
  870. $language_to_display = array('asturian', 'bulgarian', 'english', 'italian', 'french', 'slovenian', 'slovenian_unicode', 'spanish');
  871. foreach ($language_list as $key => & $value) {
  872. if (!in_array($key, $language_to_display)) {
  873. unset($language_list[$key]);
  874. }
  875. }
  876. */
  877. // Sanity checks due to the possibility for customizations.
  878. if (!is_array($language_list) || empty($language_list)) {
  879. $language_list = array('english' => 'English');
  880. }
  881. // Sorting again, if it is necessary.
  882. //asort($language_list);
  883. // More sanity checks.
  884. if (!array_key_exists($default_language, $language_list)) {
  885. if (array_key_exists('english', $language_list)) {
  886. $default_language = 'english';
  887. } else {
  888. $language_keys = array_keys($language_list);
  889. $default_language = $language_keys[0];
  890. }
  891. }
  892. // Displaying the box.
  893. echo "\t\t<select name=\"$name\">\n";
  894. foreach ($language_list as $key => $value) {
  895. if ($key == $default_language) {
  896. $option_end = ' selected="selected">';
  897. } else {
  898. $option_end = '>';
  899. }
  900. echo "\t\t\t<option value=\"$key\"$option_end";
  901. echo $value;
  902. echo "</option>\n";
  903. }
  904. echo "\t\t</select>\n";
  905. }
  906. /**
  907. * This function displays a language dropdown box so that the installatioin
  908. * can be done in the language of the user
  909. */
  910. function display_language_selection() { ?>
  911. <h2><?php get_lang('WelcomeToTheDokeosInstaller'); ?></h2>
  912. <div class="RequirementHeading">
  913. <h2><?php echo display_step_sequence(); ?><?php echo get_lang('InstallationLanguage'); ?></h2>
  914. <p><?php echo get_lang('PleaseSelectInstallationProcessLanguage'); ?>:</p>
  915. <form id="lang_form" method="post" action="<?php echo api_get_self(); ?>">
  916. <?php display_language_selection_box('language_list', api_get_interface_language()); ?>
  917. <button type="submit" name="step1" class="next" value="<?php get_lang('Next'); ?> &gt;"><?php echo get_lang('Next'); ?></button>
  918. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  919. </form>
  920. </div>
  921. <?php
  922. }
  923. /**
  924. * This function displays the requirements for installing Chamilo.
  925. *
  926. * @param string $installType
  927. * @param boolean $badUpdatePath
  928. * @param string The updatePath given (if given)
  929. * @param array $update_from_version_8 The different subversions from version 1.8
  930. * @param array $update_from_version_6 The different subversions from version 1.6
  931. *
  932. * @author unknow
  933. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  934. */
  935. function display_requirements($installType, $badUpdatePath, $updatePath = '', $update_from_version_8 = array(), $update_from_version_6 = array()) {
  936. echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('Requirements')."</h2></div>";
  937. echo '<div class="RequirementText">';
  938. echo '<strong>'.get_lang('ReadThoroughly').'</strong><br />';
  939. echo get_lang('MoreDetails').' <a href="../../documentation/installation_guide.html" target="_blank">'.get_lang('ReadTheInstallGuide').'</a>.<br />'."\n";
  940. if ($installType == 'update') {
  941. echo get_lang('IfYouPlanToUpgradeFromOlderVersionYouMightWantToHaveAlookAtTheChangelog').'<br />'."\n";
  942. }
  943. echo '</div>';
  944. // SERVER REQUIREMENTS
  945. echo '<div class="RequirementHeading"><h2>'.get_lang('ServerRequirements').'</h2>';
  946. echo '<div class="RequirementText">'.get_lang('ServerRequirementsInfo').'</div>';
  947. echo '<div class="RequirementContent">';
  948. echo '<table class="requirements">
  949. <tr>
  950. <td class="requirements-item">'.get_lang('PHPVersion').'>= 5.0</td>
  951. <td class="requirements-value">';
  952. if (phpversion() < '5.0') {
  953. echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>';
  954. } else {
  955. echo '<strong><font color="green">'.get_lang('PHPVersionOK'). ' '.phpversion().'</font></strong>';
  956. }
  957. echo ' </td>
  958. </tr>
  959. <tr>
  960. <td class="requirements-item"><a href="http://php.net/manual/en/book.session.php" target="_blank">Session</a> '.get_lang('support').'</td>
  961. <td class="requirements-value">'.check_extension('session', get_lang('Yes'), get_lang('ExtensionSessionsNotAvailable')).'</td>
  962. </tr>
  963. <tr>
  964. <td class="requirements-item"><a href="http://php.net/manual/en/book.mysql.php" target="_blank">MySQL</a> '.get_lang('support').'</td>
  965. <td class="requirements-value">'.check_extension('mysql', get_lang('Yes'), get_lang('ExtensionMySQLNotAvailable')).'</td>
  966. </tr>
  967. <tr>
  968. <td class="requirements-item"><a href="http://php.net/manual/en/book.zlib.php" target="_blank">Zlib</a> '.get_lang('support').'</td>
  969. <td class="requirements-value">'.check_extension('zlib', get_lang('Yes'), get_lang('ExtensionZlibNotAvailable')).'</td>
  970. </tr>
  971. <tr>
  972. <td class="requirements-item"><a href="http://php.net/manual/en/book.pcre.php" target="_blank">Perl-compatible regular expressions</a> '.get_lang('support').'</td>
  973. <td class="requirements-value">'.check_extension('pcre', get_lang('Yes'), get_lang('ExtensionPCRENotAvailable')).'</td>
  974. </tr>
  975. <tr>
  976. <td class="requirements-item"><a href="http://php.net/manual/en/book.xml.php" target="_blank">XML</a> '.get_lang('support').'</td>
  977. <td class="requirements-value">'.check_extension('xml', get_lang('Yes'), get_lang('No')).'</td>
  978. </tr>
  979. <tr>
  980. <td class="requirements-item"><a href="http://php.net/manual/en/book.mbstring.php" target="_blank">Multibyte string</a> '.get_lang('support').' ('.get_lang('Optional').')</td>
  981. <td class="requirements-value">'.check_extension('mbstring', get_lang('Yes'), get_lang('ExtensionMBStringNotAvailable'), true).'</td>
  982. </tr>
  983. <tr>
  984. <td class="requirements-item"><a href="http://php.net/manual/en/book.iconv.php" target="_blank">Iconv</a> '.get_lang('support').' ('.get_lang('Optional').')</td>
  985. <td class="requirements-value">'.check_extension('iconv', get_lang('Yes'), get_lang('No'), true).'</td>
  986. </tr>
  987. <tr>
  988. <td class="requirements-item"><a href="http://php.net/manual/en/book.intl.php" target="_blank">Internationalization</a> '.get_lang('support').' ('.get_lang('Optional').')</td>
  989. <td class="requirements-value">'.check_extension('intl', get_lang('Yes'), get_lang('No'), true).'</td>
  990. </tr>
  991. <tr>
  992. <td class="requirements-item"><a href="http://php.net/manual/en/book.image.php" target="_blank">GD</a> '.get_lang('support').'</td>
  993. <td class="requirements-value">'.check_extension('gd', get_lang('Yes'), get_lang('ExtensionGDNotAvailable')).'</td>
  994. </tr>
  995. <tr>
  996. <td class="requirements-item"><a href="http://php.net/manual/en/book.json.php" target="_blank">JSON</a> '.get_lang('support').'</td>
  997. <td class="requirements-value">'.check_extension('json', get_lang('Yes'), get_lang('No')).'</td>
  998. </tr>
  999. <tr>
  1000. <td class="requirements-item"><a href="http://php.net/manual/en/book.ldap.php" target="_blank">LDAP</a> '.get_lang('support').' ('.get_lang('Optional').')</td>
  1001. <td class="requirements-value">'.check_extension('ldap', get_lang('Yes'), get_lang('ExtensionLDAPNotAvailable'), true).'</td>
  1002. </tr>
  1003. <tr>
  1004. <td class="requirements-item"><a href="http://xapian.org/" target="_blank">Xapian</a> '.get_lang('support').' ('.get_lang('Optional').')</td>
  1005. <td class="requirements-value">'.check_extension('xapian', get_lang('Yes'), get_lang('No'), true).'</td>
  1006. </tr>
  1007. </table>';
  1008. echo ' </div>';
  1009. echo '</div>';
  1010. // RECOMMENDED SETTINGS
  1011. // Note: these are the settings for Joomla, does this also apply for Chamilo?
  1012. // Note: also add upload_max_filesize here so that large uploads are possible
  1013. echo '<div class="RequirementHeading"><h2>'.get_lang('RecommendedSettings').'</h2>';
  1014. echo '<div class="RequirementText">'.get_lang('RecommendedSettingsInfo').'</div>';
  1015. echo '<div class="RequirementContent">';
  1016. echo '<table class="requirements">
  1017. <tr>
  1018. <th>'.get_lang('Setting').'</th>
  1019. <th>'.get_lang('Recommended').'</th>
  1020. <th>'.get_lang('Actual').'</th>
  1021. </tr>
  1022. <tr>
  1023. <td class="requirements-item"><a href="http://php.net/manual/features.safe-mode.php">Safe Mode</a></td>
  1024. <td class="requirements-recommended">OFF</td>
  1025. <td class="requirements-value">'.check_php_setting('safe_mode','OFF').'</td>
  1026. </tr>
  1027. <tr>
  1028. <td class="requirements-item"><a href="http://php.net/manual/ref.errorfunc.php#ini.display-errors">Display Errors</a></td>
  1029. <td class="requirements-recommended">OFF</td>
  1030. <td class="requirements-value">'.check_php_setting('display_errors','OFF').'</td>
  1031. </tr>
  1032. <tr>
  1033. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.file-uploads">File Uploads</a></td>
  1034. <td class="requirements-recommended">ON</td>
  1035. <td class="requirements-value">'.check_php_setting('file_uploads','ON').'</td>
  1036. </tr>
  1037. <tr>
  1038. <td class="requirements-item"><a href="http://php.net/manual/ref.info.php#ini.magic-quotes-gpc">Magic Quotes GPC</a></td>
  1039. <td class="requirements-recommended">OFF</td>
  1040. <td class="requirements-value">'.check_php_setting('magic_quotes_gpc','OFF').'</td>
  1041. </tr>
  1042. <tr>
  1043. <td class="requirements-item"><a href="http://php.net/manual/ref.info.php#ini.magic-quotes-runtime">Magic Quotes Runtime</a></td>
  1044. <td class="requirements-recommended">OFF</td>
  1045. <td class="requirements-value">'.check_php_setting('magic_quotes_runtime','OFF').'</td>
  1046. </tr>
  1047. <tr>
  1048. <td class="requirements-item"><a href="http://php.net/manual/security.globals.php">Register Globals</a></td>
  1049. <td class="requirements-recommended">OFF</td>
  1050. <td class="requirements-value">'.check_php_setting('register_globals','OFF').'</td>
  1051. </tr>
  1052. <tr>
  1053. <td class="requirements-item"><a href="http://php.net/manual/ref.session.php#ini.session.auto-start">Session auto start</a></td>
  1054. <td class="requirements-recommended">OFF</td>
  1055. <td class="requirements-value">'.check_php_setting('session.auto_start','OFF').'</td>
  1056. </tr>
  1057. <tr>
  1058. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.short-open-tag">Short Open Tag</a></td>
  1059. <td class="requirements-recommended">OFF</td>
  1060. <td class="requirements-value">'.check_php_setting('short_open_tag','OFF').'</td>
  1061. </tr>
  1062. <tr>
  1063. <td class="requirements-item"><a href="http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-httponly">Cookie HTTP Only</a></td>
  1064. <td class="requirements-recommended">ON</td>
  1065. <td class="requirements-value">'.check_php_setting('session.cookie_httponly','ON').'</td>
  1066. </tr>
  1067. <tr>
  1068. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.upload-max-filesize">Maximum upload file size</a></td>
  1069. <td class="requirements-recommended">10M-100M</td>
  1070. <td class="requirements-value">'.ini_get('upload_max_filesize').'</td>
  1071. </tr>
  1072. <tr>
  1073. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.post-max-size">Maximum post size</a></td>
  1074. <td class="requirements-recommended">10M-100M</td>
  1075. <td class="requirements-value">'.ini_get('post_max_size').'</td>
  1076. </tr>
  1077. </table>';
  1078. echo ' </div>';
  1079. echo '</div>';
  1080. // DIRECTORY AND FILE PERMISSIONS
  1081. echo '<div class="RequirementHeading"><h2>'.get_lang('DirectoryAndFilePermissions').'</h2>';
  1082. echo '<div class="RequirementText">'.get_lang('DirectoryAndFilePermissionsInfo').'</div>';
  1083. echo '<div class="RequirementContent">';
  1084. echo '<table class="requirements">
  1085. <tr>
  1086. <td class="requirements-item">chamilo/main/inc/conf/</td>
  1087. <td class="requirements-value">'.check_writable('inc/conf/').'</td>
  1088. </tr>
  1089. <tr>
  1090. <td class="requirements-item">chamilo/main/upload/users/</td>
  1091. <td class="requirements-value">'.check_writable('upload/users/').'</td>
  1092. </tr>
  1093. <tr>
  1094. <td class="requirements-item">chamilo/main/default_course_document/images/</td>
  1095. <td class="requirements-value">'.check_writable('default_course_document/images/').'</td>
  1096. </tr>
  1097. <tr>
  1098. <td class="requirements-item">chamilo/archive/</td>
  1099. <td class="requirements-value">'.check_writable('../archive/').'</td>
  1100. </tr>
  1101. <tr>
  1102. <td class="requirements-item">chamilo/courses/</td>
  1103. <td class="requirements-value">'.check_writable('../courses/').'</td>
  1104. </tr>
  1105. <tr>
  1106. <td class="requirements-item">chamilo/home/</td>
  1107. <td class="requirements-value">'.check_writable('../home/').'</td>
  1108. </tr>
  1109. <tr>
  1110. <td class="requirements-item">chamilo/main/css/</td>
  1111. <td class="requirements-value">'.check_writable('css/', true).' ('.get_lang('SuggestionOnlyToEnableCSSUploadFeature').')</td>
  1112. </tr>
  1113. <tr>
  1114. <td class="requirements-item">chamilo/main/lang/</td>
  1115. <td class="requirements-value">'.check_writable('lang/', true).' ('.get_lang('SuggestionOnlyToEnableSubLanguageFeature').')</td>
  1116. </tr>'.
  1117. //'<tr>
  1118. // <td class="requirements-item">chamilo/searchdb/</td>
  1119. // <td class="requirements-value">'.check_writable('../searchdb/').'</td>
  1120. //</tr>'.
  1121. //'<tr>
  1122. // <td class="requirements-item">'.session_save_path().'</td>
  1123. // <td class="requirements-value">'.(is_writable(session_save_path())
  1124. // ? '<strong><font color="green">'.get_lang('Writable').'</font></strong>'
  1125. // : '<strong><font color="red">'.get_lang('NotWritable').'</font></strong>').'</td>
  1126. //</tr>'.
  1127. '';
  1128. echo ' </table>';
  1129. echo ' </div>';
  1130. echo '</div>';
  1131. if ($installType == 'update' && (empty($updatePath) || $badUpdatePath)) {
  1132. if ($badUpdatePath) { ?>
  1133. <div style="color:red; background-color:white; font-weight:bold; text-align:center;">
  1134. <?php echo get_lang('Error'); ?>!<br />
  1135. Chamilo <?php echo (isset($_POST['step2_update_6']) ? implode('|', $update_from_version_6) : implode('|', $update_from_version_8)).' '.get_lang('HasNotBeenFoundInThatDir'); ?>.
  1136. </div>
  1137. <?php }
  1138. else {
  1139. echo '<br />';
  1140. }
  1141. ?>
  1142. <table border="0" cellpadding="5" align="center">
  1143. <tr>
  1144. <td><?php echo get_lang('OldVersionRootPath'); ?>:</td>
  1145. <td><input type="text" name="updatePath" size="50" value="<?php echo ($badUpdatePath && !empty($updatePath)) ? htmlentities($updatePath) : api_get_path(SYS_SERVER_ROOT_PATH).'old_version/'; ?>" /></td>
  1146. </tr>
  1147. <tr>
  1148. <td colspan="2" align="center">
  1149. <button type="submit" class="back" name="step1" value="&lt; <?php echo get_lang('Back'); ?>" ><?php echo get_lang('Back'); ?></button>
  1150. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  1151. <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>
  1152. </td>
  1153. </tr>
  1154. </table>
  1155. <?php
  1156. } else {
  1157. $error = false;
  1158. // First, attempt to set writing permissions if we don't have them yet
  1159. $perm = api_get_permissions_for_new_directories();
  1160. $perm_file = api_get_permissions_for_new_files();
  1161. $notwritable = array();
  1162. $curdir = getcwd();
  1163. $checked_writable = api_get_path(CONFIGURATION_PATH);
  1164. if (!is_writable($checked_writable)) {
  1165. $notwritable[] = $checked_writable;
  1166. @chmod($checked_writable, $perm);
  1167. }
  1168. $checked_writable = api_get_path(SYS_CODE_PATH).'upload/users/';
  1169. if (!is_writable($checked_writable)) {
  1170. $notwritable[] = $checked_writable;
  1171. @chmod($checked_writable, $perm);
  1172. }
  1173. $checked_writable = api_get_path(SYS_CODE_PATH).'default_course_document/images/';
  1174. if (!is_writable($checked_writable)) {
  1175. $notwritable[] = $checked_writable;
  1176. @chmod($checked_writable, $perm);
  1177. }
  1178. $checked_writable = api_get_path(SYS_ARCHIVE_PATH);
  1179. if (!is_writable($checked_writable)) {
  1180. $notwritable[] = $checked_writable;
  1181. @chmod($checked_writable, $perm);
  1182. }
  1183. $checked_writable = api_get_path(SYS_COURSE_PATH);
  1184. if (!is_writable($checked_writable)) {
  1185. $notwritable[] = $checked_writable;
  1186. @chmod($checked_writable, $perm);
  1187. }
  1188. $checked_writable = api_get_path(SYS_PATH).'home/';
  1189. if (!is_writable($checked_writable)) {
  1190. $notwritable[] = realpath($checked_writable);
  1191. @chmod($checked_writable, $perm);
  1192. }
  1193. $checked_writable = api_get_path(CONFIGURATION_PATH).'configuration.php';
  1194. if (file_exists($checked_writable) && !is_writable($checked_writable)) {
  1195. $notwritable[] = $checked_writable;
  1196. @chmod($checked_writable, $perm_file);
  1197. }
  1198. // Second, if this fails, report an error
  1199. //--> The user would have to adjust the permissions manually
  1200. if (count($notwritable) > 0) {
  1201. $error = true;
  1202. echo '<div style="color:red; background-color:white; font-weight:bold; text-align:center;">';
  1203. echo get_lang('Warning').':<br />';
  1204. printf(get_lang('NoWritePermissionPleaseReadInstallGuide'), '</font><a href="../../documentation/installation_guide.html" target="blank">', '</a> <font color="red">');
  1205. echo '<ul>';
  1206. foreach ($notwritable as $value) {
  1207. echo '<li>'.$value.'</li>';
  1208. }
  1209. echo '</ul>';
  1210. echo '</div>';
  1211. }
  1212. // Check wether a Chamilo configuration file already exists.
  1213. elseif (file_exists(api_get_path(CONFIGURATION_PATH).'configuration.php')) {
  1214. echo '<div style="color:red; background-color:white; font-weight:bold; text-align:center;">';
  1215. echo get_lang('WarningExistingDokeosInstallationDetected');
  1216. echo '</div>';
  1217. }
  1218. // And now display the choice buttons (go back or install)
  1219. ?>
  1220. <p align="center">
  1221. <button type="submit" name="step1" class="back" onclick="javascript: window.location='index.php'; return false;" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button>
  1222. <button type="submit" name="step2_install" class="add" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) echo 'disabled="disabled"'; ?> ><?php echo get_lang('NewInstallation'); ?></button>
  1223. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  1224. <?php
  1225. // Real code
  1226. echo '<button type="submit" class="save" name="step2_update_8" value="Upgrade from Dokeos 1.8.x"';
  1227. if ($error) echo ' disabled="disabled"';
  1228. // Temporary code for alpha version, disabling upgrade
  1229. //echo '<input type="submit" name="step2_update" value="Upgrading is not possible in this beta version"';
  1230. //echo ' disabled="disabled"';
  1231. //end temp code
  1232. echo ' >'.get_lang('UpgradeFromDokeos18x').'</button>';
  1233. echo '<button type="submit" class="save" name="step2_update_6" value="Upgrade from Dokeos 1.6.x"';
  1234. if ($error) echo ' disabled="disabled"';
  1235. echo ' >'.get_lang('UpgradeFromDokeos16x').'</button>';
  1236. echo '</p>';
  1237. }
  1238. }
  1239. /**
  1240. * Displays the license (GNU GPL) as step 2, with
  1241. * - an "I accept" button named step3 to proceed to step 3;
  1242. * - a "Back" button named step1 to go back to the first step.
  1243. */
  1244. function display_license_agreement() {
  1245. echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('Licence').'</h2>';
  1246. echo '<p>'.get_lang('DokeosLicenseInfo').'</p>';
  1247. echo '<p><a href="../../documentation/license.html" target="_blank">'.get_lang('PrintVers').'</a></p>';
  1248. echo '</div>';
  1249. ?>
  1250. <table>
  1251. <tr><td>
  1252. <p style="font-size:75%"><textarea cols="80" rows="10" readonly><?php echo api_htmlentities(@file_get_contents(api_get_path(SYS_PATH).'documentation/license.txt')); ?></textarea></p>
  1253. </td>
  1254. </tr>
  1255. <tr><td>
  1256. <input type="checkbox" name="accept" id="accept_licence" value="1">
  1257. <label for="accept_licence"><?php echo get_lang('IAccept'); ?></label>
  1258. </td></tr>
  1259. <tr><td><p><?php echo get_lang('DokeosArtLicense'); ?></p></td></tr>
  1260. <tr>
  1261. <td>
  1262. <table width="100%">
  1263. <tr>
  1264. <td></td>
  1265. <td align="center">
  1266. <button type="submit" class="back" name="step1" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button>
  1267. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  1268. <button type="submit" class="next" name="step3" onclick="javascript: if(!document.getElementById('accept_licence').checked) { alert('<?php echo get_lang('YouMustAcceptLicence')?>');return false;}" value="<?php echo get_lang('Next'); ?> &gt;" ><?php echo get_lang('Next'); ?></button>
  1269. </td>
  1270. </tr>
  1271. </table>
  1272. </td>
  1273. </tr>
  1274. </table>
  1275. <!-- Contact information form -->
  1276. <div>
  1277. <div class="formw">
  1278. <a href="javascript://" class = "advanced_parameters" >
  1279. <span id="img_plus_and_minus">&nbsp;<img src="<?php echo api_get_path(WEB_IMG_PATH) ?>div_hide.gif" alt="<?php echo get_lang('Hide') ?>" title="<?php echo get_lang('Hide')?>" style ="vertical-align:middle" >&nbsp;<?php echo get_lang('ContactInformation') ?></span>
  1280. </a>
  1281. </div>
  1282. </div>
  1283. <div id="id_contact_form" style="display:block">
  1284. <div class="normal-message"><?php echo get_lang('ContactInformationDescription') ?></div>
  1285. <p><?php echo get_contact_registration_form() ?></p><br />
  1286. </div>
  1287. <?php
  1288. }
  1289. /**
  1290. * Get contact registration form
  1291. */
  1292. function get_contact_registration_form() {
  1293. $html ='
  1294. <div id="contact_registration">
  1295. <fieldset style="width:95%;padding:15px;border:1pt solid #eee">
  1296. <div id="div_sent_information"></div>
  1297. <form>
  1298. <div class="row">
  1299. <div class="label"><span class="form_required">*</span>'.get_lang('Name').'</div>
  1300. <div class="formw"><input id="person_name" type="text" name="person_name" size="30" /></div>
  1301. </div>
  1302. <div class="row">
  1303. <div class="label"><span class="form_required">*</span>'.get_lang('Email').'</div>
  1304. <div class="formw"><input id="person_name" type="text" name="person_email" size="30" /></div>
  1305. </div>
  1306. <div class="row">
  1307. <div class="label"><span class="form_required">*</span>'.get_lang('CompanyName').'</div>
  1308. <div class="formw"><input id="company_name" type="text" name="company_name" size="30" /></div>
  1309. </div>
  1310. <div class="row">
  1311. <div class="label"><span class="form_required">*</span>'.get_lang('CompanyActivity').'</div>
  1312. <div class="formw">
  1313. <select name="company_activity" id="company_activity" >
  1314. <option value="">--- '.get_lang('SelectOne').' ---</option>
  1315. <Option value="Advertising/Marketing/PR">Advertising/Marketing/PR</Option><Option value="Agriculture/Forestry">Agriculture/Forestry</Option>
  1316. <Option value="Architecture">Architecture</Option><Option value="Banking/Finance">Banking/Finance</Option>
  1317. <Option value="Biotech/Pharmaceuticals">Biotech/Pharmaceuticals</Option><Option value="Business Equipment">Business Equipment</Option>
  1318. <Option value="Business Services">Business Services</Option><Option value="Construction">Construction</Option>
  1319. <Option value="Consulting/Research">Consulting/Research</Option><Option value="Education">Education</Option>
  1320. <Option value="Engineering">Engineering</Option><Option value="Environmental">Environmental</Option>
  1321. <Option value="Government">Government</Option><Option value="Healthcare">Health Care</Option>
  1322. <Option value="Hospitality/Lodging/Travel">Hospitality/Lodging/Travel</Option><Option value="Insurance">Insurance</Option>
  1323. <Option value="Legal">Legal</Option><Option value="Manufacturing">Manufacturing</Option>
  1324. <Option value="Media/Entertainment">Media/Entertainment</Option><Option value="Mortgage">Mortgage</Option>
  1325. <Option value="Non-Profit">Non-Profit</Option><Option value="Real Estate">Real Estate</Option>
  1326. <Option value="Restaurant">Restaurant</Option><Option value="Retail">Retail</Option>
  1327. <Option value="Shipping/Transportation">Shipping/Transportation</Option>
  1328. <Option value="Technology">Technology</Option><Option value="Telecommunications">Telecommunications</Option>
  1329. <Option value="Other">Other</Option>
  1330. </Select>
  1331. </div>
  1332. </div>
  1333. <div class="row">
  1334. <div class="label"><span class="form_required">*</span>'.get_lang('PersonRole').'</div>
  1335. <div class="formw">
  1336. <Select name="person_role" id="person_role" >
  1337. <option value="">--- '.get_lang('SelectOne').' ---</option>
  1338. <Option value="Administration">Administration</Option><Option value="CEO/President/ Owner">CEO/President/ Owner</Option>
  1339. <Option value="CFO">CFO</Option><Option value="CIO/CTO">CIO/CTO</Option>
  1340. <Option value="Consultant">Consultant</Option><Option value="Customer Service">Customer Service</Option>
  1341. <Option value="Engineer/Programmer">Engineer/Programmer</Option><Option value="Facilities/Operations">Facilities/Operations</Option>
  1342. <Option value="Finance/ Accounting Manager">Finance/ Accounting Manager</Option><Option value="Finance/ Accounting Staff">Finance/ Accounting Staff</Option>
  1343. <Option value="General Manager">General Manager</Option><Option value="Human Resources">Human Resources</Option>
  1344. <Option value="IS/IT Management">IS/IT Management</Option><Option value="IS/ IT Staff">IS/ IT Staff</Option>
  1345. <Option value="Marketing Manager">Marketing Manager</Option><Option value="Marketing Staff">Marketing Staff</Option>
  1346. <Option value="Partner/Principal">Partner/Principal</Option><Option value="Purchasing Manager">Purchasing Manager</Option>
  1347. <Option value="Sales/ Business Dev. Manager">Sales/ Business Dev. Manager</Option><Option value="Sales/ Business Dev.">Sales/ Business Dev.</Option>
  1348. <Option value="Vice President/Senior Manager">Vice President/Senior Manager</Option><Option value="Other">Other</Option>
  1349. </Select>
  1350. </div>
  1351. </div>
  1352. <div class="row">
  1353. <div class="label">'.get_lang('HaveYouThePowerToTakeFinancialDecisions').'</div>
  1354. <div class="formw">
  1355. <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked>'.get_lang('Yes').'
  1356. <input type="radio" name="financial_decision" id="financial_decision2" value="0">'.get_lang('No').'
  1357. </div>
  1358. </div>
  1359. <div class="row">
  1360. <div class="label"><span class="form_required">*</span>'.get_lang('CompanyCountry').'</div>
  1361. <div class="formw">
  1362. '.get_countries_list_from_array(true).'
  1363. </div>
  1364. </div>
  1365. <div class="row">
  1366. <div class="label">'.get_lang('CompanyCity').'</div>
  1367. <div class="formw">
  1368. <input type="text" id="company_city" name="company_city" size="30" />
  1369. </div>
  1370. </div>
  1371. <div class="row">
  1372. <div class="label">'.get_lang('WhichLanguageWouldYouLikeToUseWhenContactingYou').'</div>
  1373. <div class="formw">
  1374. <select id="language" name="language">
  1375. <option value="bulgarian">??????????????????</option>
  1376. <option value="indonesian">Bahasa Indonesia</option>
  1377. <option value="bosnian">Bosanski</option>
  1378. <option value="german">Deutsch</option>
  1379. <option selected="selected" value="english">English</option>
  1380. <option value="spanish">Spanish</option>
  1381. <option value="french">Fran??ais</option>
  1382. <option value="italian">Italian</option>
  1383. <option value="hungarian">Magyar</option>
  1384. <option value="dutch">Nederlands</option>
  1385. <option value="brazilian">Portugu??s do Brasil</option>
  1386. <option value="portuguese">Portugu??s europeu</option>
  1387. <option value="slovenian">Sloven????ina</option>
  1388. </select>
  1389. </div>
  1390. </div>
  1391. <div class="row">
  1392. <div class="label">&nbsp;</div>
  1393. <div class="formw"><button type="button" class="save" onclick="javascript:send_contact_information();" value="'.get_lang('SendInformation').'" >'.get_lang('SendInformation').'</button></div>
  1394. </div>
  1395. <div class="row">
  1396. <div class="label">&nbsp;</div>
  1397. <div class="formw"><span class="form_required">*</span><small>'.get_lang('FieldRequired').'</small></div>
  1398. </div>
  1399. </form>
  1400. </fieldset>
  1401. </div>
  1402. ';
  1403. return $html;
  1404. }
  1405. /**
  1406. * Displays a parameter in a table row.
  1407. * Used by the display_database_settings_form function.
  1408. * @param string Type of install
  1409. * @param string Name of parameter
  1410. * @param string Field name (in the HTML form)
  1411. * @param string Field value
  1412. * @param string Extra notice (to show on the right side)
  1413. * @param boolean Whether to display in update mode
  1414. * @param string Additional attribute for the <tr> element
  1415. * @return void Direct output
  1416. */
  1417. function display_database_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $extra_notice, $display_when_update = true, $tr_attribute = '') {
  1418. echo "<tr ".$tr_attribute.">\n";
  1419. echo "<td>$parameter_name&nbsp;&nbsp;</td>\n";
  1420. if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update) {
  1421. echo '<td><input type="hidden" name="'.$form_field_name.'" id="'.$form_field_name.'" value="'.api_htmlentities($parameter_value).'" />'.$parameter_value."</td>\n";
  1422. } else {
  1423. $inputtype = $form_field_name == 'dbPassForm' ? 'password' : 'text';
  1424. //Slightly limit the length of the database prefix to avoid having to cut down the databases names later on
  1425. $maxlength = $form_field_name == 'dbPrefixForm' ? '15' : MAX_FORM_FIELD_LENGTH;
  1426. if ($install_type == INSTALL_TYPE_UPDATE) {
  1427. echo '<input type="hidden" name="'.$form_field_name.'" id="'.$form_field_name.'" value="'.api_htmlentities($parameter_value).'" />';
  1428. echo '<td>'.api_htmlentities($parameter_value)."</td>";
  1429. //echo "<td>$extra_notice</td>\n";
  1430. } else {
  1431. echo '<td><input type="'.$inputtype.'" size="'.DATABASE_FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.$maxlength.'" name="'.$form_field_name.'" id="'.$form_field_name.'" value="'.api_htmlentities($parameter_value).'" />'."</td>\n";
  1432. echo "<td>$extra_notice</td>\n";
  1433. }
  1434. }
  1435. echo "</tr>\n";
  1436. }
  1437. /**
  1438. * Displays step 3 - a form where the user can enter the installation settings
  1439. * regarding the databases - login and password, names, prefixes, single
  1440. * or multiple databases, tracking or not...
  1441. */
  1442. function display_database_settings_form($installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbPrefixForm, $enableTrackingForm, $singleDbForm, $dbNameForm, $dbStatsForm, $dbScormForm, $dbUserForm) {
  1443. if ($installType == 'update') {
  1444. global $_configuration, $update_from_version_6;
  1445. if (in_array($_POST['old_version'], $update_from_version_6)) {
  1446. $dbHostForm = get_config_param('dbHost');
  1447. $dbUsernameForm = get_config_param('dbLogin');
  1448. $dbPassForm = get_config_param('dbPass');
  1449. $dbPrefixForm = get_config_param('dbNamePrefix');
  1450. $enableTrackingForm = get_config_param('is_trackingEnabled');
  1451. $singleDbForm = get_config_param('singleDbEnabled');
  1452. $dbNameForm = get_config_param('mainDbName');
  1453. $dbStatsForm = get_config_param('statsDbName');
  1454. $dbScormForm = get_config_param('scormDbName');
  1455. $dbUserForm = get_config_param('user_personal_database');
  1456. $dbScormExists = true;
  1457. } else {
  1458. $dbHostForm = $_configuration['db_host'];
  1459. $dbUsernameForm = $_configuration['db_user'];
  1460. $dbPassForm = $_configuration['db_password'];
  1461. $dbPrefixForm = $_configuration['db_prefix'];
  1462. $enableTrackingForm = $_configuration['tracking_enabled'];
  1463. $singleDbForm = $_configuration['single_database'];
  1464. $dbNameForm = $_configuration['main_database'];
  1465. $dbStatsForm = $_configuration['statistics_database'];
  1466. $dbScormForm = $_configuration['scorm_database'];
  1467. $dbUserForm = $_configuration['user_personal_database'];
  1468. $dbScormExists = true;
  1469. }
  1470. if (empty($dbScormForm)) {
  1471. if ($singleDbForm) {
  1472. $dbScormForm = $dbNameForm;
  1473. } else {
  1474. $dbScormForm = $dbPrefixForm.'scorm';
  1475. $dbScormExists = false;
  1476. }
  1477. }
  1478. if (empty($dbUserForm)) {
  1479. $dbUserForm = $singleDbForm ? $dbNameForm : $dbPrefixForm.'chamilo_user';
  1480. }
  1481. echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>';
  1482. echo '<div class="RequirementContent">';
  1483. echo get_lang('DBSettingUpgradeIntro');
  1484. echo '</div>';
  1485. } else {
  1486. if (empty($dbPrefixForm)) { //make sure there is a default value for db prefix
  1487. //$dbPrefixForm = 'chamilo_';
  1488. }
  1489. echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2>';
  1490. echo '</div>';
  1491. echo '<div class="RequirementContent">';
  1492. echo get_lang('DBSettingIntro');
  1493. echo '</div>';
  1494. }
  1495. ?>
  1496. </td>
  1497. </tr>
  1498. <tr>
  1499. <td>
  1500. <table width="100%">
  1501. <tr>
  1502. <td width="40%"><?php echo get_lang('DBHost'); ?> </td>
  1503. <?php if ($installType == 'update'): ?>
  1504. <td width="30%"><input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?></td>
  1505. <td width="30%">&nbsp;</td>
  1506. <?php else: ?>
  1507. <td width="30%"><input type="text" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /></td>
  1508. <td width="30%"><?php echo get_lang('EG').' localhost'; ?></td>
  1509. <?php endif; ?>
  1510. </tr>
  1511. <?php
  1512. //database user username
  1513. $example_login = get_lang('EG').' root';
  1514. display_database_parameter($installType, get_lang('DBLogin'), 'dbUsernameForm', $dbUsernameForm, $example_login);
  1515. //database user password
  1516. $example_password = get_lang('EG').' '.api_generate_password();
  1517. display_database_parameter($installType, get_lang('DBPassword'), 'dbPassForm', $dbPassForm, $example_password);
  1518. //database prefix
  1519. display_database_parameter($installType, get_lang('DbPrefixForm'), 'dbPrefixForm', $dbPrefixForm, get_lang('DbPrefixCom'));
  1520. //fields for the four standard Chamilo databases
  1521. if ($installType != INSTALL_TYPE_UPDATE) {
  1522. echo '<tr><td colspan="3">';
  1523. echo '<a href="" onclick="javascript: show_hide_option();return false;" id="optionalparameters"><img style="vertical-align:middle;" src="../img/div_show.gif" alt="show-hide" /> '.get_lang('OptionalParameters', '').'</a>';
  1524. echo '</td></tr>';
  1525. }
  1526. ?>
  1527. <input type="hidden" name="enableTrackingForm" value="1" />
  1528. <tr id="optional_param6" style="display:none;">
  1529. <td><?php echo get_lang('SingleDb'); ?> </td>
  1530. <?php if ($installType == INSTALL_TYPE_UPDATE): ?>
  1531. <td><input type="hidden" name="singleDbForm" value="<?php echo $singleDbForm; ?>" /><?php echo $singleDbForm ? get_lang('One') : get_lang('Several'); ?></td>
  1532. <?php else: ?>
  1533. <td>
  1534. <input class="checkbox" type="radio" name="singleDbForm" value="1" id="singleDb1" <?php echo $singleDbForm ? 'checked="checked" ' : ''; ?> onclick="javascript: show_hide_tracking_and_user_db(this.id);" /> <label for="singleDb1"><?php echo get_lang('One'); ?></label>
  1535. <input class="checkbox" type="radio" name="singleDbForm" value="0" id="singleDb0" <?php echo $singleDbForm ? '' : 'checked="checked" '; ?> onclick="javascript: show_hide_tracking_and_user_db(this.id);" /> <label for="singleDb0"><?php echo get_lang('Several'); ?></label>
  1536. </td>
  1537. <?php endif; ?>
  1538. <td>&nbsp;</td>
  1539. </tr>
  1540. </div>
  1541. <?php
  1542. $style = 'style="display:none;"';
  1543. if ($installType == INSTALL_TYPE_UPDATE) {
  1544. $style = '';
  1545. }
  1546. display_database_parameter($installType, get_lang('MainDB'), 'dbNameForm', $dbNameForm, '&nbsp;', null, 'id="optional_param1" '.$style);
  1547. display_database_parameter($installType, get_lang('StatDB'), 'dbStatsForm', $dbStatsForm, '&nbsp;', null, 'id="optional_param2" '.$style);
  1548. if ($installType == INSTALL_TYPE_UPDATE && in_array($_POST['old_version'], $update_from_version_6)) {
  1549. display_database_parameter($installType, get_lang('ScormDB'), 'dbScormForm', $dbScormForm, '&nbsp;', null, 'id="optional_param3" '.$style);
  1550. }
  1551. display_database_parameter($installType, get_lang('UserDB'), 'dbUserForm', $dbUserForm, '&nbsp;', null, 'id="optional_param4" '.$style);
  1552. /* Tracking is always available see #2066
  1553. *
  1554. <tr id="optional_param5" style="display:none;">
  1555. <td><?php echo get_lang('EnableTracking'); ?> </td>
  1556. <?php if ($installType == 'update'): ?>
  1557. <td><input type="hidden" name="enableTrackingForm" value="<?php echo $enableTrackingForm; ?>" /><?php echo $enableTrackingForm ? get_lang('Yes') : get_lang('No'); ?></td>
  1558. <?php else: ?>
  1559. <td>
  1560. <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>
  1561. <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>
  1562. </td>
  1563. <?php endif; ?>
  1564. <td>&nbsp;</td>
  1565. </tr> */
  1566. ?>
  1567. <tr>
  1568. <td><button type="submit" class="login" name="step3" value="<?php echo get_lang('CheckDatabaseConnection'); ?>" ><?php echo get_lang('CheckDatabaseConnection'); ?></button></td>
  1569. <?php
  1570. $dbConnect = test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm, $dbNameForm);
  1571. if ($dbConnect == 1): ?>
  1572. <td colspan="2">
  1573. <div class="confirmation-message">
  1574. <!--<div style="float:left; margin-right:10px;">
  1575. <img src="../img/message_confirmation.png" alt="Confirmation" />
  1576. </div>-->
  1577. <!--<div style="float:left;">-->
  1578. Database host info: <strong><?php echo Database::get_host_info(); ?></strong><br />
  1579. Database server version: <strong><?php echo Database::get_server_info(); ?></strong><br />
  1580. Database client version: <strong><?php echo Database::get_client_info(); ?></strong><br />
  1581. Database protocol version: <strong><?php echo Database::get_proto_info(); ?></strong>
  1582. <!--</div>-->
  1583. <div style="clear:both;"></div>
  1584. </div>
  1585. </td>
  1586. <?php else: ?>
  1587. <td colspan="2">
  1588. <div style="float:left;" class="error-message">
  1589. <!--<div style="float:left; margin-right:10px;">
  1590. <img src="../img/message_error.png" alt="Error" />
  1591. </div>-->
  1592. <div style="float:left;">
  1593. <strong>Database error: <?php echo Database::errno(); ?></strong><br />
  1594. <?php echo Database::error().'<br />'; ?>
  1595. <strong><?php echo get_lang('Details').': '. get_lang('FailedConectionDatabase'); ?></strong><br />
  1596. </div>
  1597. </div>
  1598. </td>
  1599. <?php endif; ?>
  1600. </tr>
  1601. <tr>
  1602. <td><button type="submit" name="step2" class="back" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button></td>
  1603. <td>&nbsp;</td>
  1604. <td align="right"><input type="hidden" name="is_executable" id="is_executable" value="-" /><button type="submit" class="next" name="step4" value="<?php echo get_lang('Next'); ?> &gt;" /><?php echo get_lang('Next'); ?></button></td>
  1605. </tr>
  1606. </table>
  1607. <?php
  1608. }
  1609. /**
  1610. * Displays a parameter in a table row.
  1611. * Used by the display_configuration_settings_form function.
  1612. */
  1613. function display_configuration_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $display_when_update = 'true') {
  1614. echo "<tr>\n";
  1615. echo "<td>$parameter_name&nbsp;&nbsp;</td>\n";
  1616. if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update) {
  1617. echo '<td><input type="hidden" name="'.$form_field_name.'" value="'.api_htmlentities($parameter_value, ENT_QUOTES).'" />'.$parameter_value."</td>\n";
  1618. } else {
  1619. echo '<td><input type="text" size="'.FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.MAX_FORM_FIELD_LENGTH.'" name="'.$form_field_name.'" value="'.api_htmlentities($parameter_value, ENT_QUOTES).'" />'."</td>\n";
  1620. }
  1621. echo "</tr>\n";
  1622. }
  1623. /**
  1624. * Displays step 4 of the installation - configuration settings about Chamilo itself.
  1625. */
  1626. function display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $allowSelfRegProf, $loginForm, $passForm) {
  1627. if ($installType != 'update' && empty($languageForm)) {
  1628. $languageForm = $_SESSION['install_language'];
  1629. }
  1630. echo '<div class="RequirementHeading">';
  1631. echo "<h2>" . display_step_sequence() . get_lang("CfgSetting") . "</h2>";
  1632. echo '</div>';
  1633. echo '<div class="RequirementContent">';
  1634. echo '<p>'.get_lang('ConfigSettingsInfo').' <strong>main/inc/conf/configuration.php</strong></p>';
  1635. echo '</div>';
  1636. echo "</td></tr>\n<tr><td>";
  1637. echo "<table width=\"100%\">";
  1638. //First parameter: language
  1639. echo "<tr>\n";
  1640. echo '<td>'.get_lang('MainLang')."&nbsp;&nbsp;</td>\n";
  1641. if ($installType == 'update') {
  1642. echo '<td><input type="hidden" name="languageForm" value="'.api_htmlentities($languageForm, ENT_QUOTES).'" />'.$languageForm."</td>\n";
  1643. } else { // new installation
  1644. echo '<td>';
  1645. display_language_selection_box('languageForm', $languageForm);
  1646. echo "</td>\n";
  1647. }
  1648. echo "</tr>\n";
  1649. //Second parameter: Chamilo URL
  1650. echo "<tr>\n";
  1651. echo '<td>'.get_lang('ChamiloURL').' (<font color="red">'.get_lang('ThisFieldIsRequired')."</font>)&nbsp;&nbsp;</td>\n";
  1652. if ($installType == 'update') {
  1653. echo '<td>'.api_htmlentities($urlForm, ENT_QUOTES)."</td>\n";
  1654. } else {
  1655. echo '<td><input type="text" size="40" maxlength="100" name="urlForm" value="'.api_htmlentities($urlForm, ENT_QUOTES).'" />'."</td>\n";
  1656. }
  1657. echo "</tr>\n";
  1658. //Parameter 3: administrator's email
  1659. display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm);
  1660. //Parameters 4 and 5: administrator's names
  1661. if (api_is_western_name_order()) {
  1662. display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName);
  1663. display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName);
  1664. } else {
  1665. display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName);
  1666. display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName);
  1667. }
  1668. //Parameter 6: administrator's telephone
  1669. display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm);
  1670. //Parameter 7: administrator's login
  1671. display_configuration_parameter($installType, get_lang('AdminLogin'), 'loginForm', $loginForm, $installType == 'update');
  1672. //Parameter 8: administrator's password
  1673. if ($installType != 'update') {
  1674. display_configuration_parameter($installType, get_lang('AdminPass'), 'passForm', $passForm, false);
  1675. }
  1676. //Parameter 9: campus name
  1677. display_configuration_parameter($installType, get_lang('CampusName'), 'campusForm', $campusForm);
  1678. //Parameter 10: institute (short) name
  1679. display_configuration_parameter($installType, get_lang('InstituteShortName'), 'institutionForm', $institutionForm);
  1680. //Parameter 11: institute (short) name
  1681. display_configuration_parameter($installType, get_lang('InstituteURL'), 'institutionUrlForm', $institutionUrlForm);
  1682. /*
  1683. //old method
  1684. <tr>
  1685. <td><?php echo get_lang('EncryptUserPass'); ?> :</td>
  1686. <?php if($installType == 'update'): ?>
  1687. <td><input type="hidden" name="encryptPassForm" value="<?php echo $encryptPassForm; ?>" /><?php echo $encryptPassForm? get_lang('Yes') : get_lang('No'); ?></td>
  1688. <?php else: ?>
  1689. <td>
  1690. <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>
  1691. <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>
  1692. </td>
  1693. <?php endif; ?>
  1694. </tr>
  1695. */
  1696. ?>
  1697. <tr>
  1698. <td><?php echo get_lang("EncryptMethodUserPass"); ?> :</td>
  1699. <?php if ($installType == 'update'){ ?>
  1700. <td><input type="hidden" name="encryptPassForm" value="<?php echo $encryptPassForm; ?>" /><?php echo $encryptPassForm; ?></td>
  1701. <?php }else{ ?>
  1702. <td>
  1703. <input class="checkbox" type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" <?php echo ($encryptPassForm == 'sha1') ? 'checked="checked" ': ''; ?>/> <label for="encryptPass1"><?php echo 'sha1'; ?></label>
  1704. <input class="checkbox" type="radio" name="encryptPassForm" value="md5" id="encryptPass0" <?php echo $encryptPassForm == 1 ? 'checked="checked" ' : ''; ?>/> <label for="encryptPass0"><?php echo 'md5'; ?></label>
  1705. <input class="checkbox" type="radio" name="encryptPassForm" value="none" id="encryptPass2" <?php echo $encryptPassForm === '0' or $encryptPassForm === 0 ? 'checked="checked" ':''; ?>/> <label for="encryptPass2"><?php echo get_lang('None'); ?></label>
  1706. </td>
  1707. <?php } ?>
  1708. </tr>
  1709. <tr>
  1710. <td><?php echo get_lang('AllowSelfReg'); ?> :</td>
  1711. <?php if ($installType == 'update'): ?>
  1712. <td><input type="hidden" name="allowSelfReg" value="<?php echo $allowSelfReg; ?>" /><?php echo $allowSelfReg ? get_lang('Yes') : get_lang('No'); ?></td>
  1713. <?php else: ?>
  1714. <td>
  1715. <input class="checkbox" type="radio" name="allowSelfReg" value="1" id="allowSelfReg1" <?php echo $allowSelfReg ? 'checked="checked" ' : ''; ?>/> <label for="allowSelfReg1"><?php echo get_lang('Yes'); ?></label>
  1716. <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>
  1717. </td>
  1718. <?php endif; ?>
  1719. </tr>
  1720. <tr>
  1721. <td><?php echo get_lang('AllowSelfRegProf'); ?> :</td>
  1722. <?php if ($installType == 'update'): ?>
  1723. <td><input type="hidden" name="allowSelfRegProf" value="<?php echo $allowSelfRegProf; ?>" /><?php echo $allowSelfRegProf? get_lang('Yes') : get_lang('No'); ?></td>
  1724. <?php else: ?>
  1725. <td>
  1726. <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>
  1727. <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>
  1728. </td>
  1729. <?php endif; ?>
  1730. </tr>
  1731. <tr>
  1732. <td><button type="submit" class="back" name="step3" value="&lt; <?php echo get_lang('Previous'); ?>" /><?php echo get_lang('Previous'); ?></button></td>
  1733. <td align="right"><input type="hidden" name="is_executable" id="is_executable" value="-" /><button class="next" type="submit" name="step5" value="<?php echo get_lang('Next'); ?> &gt;" /><?php echo get_lang('Next'); ?></button></td>
  1734. </tr>
  1735. </table>
  1736. <?php
  1737. }
  1738. /**
  1739. * After installation is completed (step 6), this message is displayed.
  1740. */
  1741. function display_after_install_message($installType, $nbr_courses) {
  1742. ?>
  1743. <div class="RequirementHeading">
  1744. <h2><?php echo display_step_sequence() . get_lang('CfgSetting'); ?></h2>
  1745. </div>
  1746. <div class="RequirementContent">
  1747. <?php echo get_lang('FirstUseTip'); ?>
  1748. </div>
  1749. <?php
  1750. echo '<div class="warning-message">';
  1751. echo '<strong>'.get_lang('SecurityAdvice').'</strong>';
  1752. echo ': ';
  1753. printf(get_lang('ToProtectYourSiteMakeXAndYReadOnly'), 'main/inc/conf/configuration.php', 'main/install/index.php');
  1754. echo '</div>';
  1755. ?>
  1756. </form>
  1757. <a class="portal" href="../../index.php"><?php echo get_lang('GoToYourNewlyCreatedPortal'); ?></a>
  1758. <?php
  1759. }
  1760. /**
  1761. * This function return countries list from array (hardcoded)
  1762. * @param bool (Optional) True for returning countries list with select html
  1763. * @return array|string countries list
  1764. */
  1765. function get_countries_list_from_array($combo = false) {
  1766. $a_countries = array(
  1767. "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan",
  1768. "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi",
  1769. "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombi", "Comoros", "Congo (Brazzaville)", "Congo", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic",
  1770. "Denmark", "Djibouti", "Dominica", "Dominican Republic",
  1771. "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia",
  1772. "Fiji", "Finland", "France",
  1773. "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana",
  1774. "Haiti", "Honduras", "Hungary",
  1775. "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy",
  1776. "Jamaica", "Japan", "Jordan",
  1777. "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan",
  1778. "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg",
  1779. "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar",
  1780. "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway",
  1781. "Oman",
  1782. "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland","Portugal",
  1783. "Qatar",
  1784. "Romania", "Russia", "Rwanda",
  1785. "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria",
  1786. "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu",
  1787. "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan",
  1788. "Vanuatu", "Vatican City", "Venezuela", "Vietnam",
  1789. "Yemen",
  1790. "Zambia", "Zimbabwe"
  1791. );
  1792. $country_select = '';
  1793. if ($combo) {
  1794. $country_select = '<select id="country" name="country">';
  1795. $country_select .= '<option value="">--- '.get_lang('SelectOne').' ---</option>';
  1796. foreach ($a_countries as $country) {
  1797. $country_select .= '<option value="'.$country.'">'.$country.'</option>';
  1798. }
  1799. $country_select .= '</select>';
  1800. return $country_select;
  1801. }
  1802. return $a_countries;
  1803. }