From 5223bbadcee869c9a541ad27b188202b9b07fef6 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Fri, 5 Mar 2010 23:26:19 +0200 Subject: [PATCH] Feature #272 - "Registration" and "Registration settings": Adding code for managing possible encoding differencies between the system and the stored in files html-snippets. --- main/admin/configure_homepage.php | 11 +++----- main/admin/configure_inscription.php | 40 +++++++++++++++------------- main/auth/inscription.php | 27 +++++++++---------- 3 files changed, 37 insertions(+), 41 deletions(-) diff --git a/main/admin/configure_homepage.php b/main/admin/configure_homepage.php index 512786cdf6..b371017a22 100755 --- a/main/admin/configure_homepage.php +++ b/main/admin/configure_homepage.php @@ -101,7 +101,6 @@ if ($_configuration['multiple_access_urls']) { $homep = api_get_path(SYS_PATH).'home/'; //homep for Home Path } - $menuf = 'home_menu'; //menuf for Menu File $newsf = 'home_news'; //newsf for News File $topf = 'home_top'; //topf for Top File @@ -115,11 +114,11 @@ $homef = array($menuf, $newsf, $topf, $noticef, $menutabs); foreach ($homef as $my_file) { if ($_configuration['multiple_access_urls']) { if (!file_exists($homep_new.$my_file.'_'.$lang.$ext)) { - copy($homep.$my_file.$ext,$homep_new.$my_file.'_'.$lang.$ext); + copy($homep.$my_file.$ext, $homep_new.$my_file.'_'.$lang.$ext); } } else { if (!file_exists($homep.$my_file.'_'.$lang.$ext)) { - copy($homep.$my_file.$ext,$homep.$my_file.'_'.$lang.$ext); + copy($homep.$my_file.$ext, $homep.$my_file.'_'.$lang.$ext); } } } @@ -565,9 +564,7 @@ if (!empty($action)) { $Categories = Database::store_result(Database::query("SELECT name FROM $tbl_category WHERE parent_id IS NULL ORDER BY tree_pos")); } -// ------------------------- -// ---- Display section ---- -// ------------------------- +// Display section Display::display_header($tool_name); @@ -583,7 +580,7 @@ switch ($action) { } break; case 'edit_notice': - //------------ Display for edit_notice case -------------- + // Display for edit_notice case ?>
diff --git a/main/admin/configure_inscription.php b/main/admin/configure_inscription.php index f700a81a20..3f428edb60 100755 --- a/main/admin/configure_inscription.php +++ b/main/admin/configure_inscription.php @@ -76,8 +76,9 @@ if ($_configuration['multiple_access_urls']) { $clean_url = replace_dangerous_char($url); $clean_url = str_replace('/', '-', $clean_url); $clean_url .= '/'; - $homep = '../../home/'; //homep for Home Path - $homep_new = '../../home/'.$clean_url; //homep for Home Path added the url + + $homep = api_get_path(SYS_PATH).'home/'; //homep for Home Path + $homep_new = api_get_path(SYS_PATH).'home/'.$clean_url; //homep for Home Path added the url $new_url_dir = api_get_path(SYS_PATH).'home/'.$clean_url; //we create the new dir for the new sites if (!is_dir($new_url_dir)){ @@ -85,12 +86,10 @@ if ($_configuration['multiple_access_urls']) { } } } else { - $homep_new =''; - $homep = '../../home/'; //homep for Home Path + $homep_new = ''; + $homep = api_get_path(SYS_PATH).'home/'; //homep for Home Path } - - $topf = 'register_top'; //topf for Top File $ext = '.html'; //ext for HTML Extension - when used frequently, variables are $homef = array($topf); @@ -99,11 +98,11 @@ $homef = array($topf); foreach ($homef as $my_file) { if ($_configuration['multiple_access_urls']) { if (!file_exists($homep_new.$my_file.'_'.$lang.$ext)) { - copy($homep.$my_file.$ext,$homep_new.$my_file.'_'.$lang.$ext); + copy($homep.$my_file.$ext, $homep_new.$my_file.'_'.$lang.$ext); } } else { if (!file_exists($homep.$my_file.'_'.$lang.$ext)) { - copy($homep.$my_file.$ext,$homep.$my_file.'_'.$lang.$ext); + copy($homep.$my_file.$ext, $homep.$my_file.'_'.$lang.$ext); } } } @@ -146,12 +145,13 @@ if (!empty($action)) { // This request is only the preparation for the update of the home_top $home_top = ''; if (is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) { - $home_top = file_get_contents($homep.$topf.'_'.$lang.$ext); + $home_top = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext); } elseif (is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) { - $home_top = file_get_contents($homep.$topf.$lang.$ext); + $home_top = @(string)file_get_contents($homep.$topf.$lang.$ext); } else { $errorMsg = get_lang('HomePageFilesNotReadable'); } + $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top))); break; } } @@ -372,7 +372,7 @@ if ($display_all_form) { } -//------------ Terms and conditions +// Terms and conditions if (get_setting('allow_terms_conditions') == 'true') { $language = api_get_interface_language(); $language = api_get_language_id($language); @@ -449,8 +449,8 @@ switch ($action){ $open = $home_top; } else { $name = $newsf; - $open = @file_get_contents($homep.$newsf.'_'.$lang.$ext); - + $open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext); + $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); } if (!empty($errorMsg)) { @@ -484,14 +484,16 @@ switch ($action){ //Form of language api_display_language_form(); echo '  '.Display::display_icon('edit.gif', get_lang('Edit')).' '.get_lang('EditNotice').''; - echo '
'; - $home_notice = ''; - if(file_exists($homep.$topf.'_'.$lang.$ext)) { - $home_notice = @file_get_contents($homep.$topf.'_'.$lang.$ext); + //echo '
'; + echo '
'; + $open = ''; + if (file_exists($homep.$topf.'_'.$lang.$ext)) { + $open = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext); } else { - $home_notice = @file_get_contents($homep.$topf.$ext); + $open = @(string)file_get_contents($homep.$topf.$ext); } - echo $home_notice; + $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); + echo $open; echo '
'; $form->display(); break; diff --git a/main/auth/inscription.php b/main/auth/inscription.php index f993d04bcd..0f9c2a0522 100755 --- a/main/auth/inscription.php +++ b/main/auth/inscription.php @@ -53,9 +53,7 @@ echo '
'; echo $tool_name; echo '
'; -//Header of Configure Inscription - -$home = '../../home/'; +$home = api_get_path(SYS_PATH).'home/'; if ($_configuration['multiple_access_urls']) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { @@ -64,8 +62,8 @@ if ($_configuration['multiple_access_urls']) { $clean_url = replace_dangerous_char($url); $clean_url = str_replace('/','-',$clean_url); $clean_url .= '/'; - $home_old = '../../home/'; - $home= '../../home/'.$clean_url; + $home_old = api_get_path(SYS_PATH).'home/'; + $home = api_get_path(SYS_PATH).'home/'.$clean_url; } } @@ -78,8 +76,9 @@ if (!empty($_SESSION['user_language_choice'])) { } if (file_exists($home.'register_top_'.$user_selected_language.'.html')) { - $home_top_temp = file_get_contents($home.'register_top_'.$user_selected_language.'.html'); + $home_top_temp = @(string)file_get_contents($home.'register_top_'.$user_selected_language.'.html'); $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp); + $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); echo '
'.$open.'
'; } @@ -302,13 +301,12 @@ if ($display_all_form) { } } -//------------ Terms and conditions + +// Terms and conditions if (api_get_setting('allow_terms_conditions') == 'true') { - //$language = api_get_setting('platformLanguage'); $language = api_get_interface_language(); $language = api_get_language_id($language); $term_preview = LegalManager::get_last_condition($language); - if (!$term_preview) { //we load from the platform $language = api_get_setting('platformLanguage'); @@ -320,14 +318,15 @@ if (api_get_setting('allow_terms_conditions') == 'true') { $term_preview = LegalManager::get_last_condition($language); } } - // Version and language //password + // Version and language $form->addElement('hidden', 'legal_accept_type', $term_preview['version'].':'.$term_preview['language_id']); $form->addElement('hidden', 'legal_info', $term_preview['legal_id'].':'.$term_preview['language_id']); + // Password if (isset($_SESSION['info_current_user'][1]) && isset($_SESSION['info_current_user'][2])) { - $form->addElement('hidden', 'login',$_SESSION['info_current_user'][1]); - $form->addElement('hidden', 'password',$_SESSION['info_current_user'][2]); + $form->addElement('hidden', 'login', $_SESSION['info_current_user'][1]); + $form->addElement('hidden', 'password', $_SESSION['info_current_user'][2]); } - if($term_preview['type'] == 1) { + if ($term_preview['type'] == 1) { $form->addElement('checkbox', 'legal_accept', null, get_lang('IHaveReadAndAgree').' '.get_lang('TermsAndConditions').''); $form->addRule('extra_legal_accept', get_lang('ThisFieldIsRequired'), 'required'); } else { @@ -588,7 +587,5 @@ if (!isset($_POST['username'])) {
-