install.lib.php 90 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980
  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}'] = '';
  276. $config['{DATABASE_MAIN}'] = $dbNameForm;
  277. $config['{DATABASE_STATS}'] = $dbNameForm;
  278. $config['{DATABASE_SCORM}'] = $dbNameForm;
  279. $config['{DATABASE_PERSONAL}'] = $dbNameForm;
  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('Chamilo 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. $multipleDbCheck = @Database::query("CREATE DATABASE ".$dbNameForm);
  566. if ($multipleDbCheck !== false) {
  567. //$multipleDbCheck = @Database::query("DROP DATABASE IF EXISTS ".$dbPrefixForm."test_chamilo_connection");
  568. $multipleDbCheck = @Database::query("DROP DATABASE IF EXISTS ".$dbNameForm);
  569. if ($multipleDbCheck !== false) {
  570. $dbConnect = 1;
  571. } else {
  572. $dbConnect = 0;
  573. }
  574. } else {
  575. $dbConnect = 0;
  576. }
  577. }
  578. } else {
  579. $dbConnect = -1;
  580. }
  581. 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.
  582. }
  583. /**
  584. * Fills the countries table with a list of countries.
  585. */
  586. function fill_track_countries_table($track_countries_table) {
  587. $file_path = dirname(__FILE__).'/'.COUNTRY_DATA_FILENAME;
  588. $countries = file($file_path);
  589. $add_country_sql = "INSERT INTO $track_countries_table (id, code, country, counter) VALUES ";
  590. foreach ($countries as $line) {
  591. $elems = split(',',$line);
  592. $add_country_sql .= '('.intval($elems[0]).',\''.Database::escape_string($elems[1]).'\',\''.Database::escape_string($elems[2]).'\','.intval($elems[3]).'),';
  593. }
  594. $add_country_sql = substr($add_country_sql,0,-1);
  595. //$add_country_sql = "LOAD DATA INFILE '".Database::escape_string($file_path)."' INTO TABLE $track_countries_table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\'';";
  596. @ Database::query($add_country_sql);
  597. }
  598. /**
  599. * Creates the structure of the main database and fills it
  600. * with data. Placeholder symbols in the main database file
  601. * have to be replaced by the settings entered by the user during installation.
  602. *
  603. * @param array $installation_settings list of settings entered by the user
  604. * @param string optional path about the script for database
  605. * @return void
  606. */
  607. function load_main_database($installation_settings, $db_script = '') {
  608. if (!empty($db_script)) {
  609. if (file_exists($db_script)) {
  610. $sql_text = file_get_contents($db_script);
  611. }
  612. } else {
  613. $db_script = api_get_path(SYS_CODE_PATH).'install/'.SYSTEM_MAIN_DATABASE_FILE;
  614. if (file_exists($db_script)) {
  615. $sql_text = file_get_contents($db_script);
  616. }
  617. }
  618. //replace symbolic parameters with user-specified values
  619. foreach ($installation_settings as $key => $value) {
  620. $sql_text = str_replace($key, Database::escape_string($value), $sql_text);
  621. }
  622. //split in array of sql strings
  623. $sql_instructions = array();
  624. $success = split_sql_file($sql_instructions, $sql_text);
  625. //execute the sql instructions
  626. $count = count($sql_instructions);
  627. for ($i = 0; $i < $count; $i++) {
  628. $this_sql_query = $sql_instructions[$i]['query'];
  629. Database::query($this_sql_query);
  630. }
  631. }
  632. /**
  633. * Creates the structure of the stats database
  634. * @param string Name of the file containing the SQL script inside the install directory
  635. */
  636. function load_database_script($db_script) {
  637. $db_script = api_get_path(SYS_CODE_PATH).'install/'.$db_script;
  638. if (file_exists($db_script)) {
  639. $sql_text = file_get_contents($db_script);
  640. }
  641. //split in array of sql strings
  642. $sql_instructions = array();
  643. $success = split_sql_file($sql_instructions, $sql_text);
  644. //execute the sql instructions
  645. $count = count($sql_instructions);
  646. for ($i = 0; $i < $count; $i++) {
  647. $this_sql_query = $sql_instructions[$i]['query'];
  648. Database::query($this_sql_query);
  649. }
  650. }
  651. /**
  652. * Function copied and adapted from phpMyAdmin 2.6.0 PMA_splitSqlFile (also GNU GPL)
  653. * Removes comment lines and splits up large sql files into individual queries
  654. * Last revision: September 23, 2001 - gandon
  655. * @param array the splitted sql commands
  656. * @param string the sql commands
  657. * @param integer the MySQL release number (because certains php3 versions
  658. * can't get the value of a constant from within a function)
  659. * @return boolean always true
  660. */
  661. function split_sql_file(&$ret, $sql) {
  662. // do not trim, see bug #1030644
  663. //$sql = trim($sql);
  664. $sql = rtrim($sql, "\n\r");
  665. $sql_len = strlen($sql);
  666. $char = '';
  667. $string_start = '';
  668. $in_string = false;
  669. $nothing = true;
  670. $time0 = time();
  671. for ($i = 0; $i < $sql_len; ++$i) {
  672. $char = $sql[$i];
  673. // We are in a string, check for not escaped end of strings except for
  674. // backquotes that can't be escaped
  675. if ($in_string) {
  676. for (;;) {
  677. $i = strpos($sql, $string_start, $i);
  678. // No end of string found -> add the current substring to the
  679. // returned array
  680. if (!$i) {
  681. $ret[] = $sql;
  682. return true;
  683. }
  684. // Backquotes or no backslashes before quotes: it's indeed the
  685. // end of the string -> exit the loop
  686. elseif ($string_start == '`' || $sql[$i - 1] != '\\') {
  687. $string_start = '';
  688. $in_string = false;
  689. break;
  690. }
  691. // one or more Backslashes before the presumed end of string...
  692. else {
  693. // ... first checks for escaped backslashes
  694. $j = 2;
  695. $escaped_backslash = false;
  696. while ($i - $j > 0 && $sql[$i - $j] == '\\') {
  697. $escaped_backslash = !$escaped_backslash;
  698. $j++;
  699. }
  700. // ... if escaped backslashes: it's really the end of the
  701. // string -> exit the loop
  702. if ($escaped_backslash) {
  703. $string_start = '';
  704. $in_string = false;
  705. break;
  706. }
  707. // ... else loop
  708. else {
  709. $i++;
  710. }
  711. } // end if...elseif...else
  712. } // end for
  713. } // end if (in string)
  714. // lets skip comments (/*, -- and #)
  715. elseif (($char == '-' && $sql_len > $i + 2 && $sql[$i + 1] == '-' && $sql[$i + 2] <= ' ') || $char == '#' || ($char == '/' && $sql_len > $i + 1 && $sql[$i + 1] == '*')) {
  716. $i = strpos($sql, $char == '/' ? '*/' : "\n", $i);
  717. // didn't we hit end of string?
  718. if ($i === false) {
  719. break;
  720. }
  721. if ($char == '/') $i++;
  722. }
  723. // We are not in a string, first check for delimiter...
  724. elseif ($char == ';') {
  725. // if delimiter found, add the parsed part to the returned array
  726. $ret[] = array('query' => substr($sql, 0, $i), 'empty' => $nothing);
  727. $nothing = true;
  728. $sql = ltrim(substr($sql, min($i + 1, $sql_len)));
  729. $sql_len = strlen($sql);
  730. if ($sql_len) {
  731. $i = -1;
  732. } else {
  733. // The submited statement(s) end(s) here
  734. return true;
  735. }
  736. } // end elseif (is delimiter)
  737. // ... then check for start of a string,...
  738. elseif (($char == '"') || ($char == '\'') || ($char == '`')) {
  739. $in_string = true;
  740. $nothing = false;
  741. $string_start = $char;
  742. } // end elseif (is start of string)
  743. elseif ($nothing) {
  744. $nothing = false;
  745. }
  746. // loic1: send a fake header each 30 sec. to bypass browser timeout
  747. $time1 = time();
  748. if ($time1 >= $time0 + 30) {
  749. $time0 = $time1;
  750. header('X-pmaPing: Pong');
  751. } // end if
  752. } // end for
  753. // add any rest to the returned array
  754. if (!empty($sql) && preg_match('@[^[:space:]]+@', $sql)) {
  755. $ret[] = array('query' => $sql, 'empty' => $nothing);
  756. }
  757. return true;
  758. } // end of the 'split_sql_file()' function
  759. /**
  760. * Get an SQL file's contents
  761. *
  762. * This function bases its parsing on the pre-set format of the specific SQL files in
  763. * the install/upgrade procedure:
  764. * Lines starting with "--" are comments (but need to be taken into account as they also hold sections names)
  765. * Other lines are considered to be one-line-per-query lines (this is checked quickly by this function)
  766. * @param string File to parse (in the current directory)
  767. * @param string Section to return
  768. * @param boolean Print (true) or hide (false) error texts when they occur
  769. */
  770. function get_sql_file_contents($file, $section, $print_errors = true) {
  771. //check given parameters
  772. if (empty($file)) {
  773. $error = "Missing name of file to parse in get_sql_file_contents()";
  774. if ($print_errors) echo $error;
  775. return false;
  776. }
  777. if (!in_array($section, array('main', 'user', 'stats', 'scorm', 'course'))) {
  778. $error = "Section '$section' is not authorized in get_sql_file_contents()";
  779. if ($print_errors) echo $error;
  780. return false;
  781. }
  782. $filepath = getcwd().'/'.$file;
  783. if (!is_file($filepath) or !is_readable($filepath)) {
  784. $error = "File $filepath not found or not readable in get_sql_file_contents()";
  785. if ($print_errors) echo $error;
  786. return false;
  787. }
  788. //read the file in an array
  789. // Empty lines should not be executed as SQL statements, because errors occur, see Task #2167.
  790. $file_contents = file($filepath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  791. if (!is_array($file_contents) or count($file_contents) < 1) {
  792. $error = "File $filepath looks empty in get_sql_file_contents()";
  793. if ($print_errors) echo $error;
  794. return false;
  795. }
  796. //prepare the resulting array
  797. $section_contents = array();
  798. $record = false;
  799. foreach ($file_contents as $index => $line) {
  800. if (substr($line, 0, 2) == '--') {
  801. //This is a comment. Check if section name, otherwise ignore
  802. $result = array();
  803. if (preg_match('/^-- xx([A-Z]*)xx/', $line, $result)) { //we got a section name here
  804. if ($result[1] == strtoupper($section)) {
  805. //we have the section we are looking for, start recording
  806. $record = true;
  807. } else {
  808. //we have another section's header. If we were recording, stop now and exit loop
  809. if ($record) {
  810. break;
  811. }
  812. $record = false;
  813. }
  814. }
  815. } else {
  816. if ($record) {
  817. if (!empty($line)) {
  818. $section_contents[] = $line;
  819. }
  820. }
  821. }
  822. }
  823. //now we have our section's SQL statements group ready, return
  824. return $section_contents;
  825. }
  826. /**
  827. * Adds a new document to the database - specific to version 1.8.0
  828. *
  829. * @param array $_course
  830. * @param string $path
  831. * @param string $filetype
  832. * @param int $filesize
  833. * @param string $title
  834. * @return id if inserted document
  835. */
  836. function add_document_180($_course, $path, $filetype, $filesize, $title, $comment = null) {
  837. $table_document = Database::get_course_table(TABLE_DOCUMENT, $_course['dbName']);
  838. $sql = "INSERT INTO $table_document
  839. (`path`,`filetype`,`size`,`title`, `comment`)
  840. VALUES ('$path','$filetype','$filesize','".
  841. Database::escape_string($title)."', '$comment')";
  842. if (Database::query($sql)) {
  843. //display_message("Added to database (id ".Database::insert_id().")!");
  844. return Database::insert_id();
  845. } else {
  846. //display_error("The uploaded file could not be added to the database (".Database::error().")!");
  847. return false;
  848. }
  849. }
  850. /* DISPLAY FUNCTIONS */
  851. /**
  852. * This function prints class=active_step $current_step=$param
  853. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  854. */
  855. function step_active($param) {
  856. global $current_step;
  857. if ($param == $current_step) {
  858. echo 'class="current_step" ';
  859. }
  860. }
  861. /**
  862. * This function displays the Step X of Y -
  863. * @return string String that says 'Step X of Y' with the right values
  864. */
  865. function display_step_sequence() {
  866. global $current_step;
  867. return get_lang('Step'.$current_step).' &ndash; ';
  868. }
  869. /**
  870. * Displays a drop down box for selection the preferred language.
  871. */
  872. function display_language_selection_box($name = 'language_list', $default_language = 'english') {
  873. // Reading language list.
  874. $language_list = get_language_folder_list();
  875. /*
  876. // Reduction of the number of languages shown. Enable this fragment of code for customization purposes.
  877. // Modify the language list according to your preference. Don't exclude the 'english' item.
  878. $language_to_display = array('asturian', 'bulgarian', 'english', 'italian', 'french', 'slovenian', 'slovenian_unicode', 'spanish');
  879. foreach ($language_list as $key => & $value) {
  880. if (!in_array($key, $language_to_display)) {
  881. unset($language_list[$key]);
  882. }
  883. }
  884. */
  885. // Sanity checks due to the possibility for customizations.
  886. if (!is_array($language_list) || empty($language_list)) {
  887. $language_list = array('english' => 'English');
  888. }
  889. // Sorting again, if it is necessary.
  890. //asort($language_list);
  891. // More sanity checks.
  892. if (!array_key_exists($default_language, $language_list)) {
  893. if (array_key_exists('english', $language_list)) {
  894. $default_language = 'english';
  895. } else {
  896. $language_keys = array_keys($language_list);
  897. $default_language = $language_keys[0];
  898. }
  899. }
  900. // Displaying the box.
  901. echo "\t\t<select name=\"$name\">\n";
  902. foreach ($language_list as $key => $value) {
  903. if ($key == $default_language) {
  904. $option_end = ' selected="selected">';
  905. } else {
  906. $option_end = '>';
  907. }
  908. echo "\t\t\t<option value=\"$key\"$option_end";
  909. echo $value;
  910. echo "</option>\n";
  911. }
  912. echo "\t\t</select>\n";
  913. }
  914. /**
  915. * This function displays a language dropdown box so that the installatioin
  916. * can be done in the language of the user
  917. */
  918. function display_language_selection() { ?>
  919. <h2><?php get_lang('WelcomeToTheDokeosInstaller'); ?></h2>
  920. <div class="RequirementHeading">
  921. <h2><?php echo display_step_sequence(); ?><?php echo get_lang('InstallationLanguage'); ?></h2>
  922. <p><?php echo get_lang('PleaseSelectInstallationProcessLanguage'); ?>:</p>
  923. <form id="lang_form" method="post" action="<?php echo api_get_self(); ?>">
  924. <?php display_language_selection_box('language_list', api_get_interface_language()); ?>
  925. <button type="submit" name="step1" class="next" value="<?php echo get_lang('Next'); ?>"><?php echo get_lang('Next'); ?></button>
  926. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  927. </form>
  928. </div>
  929. <?php
  930. }
  931. /**
  932. * This function displays the requirements for installing Chamilo.
  933. *
  934. * @param string $installType
  935. * @param boolean $badUpdatePath
  936. * @param string The updatePath given (if given)
  937. * @param array $update_from_version_8 The different subversions from version 1.8
  938. * @param array $update_from_version_6 The different subversions from version 1.6
  939. *
  940. * @author unknow
  941. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  942. */
  943. function display_requirements($installType, $badUpdatePath, $updatePath = '', $update_from_version_8 = array(), $update_from_version_6 = array()) {
  944. echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('Requirements')."</h2></div>";
  945. echo '<div class="RequirementText">';
  946. echo '<strong>'.get_lang('ReadThoroughly').'</strong><br />';
  947. echo get_lang('MoreDetails').' <a href="../../documentation/installation_guide.html" target="_blank">'.get_lang('ReadTheInstallGuide').'</a>.<br />'."\n";
  948. if ($installType == 'update') {
  949. echo get_lang('IfYouPlanToUpgradeFromOlderVersionYouMightWantToHaveAlookAtTheChangelog').'<br />';
  950. }
  951. echo '</div>';
  952. // SERVER REQUIREMENTS
  953. echo '<div class="RequirementHeading"><h2>'.get_lang('ServerRequirements').'</h2>';
  954. echo '<div class="RequirementText">'.get_lang('ServerRequirementsInfo').'</div>';
  955. echo '<div class="RequirementContent">';
  956. echo '<table class="requirements">
  957. <tr>
  958. <td class="requirements-item">'.get_lang('PHPVersion').'>= 5.0</td>
  959. <td class="requirements-value">';
  960. if (phpversion() < '5.0') {
  961. echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>';
  962. } else {
  963. echo '<strong><font color="green">'.get_lang('PHPVersionOK'). ' '.phpversion().'</font></strong>';
  964. }
  965. echo ' </td>
  966. </tr>
  967. <tr>
  968. <td class="requirements-item"><a href="http://php.net/manual/en/book.session.php" target="_blank">Session</a> '.get_lang('support').'</td>
  969. <td class="requirements-value">'.check_extension('session', get_lang('Yes'), get_lang('ExtensionSessionsNotAvailable')).'</td>
  970. </tr>
  971. <tr>
  972. <td class="requirements-item"><a href="http://php.net/manual/en/book.mysql.php" target="_blank">MySQL</a> '.get_lang('support').'</td>
  973. <td class="requirements-value">'.check_extension('mysql', get_lang('Yes'), get_lang('ExtensionMySQLNotAvailable')).'</td>
  974. </tr>
  975. <tr>
  976. <td class="requirements-item"><a href="http://php.net/manual/en/book.zlib.php" target="_blank">Zlib</a> '.get_lang('support').'</td>
  977. <td class="requirements-value">'.check_extension('zlib', get_lang('Yes'), get_lang('ExtensionZlibNotAvailable')).'</td>
  978. </tr>
  979. <tr>
  980. <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>
  981. <td class="requirements-value">'.check_extension('pcre', get_lang('Yes'), get_lang('ExtensionPCRENotAvailable')).'</td>
  982. </tr>
  983. <tr>
  984. <td class="requirements-item"><a href="http://php.net/manual/en/book.xml.php" target="_blank">XML</a> '.get_lang('support').'</td>
  985. <td class="requirements-value">'.check_extension('xml', get_lang('Yes'), get_lang('No')).'</td>
  986. </tr>
  987. <tr>
  988. <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>
  989. <td class="requirements-value">'.check_extension('mbstring', get_lang('Yes'), get_lang('ExtensionMBStringNotAvailable'), true).'</td>
  990. </tr>
  991. <tr>
  992. <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>
  993. <td class="requirements-value">'.check_extension('iconv', get_lang('Yes'), get_lang('No'), true).'</td>
  994. </tr>
  995. <tr>
  996. <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>
  997. <td class="requirements-value">'.check_extension('intl', get_lang('Yes'), get_lang('No'), true).'</td>
  998. </tr>
  999. <tr>
  1000. <td class="requirements-item"><a href="http://php.net/manual/en/book.image.php" target="_blank">GD</a> '.get_lang('support').'</td>
  1001. <td class="requirements-value">'.check_extension('gd', get_lang('Yes'), get_lang('ExtensionGDNotAvailable')).'</td>
  1002. </tr>
  1003. <tr>
  1004. <td class="requirements-item"><a href="http://php.net/manual/en/book.json.php" target="_blank">JSON</a> '.get_lang('support').'</td>
  1005. <td class="requirements-value">'.check_extension('json', get_lang('Yes'), get_lang('No')).'</td>
  1006. </tr>
  1007. <tr>
  1008. <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>
  1009. <td class="requirements-value">'.check_extension('ldap', get_lang('Yes'), get_lang('ExtensionLDAPNotAvailable'), true).'</td>
  1010. </tr>
  1011. <tr>
  1012. <td class="requirements-item"><a href="http://xapian.org/" target="_blank">Xapian</a> '.get_lang('support').' ('.get_lang('Optional').')</td>
  1013. <td class="requirements-value">'.check_extension('xapian', get_lang('Yes'), get_lang('No'), true).'</td>
  1014. </tr>
  1015. </table>';
  1016. echo ' </div>';
  1017. echo '</div>';
  1018. // RECOMMENDED SETTINGS
  1019. // Note: these are the settings for Joomla, does this also apply for Chamilo?
  1020. // Note: also add upload_max_filesize here so that large uploads are possible
  1021. echo '<div class="RequirementHeading"><h2>'.get_lang('RecommendedSettings').'</h2>';
  1022. echo '<div class="RequirementText">'.get_lang('RecommendedSettingsInfo').'</div>';
  1023. echo '<div class="RequirementContent">';
  1024. echo '<table class="requirements">
  1025. <tr>
  1026. <th>'.get_lang('Setting').'</th>
  1027. <th>'.get_lang('Recommended').'</th>
  1028. <th>'.get_lang('Actual').'</th>
  1029. </tr>
  1030. <tr>
  1031. <td class="requirements-item"><a href="http://php.net/manual/features.safe-mode.php">Safe Mode</a></td>
  1032. <td class="requirements-recommended">OFF</td>
  1033. <td class="requirements-value">'.check_php_setting('safe_mode','OFF').'</td>
  1034. </tr>
  1035. <tr>
  1036. <td class="requirements-item"><a href="http://php.net/manual/ref.errorfunc.php#ini.display-errors">Display Errors</a></td>
  1037. <td class="requirements-recommended">OFF</td>
  1038. <td class="requirements-value">'.check_php_setting('display_errors','OFF').'</td>
  1039. </tr>
  1040. <tr>
  1041. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.file-uploads">File Uploads</a></td>
  1042. <td class="requirements-recommended">ON</td>
  1043. <td class="requirements-value">'.check_php_setting('file_uploads','ON').'</td>
  1044. </tr>
  1045. <tr>
  1046. <td class="requirements-item"><a href="http://php.net/manual/ref.info.php#ini.magic-quotes-gpc">Magic Quotes GPC</a></td>
  1047. <td class="requirements-recommended">OFF</td>
  1048. <td class="requirements-value">'.check_php_setting('magic_quotes_gpc','OFF').'</td>
  1049. </tr>
  1050. <tr>
  1051. <td class="requirements-item"><a href="http://php.net/manual/ref.info.php#ini.magic-quotes-runtime">Magic Quotes Runtime</a></td>
  1052. <td class="requirements-recommended">OFF</td>
  1053. <td class="requirements-value">'.check_php_setting('magic_quotes_runtime','OFF').'</td>
  1054. </tr>
  1055. <tr>
  1056. <td class="requirements-item"><a href="http://php.net/manual/security.globals.php">Register Globals</a></td>
  1057. <td class="requirements-recommended">OFF</td>
  1058. <td class="requirements-value">'.check_php_setting('register_globals','OFF').'</td>
  1059. </tr>
  1060. <tr>
  1061. <td class="requirements-item"><a href="http://php.net/manual/ref.session.php#ini.session.auto-start">Session auto start</a></td>
  1062. <td class="requirements-recommended">OFF</td>
  1063. <td class="requirements-value">'.check_php_setting('session.auto_start','OFF').'</td>
  1064. </tr>
  1065. <tr>
  1066. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.short-open-tag">Short Open Tag</a></td>
  1067. <td class="requirements-recommended">OFF</td>
  1068. <td class="requirements-value">'.check_php_setting('short_open_tag','OFF').'</td>
  1069. </tr>
  1070. <tr>
  1071. <td class="requirements-item"><a href="http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-httponly">Cookie HTTP Only</a></td>
  1072. <td class="requirements-recommended">ON</td>
  1073. <td class="requirements-value">'.check_php_setting('session.cookie_httponly','ON').'</td>
  1074. </tr>
  1075. <tr>
  1076. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.upload-max-filesize">Maximum upload file size</a></td>
  1077. <td class="requirements-recommended">10M-100M</td>
  1078. <td class="requirements-value">'.ini_get('upload_max_filesize').'</td>
  1079. </tr>
  1080. <tr>
  1081. <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.post-max-size">Maximum post size</a></td>
  1082. <td class="requirements-recommended">10M-100M</td>
  1083. <td class="requirements-value">'.ini_get('post_max_size').'</td>
  1084. </tr>
  1085. </table>';
  1086. echo ' </div>';
  1087. echo '</div>';
  1088. // DIRECTORY AND FILE PERMISSIONS
  1089. echo '<div class="RequirementHeading"><h2>'.get_lang('DirectoryAndFilePermissions').'</h2>';
  1090. echo '<div class="RequirementText">'.get_lang('DirectoryAndFilePermissionsInfo').'</div>';
  1091. echo '<div class="RequirementContent">';
  1092. echo '<table class="requirements">
  1093. <tr>
  1094. <td class="requirements-item">chamilo/main/inc/conf/</td>
  1095. <td class="requirements-value">'.check_writable('inc/conf/').'</td>
  1096. </tr>
  1097. <tr>
  1098. <td class="requirements-item">chamilo/main/upload/users/</td>
  1099. <td class="requirements-value">'.check_writable('upload/users/').'</td>
  1100. </tr>
  1101. <tr>
  1102. <td class="requirements-item">chamilo/main/default_course_document/images/</td>
  1103. <td class="requirements-value">'.check_writable('default_course_document/images/').'</td>
  1104. </tr>
  1105. <tr>
  1106. <td class="requirements-item">chamilo/archive/</td>
  1107. <td class="requirements-value">'.check_writable('../archive/').'</td>
  1108. </tr>
  1109. <tr>
  1110. <td class="requirements-item">chamilo/courses/</td>
  1111. <td class="requirements-value">'.check_writable('../courses/').'</td>
  1112. </tr>
  1113. <tr>
  1114. <td class="requirements-item">chamilo/home/</td>
  1115. <td class="requirements-value">'.check_writable('../home/').'</td>
  1116. </tr>
  1117. <tr>
  1118. <td class="requirements-item">chamilo/main/css/</td>
  1119. <td class="requirements-value">'.check_writable('css/', true).' ('.get_lang('SuggestionOnlyToEnableCSSUploadFeature').')</td>
  1120. </tr>
  1121. <tr>
  1122. <td class="requirements-item">chamilo/main/lang/</td>
  1123. <td class="requirements-value">'.check_writable('lang/', true).' ('.get_lang('SuggestionOnlyToEnableSubLanguageFeature').')</td>
  1124. </tr>'.
  1125. //'<tr>
  1126. // <td class="requirements-item">chamilo/searchdb/</td>
  1127. // <td class="requirements-value">'.check_writable('../searchdb/').'</td>
  1128. //</tr>'.
  1129. //'<tr>
  1130. // <td class="requirements-item">'.session_save_path().'</td>
  1131. // <td class="requirements-value">'.(is_writable(session_save_path())
  1132. // ? '<strong><font color="green">'.get_lang('Writable').'</font></strong>'
  1133. // : '<strong><font color="red">'.get_lang('NotWritable').'</font></strong>').'</td>
  1134. //</tr>'.
  1135. '';
  1136. echo ' </table>';
  1137. echo ' </div>';
  1138. echo '</div>';
  1139. if ($installType == 'update' && (empty($updatePath) || $badUpdatePath)) {
  1140. if ($badUpdatePath) { ?>
  1141. <div class="error-message">
  1142. <?php echo get_lang('Error'); ?>!<br />
  1143. Chamilo <?php echo (isset($_POST['step2_update_6']) ? implode('|', $update_from_version_6) : implode('|', $update_from_version_8)).' '.get_lang('HasNotBeenFoundInThatDir'); ?>.
  1144. </div>
  1145. <?php }
  1146. else {
  1147. echo '<br />';
  1148. }
  1149. ?>
  1150. <table border="0" cellpadding="5" align="center">
  1151. <tr>
  1152. <td><?php echo get_lang('OldVersionRootPath'); ?>:</td>
  1153. <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>
  1154. </tr>
  1155. <tr>
  1156. <td colspan="2" align="center">
  1157. <button type="submit" class="back" name="step1" value="&lt; <?php echo get_lang('Back'); ?>" ><?php echo get_lang('Back'); ?></button>
  1158. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  1159. <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>
  1160. </td>
  1161. </tr>
  1162. </table>
  1163. <?php
  1164. } else {
  1165. $error = false;
  1166. // First, attempt to set writing permissions if we don't have them yet
  1167. $perm = api_get_permissions_for_new_directories();
  1168. $perm_file = api_get_permissions_for_new_files();
  1169. $notwritable = array();
  1170. $curdir = getcwd();
  1171. $checked_writable = api_get_path(CONFIGURATION_PATH);
  1172. if (!is_writable($checked_writable)) {
  1173. $notwritable[] = $checked_writable;
  1174. @chmod($checked_writable, $perm);
  1175. }
  1176. $checked_writable = api_get_path(SYS_CODE_PATH).'upload/users/';
  1177. if (!is_writable($checked_writable)) {
  1178. $notwritable[] = $checked_writable;
  1179. @chmod($checked_writable, $perm);
  1180. }
  1181. $checked_writable = api_get_path(SYS_CODE_PATH).'default_course_document/images/';
  1182. if (!is_writable($checked_writable)) {
  1183. $notwritable[] = $checked_writable;
  1184. @chmod($checked_writable, $perm);
  1185. }
  1186. $checked_writable = api_get_path(SYS_ARCHIVE_PATH);
  1187. if (!is_writable($checked_writable)) {
  1188. $notwritable[] = $checked_writable;
  1189. @chmod($checked_writable, $perm);
  1190. }
  1191. $checked_writable = api_get_path(SYS_COURSE_PATH);
  1192. if (!is_writable($checked_writable)) {
  1193. $notwritable[] = $checked_writable;
  1194. @chmod($checked_writable, $perm);
  1195. }
  1196. $checked_writable = api_get_path(SYS_PATH).'home/';
  1197. if (!is_writable($checked_writable)) {
  1198. $notwritable[] = realpath($checked_writable);
  1199. @chmod($checked_writable, $perm);
  1200. }
  1201. $checked_writable = api_get_path(CONFIGURATION_PATH).'configuration.php';
  1202. if (file_exists($checked_writable) && !is_writable($checked_writable)) {
  1203. $notwritable[] = $checked_writable;
  1204. @chmod($checked_writable, $perm_file);
  1205. }
  1206. // Second, if this fails, report an error
  1207. //--> The user would have to adjust the permissions manually
  1208. if (count($notwritable) > 0) {
  1209. $error = true;
  1210. echo '<div class="error-message">';
  1211. echo '<center><h3>'.get_lang('Warning').'</h3></center>';
  1212. printf(get_lang('NoWritePermissionPleaseReadInstallGuide'), '</font>
  1213. <a href="../../documentation/installation_guide.html" target="blank">', '</a> <font color="red">');
  1214. echo '</div>';
  1215. echo '<ul>';
  1216. foreach ($notwritable as $value) {
  1217. echo '<li>'.$value.'</li>';
  1218. }
  1219. echo '</ul>';
  1220. }
  1221. // Check wether a Chamilo configuration file already exists.
  1222. elseif (file_exists(api_get_path(CONFIGURATION_PATH).'configuration.php')) {
  1223. echo '<div class="warning-message"><h4><center>';
  1224. echo get_lang('WarningExistingDokeosInstallationDetected');
  1225. echo '</center></h4></div>';
  1226. }
  1227. // And now display the choice buttons (go back or install)
  1228. ?>
  1229. <p align="center" style="padding-top:15px">
  1230. <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>
  1231. <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>
  1232. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  1233. <?php
  1234. // Real code
  1235. echo '<button type="submit" class="save" name="step2_update_8" value="Upgrade from Dokeos 1.8.x"';
  1236. if ($error) echo ' disabled="disabled"';
  1237. // Temporary code for alpha version, disabling upgrade
  1238. //echo '<input type="submit" name="step2_update" value="Upgrading is not possible in this beta version"';
  1239. //echo ' disabled="disabled"';
  1240. //end temp code
  1241. echo ' >'.get_lang('UpgradeFromDokeos18x').'</button>';
  1242. echo '<button type="submit" class="save" name="step2_update_6" value="Upgrade from Dokeos 1.6.x"';
  1243. if ($error) echo ' disabled="disabled"';
  1244. echo ' >'.get_lang('UpgradeFromDokeos16x').'</button>';
  1245. echo '</p>';
  1246. }
  1247. }
  1248. /**
  1249. * Displays the license (GNU GPL) as step 2, with
  1250. * - an "I accept" button named step3 to proceed to step 3;
  1251. * - a "Back" button named step1 to go back to the first step.
  1252. */
  1253. function display_license_agreement() {
  1254. echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('Licence').'</h2>';
  1255. echo '<p>'.get_lang('DokeosLicenseInfo').'</p>';
  1256. echo '<p><a href="../../documentation/license.html" target="_blank">'.get_lang('PrintVers').'</a></p>';
  1257. echo '</div>';
  1258. ?>
  1259. <table>
  1260. <tr><td>
  1261. <p style="font-size:90%">
  1262. <textarea cols="90" rows="7" readonly>
  1263. <?php echo api_htmlentities(@file_get_contents(api_get_path(SYS_PATH).'documentation/license.txt')); ?>
  1264. </textarea></p>
  1265. </td>
  1266. </tr>
  1267. <tr><td>
  1268. <input type="checkbox" name="accept" id="accept_licence" value="1" />
  1269. <label for="accept_licence"><?php echo get_lang('IAccept'); ?></label>
  1270. </td>
  1271. </tr>
  1272. <tr><td><p style="color:#666"><br /><?php echo get_lang('DokeosArtLicense'); ?></p></td></tr>
  1273. <tr>
  1274. <td>
  1275. <table width="100%">
  1276. <tr>
  1277. <td></td>
  1278. <td align="center">
  1279. <button type="submit" class="back" name="step1" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button>
  1280. <input type="hidden" name="is_executable" id="is_executable" value="-" />
  1281. <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>
  1282. </td>
  1283. </tr>
  1284. </table>
  1285. </td>
  1286. </tr>
  1287. </table>
  1288. <!-- Contact information form -->
  1289. <div>
  1290. <a href="javascript://" class = "advanced_parameters" >
  1291. <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>
  1292. </a>
  1293. </div>
  1294. <div id="id_contact_form" style="display:block">
  1295. <div class="normal-message"><?php echo get_lang('ContactInformationDescription') ?></div>
  1296. <div id="contact_registration">
  1297. <p><?php echo get_contact_registration_form() ?></p><br />
  1298. </div>
  1299. </div>
  1300. <?php
  1301. }
  1302. /**
  1303. * Get contact registration form
  1304. */
  1305. function get_contact_registration_form() {
  1306. $html ='
  1307. <form>
  1308. <fieldset style="width:95%;padding:15px;border:1pt solid #eee">
  1309. <div id="div_sent_information"></div>
  1310. <div class="row">
  1311. <div class="label"><span class="form_required">*</span>'.get_lang('Name').'</div>
  1312. <div class="formw"><input id="person_name" type="text" name="person_name" size="30" /></div>
  1313. </div>
  1314. <div class="row">
  1315. <div class="label"><span class="form_required">*</span>'.get_lang('Email').'</div>
  1316. <div class="formw"><input id="person_name" type="text" name="person_email" size="30" /></div>
  1317. </div>
  1318. <div class="row">
  1319. <div class="label"><span class="form_required">*</span>'.get_lang('CompanyName').'</div>
  1320. <div class="formw"><input id="company_name" type="text" name="company_name" size="30" /></div>
  1321. </div>
  1322. <div class="row">
  1323. <div class="label"><span class="form_required">*</span>'.get_lang('CompanyActivity').'</div>
  1324. <div class="formw">
  1325. <select name="company_activity" id="company_activity" >
  1326. <option value="">--- '.get_lang('SelectOne').' ---</option>
  1327. <Option value="Advertising/Marketing/PR">Advertising/Marketing/PR</Option><Option value="Agriculture/Forestry">Agriculture/Forestry</Option>
  1328. <Option value="Architecture">Architecture</Option><Option value="Banking/Finance">Banking/Finance</Option>
  1329. <Option value="Biotech/Pharmaceuticals">Biotech/Pharmaceuticals</Option><Option value="Business Equipment">Business Equipment</Option>
  1330. <Option value="Business Services">Business Services</Option><Option value="Construction">Construction</Option>
  1331. <Option value="Consulting/Research">Consulting/Research</Option><Option value="Education">Education</Option>
  1332. <Option value="Engineering">Engineering</Option><Option value="Environmental">Environmental</Option>
  1333. <Option value="Government">Government</Option><Option value="Healthcare">Health Care</Option>
  1334. <Option value="Hospitality/Lodging/Travel">Hospitality/Lodging/Travel</Option><Option value="Insurance">Insurance</Option>
  1335. <Option value="Legal">Legal</Option><Option value="Manufacturing">Manufacturing</Option>
  1336. <Option value="Media/Entertainment">Media/Entertainment</Option><Option value="Mortgage">Mortgage</Option>
  1337. <Option value="Non-Profit">Non-Profit</Option><Option value="Real Estate">Real Estate</Option>
  1338. <Option value="Restaurant">Restaurant</Option><Option value="Retail">Retail</Option>
  1339. <Option value="Shipping/Transportation">Shipping/Transportation</Option>
  1340. <Option value="Technology">Technology</Option><Option value="Telecommunications">Telecommunications</Option>
  1341. <Option value="Other">Other</Option>
  1342. </select>
  1343. </div>
  1344. </div>
  1345. <div class="row">
  1346. <div class="label"><span class="form_required">*</span>'.get_lang('PersonRole').'</div>
  1347. <div class="formw">
  1348. <select name="person_role" id="person_role" >
  1349. <option value="">--- '.get_lang('SelectOne').' ---</option>
  1350. <Option value="Administration">Administration</Option><Option value="CEO/President/ Owner">CEO/President/ Owner</Option>
  1351. <Option value="CFO">CFO</Option><Option value="CIO/CTO">CIO/CTO</Option>
  1352. <Option value="Consultant">Consultant</Option><Option value="Customer Service">Customer Service</Option>
  1353. <Option value="Engineer/Programmer">Engineer/Programmer</Option><Option value="Facilities/Operations">Facilities/Operations</Option>
  1354. <Option value="Finance/ Accounting Manager">Finance/ Accounting Manager</Option><Option value="Finance/ Accounting Staff">Finance/ Accounting Staff</Option>
  1355. <Option value="General Manager">General Manager</Option><Option value="Human Resources">Human Resources</Option>
  1356. <Option value="IS/IT Management">IS/IT Management</Option><Option value="IS/ IT Staff">IS/ IT Staff</Option>
  1357. <Option value="Marketing Manager">Marketing Manager</Option><Option value="Marketing Staff">Marketing Staff</Option>
  1358. <Option value="Partner/Principal">Partner/Principal</Option><Option value="Purchasing Manager">Purchasing Manager</Option>
  1359. <Option value="Sales/ Business Dev. Manager">Sales/ Business Dev. Manager</Option><Option value="Sales/ Business Dev.">Sales/ Business Dev.</Option>
  1360. <Option value="Vice President/Senior Manager">Vice President/Senior Manager</Option><Option value="Other">Other</Option>
  1361. </select>
  1362. </div>
  1363. </div>
  1364. <div class="row">
  1365. <div class="label"><span class="form_required">*</span>'.get_lang('CompanyCountry').'</div>
  1366. <div class="formw">'.get_countries_list_from_array(true).'</div>
  1367. </div>
  1368. <div class="row">
  1369. <div class="label">'.get_lang('CompanyCity').'</div>
  1370. <div class="formw">
  1371. <input type="text" id="company_city" name="company_city" size="30" />
  1372. </div>
  1373. </div>
  1374. <div class="row">
  1375. <div class="label">'.get_lang('WhichLanguageWouldYouLikeToUseWhenContactingYou').'</div>
  1376. <div class="formw">
  1377. <select id="language" name="language">
  1378. <option value="bulgarian">Bulgarian</option>
  1379. <option value="indonesian">Bahasa Indonesia</option>
  1380. <option value="bosnian">Bosanski</option>
  1381. <option value="german">Deutsch</option>
  1382. <option selected="selected" value="english">English</option>
  1383. <option value="spanish">Spanish</option>
  1384. <option value="french">Français</option>
  1385. <option value="italian">Italian</option>
  1386. <option value="hungarian">Magyar</option>
  1387. <option value="dutch">Nederlands</option>
  1388. <option value="brazilian">Português do Brasil</option>
  1389. <option value="portuguese">Português europeu</option>
  1390. <option value="slovenian">Slovenčina</option>
  1391. </select>
  1392. </div>
  1393. </div>
  1394. <div class="row">
  1395. <div class="label">'.get_lang('HaveYouThePowerToTakeFinancialDecisions').'</div>
  1396. <div class="formw">
  1397. <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked />'.get_lang('Yes').'
  1398. <input type="radio" name="financial_decision" id="financial_decision2" value="0" />'.get_lang('No').'
  1399. </div>
  1400. </div>
  1401. <div class="clear"></div>
  1402. <div class="row">
  1403. <div class="label">&nbsp;</div>
  1404. <div class="formw"><button type="button" class="save" onclick="javascript:send_contact_information();" value="'.get_lang('SendInformation').'" >'.get_lang('SendInformation').'</button></div>
  1405. </div>
  1406. <div class="row">
  1407. <div class="label">&nbsp;</div>
  1408. <div class="formw"><span class="form_required">*</span><small>'.get_lang('FieldRequired').'</small></div>
  1409. </div>
  1410. </fieldset></form>';
  1411. return $html;
  1412. }
  1413. /**
  1414. * Displays a parameter in a table row.
  1415. * Used by the display_database_settings_form function.
  1416. * @param string Type of install
  1417. * @param string Name of parameter
  1418. * @param string Field name (in the HTML form)
  1419. * @param string Field value
  1420. * @param string Extra notice (to show on the right side)
  1421. * @param boolean Whether to display in update mode
  1422. * @param string Additional attribute for the <tr> element
  1423. * @return void Direct output
  1424. */
  1425. function display_database_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $extra_notice, $display_when_update = true, $tr_attribute = '') {
  1426. echo "<tr ".$tr_attribute.">";
  1427. echo "<td>$parameter_name&nbsp;&nbsp;</td>";
  1428. if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update) {
  1429. echo '<td><input type="hidden" name="'.$form_field_name.'" id="'.$form_field_name.'" value="'.api_htmlentities($parameter_value).'" />'.$parameter_value."</td>";
  1430. } else {
  1431. $inputtype = $form_field_name == 'dbPassForm' ? 'password' : 'text';
  1432. //Slightly limit the length of the database prefix to avoid having to cut down the databases names later on
  1433. $maxlength = $form_field_name == 'dbPrefixForm' ? '15' : MAX_FORM_FIELD_LENGTH;
  1434. if ($install_type == INSTALL_TYPE_UPDATE) {
  1435. echo '<input type="hidden" name="'.$form_field_name.'" id="'.$form_field_name.'" value="'.api_htmlentities($parameter_value).'" />';
  1436. echo '<td>'.api_htmlentities($parameter_value)."</td>";
  1437. //echo "<td>$extra_notice</td>\n";
  1438. } else {
  1439. 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>";
  1440. echo "<td>$extra_notice</td>";
  1441. }
  1442. }
  1443. echo "</tr>";
  1444. }
  1445. /**
  1446. * Displays step 3 - a form where the user can enter the installation settings
  1447. * regarding the databases - login and password, names, prefixes, single
  1448. * or multiple databases, tracking or not...
  1449. */
  1450. function display_database_settings_form($installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbPrefixForm, $enableTrackingForm, $singleDbForm, $dbNameForm, $dbStatsForm, $dbScormForm, $dbUserForm) {
  1451. if ($installType == 'update') {
  1452. global $_configuration, $update_from_version_6;
  1453. if (in_array($_POST['old_version'], $update_from_version_6)) {
  1454. $dbHostForm = get_config_param('dbHost');
  1455. $dbUsernameForm = get_config_param('dbLogin');
  1456. $dbPassForm = get_config_param('dbPass');
  1457. $dbPrefixForm = get_config_param('dbNamePrefix');
  1458. $enableTrackingForm = get_config_param('is_trackingEnabled');
  1459. $singleDbForm = get_config_param('singleDbEnabled');
  1460. $dbNameForm = get_config_param('mainDbName');
  1461. $dbStatsForm = get_config_param('statsDbName');
  1462. $dbScormForm = get_config_param('scormDbName');
  1463. $dbUserForm = get_config_param('user_personal_database');
  1464. $dbScormExists = true;
  1465. } else {
  1466. $dbHostForm = $_configuration['db_host'];
  1467. $dbUsernameForm = $_configuration['db_user'];
  1468. $dbPassForm = $_configuration['db_password'];
  1469. $dbPrefixForm = $_configuration['db_prefix'];
  1470. $enableTrackingForm = $_configuration['tracking_enabled'];
  1471. $singleDbForm = $_configuration['single_database'];
  1472. $dbNameForm = $_configuration['main_database'];
  1473. $dbStatsForm = $_configuration['statistics_database'];
  1474. $dbScormForm = $_configuration['scorm_database'];
  1475. $dbUserForm = $_configuration['user_personal_database'];
  1476. $dbScormExists = true;
  1477. }
  1478. if (empty($dbScormForm)) {
  1479. if ($singleDbForm) {
  1480. $dbScormForm = $dbNameForm;
  1481. } else {
  1482. $dbScormForm = $dbPrefixForm.'scorm';
  1483. $dbScormExists = false;
  1484. }
  1485. }
  1486. if (empty($dbUserForm)) {
  1487. $dbUserForm = $singleDbForm ? $dbNameForm : $dbPrefixForm.'chamilo_user';
  1488. }
  1489. echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>';
  1490. echo '<div class="RequirementContent">';
  1491. echo get_lang('DBSettingUpgradeIntro');
  1492. echo '</div>';
  1493. } else {
  1494. if (empty($dbPrefixForm)) { //make sure there is a default value for db prefix
  1495. $dbPrefixForm = '';
  1496. }
  1497. echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>';
  1498. echo '<div class="RequirementContent">';
  1499. echo get_lang('DBSettingIntro');
  1500. echo '</div>';
  1501. }
  1502. ?>
  1503. </td>
  1504. </tr>
  1505. <tr>
  1506. <td>
  1507. <table class="data_table_no_border">
  1508. <tr>
  1509. <td width="40%"><?php echo get_lang('DBHost'); ?> </td>
  1510. <?php if ($installType == 'update'): ?>
  1511. <td width="30%"><input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?></td>
  1512. <td width="30%">&nbsp;</td>
  1513. <?php else: ?>
  1514. <td width="30%"><input type="text" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /></td>
  1515. <td width="30%"><?php echo get_lang('EG').' localhost'; ?></td>
  1516. <?php endif; ?>
  1517. </tr>
  1518. <tr>
  1519. <?php
  1520. //database user username
  1521. $example_login = get_lang('EG').' root';
  1522. display_database_parameter($installType, get_lang('DBLogin'), 'dbUsernameForm', $dbUsernameForm, $example_login);
  1523. //database user password
  1524. $example_password = get_lang('EG').' '.api_generate_password();
  1525. display_database_parameter($installType, get_lang('DBPassword'), 'dbPassForm', $dbPassForm, $example_password);
  1526. //Fields for the four standard Chamilo databases
  1527. if ($installType != INSTALL_TYPE_UPDATE) {
  1528. /*echo '<tr><td colspan="3">';
  1529. echo '<a href="#;" onclick="javascript:show_hide_option();" id="optionalparameters">
  1530. <img style="vertical-align:middle;" src="../img/div_show.gif" alt="show-hide" /> '.get_lang('OptionalParameters').'</a>';
  1531. echo '</td></tr>';*/
  1532. }
  1533. ?>
  1534. <input type="hidden" name="enableTrackingForm" value="1" />
  1535. <?php
  1536. $style = '';
  1537. if ($installType == INSTALL_TYPE_UPDATE) {
  1538. $style = '';
  1539. }
  1540. //Database Name
  1541. display_database_parameter($installType, get_lang('MainDB'), 'dbNameForm', $dbNameForm, '&nbsp;', null, 'id="optional_param1" '.$style);
  1542. //Only for updates we show this options
  1543. if ($installType == INSTALL_TYPE_UPDATE) {
  1544. display_database_parameter($installType, get_lang('StatDB'), 'dbStatsForm', $dbStatsForm, '&nbsp;', null, 'id="optional_param2" '.$style);
  1545. if ($installType == INSTALL_TYPE_UPDATE && in_array($_POST['old_version'], $update_from_version_6)) {
  1546. display_database_parameter($installType, get_lang('ScormDB'), 'dbScormForm', $dbScormForm, '&nbsp;', null, 'id="optional_param3" '.$style);
  1547. }
  1548. display_database_parameter($installType, get_lang('UserDB'), 'dbUserForm', $dbUserForm, '&nbsp;', null, 'id="optional_param4" '.$style);
  1549. }
  1550. //Database Prefix
  1551. //display_database_parameter($installType, get_lang('DbPrefixForm'), 'dbPrefixForm', $dbPrefixForm, '', null, 'id="optional_param5" '.$style); //get_lang('DbPrefixCom')
  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. Database host: <strong><?php echo Database::get_host_info(); ?></strong><br />
  1575. Database server version: <strong><?php echo Database::get_server_info(); ?></strong><br />
  1576. Database client version: <strong><?php echo Database::get_client_info(); ?></strong><br />
  1577. Database protocol version: <strong><?php echo Database::get_proto_info(); ?></strong>
  1578. <div style="clear:both;"></div>
  1579. </div>
  1580. </td>
  1581. <?php else: ?>
  1582. <td colspan="2">
  1583. <div style="float:left;" class="error-message">
  1584. <div style="float:left;">
  1585. <strong>Database error: <?php echo Database::errno(); ?></strong><br />
  1586. <?php echo Database::error().'<br />'; ?>
  1587. <strong><?php echo get_lang('Details').': '. get_lang('FailedConectionDatabase'); ?></strong><br />
  1588. </div>
  1589. </div>
  1590. </td>
  1591. <?php endif; ?>
  1592. </tr>
  1593. <tr>
  1594. <td><button type="submit" name="step2" class="back" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button></td>
  1595. <td>&nbsp;</td>
  1596. <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>
  1597. </tr>
  1598. </table>
  1599. <?php
  1600. }
  1601. /**
  1602. * Displays a parameter in a table row.
  1603. * Used by the display_configuration_settings_form function.
  1604. */
  1605. function display_configuration_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $display_when_update = 'true') {
  1606. echo "<tr>\n";
  1607. echo "<td>$parameter_name&nbsp;&nbsp;</td>\n";
  1608. if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update) {
  1609. echo '<td><input type="hidden" name="'.$form_field_name.'" value="'.api_htmlentities($parameter_value, ENT_QUOTES).'" />'.$parameter_value."</td>\n";
  1610. } else {
  1611. 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";
  1612. }
  1613. echo "</tr>\n";
  1614. }
  1615. /**
  1616. * Displays step 4 of the installation - configuration settings about Chamilo itself.
  1617. */
  1618. function display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $allowSelfRegProf, $loginForm, $passForm) {
  1619. if ($installType != 'update' && empty($languageForm)) {
  1620. $languageForm = $_SESSION['install_language'];
  1621. }
  1622. echo '<div class="RequirementHeading">';
  1623. echo "<h2>" . display_step_sequence() . get_lang("CfgSetting") . "</h2>";
  1624. echo '</div>';
  1625. echo '<div class="RequirementContent">';
  1626. echo '<p>'.get_lang('ConfigSettingsInfo').' <strong>main/inc/conf/configuration.php</strong></p>';
  1627. echo '</div>';
  1628. echo "</td></tr> <tr><td>";
  1629. echo '<table class="data_table_no_border">';
  1630. //First parameter: language
  1631. echo "<tr>";
  1632. echo '<td>'.get_lang('MainLang')."&nbsp;&nbsp;</td>";
  1633. if ($installType == 'update') {
  1634. echo '<td><input type="hidden" name="languageForm" value="'.api_htmlentities($languageForm, ENT_QUOTES).'" />'.$languageForm."</td>";
  1635. } else { // new installation
  1636. echo '<td>';
  1637. display_language_selection_box('languageForm', $languageForm);
  1638. echo "</td>\n";
  1639. }
  1640. echo "</tr>\n";
  1641. //Second parameter: Chamilo URL
  1642. echo "<tr>\n";
  1643. echo '<td>'.get_lang('ChamiloURL').' (<font color="red">'.get_lang('ThisFieldIsRequired')."</font>)&nbsp;&nbsp;</td>";
  1644. if ($installType == 'update') {
  1645. echo '<td>'.api_htmlentities($urlForm, ENT_QUOTES)."</td>\n";
  1646. } else {
  1647. echo '<td><input type="text" size="40" maxlength="100" name="urlForm" value="'.api_htmlentities($urlForm, ENT_QUOTES).'" />'."</td>";
  1648. }
  1649. echo "</tr>";
  1650. //Parameter 3: administrator's email
  1651. display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm);
  1652. //Parameters 4 and 5: administrator's names
  1653. if (api_is_western_name_order()) {
  1654. display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName);
  1655. display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName);
  1656. } else {
  1657. display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName);
  1658. display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName);
  1659. }
  1660. //Parameter 6: administrator's telephone
  1661. display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm);
  1662. //Parameter 7: administrator's login
  1663. display_configuration_parameter($installType, get_lang('AdminLogin'), 'loginForm', $loginForm, $installType == 'update');
  1664. //Parameter 8: administrator's password
  1665. if ($installType != 'update') {
  1666. display_configuration_parameter($installType, get_lang('AdminPass'), 'passForm', $passForm, false);
  1667. }
  1668. //Parameter 9: campus name
  1669. display_configuration_parameter($installType, get_lang('CampusName'), 'campusForm', $campusForm);
  1670. //Parameter 10: institute (short) name
  1671. display_configuration_parameter($installType, get_lang('InstituteShortName'), 'institutionForm', $institutionForm);
  1672. //Parameter 11: institute (short) name
  1673. display_configuration_parameter($installType, get_lang('InstituteURL'), 'institutionUrlForm', $institutionUrlForm);
  1674. /*
  1675. //old method
  1676. <tr>
  1677. <td><?php echo get_lang('EncryptUserPass'); ?> :</td>
  1678. <?php if($installType == 'update'): ?>
  1679. <td><input type="hidden" name="encryptPassForm" value="<?php echo $encryptPassForm; ?>" /><?php echo $encryptPassForm? get_lang('Yes') : get_lang('No'); ?></td>
  1680. <?php else: ?>
  1681. <td>
  1682. <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>
  1683. <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>
  1684. </td>
  1685. <?php endif; ?>
  1686. </tr>
  1687. */
  1688. ?>
  1689. <tr>
  1690. <td><?php echo get_lang("EncryptMethodUserPass"); ?> :</td>
  1691. <?php if ($installType == 'update') { ?>
  1692. <td><input type="hidden" name="encryptPassForm" value="<?php echo $encryptPassForm; ?>" /><?php echo $encryptPassForm; ?></td>
  1693. <?php } else { ?>
  1694. <td>
  1695. <input class="checkbox" type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" <?php echo ($encryptPassForm == 'sha1') ? 'checked="checked" ': ''; ?>/> <label for="encryptPass1"><?php echo 'sha1'; ?></label>
  1696. <input class="checkbox" type="radio" name="encryptPassForm" value="md5" id="encryptPass0" <?php echo $encryptPassForm == 1 ? 'checked="checked" ' : ''; ?>/> <label for="encryptPass0"><?php echo 'md5'; ?></label>
  1697. <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>
  1698. </td>
  1699. <?php } ?>
  1700. </tr>
  1701. <tr>
  1702. <td><?php echo get_lang('AllowSelfReg'); ?> :</td>
  1703. <?php if ($installType == 'update'): ?>
  1704. <td><input type="hidden" name="allowSelfReg" value="<?php echo $allowSelfReg; ?>" /><?php echo $allowSelfReg ? get_lang('Yes') : get_lang('No'); ?></td>
  1705. <?php else: ?>
  1706. <td>
  1707. <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>
  1708. <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>
  1709. </td>
  1710. <?php endif; ?>
  1711. </tr>
  1712. <tr>
  1713. <td><?php echo get_lang('AllowSelfRegProf'); ?> :</td>
  1714. <?php if ($installType == 'update'): ?>
  1715. <td><input type="hidden" name="allowSelfRegProf" value="<?php echo $allowSelfRegProf; ?>" /><?php echo $allowSelfRegProf? get_lang('Yes') : get_lang('No'); ?></td>
  1716. <?php else: ?>
  1717. <td>
  1718. <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>
  1719. <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>
  1720. </td>
  1721. <?php endif; ?>
  1722. </tr>
  1723. <tr>
  1724. <td><button type="submit" class="back" name="step3" value="&lt; <?php echo get_lang('Previous'); ?>" /><?php echo get_lang('Previous'); ?></button></td>
  1725. <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>
  1726. </tr>
  1727. </table>
  1728. <?php
  1729. }
  1730. /**
  1731. * After installation is completed (step 6), this message is displayed.
  1732. */
  1733. function display_after_install_message($installType, $nbr_courses) {
  1734. ?>
  1735. <div class="RequirementHeading">
  1736. <h2><?php echo display_step_sequence() . get_lang('CfgSetting'); ?></h2>
  1737. </div>
  1738. <div class="RequirementContent">
  1739. <?php echo get_lang('FirstUseTip'); ?>
  1740. </div>
  1741. <?php
  1742. echo '<div class="warning-message">';
  1743. echo '<strong>'.get_lang('SecurityAdvice').'</strong>';
  1744. echo ': ';
  1745. printf(get_lang('ToProtectYourSiteMakeXAndYReadOnly'), 'main/inc/conf/configuration.php', 'main/install/index.php');
  1746. echo '</div>';
  1747. ?></form>
  1748. <br /><br />
  1749. <a class="a_button green" href="../../index.php"><?php echo get_lang('GoToYourNewlyCreatedPortal'); ?></a>
  1750. <?php
  1751. }
  1752. /**
  1753. * This function return countries list from array (hardcoded)
  1754. * @param bool (Optional) True for returning countries list with select html
  1755. * @return array|string countries list
  1756. */
  1757. function get_countries_list_from_array($combo = false) {
  1758. $a_countries = array(
  1759. "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan",
  1760. "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi",
  1761. "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",
  1762. "Denmark", "Djibouti", "Dominica", "Dominican Republic",
  1763. "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia",
  1764. "Fiji", "Finland", "France",
  1765. "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana",
  1766. "Haiti", "Honduras", "Hungary",
  1767. "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy",
  1768. "Jamaica", "Japan", "Jordan",
  1769. "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan",
  1770. "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg",
  1771. "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar",
  1772. "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway",
  1773. "Oman",
  1774. "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland","Portugal",
  1775. "Qatar",
  1776. "Romania", "Russia", "Rwanda",
  1777. "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",
  1778. "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu",
  1779. "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan",
  1780. "Vanuatu", "Vatican City", "Venezuela", "Vietnam",
  1781. "Yemen",
  1782. "Zambia", "Zimbabwe"
  1783. );
  1784. $country_select = '';
  1785. if ($combo) {
  1786. $country_select = '<select id="country" name="country">';
  1787. $country_select .= '<option value="">--- '.get_lang('SelectOne').' ---</option>';
  1788. foreach ($a_countries as $country) {
  1789. $country_select .= '<option value="'.$country.'">'.$country.'</option>';
  1790. }
  1791. $country_select .= '</select>';
  1792. return $country_select;
  1793. }
  1794. return $a_countries;
  1795. }