@ -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;
}
}
/**
@ -232,13 +232,13 @@ 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)) {
if (is_writable($folder)) {
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 '< div class = "RequirementText" > ';
echo '< strong > '.get_lang('ReadThoroughly').'< / strong > < br / > ';
echo get_lang('MoreDetails').' < a href = "../../documentation/installation_guide.html" target = "_blank" > '.get_lang('ReadTheInstallGuide').'< / a > .< br / > '."\n";
if ($installType == 'update') {
echo get_lang('IfYouPlanToUpgradeFromOlderVersionYouMightWantToHaveAlookAtTheChangelog').'< br / > ';
}
@ -1068,12 +1068,12 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u
// SERVER REQUIREMENTS
echo '< div class = "RequirementHeading" > < h2 > '.get_lang('ServerRequirements').'< / h2 > ';
$timezone = check_php_setting_exists("date.timezone");
if (!$timezone) {
echo "< div class = 'warning-message' > ".Display::return_icon('warning.png',get_lang('Warning'),'',ICON_SIZE_MEDIUM).get_lang("DateTimezoneSettingNotSet")."< / div > ";
}
echo '< div class = "RequirementText" > '.get_lang('ServerRequirementsInfo').'< / div > ';
echo '< div class = "RequirementContent" > ';
echo '< table class = "table" >
@ -1135,7 +1135,7 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u
< td class = "requirements-item" > < a href = "http://xapian.org/" target = "_blank" > Xapian< / a > '.get_lang('support').' ('.get_lang('Optional').')< / td >
< td class = "requirements-value" > '.check_extension('xapian', get_lang('Yes'), get_lang('No'), true).'< / td >
< / tr >
< tr >
< td class = "requirements-item" > < a href = "http://php.net/manual/en/book.curl.php" target = "_blank" > cURL< / a > '.get_lang('support').' ('.get_lang('Optional').')< / td >
< td class = "requirements-value" > '.check_extension('curl', get_lang('Yes'), get_lang('No'), true).'< / td >
@ -1211,7 +1211,7 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u
< td class = "requirements-item" > < a href = "http://php.net/manual/ini.core.php#ini.post-max-size" > Maximum post size< / a > < / td >
< td class = "requirements-recommended" > '.Display::label('>= '.REQUIRED_MIN_POST_MAX_SIZE.'M', 'success').'< / td >
< td class = "requirements-value" > '.compare_setting_values(ini_get('post_max_size'), REQUIRED_MIN_POST_MAX_SIZE).'< / td >
< / tr >
< / tr >
< tr >
< td class = "requirements-item" > < a href = "http://www.php.net/manual/en/ini.core.php#ini.memory-limit" > Memory Limit< / a > < / td >
< td class = "requirements-recommended" > '.Display::label('>= '.REQUIRED_MIN_MEMORY_LIMIT.'M', 'success').'< / td >
@ -1225,102 +1225,102 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u
echo '< div class = "RequirementHeading" > < h2 > '.get_lang('DirectoryAndFilePermissions').'< / h2 > ';
echo '< div class = "RequirementText" > '.get_lang('DirectoryAndFilePermissionsInfo').'< / div > ';
echo '< div class = "RequirementContent" > ';
$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 ');
$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'), 'important ');
echo '< table class = "table" >
< tr >
< td class = "requirements-item" > chamilo/main/ inc/conf/< / td >
< td class = "requirements-value" > '.check_writable('inc/conf/').'< / td >
< td class = "requirements-item" > '.api_get_path(SYS_CODE_PATH).' inc/conf/< / td >
< td class = "requirements-value" > '.check_writable(api_get_path(SYS_CODE_PATH). 'inc/conf/').'< / td >
< / tr >
< tr >
< td class = "requirements-item" > chamilo/main/ upload/users/< / td >
< td class = "requirements-value" > '.check_writable('upload/users/').'< / td >
< td class = "requirements-item" > '.api_get_path(SYS_CODE_PATH).' upload/users/< / td >
< td class = "requirements-value" > '.check_writable(api_get_path(SYS_CODE_PATH). 'upload/users/').'< / td >
< / tr >
< tr >
< td class = "requirements-item" > chamilo/main/ default_course_document/images/< / td >
< td class = "requirements-value" > '.check_writable('default_course_document/images/').'< / td >
< td class = "requirements-item" > '.api_get_path(SYS_CODE_PATH).' default_course_document/images/< / td >
< td class = "requirements-value" > '.check_writable(api_get_path(SYS_CODE_PATH). 'default_course_document/images/').'< / td >
< / tr >
< tr >
< td class = "requirements-item" > chamilo/archive/ < / td >
< td class = "requirements-value" > '.check_writable('../archive/' ).'< / td >
< td class = "requirements-item" > '.api_get_path(SYS_ARCHIVE_PATH).' < / td >
< td class = "requirements-value" > '.check_writable(api_get_path(SYS_ARCHIVE_PATH) ).'< / td >
< / tr >
< tr >
< td class = "requirements-item" > chamilo/courses/ < / td >
< td class = "requirements-value" > '.check_writable('../courses/' ).' < / td >
< / tr >
< td class = "requirements-item" > '.api_get_path(SYS_COURSE_PATH).' < / td >
< td class = "requirements-value" > '.check_writable(api_get_path(SYS_COURSE_PATH) ).' < / td >
< / tr >
< tr >
< td class = "requirements-item" > '.get_lang('CourseTestWasCreated').'< / td >
< td class = "requirements-value" > '.$course_test_was_created.' < / td >
< / tr >
< / tr >
< tr >
< td class = "requirements-item" > '.get_lang('PermissionsForNewDirs').'< / td >
< td class = "requirements-value" > '.$dir_perm.' < / td >
< / tr >
< / tr >
< tr >
< td class = "requirements-item" > '.get_lang('PermissionsForNewFiles').'< / td >
< td class = "requirements-value" > '.$file_perm.' < / td >
< / tr >
< / tr >
< tr >
< td class = "requirements-item" > chamilo/home/< / td >
< td class = "requirements-value" > '.check_writable('../ home/').'< / td >
< td class = "requirements-value" > '.check_writable(api_get_path(SYS_CODE_PATH). 'home/').'< / td >
< / tr >
< tr >
< td class = "requirements-item" > chamilo/main/css/< / td >
< td class = "requirements-value" > '.check_writable('css/', true).' ('.get_lang('SuggestionOnlyToEnableCSSUploadFeature').')< / td >
< td class = "requirements-value" > '.check_writable(api_get_path(SYS_CODE_PATH). 'css/', true).' ('.get_lang('SuggestionOnlyToEnableCSSUploadFeature').')< / td >
< / tr >
< tr >
< td class = "requirements-item" > chamilo/main/lang/< / td >
< td class = "requirements-value" > '.check_writable('lang/', true).' ('.get_lang('SuggestionOnlyToEnableSubLanguageFeature').')< / td >
< td class = "requirements-value" > '.check_writable(api_get_path(SYS_CODE_PATH). 'lang/', true).' ('.get_lang('SuggestionOnlyToEnableSubLanguageFeature').')< / td >
< / tr > '.
//'< tr >
// < td class = "requirements-item" > chamilo/searchdb/< / td >
@ -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)) {
@ -1428,13 +1428,13 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u
printf(get_lang('NoWritePermissionPleaseReadInstallGuide'), '< / font >
< a href = "../../documentation/installation_guide.html" target = "blank" > ', '< / a > < font color = "red" > ');
echo '< / div > ';
echo '< ul > ';
foreach ($notwritable as $value) {
echo '< li > '.$value.'< / li > ';
}
echo '< / ul > ';
}
// Check wether a Chamilo configuration file already exists.
@ -1487,7 +1487,7 @@ function display_license_agreement() {
< / td >
< / tr >
< tr > < td >
< label class = "checkbox" >
< label class = "checkbox" >
< input type = "checkbox" name = "accept" id = "accept_licence" value = "1" / >
<?php echo get_lang ( 'IAccept' ); ?>
< / label >
@ -1512,18 +1512,18 @@ function display_license_agreement() {
<!-- Contact information form -->
< div >
< a href = "javascript://" class = "advanced_parameters" >
< span id = "img_plus_and_minus" > < 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" /> <?php echo get_lang ( 'ContactInformation' ) ?> </ span >
< / a >
< / div >
< div id = "id_contact_form" style = "display:block" >
< div class = "normal-message" > <?php echo get_lang ( 'ContactInformationDescription' ) ?> </ div >
< div id = "contact_registration" >
< p > <?php echo get_contact_registration_form () ?> </ p >< br />
< / div >
< / div >
< / div >
<?php
}
@ -1535,9 +1535,9 @@ function display_license_agreement() {
function get_contact_registration_form() {
$html ='
< form class = "form-horizontal" >
< form class = "form-horizontal" >
< fieldset style = "width:95%;padding:15px;border:1pt solid #eee" >
< div id = "div_sent_information" > < / div >
< div id = "div_sent_information" > < / div >
< div class = "control-group" >
< label class = "control-label" > < span class = "form_required" > *< / span > '.get_lang('Name').'< / label >
< div class = "controls" > < input id = "person_name" type = "text" name = "person_name" size = "30" / > < / div >
@ -1593,7 +1593,7 @@ function get_contact_registration_form() {
< / select >
< / div >
< / div >
< div class = "control-group" >
< div class = "control-label" > < span class = "form_required" > *< / span > '.get_lang('CompanyCountry').'< / div >
< div class = "controls" > '.get_countries_list_from_array(true).'< / div >
@ -1624,7 +1624,7 @@ function get_contact_registration_form() {
< / select >
< / div >
< / div >
< div class = "control-group" >
< div class = "control-label" > '.get_lang('HaveYouThePowerToTakeFinancialDecisions').'< / div >
< div class = "controls" >
@ -1640,7 +1640,7 @@ function get_contact_registration_form() {
< div class = "control-group" >
< div class = "control-label" > < / div >
< div class = "controls" > < span class = "form_required" > *< / span > < small > '.get_lang('FieldRequired').'< / small > < / div >
< / div >
< / div >
< / fieldset > < / form > ';
return $html;
@ -1661,7 +1661,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 "< tr " . $ tr_attribute . " > ";
echo "< td > $parameter_name < / td > ";
if ($install_type == INSTALL_TYPE_UPDATE & & $display_when_update) {
echo '< td > < input type = "hidden" name = "'.$form_field_name.'" id = "'.$form_field_name.'" value = "'.api_htmlentities($parameter_value).'" / > '.$parameter_value."< / td > ";
} else {
@ -1671,12 +1671,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 '< input type = "hidden" name = "'.$form_field_name.'" id = "'.$form_field_name.'" value = "'.api_htmlentities($parameter_value).'" / > ';
echo '< td > '.api_htmlentities($parameter_value)."< / td > ";
echo '< td > '.api_htmlentities($parameter_value)."< / td > ";
} else {
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 > ";
echo "< td > $extra_notice< / td > ";
}
}
echo "< / tr > ";
}
@ -1693,14 +1693,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');
@ -1727,7 +1727,7 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
$dbScormExists = false;
}
}
if (empty($dbUserForm)) {
$dbUserForm = $singleDbForm ? $dbNameForm : $dbPrefixForm.'chamilo_user';
}
@ -1742,13 +1742,13 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
echo '< div class = "RequirementHeading" > < h2 > ' . display_step_sequence() .get_lang('DBSetting') . '< / h2 > < / div > ';
echo '< div class = "RequirementContent" > ';
echo get_lang('DBSettingIntro');
echo '< / div > ';
echo '< / div > ';
}
?>
?>
< / td >
< / tr >
< tr >
< td >
< td >
< table class = "data_table_no_border" >
< tr >
< td width = "40%" > <?php echo get_lang ( 'DBHost' ); ?> </ td >
@ -1761,7 +1761,7 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
<?php endif ; ?>
< / tr >
< tr >
<?php
<?php
//database user username
$example_login = get_lang('EG').' root';
display_database_parameter($installType, get_lang('DBLogin'), 'dbUsernameForm', $dbUsernameForm, $example_login);
@ -1771,26 +1771,26 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
display_database_parameter($installType, get_lang('DBPassword'), 'dbPassForm', $dbPassForm, $example_password);
echo '< input type = "hidden" name = "enableTrackingForm" value = "1" / > ';
$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);
}
?>
@ -1800,43 +1800,43 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
< button type = "submit" class = "btn" name = "step3" value = " <?php echo get_lang ( 'CheckDatabaseConnection' ); ?> " >
<?php echo get_lang ( 'CheckDatabaseConnection' ); ?> </ button >
< / td >
< / tr >
< / tr >
< tr >
< td >
<?php
$dbConnect = test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm, $dbNameForm);
$dbConnect = test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm, $dbNameForm);
$database_exists_text = '';
if (database_exists($dbNameForm)) {
$database_exists_text = '< div class = "warning-message" > '.get_lang('ADatabaseWithTheSameNameAlreadyExists').'< / div > ';
} else {
} else {
if ($dbConnect == -1) {
$database_exists_text = '< div class = "warning-message" > '.sprintf(get_lang('UserXCantHaveAccessInTheDatabaseX'), $dbUsernameForm, $dbNameForm).'< / div > ';
$database_exists_text = '< div class = "warning-message" > '.sprintf(get_lang('UserXCantHaveAccessInTheDatabaseX'), $dbUsernameForm, $dbNameForm).'< / div > ';
} 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 = '< div class = "normal-message" > '.sprintf(get_lang('DatabaseXWillBeCreated'), $dbNameForm, $dbUsernameForm).'< / div > ';
} else {
$dbConnect = 0;
$database_exists_text = '< div class = "warning-message" > '.sprintf(get_lang('DatabaseXCantBeCreatedUserXDoestHaveEnoughPermissions'), $dbNameForm, $dbUsernameForm).'< / div > ';
$database_exists_text = '< div class = "warning-message" > '.sprintf(get_lang('DatabaseXCantBeCreatedUserXDoestHaveEnoughPermissions'), $dbNameForm, $dbUsernameForm).'< / div > ';
}
}
}
}
}
if ($dbConnect == 1): ?>
< td colspan = "2" >
<?php echo $database_exists_text ?>
< div id = "db_status" class = "confirmation-message" >
< div id = "db_status" class = "confirmation-message" >
Database host: < strong > <?php echo Database :: get_host_info (); ?> </ strong >< br />
Database server version: < strong > <?php echo Database :: get_server_info (); ?> </ strong >< br />
Database client version: < strong > <?php echo Database :: get_client_info (); ?> </ strong >< br />
@ -1844,15 +1844,15 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
< div style = "clear:both;" > < / div >
< / div >
< / td >
<?php else : ?>
<?php else : ?>
< td colspan = "2" >
<?php echo $database_exists_text ?>
< div id = "db_status" style = "float:left;" class = "error-message" >
< div id = "db_status" style = "float:left;" class = "error-message" >
< div style = "float:left;" >
< strong > <?php echo get_lang ( 'FailedConectionDatabase' ); ?> </ strong >< br />
< strong > Database error: <?php echo Database :: errno (); ?> </ strong >< br />
<?php echo Database :: error () . '<br />' ; ?>
< / div >
< / div >
< / td >
@ -1865,11 +1865,11 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
< td > < / td >
< td align = "right" >
< input type = "hidden" name = "is_executable" id = "is_executable" value = "-" / >
<?php if ( $dbConnect == 1 ) { ?>
<?php if ( $dbConnect == 1 ) { ?>
< button type = "submit" class = "btn next" name = "step4" value = " <?php echo get_lang ( 'Next' ); ?> >" /> <?php echo get_lang ( 'Next' ); ?> </ button >
<?php } else { ?>
< button disabled = "disabled" type = "submit" class = "btn next disabled" name = "step4" value = " <?php echo get_lang ( 'Next' ); ?> >" /> <?php echo get_lang ( 'Next' ); ?> </ button >
<?php } ?>
<?php } ?>
< / td >
< / tr >
< / table >
@ -1904,20 +1904,20 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
echo '< div class = "RequirementContent" > ';
echo '< p > '.get_lang('ConfigSettingsInfo').' < strong > main/inc/conf/configuration.php< / strong > < / p > ';
echo '< / div > ';
echo '< fieldset > ';
echo '< legend > '.get_lang('Administrator').'< / legend > ';
echo '< table class = "data_table_no_border" > ';
//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);
@ -1926,21 +1926,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 '< / table > ';
echo '< / table > ';
echo '< / fieldset > ';
echo '< fieldset > ';
echo '< legend > '.get_lang('Platform').'< / legend > ';
echo '< table class = "data_table_no_border" > ';
echo '< table class = "data_table_no_border" > ';
//First parameter: language
echo "< tr > ";
echo '< td > '.get_lang('MainLang')." < / td > ";
@ -1953,8 +1953,8 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
echo "< / td > \n";
}
echo "< / tr > \n";
//Second parameter: Chamilo URL
echo "< tr > ";
echo '< td > '.get_lang('ChamiloURL').' (< font color = "red" > '.get_lang('ThisFieldIsRequired')."< / font > ) < / td > ";
@ -1987,15 +1987,15 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
< label class = "checkbox inline" >
< input class = "checkbox" type = "radio" name = "encryptPassForm" value = "sha1" id = "encryptPass1" <?php echo ( $encryptPassForm == 'sha1' ) ? 'checked="checked" ' : '' ; ?> /> <?php echo 'sha1' ; ?>
< / label >
< label class = "checkbox inline" >
< label class = "checkbox inline" >
< input class = "checkbox" type = "radio" name = "encryptPassForm" value = "md5" id = "encryptPass0" <?php echo $encryptPassForm == 1 ? 'checked="checked" ' : '' ; ?> /> <?php echo 'md5' ; ?>
< / label >
< label class = "checkbox inline" >
< input class = "checkbox" type = "radio" name = "encryptPassForm" value = "none" id = "encryptPass2" <?php echo $encryptPassForm === '0' or $encryptPassForm === 0 ? 'checked="checked" ' : '' ; ?> /> <?php echo get_lang ( 'None' ); ?>
< / label >
< / div >
< / td >
<?php } ?>
@ -2117,7 +2117,7 @@ function get_countries_list_from_array($combo = false) {
}
/**
* Lockis settings that can't be changed in other portals
* Lockis settings that can't be changed in other portals
*/
function locking_settings() {
$access_url_locked_settings = api_get_locked_settings();
@ -2128,34 +2128,35 @@ function locking_settings() {
}
}
function update_dir_and_files_permissions() {
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
function update_dir_and_files_permissions() {
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$permissions_for_new_directories = isset($_SESSION['permissions_for_new_directories']) ? $_SESSION['permissions_for_new_directories'] : 0770;
$permissions_for_new_files = isset($_SESSION['permissions_for_new_files']) ? $_SESSION['permissions_for_new_files'] : 0660;
// use decoct() to store as string
$sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_directories)."' WHERE variable = 'permissions_for_new_directories'";
Database::query($sql);
$sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_files)."' WHERE variable = 'permissions_for_new_files'";
Database::query($sql);
unset($_SESSION['permissions_for_new_directories']);
unset($_SESSION['permissions_for_new_files']);
}
function compare_setting_values($current_value, $wanted_value) {
$current_value_string = $current_value;
$current_value = (float)$current_value;
$current_value = (float)$current_value;
$wanted_value = (float)$wanted_value;
if ($current_value >= $wanted_value) {
return Display::label($current_value_string, 'success');
} else {
return Display::label($current_value_string, 'important');
}
}
}
function check_course_script_interpretation($course_dir, $course_attempt_name, $file = 'test.php'){
function check_course_script_interpretation($course_dir, $course_attempt_name, $file = 'test.php')
{
$output = false;
//Write in file
$file_name = $course_dir.'/'.$file;
@ -2165,7 +2166,8 @@ function check_course_script_interpretation($course_dir, $course_attempt_name, $
if ($handler = @fopen($file_name, "w")) {
//write content
if (fwrite($handler, $content)) {
$sock_errno = ''; $sock_errmsg = '';
$sock_errno = '';
$sock_errmsg = '';
$url = api_get_path(WEB_COURSE_PATH).$course_attempt_name.'/'.$file;
$parsed_url = parse_url($url);