install.lib.php 93 KB

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