From 19efb7c8f56826accc36d457b916d8cce8404e33 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Thu, 4 Mar 2010 09:42:12 +0200 Subject: [PATCH] Feature #272 - Portal homepage: Making sure that html-snippets that come from files will always be shown using the system encoding. --- index.php | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/index.php b/index.php index eb062edd46..3d027ef282 100755 --- a/index.php +++ b/index.php @@ -206,7 +206,9 @@ if ($_configuration['multiple_access_urls']) { $page_included = false; if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) { - include './'.$home.$_GET['include']; + $open = @(string)file_get_contents(api_get_path(SYS_PATH).$home.$_GET['include']); + $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); + echo $open; $page_included = true; } else { @@ -236,6 +238,7 @@ if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['in $home_top_temp = get_lang('PortalHomepageDefaultIntroduction'); } $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; } @@ -377,6 +380,7 @@ function display_anonymous_right_menu() { global $loginFailed, $_plugins, $_user, $menu_navigation; $platformLanguage = api_get_setting('platformLanguage'); + $sys_path = api_get_path(SYS_PATH); if (!($_user['user_id']) || api_is_anonymous($_user['user_id']) ) { // only display if the user isn't logged in api_display_language_form(true); @@ -475,21 +479,21 @@ function display_anonymous_right_menu() { $user_selected_language = $platformLanguage; } - if (!file_exists($home.'home_menu_'.$user_selected_language.'.html') && file_exists($home.'home_menu.html') && file_get_contents($home.'home_menu.html') != '') { - echo "
", "".get_lang("MenuGeneral").""; - echo "'; - echo '
'; + $home_menu = @(string)file_get_contents($sys_path.$home.'home_menu_'.$user_selected_language.'.html'); + if (empty($home_menu)) { + $home_menu = @(string)file_get_contents($sys_path.$home_old.'home_menu_'.$user_selected_language.'.html'); } - elseif(file_exists($home.'home_menu_'.$user_selected_language.'.html') && file_get_contents($home.'home_menu_'.$user_selected_language.'.html') != '') { + if (empty($home_menu)) { + $home_menu = @(string)file_get_contents($sys_path.$home.'home_menu.html'); + } + if (empty($home_menu)) { + $home_menu = @(string)file_get_contents($sys_path.$home_old.'home_menu.html'); + } + if (!empty($home_menu)) { echo "
", "".get_lang("MenuGeneral").""; echo "'; echo '
'; } @@ -502,18 +506,14 @@ function display_anonymous_right_menu() { // includes for any files to be displayed below anonymous right menu - if (!file_exists($home.'home_notice_'.$user_selected_language.'.html') && file_exists($home.'home_notice.html') && file_get_contents($home.'home_notice.html') != '') { - echo '
'; - if (file_exists($home.'home_notice.html')) { - include ($home.'home_notice.html'); - } else { - include ($home_old.'home_notice.html'); - } - echo '
'; + $home_notice = @(string)file_get_contents($sys_path.$home.'home_notice_'.$user_selected_language.'.html'); + if (empty($home_notice)) { + $home_notice = @(string)file_get_contents($sys_path.$home.'home_notice.html'); } - elseif(file_exists($home.'home_notice_'.$user_selected_language.'.html') && file_get_contents($home.'home_notice_'.$user_selected_language.'.html') != '') { + if (!empty($home_notice)) { echo '
'; - include($home.'home_notice_'.$user_selected_language.'.html'); + $home_notice = api_to_system_encoding($home_notice, api_detect_encoding(strip_tags($home_notice))); + echo $home_notice; echo '
'; } }