X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=a7cd723a8d52654eee61469a7306f962cc33a7cc;hb=57a53db86560e6591c06c535b888f791d273ae2f;hp=9376897615ada0f47bc33ea0f0338f1ab99f4706;hpb=03ba5e2fb6ea0b03d4286fa1cc6dcbbc23c7b3df;p=mailer.git
diff --git a/inc/functions.php b/inc/functions.php
index 9376897615..a7cd723a8d 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -85,16 +85,7 @@ function outputHtml ($htmlCode, $newLine = true) {
app_die(__FUNCTION__, __LINE__, '{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}');
break;
} // END - switch
- } elseif ((getPhpCaching() == 'on') && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) {
- // Headers already sent?
- if (headers_sent()) {
- // Log this error
- logDebugMessage(__FUNCTION__, __LINE__, 'Headers already sent! We need debug backtrace here.');
-
- // Trigger an user error
- debug_report_bug('Headers are already sent!');
- } // END - if
-
+ } elseif ((getPhpCaching() == 'on') && ((!isset($GLOBALS['header'])) || (count($GLOBALS['header']) == 0))) {
// Output cached HTML code
$GLOBALS['output'] = ob_get_contents();
@@ -130,6 +121,9 @@ function outputHtml ($htmlCode, $newLine = true) {
// Output code here, DO NOT REMOVE! ;-)
outputRawCode($GLOBALS['output']);
+ } else {
+ // And flush all headers
+ flushHeaders();
}
}
@@ -142,7 +136,7 @@ function sendHttpHeaders () {
sendHeader('HTTP/1.1 200');
// General headers for no caching
- sendHeader('Expired: ' . $now); // RFC2616 - Section 14.21
+ sendHeader('Expires: ' . $now); // RFC2616 - Section 14.21
sendHeader('Last-Modified: ' . $now);
sendHeader('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
sendHeader('Pragma: no-cache'); // HTTP/1.0
@@ -177,8 +171,26 @@ function compileFinalOutput () {
$cnt++;
} // END - while
+ // Compress it?
+ if (!empty($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos('gzip', $_SERVER['HTTP_ACCEPT_ENCODING']) !== null)) {
+ // Compress it for HTTP gzip
+ $GLOBALS['output'] = gzencode($GLOBALS['output'], 9, true);
+
+ // Add header
+ sendHeader('Content-Encoding: gzip');
+ } elseif (!empty($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos('deflate', $_SERVER['HTTP_ACCEPT_ENCODING']) !== null)) {
+ // Compress it for HTTP deflate
+ $GLOBALS['output'] = gzcompress($GLOBALS['output'], 9);
+
+ // Add header
+ sendHeader('Content-Encoding: deflate');
+ }
+
// Add final length
sendHeader('Content-Length: ' . strlen($GLOBALS['output']));
+
+ // Flush all headers
+ flushHeaders();
}
// Output the raw HTML code
@@ -217,7 +229,6 @@ function addFatalMessage ($F, $L, $message, $extra = '') {
$GLOBALS['fatal_messages'][] = $message;
// Log fatal messages away
- debug_report_bug($message);
logDebugMessage($F, $L, 'Fatal error message: ' . $message);
}
@@ -284,7 +295,7 @@ function loadTemplate ($template, $return = false, $content = array()) {
// Do we have to compile the code?
$ret = '';
- if ((strpos($GLOBALS['tpl_content'], '$') !== false) || (strpos($GLOBALS['tpl_content'], '{--') !== false) || (strpos($GLOBALS['tpl_content'], '{!') !== false) || (strpos($GLOBALS['tpl_content'], '{?') !== false)) {
+ if ((strpos($GLOBALS['tpl_content'], '$') !== false) || (strpos($GLOBALS['tpl_content'], '{--') !== false) || (strpos($GLOBALS['tpl_content'], '{!') !== false) || (strpos($GLOBALS['tpl_content'], '{?') !== false) || (strpos($GLOBALS['tpl_content'], '{%') !== false)) {
// Normal HTML output?
if (getOutputMode() == '0') {
// Add surrounding HTML comments to help finding bugs faster
@@ -415,12 +426,15 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0') {
// Is content an array?
if (is_array($content)) {
// Add expiration to array
- if (getConfig('auto_purge') == '0') {
+ if ((isConfigEntrySet('auto_purge')) && (getConfig('auto_purge') == '0')) {
// Will never expire!
$content['expiration'] = getMessage('MAIL_WILL_NEVER_EXPIRE');
- } else {
+ } elseif (isConfigEntrySet('auto_purge')) {
// Create nice date string
$content['expiration'] = createFancyTime(getConfig('auto_purge'));
+ } else {
+ // Missing entry
+ $content['expiration'] = getMessage('MAIL_NO_CONFIG_AUTO_PURGE');
}
} // END - if
@@ -574,10 +588,10 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = '
if (isDebugModeEnabled()) {
// In debug mode we want to display the mail instead of sending it away so we can debug this part
outputHtml('
-Headers : ' . str_replace('<', '<', str_replace('>', '>', secureString(trim($mailHeader)))) . '
-To : ' . $toEmail . '
-Subject : ' . $subject . '
-Message : ' . $message . '
+Headers : ' . htmlentities(utf8_decode(trim($mailHeader))) . '
+To : ' . htmlentities(utf8_decode($toEmail)) . '
+Subject : ' . htmlentities(utf8_decode($subject)) . '
+Message : ' . htmlentities(utf8_decode($message)) . '
');
} elseif (($isHtml == 'Y') && (isExtensionActive('html_mail'))) {
// Send mail as HTML away
@@ -738,7 +752,7 @@ function translateYesNo ($yn) {
// Translates the "pool type" into human-readable
function translatePoolType ($type) {
// Default?type is unknown
- $translated = sprintf(getMessage('POOL_TYPE_UNKNOWN'), $type);
+ $translated = getMaskedMessage('POOL_TYPE_UNKNOWN', $type);
// Generate constant
$constName = sprintf("POOL_TYPE_%s", $type);
@@ -829,7 +843,7 @@ function translateUserStatus ($status) {
default:
logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status));
- $ret = sprintf(getMessage('UNKNOWN_STATUS'), $status);
+ $ret = getMaskedMessage('UNKNOWN_STATUS', $status);
break;
} // END - switch
@@ -918,14 +932,6 @@ function redirectToUrl ($URL) {
$rel = '';
} // END - if
- // Get output buffer
- $GLOBALS['output'] = ob_get_contents();
-
- // Clear it only if there is content
- if (!empty($GLOBALS['output'])) {
- clearOutputBuffer();
- } // END - if
-
// Three different ways to debug...
//* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'URL=' . $URL);
@@ -1378,6 +1384,16 @@ function generateImageOrCode ($img_code, $headerSent = true) {
}
// Create selection box or array of splitted timestamp
function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = 'center', $return_array=false) {
+ // Do not continue if ONE_DAY is absend
+ if (!isConfigEntrySet('ONE_DAY')) {
+ // And return the timestamp itself or empty array
+ if ($return_array === true) {
+ return array();
+ } else {
+ return $timestamp;
+ }
+ } // END - if
+
// Calculate 2-seconds timestamp
$stamp = round($timestamp);
//* DEBUG: */ print("*" . $stamp.'/' . $timestamp."*
");
@@ -1472,7 +1488,7 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
if (ereg('Y', $display) || (empty($display))) {
// Generate year selection
- $OUT .= " |