diff --git a/main/install/install.lib.php b/main/install/install.lib.php
index dd78704f4b..f1ba6063dc 100644
--- a/main/install/install.lib.php
+++ b/main/install/install.lib.php
@@ -27,25 +27,25 @@ define('SYSTEM_CONFIG_FILENAME', 'configuration.dist.php');
* @author Ivan Tcholakov, 2010;
*/
function is_already_installed_system() {
- global $new_version;
+ global $new_version;
- if (empty($new_version)) {
- return true; // Must be initialized.
- }
+ if (empty($new_version)) {
+ return true; // Must be initialized.
+ }
- $current_config_file = api_get_path(CONFIGURATION_PATH).'configuration.php';
- if (!file_exists($current_config_file)) {
- return false; // Configuration file does not exist, install the system.
- }
- require $current_config_file;
+ $current_config_file = api_get_path(CONFIGURATION_PATH).'configuration.php';
+ if (!file_exists($current_config_file)) {
+ return false; // Configuration file does not exist, install the system.
+ }
+ require $current_config_file;
- $current_version = trim($_configuration['dokeos_version']);
- if (empty($current_version)) {
- $current_version = trim($_configuration['system_version']);
- }
+ $current_version = trim($_configuration['dokeos_version']);
+ if (empty($current_version)) {
+ $current_version = trim($_configuration['system_version']);
+ }
- // If the current version is old, upgrading is assumed, the installer goes ahead.
- return empty($current_version) ? false : version_compare($current_version, $new_version, '>=');
+ // If the current version is old, upgrading is assumed, the installer goes ahead.
+ return empty($current_version) ? false : version_compare($current_version, $new_version, '>=');
}
/**
@@ -62,15 +62,15 @@ function is_already_installed_system() {
* @version Dokeos 1.8.1, May 2007
*/
function check_extension($extension_name, $return_success = 'Yes', $return_failure = 'No', $optional = false) {
- if (extension_loaded($extension_name)) {
- return ''.$return_success.'';
- } else {
- if ($optional) {
- return ''.$return_failure.'';
- } else {
- return ''.$return_failure.'';
- }
- }
+ if (extension_loaded($extension_name)) {
+ return ''.$return_success.'';
+ } else {
+ if ($optional) {
+ return ''.$return_failure.'';
+ } else {
+ return ''.$return_failure.'';
+ }
+ }
}
/**
@@ -80,12 +80,12 @@ function check_extension($extension_name, $return_success = 'Yes', $return_failu
* @version Dokeos 1.8, august 2006
*/
function check_php_setting($php_setting, $recommended_value, $return_success = false, $return_failure = false) {
- $current_php_value = get_php_setting($php_setting);
- if ($current_php_value == $recommended_value) {
- return ''.$current_php_value.' '.$return_success.'';
- } else {
- return ''.$current_php_value.' '.$return_failure.'';
- }
+ $current_php_value = get_php_setting($php_setting);
+ if ($current_php_value == $recommended_value) {
+ return ''.$current_php_value.' '.$return_success.'';
+ } else {
+ return ''.$current_php_value.' '.$return_failure.'';
+ }
}
/**
@@ -96,7 +96,7 @@ function check_php_setting($php_setting, $recommended_value, $return_success = f
* @author Joomla
*/
function get_php_setting($val) {
- return ini_get($val) == '1' ? 'ON' : 'OFF';
+ return ini_get($val) == '1' ? 'ON' : 'OFF';
}
/**
@@ -107,19 +107,19 @@ function get_php_setting($val) {
* @author Christophe Gesché
*/
function true_false($var) {
- return $var ? 'true' : 'false';
+ return $var ? 'true' : 'false';
}
/**
* Removes memory and time limits as much as possible.
*/
function remove_memory_and_time_limits() {
- if (function_exists('ini_set')) {
- ini_set('memory_limit', -1);
- ini_set('max_execution_time', 0);
- } else {
- error_log('Update-db script: could not change memory and time limits', 0);
- }
+ if (function_exists('ini_set')) {
+ ini_set('memory_limit', -1);
+ ini_set('max_execution_time', 0);
+ } else {
+ error_log('Update-db script: could not change memory and time limits', 0);
+ }
}
/**
@@ -128,83 +128,83 @@ function remove_memory_and_time_limits() {
* @author Ivan Tcholakov, 2010
*/
function detect_browser_language() {
- static $language_index = array(
- 'ar' => 'arabic',
- 'ast' => 'asturian',
- 'bg' => 'bulgarian',
- 'bs' => 'bosnian',
- 'ca' => 'catalan',
- 'zh' => 'simpl_chinese',
- 'zh-tw' => 'trad_chinese',
- 'cs' => 'czech',
- 'da' => 'danish',
- 'prs' => 'dari',
- 'de' => 'german',
- 'el' => 'greek',
- 'en' => 'english',
- 'es' => 'spanish',
- 'eo' => 'esperanto',
- 'eu' => 'euskera',
- 'fa' => 'persian',
- 'fr' => 'french',
- 'fur' => 'friulian',
- 'gl' => 'galician',
- 'ka' => 'georgian',
- 'hr' => 'croatian',
- 'he' => 'hebrew',
- 'id' => 'indonesian',
- 'it' => 'italian',
- 'ko' => 'korean',
- 'lv' => 'latvian',
- 'lt' => 'lithuanian',
- 'mk' => 'macedonian',
- 'hu' => 'hungarian',
- 'ms' => 'malay',
- 'nl' => 'dutch',
- 'ja' => 'japanese',
- 'no' => 'norwegian',
- 'oc' => 'occitan',
- 'ps' => 'pashto',
- 'pl' => 'polish',
- 'pt' => 'portuguese',
- 'pt-br' => 'brazilian',
- 'ro' => 'romanian',
- 'qu' => 'quechua_cusco',
- 'ru' => 'russian',
- 'sk' => 'slovak',
- 'sl' => 'slovenian',
- 'sr' => 'serbian',
- 'fi' => 'finnish',
- 'sv' => 'swedish',
- 'th' => 'thai',
- 'tr' => 'turkce',
- 'uk' => 'ukrainian',
- 'vi' => 'vietnamese',
- 'sw' => 'swahili',
- 'yo' => 'yoruba'
- );
-
- $system_available_languages = & get_language_folder_list();
-
- $accept_languages = strtolower(str_replace('_', '-', $_SERVER['HTTP_ACCEPT_LANGUAGE']));
- foreach ($language_index as $code => $language) {
- if (strpos($accept_languages, $code) === 0) {
- if (!empty($system_available_languages[$language])) {
- return $language;
- }
- }
- }
-
- $user_agent = strtolower(str_replace('_', '-', $_SERVER['HTTP_USER_AGENT']));
- foreach ($language_index as $code => $language) {
- if (preg_match("/[[( ]{$code}[;,_-)]/", $user_agent)) {
- if (!empty($system_available_languages[$language])) {
- return $language;
- }
- }
- }
-
- return 'english';
+ static $language_index = array(
+ 'ar' => 'arabic',
+ 'ast' => 'asturian',
+ 'bg' => 'bulgarian',
+ 'bs' => 'bosnian',
+ 'ca' => 'catalan',
+ 'zh' => 'simpl_chinese',
+ 'zh-tw' => 'trad_chinese',
+ 'cs' => 'czech',
+ 'da' => 'danish',
+ 'prs' => 'dari',
+ 'de' => 'german',
+ 'el' => 'greek',
+ 'en' => 'english',
+ 'es' => 'spanish',
+ 'eo' => 'esperanto',
+ 'eu' => 'euskera',
+ 'fa' => 'persian',
+ 'fr' => 'french',
+ 'fur' => 'friulian',
+ 'gl' => 'galician',
+ 'ka' => 'georgian',
+ 'hr' => 'croatian',
+ 'he' => 'hebrew',
+ 'id' => 'indonesian',
+ 'it' => 'italian',
+ 'ko' => 'korean',
+ 'lv' => 'latvian',
+ 'lt' => 'lithuanian',
+ 'mk' => 'macedonian',
+ 'hu' => 'hungarian',
+ 'ms' => 'malay',
+ 'nl' => 'dutch',
+ 'ja' => 'japanese',
+ 'no' => 'norwegian',
+ 'oc' => 'occitan',
+ 'ps' => 'pashto',
+ 'pl' => 'polish',
+ 'pt' => 'portuguese',
+ 'pt-br' => 'brazilian',
+ 'ro' => 'romanian',
+ 'qu' => 'quechua_cusco',
+ 'ru' => 'russian',
+ 'sk' => 'slovak',
+ 'sl' => 'slovenian',
+ 'sr' => 'serbian',
+ 'fi' => 'finnish',
+ 'sv' => 'swedish',
+ 'th' => 'thai',
+ 'tr' => 'turkce',
+ 'uk' => 'ukrainian',
+ 'vi' => 'vietnamese',
+ 'sw' => 'swahili',
+ 'yo' => 'yoruba'
+ );
+
+ $system_available_languages = & get_language_folder_list();
+
+ $accept_languages = strtolower(str_replace('_', '-', $_SERVER['HTTP_ACCEPT_LANGUAGE']));
+ foreach ($language_index as $code => $language) {
+ if (strpos($accept_languages, $code) === 0) {
+ if (!empty($system_available_languages[$language])) {
+ return $language;
+ }
+ }
+ }
+
+ $user_agent = strtolower(str_replace('_', '-', $_SERVER['HTTP_USER_AGENT']));
+ foreach ($language_index as $code => $language) {
+ if (preg_match("/[[( ]{$code}[;,_-)]/", $user_agent)) {
+ if (!empty($system_available_languages[$language])) {
+ return $language;
+ }
+ }
+ }
+
+ return 'english';
}
@@ -214,15 +214,15 @@ function detect_browser_language() {
* This function checks if the given folder is writable
*/
function check_writable($folder, $suggestion = false) {
- if (is_writable(api_get_path(SYS_CODE_PATH).$folder)) {
- return ''.get_lang('Writable').'';
- } else {
- if ($suggestion) {
- return ''.get_lang('NotWritable').'';
- } else {
- return ''.get_lang('NotWritable').'';
- }
- }
+ if (is_writable(api_get_path(SYS_CODE_PATH).$folder)) {
+ return ''.get_lang('Writable').'';
+ } else {
+ if ($suggestion) {
+ return ''.get_lang('NotWritable').'';
+ } else {
+ return ''.get_lang('NotWritable').'';
+ }
+ }
}
/**
@@ -232,19 +232,19 @@ function check_writable($folder, $suggestion = false) {
* @return array The lines of the file returned as an array
*/
function file_to_array($filename) {
- $fp = fopen($filename, 'rb');
- $buffer = fread($fp, filesize($filename));
- fclose($fp);
- return explode('
', nl2br($buffer));
+ $fp = fopen($filename, 'rb');
+ $buffer = fread($fp, filesize($filename));
+ fclose($fp);
+ return explode('
', nl2br($buffer));
}
/**
* We assume this function is called from install scripts that reside inside the install folder.
*/
function set_file_folder_permissions() {
- @chmod('.', 0755); //set permissions on install dir
- @chmod('..', 0755); //set permissions on parent dir of install dir
- @chmod('country_data.csv.csv', 0755);
+ @chmod('.', 0755); //set permissions on install dir
+ @chmod('..', 0755); //set permissions on parent dir of install dir
+ @chmod('country_data.csv.csv', 0755);
}
/**
@@ -252,14 +252,14 @@ function set_file_folder_permissions() {
* @param string $url_append The path from your webroot to your chamilo root
*/
function write_courses_htaccess_file($url_append) {
- $content = file_get_contents(dirname(__FILE__).'/'.COURSES_HTACCESS_FILENAME);
- $content = str_replace('{CHAMILO_URL_APPEND_PATH}', $url_append, $content);
- $fp = @ fopen(api_get_path(SYS_PATH).'courses/.htaccess', 'w');
- if ($fp) {
- fwrite($fp, $content);
- return fclose($fp);
- }
- return false;
+ $content = file_get_contents(dirname(__FILE__).'/'.COURSES_HTACCESS_FILENAME);
+ $content = str_replace('{CHAMILO_URL_APPEND_PATH}', $url_append, $content);
+ $fp = @ fopen(api_get_path(SYS_PATH).'courses/.htaccess', 'w');
+ if ($fp) {
+ fwrite($fp, $content);
+ return fclose($fp);
+ }
+ return false;
}
/**
@@ -268,125 +268,125 @@ function write_courses_htaccess_file($url_append) {
*/
function write_system_config_file($path) {
- global $dbHostForm;
- global $dbUsernameForm;
- global $dbPassForm;
- global $enableTrackingForm;
- global $singleDbForm;
- global $dbPrefixForm;
- global $dbNameForm;
- global $dbStatsForm;
- global $dbScormForm;
- global $dbUserForm;
- global $urlForm;
- global $pathForm;
- global $urlAppendPath;
- global $languageForm;
- global $encryptPassForm;
- global $installType;
- global $updatePath;
- global $session_lifetime;
- global $new_version;
- global $new_version_stable;
-
- $root_sys = api_add_trailing_slash(str_replace('\\', '/', realpath($pathForm)));
- $content = file_get_contents(dirname(__FILE__).'/'.SYSTEM_CONFIG_FILENAME);
-
- $config['{DATE_GENERATED}'] = date('r');
- $config['{DATABASE_HOST}'] = $dbHostForm;
- $config['{DATABASE_USER}'] = $dbUsernameForm;
- $config['{DATABASE_PASSWORD}'] = $dbPassForm;
- $config['TRACKING_ENABLED'] = true_false($enableTrackingForm);
- $config['SINGLE_DATABASE'] = true_false($singleDbForm);
- $config['{COURSE_TABLE_PREFIX}'] = ($singleDbForm ? 'crs_' : '');
- $config['{DATABASE_GLUE}'] = ($singleDbForm ? '_' : '`.`');
- $config['{DATABASE_PREFIX}'] = $dbPrefixForm;
- $config['{DATABASE_MAIN}'] = $dbNameForm;
- $config['{DATABASE_STATS}'] = (($singleDbForm && empty($dbStatsForm)) ? $dbNameForm : $dbStatsForm);
- $config['{DATABASE_SCORM}'] = (($singleDbForm && empty($dbScormForm)) ? $dbNameForm : $dbScormForm);
- $config['{DATABASE_PERSONAL}'] =(($singleDbForm && empty($dbUserForm)) ? $dbNameForm : $dbUserForm);
- $config['{ROOT_WEB}'] = $urlForm;
- $config['{ROOT_SYS}'] = $root_sys;
- $config['{URL_APPEND_PATH}'] = $urlAppendPath;
- $config['{PLATFORM_LANGUAGE}'] = $languageForm;
- $config['{SECURITY_KEY}'] = md5(uniqid(rand().time()));
- $config['{ENCRYPT_PASSWORD}'] = $encryptPassForm;
-
- $config['SESSION_LIFETIME'] = $session_lifetime;
- $config['{NEW_VERSION}'] = $new_version;
- $config['NEW_VERSION_STABLE'] = true_false($new_version_stable);
-
- foreach ($config as $key => $value) {
- $content = str_replace($key, $value, $content);
- }
-
- $fp = @ fopen($path, 'w');
-
- if (!$fp) {
- echo 'Your script doesn\'t have write access to the config directory
- ('.str_replace('\\', '/', realpath($path)).')
- You probably do not have write access on Chamilo root directory,
- i.e. you should CHMOD 777 or 755 or 775.
- Your problems can be related on two possible causes:
-
- - Permission problems.
Try initially with chmod -R 777 and increase restrictions gradually.
- - PHP is running in Safe-Mode. If possible, try to switch it off.
-
- Read about this problem in Support Forum
- Please go back to step 5.
-
-