From 99484b1618624e7368d1fa6719981da80932fb14 Mon Sep 17 00:00:00 2001 From: Diego Escalante Urrelo Date: Thu, 20 Mar 2014 21:25:13 -0500 Subject: [PATCH 1/3] install: Improve GPL display Use
 to display the GPL license instead of a hacked 

+
From c74ca5f484518866da96c5c72650120d110f0b8f Mon Sep 17 00:00:00 2001 From: Diego Escalante Urrelo Date: Thu, 20 Mar 2014 22:05:54 -0500 Subject: [PATCH 2/3] install.lib.php: Fix whitespace and indentation --- main/install/install.lib.php | 375 +++++++++++++++++------------------ 1 file changed, 187 insertions(+), 188 deletions(-) diff --git a/main/install/install.lib.php b/main/install/install.lib.php index f058ba6aab..f6f63b193a 100755 --- a/main/install/install.lib.php +++ b/main/install/install.lib.php @@ -38,7 +38,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']); @@ -89,7 +89,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'); } } @@ -102,7 +102,7 @@ function check_php_setting_exists($php_setting) { return ini_get($php_setting); } return false; -} +} /** @@ -236,9 +236,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'); } } } @@ -319,8 +319,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; @@ -453,7 +453,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 @@ -623,27 +623,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. @@ -652,10 +652,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. } @@ -690,7 +690,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); } @@ -699,7 +699,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); } @@ -719,7 +719,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); @@ -728,12 +728,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); }*/ } } @@ -1060,7 +1060,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').'
'; } @@ -1068,12 +1068,12 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u // SERVER REQUIREMENTS echo '

'.get_lang('ServerRequirements').'

'; - + $timezone = check_php_setting_exists("date.timezone"); if (!$timezone) { echo "
".Display::return_icon('warning.png',get_lang('Warning'),'',ICON_SIZE_MEDIUM).get_lang("DateTimezoneSettingNotSet")."
"; } - + echo '
'.get_lang('ServerRequirementsInfo').'
'; echo '
'; echo ' @@ -1135,7 +1135,7 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u - + @@ -1211,7 +1211,7 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u - + @@ -1225,56 +1225,56 @@ 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.php'); @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; $file_course_test_was_created = false; - if (is_dir($course_dir)) { + if (is_dir($course_dir)) { foreach ($perms_fil as $perm) { if ($file_course_test_was_created == true) { break; } $r = @touch($course_dir.'/test.php',$perm); - if ($r === true) { + if ($r === true) { $fil_perm_verified = $perm; if (check_course_script_interpretation($course_dir, $course_attempt_name, 'test.php')) { $file_course_test_was_created = true; } } } - } - + } + @unlink($course_dir.'/test.php'); @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 && $file_course_test_was_created == true) ? Display::label(get_lang('Yes'), 'success') : Display::label(get_lang('No'), 'warning'); echo '
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).'Maximum post size '.compare_setting_values(ini_get('post_max_size'), REQUIRED_MIN_POST_MAX_SIZE).'
Memory Limit
@@ -1297,19 +1297,19 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u - + - + - + - + @@ -1365,7 +1365,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(); @@ -1400,11 +1400,11 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u $notwritable[] = $checked_writable; @chmod($checked_writable, $perm); } - + if ($course_test_was_created == false || $file_course_test_was_created == false) { $error = true; } - + $checked_writable = api_get_path(SYS_PATH).'home/'; if (!is_writable($checked_writable)) { @@ -1424,17 +1424,15 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u if (count($notwritable) > 0) { $error = true; echo '
'; - echo '

'.get_lang('Warning').'

'; - printf(get_lang('NoWritePermissionPleaseReadInstallGuide'), ' - ', ' '); - echo '
'; - + echo '

'.get_lang('Warning').'

'; + printf(get_lang('NoWritePermissionPleaseReadInstallGuide'), '
+ ', ''); + echo ''; echo '
    '; foreach ($notwritable as $value) { echo '
  • '.$value.'
  • '; } echo '
'; - } // Check wether a Chamilo configuration file already exists. @@ -1479,49 +1477,51 @@ function display_license_agreement() { echo ''; ?>
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/').'
- - + - - -
+
- +

+ +


+ - - - - + + + +
- - - -
+ + + +
+ + -
- - -  <?php echo get_lang('Hide') ?>  - - -
- +
+ + +  <?php echo get_lang('Hide') ?>  + + +
+
-
+
-


-
-
+


+
+
+
-
+
@@ -1590,7 +1590,7 @@ function get_contact_registration_form() {
- +
*'.get_lang('CompanyCountry').'
'.get_countries_list_from_array(true).'
@@ -1621,7 +1621,7 @@ function get_contact_registration_form() {
- +
'.get_lang('HaveYouThePowerToTakeFinancialDecisions').'
@@ -1637,7 +1637,7 @@ function get_contact_registration_form() {
 
*'.get_lang('FieldRequired').'
-
+
'; return $html; @@ -1658,7 +1658,7 @@ return $html; function display_database_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $extra_notice, $display_when_update = true, $tr_attribute = '') { echo ""; echo "$parameter_name  "; - + if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update) { echo ''.$parameter_value.""; } else { @@ -1668,12 +1668,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 ''.api_htmlentities($parameter_value).""; + echo ''.api_htmlentities($parameter_value).""; } else { echo ''.""; echo "$extra_notice"; } - + } echo ""; } @@ -1689,31 +1689,31 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo global $_configuration, $update_from_version_6; 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'); + $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'); - $dbScormExists = true; + $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'); + $dbScormExists = true; } else { - $dbHostForm = $_configuration['db_host']; - $dbUsernameForm = $_configuration['db_user']; - $dbPassForm = $_configuration['db_password']; - $dbPrefixForm = $_configuration['db_prefix']; + $dbHostForm = $_configuration['db_host']; + $dbUsernameForm = $_configuration['db_user']; + $dbPassForm = $_configuration['db_password']; + $dbPrefixForm = $_configuration['db_prefix']; $enableTrackingForm = $_configuration['tracking_enabled']; - $singleDbForm = $_configuration['single_database']; - $dbNameForm = $_configuration['main_database']; - $dbStatsForm = $_configuration['statistics_database']; - $dbScormForm = $_configuration['scorm_database']; - $dbUserForm = $_configuration['user_personal_database']; - $dbScormExists = true; + $singleDbForm = $_configuration['single_database']; + $dbNameForm = $_configuration['main_database']; + $dbStatsForm = $_configuration['statistics_database']; + $dbScormForm = $_configuration['scorm_database']; + $dbUserForm = $_configuration['user_personal_database']; + $dbScormExists = true; } if (empty($dbScormForm)) { @@ -1724,7 +1724,7 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo $dbScormExists = false; } } - + if (empty($dbUserForm)) { $dbUserForm = $singleDbForm ? $dbNameForm : $dbPrefixForm.'chamilo_user'; } @@ -1739,13 +1739,13 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo echo '

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

'; echo '
'; echo get_lang('DBSettingIntro'); - echo '
'; + echo '
'; } - ?> + ?> - + @@ -1758,7 +1758,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); + 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); } ?> @@ -1797,43 +1797,43 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo - + - + @@ -1862,11 +1861,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:
@@ -1841,15 +1841,14 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
-
+

- Database error:
- '; ?> - + Database error:
+ '; ?>
  - + - +
@@ -1901,20 +1900,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); @@ -1923,21 +1922,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 '"; @@ -1950,8 +1949,8 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo echo "\n"; } echo "\n"; - - + + //Second parameter: Chamilo URL echo ""; echo '"; @@ -1984,15 +1983,15 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo - - @@ -2023,12 +2023,12 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
'.get_lang('MainLang')."  
'.get_lang('ChamiloURL').' ('.get_lang('ThisFieldIsRequired').")  
-
@@ -2004,11 +2004,11 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
-
-