From: Roland Häder Date: Wed, 23 Jan 2013 18:20:07 +0000 (+0000) Subject: Added support for favicon.ico/gif/png in base path (very basic support) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3360f076d2251f554b2dfb420c18367af363ce2a;p=mailer.git Added support for favicon.ico/gif/png in base path (very basic support) --- diff --git a/inc/template-functions.php b/inc/template-functions.php index 9c9059d314..fa47705d73 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -2051,6 +2051,71 @@ function addJavaScriptMenuContent ($menuMode, $mainAction, $action, $what) { return $OUT; } +// Tries to anonymize some sensitive data (e.g. IP address, user agent, referrer, etc.) +function anonymizeSensitiveData ($data) { + // Trim it + $data = trim($data); + + // Is it empty? + if (empty($data)) { + // Then add three dashes + $data = '---'; + } elseif (isUrlValid($data)) { + // Is a referrer, so is it black-listed? + if (isAdmin()) { + // Is admin, has always priority + $data = '[{--ADMIN_TEST_URL--}]'; + } elseif ((isExtensionActive('blacklist')) && (isUrlBlacklisted($data))) { + // Yes, so replace it with text + $data = '{--URL_IS_BLACKLISTED--}'; + } else { + // A member is viewing this referral URL + $data = '[{--MEMBER_TEST_URL--}]'; + } + } elseif (isIp4AddressValid($data)) { + // Is an IPv4 address + $ipArray = explode('.', $data); + + // Only display first 2 octets + $data = $ipArray[0] . '.' . $ipArray[1] . '.?.?'; + } else { + // Generic data + $data = '{--DATA_IS_HIDDEN--}'; + } + + // Return it (hopefully) anonymized + return $data; +} + +/** + * Removes all comments, tabs and new-line characters to compact the content + * + * @param $uncompactedContent The uncompacted content + * @return $compactedContent The compacted content + */ +function compactContent ($uncompactedContent) { + // First, remove all tab/new-line/revert characters + $compactedContent = str_replace(chr(9), '', str_replace(PHP_EOL, '', str_replace(chr(13), '', $uncompactedContent))); + + // Make a space after > + $compactedContent = str_replace(array('>', ' '), array('> ', ' '), $compactedContent); + + // Then regex all comments like away + preg_match_all('//', $compactedContent, $matches); + + // Do we have entries? + if (isset($matches[0][0])) { + // Remove all + foreach ($matches[0] as $match) { + // Remove the match + $compactedContent = str_replace($match, '', $compactedContent); + } // END - foreach + } // END - if + + // Return compacted content + return $compactedContent; +} + //----------------------------------------------------------------------------- // Template helper functions for EL code //----------------------------------------------------------------------------- @@ -2278,69 +2343,23 @@ function doTemplateLoadTemplate ($templateName, $clear = FALSE, $theTemplate, $c return loadTemplate($theTemplate, TRUE, $content); } -// Tries to anonymize some sensitive data (e.g. IP address, user agent, referrer, etc.) -function anonymizeSensitiveData ($data) { - // Trim it - $data = trim($data); +// Output HTML code for favicon.ico, if found +function doTemplateMetaFavIcon ($templateName, $clear = FALSE) { + // Default is not found + $out = ''; - // Is it empty? - if (empty($data)) { - // Then add three dashes - $data = '---'; - } elseif (isUrlValid($data)) { - // Is a referrer, so is it black-listed? - if (isAdmin()) { - // Is admin, has always priority - $data = '[{--ADMIN_TEST_URL--}]'; - } elseif ((isExtensionActive('blacklist')) && (isUrlBlacklisted($data))) { - // Yes, so replace it with text - $data = '{--URL_IS_BLACKLISTED--}'; - } else { - // A member is viewing this referral URL - $data = '[{--MEMBER_TEST_URL--}]'; - } - } elseif (isIp4AddressValid($data)) { - // Is an IPv4 address - $ipArray = explode('.', $data); - - // Only display first 2 octets - $data = $ipArray[0] . '.' . $ipArray[1] . '.?.?'; - } else { - // Generic data - $data = '{--DATA_IS_HIDDEN--}'; - } - - // Return it (hopefully) anonymized - return $data; -} - -/** - * Removes all comments, tabs and new-line characters to compact the content - * - * @param $uncompactedContent The uncompacted content - * @return $compactedContent The compacted content - */ -function compactContent ($uncompactedContent) { - // First, remove all tab/new-line/revert characters - $compactedContent = str_replace(chr(9), '', str_replace(PHP_EOL, '', str_replace(chr(13), '', $uncompactedContent))); - - // Make a space after > - $compactedContent = str_replace(array('>', ' '), array('> ', ' '), $compactedContent); - - // Then regex all comments like away - preg_match_all('//', $compactedContent, $matches); - - // Do we have entries? - if (isset($matches[0][0])) { - // Remove all - foreach ($matches[0] as $match) { - // Remove the match - $compactedContent = str_replace($match, '', $compactedContent); - } // END - foreach - } // END - if + // Check all common extensions + foreach (array('ico', 'gif', 'png') as $extension) { + // Is the file there? + if (isFileReadable(getPath() . 'favicon.' . $extension)) { + // Then use this and abort + $out = ''; + break; + } // END - if + } // END - while - // Return compacted content - return $compactedContent; + // Return code + return $out; } // [EOF] diff --git a/templates/de/html/page_header.tpl b/templates/de/html/page_header.tpl index bb99026d63..c41cd59239 100644 --- a/templates/de/html/page_header.tpl +++ b/templates/de/html/page_header.tpl @@ -6,6 +6,7 @@ +{%template,MetaFavIcon%}