X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ftemplate-functions.php;h=4b6420a59f013706ed0e545a6329842f5762200a;hb=f151c251ccff7d143c8470e4451ce922ee40bd9d;hp=9c9059d31494a22c23bc8a0004515d484b547917;hpb=ec0f04e64a8fdac50913692615198e68ff77b078;p=mailer.git diff --git a/inc/template-functions.php b/inc/template-functions.php index 9c9059d314..4b6420a59f 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -16,7 +16,7 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2012 by Mailer Developer Team * + * Copyright (c) 2009 - 2013 by Mailer Developer Team * * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -1162,16 +1162,16 @@ function generateEmailLink ($email, $table = 'admins') { * functionality like logging and admin notification (which you can configure * through your admin area). * - * @param $F Function or file basename where the error came from - * @param $L Line number where the error came from + * @param $file Function or file basename where the error came from + * @param $line Line number where the error came from * @param $message Message which shall be output to web * @return void */ -function app_exit ($F, $L, $message) { +function app_exit ($file, $line, $message) { // Check if Script is already dieing and not let it kill itself another 1000 times if (isset($GLOBALS['app_died'])) { // Script tried to kill itself twice - die('[' . __FUNCTION__ . ':' . __LINE__ . ']: Script wanted to kill itself more than once! Raw message=' . $message . ', file/function=' . $F . ', line=' . $L); + die('[' . __FUNCTION__ . ':' . __LINE__ . ']: Script wanted to kill itself more than once! Raw message=' . $message . ', file/function=' . $file . ', line=' . $line); } // END - if // Make sure, that the script realy realy diese here and now @@ -1192,8 +1192,8 @@ function app_exit ($F, $L, $message) { // Rewrite message for output $message = sprintf( getMessage('MAILER_HAS_DIED'), - basename($F), - $L, + basename($file), + $line, $message ); @@ -1258,16 +1258,16 @@ function displayParsingTime () { * app_exit() is more a "private" function and will only output a bug message to * the user, no email and no logging. * - * @param $F Function or file basename where the error came from - * @param $L Line number where the error came from + * @param $file Function or file basename where the error came from + * @param $line Line number where the error came from * @param $sendEmail Wether to send an email to all configured administrators * @return void */ -function reportBug ($F, $L, $message = '', $sendEmail = TRUE) { +function reportBug ($file, $line, $message = '', $sendEmail = TRUE) { // Is this already called? if (isset($GLOBALS[__FUNCTION__])) { // Other backtrace - print '[' . $F . ':' . $L . ':] ' . __FUNCTION__ . ' has already died! Message:' . $message . '
Backtrace:
';
+		print '[' . $file . ':' . $line . ':] ' . __FUNCTION__ . ' has already died! Message:' . $message . '
Backtrace:
';
 		debug_print_backtrace();
 		die('
'); } // END - if @@ -1289,7 +1289,7 @@ function reportBug ($F, $L, $message = '', $sendEmail = TRUE) { ); // @TODO Add a little more infos here - logDebugMessage($F, $L, strip_tags($message)); + logDebugMessage($file, $line, strip_tags($message)); } // END - if // Add output @@ -1314,7 +1314,7 @@ function reportBug ($F, $L, $message = '', $sendEmail = TRUE) { // Is there HTML/CSS/AJAX mode? if (((isHtmlOutputMode()) || (isCssOutputMode()) || (isAjaxOutputMode())) && (isDebugModeEnabled())) { // And abort here - app_exit($F, $L, $debug); + app_exit($file, $line, $debug); } else { // Raw/image output mode and all other modes doesn't work well with text ... die(); @@ -1519,7 +1519,7 @@ function determinePageTitle () { $pageTitle = ''; // Config and database connection valid? - if ((isConfigLocalLoaded()) && (isConfigurationLoaded()) && (SQL_IS_LINK_UP()) && (isExtensionInstalledAndNewer('sql_patches', '0.1.6'))) { + if ((isConfigLocalLoaded()) && (isConfigurationLoaded()) && (isSqlLinkUp()) && (isExtensionInstalledAndNewer('sql_patches', '0.1.6'))) { // Title decoration enabled? if ((isTitleDecorationEnabled()) && (getTitleLeft() != '')) { $pageTitle .= '{%config,trim=title_left%} '; @@ -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]