From d6a78438610daeacb958ad304bc9cd66b3c02bbd Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Sat, 6 Mar 2010 15:34:30 +0200 Subject: [PATCH] Feature #272 - The banner: Adding code for managing possible encoding differencies between the system and the stored in files html-snippets. Minor changes in "Configure homepage". --- main/admin/configure_homepage.php | 50 +++++++++++++++---------------- main/inc/banner.inc.php | 25 +++++++++++----- 2 files changed, 43 insertions(+), 32 deletions(-) diff --git a/main/admin/configure_homepage.php b/main/admin/configure_homepage.php index 55abe1e16c..18edf4f280 100755 --- a/main/admin/configure_homepage.php +++ b/main/admin/configure_homepage.php @@ -230,8 +230,8 @@ if (!empty($action)) { } else { // We update all the news file $_languages = api_get_languages(); - foreach ($_languages["name"] as $key => $value) { - $english_name = $_languages["folder"][$key]; + foreach ($_languages['name'] as $key => $value) { + $english_name = $_languages['folder'][$key]; if (file_exists($homep.$newsf.'_'.$english_name.$ext)) { if (is_writable($homep.$newsf.'_'.$english_name.$ext)) { $fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w'); @@ -268,7 +268,7 @@ if (!empty($action)) { if ($link_url == 'http://') { $link_url = ''; - } elseif (!empty($link_url) && !strstr($link_url,'://')) { + } elseif (!empty($link_url) && !strstr($link_url, '://')) { $link_url='http://'.$link_url; } $menuf = ($action == 'insert_tabs' || $action == 'edit_tabs')? $menutabs : $menuf; @@ -384,7 +384,7 @@ if (!empty($action)) { // link and re-writing the array to the file $link_index = intval($_GET['link_index']); $menuf = ($action == 'delete_tabs')? $menutabs : $menuf; - $home_menu = file($homep.$menuf.'_'.$lang.$ext); + $home_menu = @file($homep.$menuf.'_'.$lang.$ext); if (empty($home_menu)) { $home_menu = array(); } @@ -392,7 +392,7 @@ if (!empty($action)) { if ($key == $link_index) { unset($home_menu[$key]); } else { - $home_menu[$key]=trim($enreg); + $home_menu[$key] = trim($enreg); } } $home_menu = implode("\n", $home_menu); @@ -414,9 +414,9 @@ 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'); } @@ -426,9 +426,9 @@ if (!empty($action)) { // This request is only the preparation for the update of the home_notice $home_notice = ''; if (is_file($homep.$noticef.'_'.$lang.$ext) && is_readable($homep.$noticef.'_'.$lang.$ext)) { - $home_notice = file($homep.$noticef.'_'.$lang.$ext); + $home_notice = @file($homep.$noticef.'_'.$lang.$ext); } elseif (is_file($homep.$noticef.$lang.$ext) && is_readable($homep.$noticef.$lang.$ext)) { - $home_notice = file($homep.$noticef.$lang.$ext); + $home_notice = @file($homep.$noticef.$lang.$ext); } else { $errorMsg = get_lang('HomePageFilesNotReadable'); } @@ -444,9 +444,9 @@ if (!empty($action)) { // This request is the preparation for the update of the home_news page $home_news = ''; if (is_file($homep.$newsf.'_'.$lang.$ext) && is_readable($homep.$newsf.'_'.$lang.$ext)) { - $home_news = file_get_contents($homep.$newsf.'_'.$lang.$ext); + $home_news = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext); } elseif (is_file($homep.$newsf.$lang.$ext) && is_readable($homep.$newsf.$lang.$ext)) { - $home_news = file_get_contents($homep.$newsf.$lang.$ext); + $home_news = @(string)file_get_contents($homep.$newsf.$lang.$ext); } else { $errorMsg = get_lang('HomePageFilesNotReadable'); } @@ -457,9 +457,9 @@ if (!empty($action)) { $home_menu = ''; $menuf = ($action == 'edit_tabs')? $menutabs : $menuf; if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) { - $home_menu = file($homep.$menuf.'_'.$lang.$ext); + $home_menu = @file($homep.$menuf.'_'.$lang.$ext); } elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) { - $home_menu = file($homep.$menuf.$lang.$ext); + $home_menu = @file($homep.$menuf.$lang.$ext); } else { $errorMsg = get_lang('HomePageFilesNotReadable'); } @@ -476,9 +476,9 @@ if (!empty($action)) { // This request is the preparation for the addition of an item in home_menu $home_menu = ''; if (is_file($homep.$menutabs.'_'.$lang.$ext) && is_readable($homep.$menutabs.'_'.$lang.$ext)) { - $home_menu = file($homep.$menutabs.'_'.$lang.$ext); + $home_menu = @file($homep.$menutabs.'_'.$lang.$ext); } elseif (is_file($homep.$menutabs.$lang.$ext) && is_readable($homep.$menutabs.$lang.$ext)) { - $home_menu = file($homep.$menutabs.$lang.$ext); + $home_menu = @file($homep.$menutabs.$lang.$ext); } else { $errorMsg = get_lang('HomePageFilesNotReadable'); } @@ -497,9 +497,9 @@ if (!empty($action)) { $home_menu = ''; $menuf = ($action == 'edit_tabs')? $menutabs : $menuf; if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) { - $home_menu = file($homep.$menuf.'_'.$lang.$ext); + $home_menu = @file($homep.$menuf.'_'.$lang.$ext); } elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) { - $home_menu = file($homep.$menuf.$lang.$ext); + $home_menu = @file($homep.$menuf.$lang.$ext); } else { $errorMsg = get_lang('HomePageFilesNotReadable'); } @@ -544,7 +544,7 @@ if (!empty($action)) { if (!strstr($filename, '/') && strstr($filename, '.html')) { // Get oonly the contents of the link file - $link_html = file(api_get_path(SYS_PATH).'home/'.$filename); + $link_html = @file(api_get_path(SYS_PATH).'home/'.$filename); $link_html = implode('', $link_html); $link_url = ''; } else { @@ -686,7 +686,7 @@ 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))); @@ -751,9 +751,9 @@ switch ($action) {
- + $enreg) { $enreg = trim($enreg); if (!empty($enreg)) {