diff --git a/main/install/install.lib.php b/main/install/install.lib.php index 0f0e7ddf0b..9e9b0bcd63 100755 --- a/main/install/install.lib.php +++ b/main/install/install.lib.php @@ -39,7 +39,7 @@ function is_already_installed_system() { return false; // Configuration file does not exist, install the system. } require $current_config_file; - + $current_version = null; if (isset($_configuration['dokeos_version'])) { $current_version = trim($_configuration['dokeos_version']); @@ -90,7 +90,7 @@ function check_php_setting($php_setting, $recommended_value, $return_success = f if ($current_php_value == $recommended_value) { return Display::label($current_php_value.' '.$return_success, 'success'); } else { - return Display::label($current_php_value.' '.$return_success, 'important'); + return Display::label($current_php_value.' '.$return_success, 'important'); } } @@ -225,9 +225,9 @@ function check_writable($folder, $suggestion = false) { return Display::label(get_lang('Writable'), 'success'); } else { if ($suggestion) { - return Display::label(get_lang('NotWritable'), 'info'); + return Display::label(get_lang('NotWritable'), 'info'); } else { - return Display::label(get_lang('NotWritable'), 'important'); + return Display::label(get_lang('NotWritable'), 'important'); } } } @@ -308,8 +308,8 @@ function write_system_config_file($path) { $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['{COURSE_TABLE_PREFIX}'] = ($singleDbForm ? 'crs_' : ''); + $config['{DATABASE_GLUE}'] = ($singleDbForm ? '_' : '`.`'); $config['{DATABASE_PREFIX}'] = ''; $config['{DATABASE_MAIN}'] = $dbNameForm; $config['{DATABASE_STATS}'] = $dbNameForm; @@ -442,7 +442,7 @@ function get_config_param($param, $updatePath = '') { } if (file_exists($updatePath.$updateFromConfigFile) && !is_dir($updatePath.$updateFromConfigFile)) { - + // The parameter was not found among the global variables, so look into the old configuration file. // Make sure the installedVersion file is read first so it is overwritten @@ -612,27 +612,27 @@ function database_server_connect() { /** * Database exists for the MYSQL user * @param type $database_name - * @return boolean + * @return boolean */ -function database_exists($database_name) { +function database_exists($database_name) { if (empty($database_name)) { return false; - } - $select_database = @Database::select_db($database_name); - $show_database = false; - $sql = "SHOW DATABASES LIKE '".addslashes($database_name)."'"; + } + $select_database = @Database::select_db($database_name); + $show_database = false; + $sql = "SHOW DATABASES LIKE '".addslashes($database_name)."'"; $result = @Database::query($sql); if (Database::num_rows($result)) { $show_database = true; - } + } return $select_database || $show_database; } /** - * In step 3. Tests establishing connection to the database server. - * If it's a single database environment the function checks if the database exist. - * If the database doesn't exist we check the creation permissions. - * + * In step 3. Tests establishing connection to the database server. + * If it's a single database environment the function checks if the database exist. + * If the database doesn't exist we check the creation permissions. + * * @return int 1 when there is no problem; * 0 when a new database is impossible to be created, then the single/multiple database configuration is impossible too * -1 when there is no connection established. @@ -641,10 +641,10 @@ function test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbFor $dbConnect = -1; //Checking user credentials if (@Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)) !== false) { - $dbConnect = 1; + $dbConnect = 1; } else { $dbConnect = -1; - } + } 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. } @@ -679,7 +679,7 @@ function load_main_database($installation_settings, $db_script = '') { $sql_text = file_get_contents($db_script); } } else { - $db_script = api_get_path(SYS_CODE_PATH).'install/'.SYSTEM_MAIN_DATABASE_FILE; + $db_script = api_get_path(SYS_CODE_PATH).'install/'.SYSTEM_MAIN_DATABASE_FILE; if (file_exists($db_script)) { $sql_text = file_get_contents($db_script); } @@ -688,7 +688,7 @@ function load_main_database($installation_settings, $db_script = '') { //replace symbolic parameters with user-specified values foreach ($installation_settings as $key => $value) { $sql_text = str_replace($key, Database::escape_string($value), $sql_text); - } + } parse_sql_queries($sql_text); } @@ -708,7 +708,7 @@ function parse_sql_queries($sql_text) { //split in array of sql strings $sql_instructions = array(); - split_sql_file($sql_instructions, $sql_text); + split_sql_file($sql_instructions, $sql_text); //execute the sql instructions $count = count($sql_instructions); @@ -717,12 +717,12 @@ function parse_sql_queries($sql_text) { Database::query($this_sql_query); //UTF8 fix see #5678 /* - if (strpos(strtolower($this_sql_query), 'create table') === false) { + if (strpos(strtolower($this_sql_query), 'create table') === false) { Database::query($this_sql_query); } else { - //$this_sql_query .= substr($this_sql_query, strlen($this_sql_query), strlen($this_sql_query)-1); - $this_sql_query .= ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci '; - Database::query($this_sql_query); + //$this_sql_query .= substr($this_sql_query, strlen($this_sql_query), strlen($this_sql_query)-1); + $this_sql_query .= ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci '; + Database::query($this_sql_query); }*/ } } @@ -1049,7 +1049,7 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u echo '
'; echo ''.get_lang('ReadThoroughly').'
'; echo get_lang('MoreDetails').' '.get_lang('ReadTheInstallGuide').'.
'."\n"; - + if ($installType == 'update') { echo get_lang('IfYouPlanToUpgradeFromOlderVersionYouMightWantToHaveAlookAtTheChangelog').'
'; } @@ -1118,7 +1118,7 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u Xapian '.get_lang('support').' ('.get_lang('Optional').') '.check_extension('xapian', get_lang('Yes'), get_lang('No'), true).' - + cURL '.get_lang('support').' ('.get_lang('Optional').') '.check_extension('curl', get_lang('Yes'), get_lang('No'), true).' @@ -1194,7 +1194,7 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u Maximum post size '.Display::label('>= '.REQUIRED_MIN_POST_MAX_SIZE.'M', 'success').' '.compare_setting_values(ini_get('post_max_size'), REQUIRED_MIN_POST_MAX_SIZE).' - + Memory Limit '.Display::label('>= '.REQUIRED_MIN_MEMORY_LIMIT.'M', 'success').' @@ -1208,50 +1208,50 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u echo '

'.get_lang('DirectoryAndFilePermissions').'

'; echo '
'.get_lang('DirectoryAndFilePermissionsInfo').'
'; echo '
'; - + $course_attempt_name = '__XxTestxX__'; - $course_dir = api_get_path(SYS_COURSE_PATH).$course_attempt_name; - + $course_dir = api_get_path(SYS_COURSE_PATH).$course_attempt_name; + //Just in case @unlink($course_dir.'/test.txt'); @rmdir($course_dir); - + $perms_dir = array(0777, 0755, 0775, 0770, 0750, 0700); $perms_fil = array(0666, 0644, 0664, 0660, 0640, 0600); - + $course_test_was_created = false; - + $dir_perm_verified = 0777; foreach ($perms_dir as $perm) { - $r = @mkdir($course_dir, $perm); - if ($r === true) { + $r = @mkdir($course_dir, $perm); + if ($r === true) { $dir_perm_verified = $perm; $course_test_was_created = true; break; } } - + $fil_perm_verified = 0666; - - if (is_dir($course_dir)) { + + if (is_dir($course_dir)) { foreach ($perms_fil as $perm) { $r = @touch($course_dir.'/test.txt',$perm); - if ($r === true) { + if ($r === true) { $fil_perm_verified = $perm; break; } } - } - + } + @unlink($course_dir.'/test.txt'); @rmdir($course_dir); - + $_SESSION['permissions_for_new_directories'] = $_setting['permissions_for_new_directories'] = $dir_perm_verified; $_SESSION['permissions_for_new_files'] = $_setting['permissions_for_new_files'] = $fil_perm_verified; - + $dir_perm = Display::label('0'.decoct($dir_perm_verified), 'info'); $file_perm = Display::label('0'.decoct($fil_perm_verified), 'info'); - + $course_test_was_created = $course_test_was_created == true ? Display::label(get_lang('Yes'), 'success') : Display::label(get_lang('No'), 'warning'); echo ' @@ -1274,19 +1274,19 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u - + - + - + - + @@ -1342,7 +1342,7 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u } else { $error = false; // First, attempt to set writing permissions if we don't have them yet - $perm = api_get_permissions_for_new_directories(); + $perm = api_get_permissions_for_new_directories(); $perm_file = api_get_permissions_for_new_files(); $notwritable = array(); @@ -1377,11 +1377,11 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u $notwritable[] = $checked_writable; @chmod($checked_writable, $perm); } - + if ($course_test_was_created == false) { $error = true; } - + $checked_writable = api_get_path(SYS_PATH).'home/'; if (!is_writable($checked_writable)) { @@ -1405,13 +1405,13 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u printf(get_lang('NoWritePermissionPleaseReadInstallGuide'), '', ''); echo ''; - + echo '
    '; foreach ($notwritable as $value) { echo '
  • '.$value.'
  • '; } echo '
'; - + } // Check wether a Chamilo configuration file already exists. @@ -1464,7 +1464,7 @@ function display_license_agreement() {
"; echo ""; - + if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update) { echo '"; } else { @@ -1648,12 +1648,12 @@ function display_database_parameter($install_type, $parameter_name, $form_field_ $maxlength = $form_field_name == 'dbPrefixForm' ? '15' : MAX_FORM_FIELD_LENGTH; if ($install_type == INSTALL_TYPE_UPDATE) { echo ''; - echo '"; + echo '"; } else { echo '"; echo ""; } - + } echo ""; } @@ -1670,14 +1670,14 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo if (in_array($_POST['old_version'], $update_from_version_6)) { $dbHostForm = get_config_param('dbHost'); - + $dbUsernameForm = get_config_param('dbLogin'); $dbPassForm = get_config_param('dbPass'); $dbPrefixForm = get_config_param('dbNamePrefix'); $enableTrackingForm = get_config_param('is_trackingEnabled'); $singleDbForm = get_config_param('singleDbEnabled'); $dbHostForm = get_config_param('mainDbName'); - + $dbStatsForm = get_config_param('statsDbName'); $dbScormForm = get_config_param('scormDbName'); $dbUserForm = get_config_param('user_personal_database'); @@ -1704,7 +1704,7 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo $dbScormExists = false; } } - + if (empty($dbUserForm)) { $dbUserForm = $singleDbForm ? $dbNameForm : $dbPrefixForm.'chamilo_user'; } @@ -1721,14 +1721,14 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo echo '

' . display_step_sequence() .get_lang('DBSetting') . '

'; echo '
'; echo get_lang('DBSettingIntro'); - echo '
'; + echo ''; } - $dbConnect = test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm, $dbNameForm); - ?> + $dbConnect = test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm, $dbNameForm); + ?>
-
chamilo/courses/ '.check_writable('../courses/').'
'.get_lang('CourseTestWasCreated').' '.$course_test_was_created.'
'.get_lang('PermissionsForNewDirs').' '.$dir_perm.'
'.get_lang('PermissionsForNewFiles').' '.$file_perm.'
chamilo/home/ '.check_writable('../home/').'
-
$parameter_name  '.$parameter_value."'.api_htmlentities($parameter_value)."'.api_htmlentities($parameter_value)."'."$extra_notice
+ @@ -1741,7 +1741,7 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo - '; - - $style = ''; + + $style = ''; if ($installType == INSTALL_TYPE_UPDATE) { $style = ''; - } - + } + //Database Name fix replace weird chars if ($installType != INSTALL_TYPE_UPDATE) { $dbNameForm = str_replace(array('-','*', '$', ' ', '.'), '', $dbNameForm); - $dbNameForm = replace_dangerous_char($dbNameForm); + $dbNameForm = replace_dangerous_char($dbNameForm); } - + display_database_parameter($installType, get_lang('MainDB'), 'dbNameForm', $dbNameForm, ' ', null, 'id="optional_param1" '.$style); - + //Only for updates we show this options if ($installType == INSTALL_TYPE_UPDATE) { display_database_parameter($installType, get_lang('StatDB'), 'dbStatsForm', $dbStatsForm, ' ', null, 'id="optional_param2" '.$style); if ($installType == INSTALL_TYPE_UPDATE && in_array($_POST['old_version'], $update_from_version_6)) { display_database_parameter($installType, get_lang('ScormDB'), 'dbScormForm', $dbScormForm, ' ', null, 'id="optional_param3" '.$style); - } + } display_database_parameter($installType, get_lang('UserDB'), 'dbUserForm', $dbUserForm, ' ', null, 'id="optional_param4" '.$style); } ?> @@ -1780,42 +1780,42 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo - + - + @@ -1844,11 +1844,11 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
- + '.get_lang('ADatabaseWithTheSameNameAlreadyExists').''; - } else { + } else { if ($dbConnect == -1) { - $database_exists_text = '
'.sprintf(get_lang('UserXCantHaveAccessInTheDatabaseX'), $dbUsernameForm, $dbNameForm).'
'; + $database_exists_text = '
'.sprintf(get_lang('UserXCantHaveAccessInTheDatabaseX'), $dbUsernameForm, $dbNameForm).'
'; } else { //Try to create the database - $user_can_create_databases = false; + $user_can_create_databases = false; $multipleDbCheck = @Database::query("CREATE DATABASE ".mysql_real_escape_string($dbNameForm)); if ($multipleDbCheck !== false) { - $multipleDbCheck = @Database::query("DROP DATABASE IF EXISTS ".mysql_real_escape_string($dbNameForm)); + $multipleDbCheck = @Database::query("DROP DATABASE IF EXISTS ".mysql_real_escape_string($dbNameForm)); $user_can_create_databases = true; - } + } if ($user_can_create_databases) { $database_exists_text = '
'.sprintf(get_lang('DatabaseXWillBeCreated'), $dbNameForm, $dbUsernameForm).'
'; } else { $dbConnect = 0; - $database_exists_text = '
'.sprintf(get_lang('DatabaseXCantBeCreatedUserXDoestHaveEnoughPermissions'), $dbNameForm, $dbUsernameForm).'
'; + $database_exists_text = '
'.sprintf(get_lang('DatabaseXCantBeCreatedUserXDoestHaveEnoughPermissions'), $dbNameForm, $dbUsernameForm).'
'; } - } - } - + } + } + if ($dbConnect == 1): ?>
-
+
Database host:
Database server version:
Database client version:
@@ -1823,15 +1823,15 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
-
+

Database error:
'; ?> - +
  - + - +
@@ -1883,20 +1883,20 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo echo '
'; echo '

'.get_lang('ConfigSettingsInfo').' main/inc/conf/configuration.php

'; echo '
'; - + echo '
'; echo ''.get_lang('Administrator').''; echo ''; - + //Parameter 1: administrator's login - + display_configuration_parameter($installType, get_lang('AdminLogin'), 'loginForm', $loginForm, $installType == 'update'); - + //Parameter 2: administrator's password if ($installType != 'update') { display_configuration_parameter($installType, get_lang('AdminPass'), 'passForm', $passForm, false); - } - + } + //Parameters 3 and 4: administrator's names if (api_is_western_name_order()) { display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName); @@ -1905,21 +1905,21 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName); display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName); } - + //Parameter 3: administrator's email display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm); //Parameter 6: administrator's telephone display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm); - - echo '
'; + + echo '
'; echo ''; - + echo '
'; echo ''.get_lang('Platform').''; - - echo ''; - + + echo '
'; + //First parameter: language echo ""; echo '"; @@ -1932,8 +1932,8 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo echo "\n"; } echo "\n"; - - + + //Second parameter: Chamilo URL echo ""; echo '"; @@ -1966,15 +1966,15 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo - -
'.get_lang('MainLang')."  
'.get_lang('ChamiloURL').' ('.get_lang('ThisFieldIsRequired').")