X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=eb36b77d60840cef80982cc30d907c83fb9cbdd9;hp=4df8f56b0d712e981ab6df255419c174142611e6;hb=0cbe2bfe902d26f0e99be6005140a9d8c350f017;hpb=62b4ef5bb0b63f7cac5f0dccd816246a108a5d83 diff --git a/inc/functions.php b/inc/functions.php index 4df8f56b0d..eb36b77d60 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(); @@ -108,12 +99,12 @@ function outputHtml ($htmlCode, $newLine = true) { $GLOBALS['output'] = rewriteLinksInCode($GLOBALS['output']); } // END - if - // Compile and run finished rendered HTML code - compileFinalOutput(); - // Send all HTTP headers sendHttpHeaders(); + // Compile and run finished rendered HTML code + compileFinalOutput(); + // Output code here, DO NOT REMOVE! ;-) outputRawCode($GLOBALS['output']); } elseif ((getConfig('OUTPUT_MODE') == 'render') && (!empty($GLOBALS['output']))) { @@ -122,14 +113,17 @@ function outputHtml ($htmlCode, $newLine = true) { $GLOBALS['output'] = rewriteLinksInCode($GLOBALS['output']); } // END - if - // Compile and run finished rendered HTML code - compileFinalOutput(); - // Send all HTTP headers sendHttpHeaders(); + // Compile and run finished rendered HTML code + compileFinalOutput(); + // 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); } @@ -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,28 +932,19 @@ 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); //* DEBUG: */ die($URL); // Simple probe for bots/spiders from search engines - if ((strpos(detectUserAgent(), 'spider') !== false) || (strpos(detectUserAgent(), 'bot') !== false)) { + if (isSpider()) { // Secure the URL against bad things such als HTML insertions and so on... $URL = secureString($URL); // Output new location link as anchor outputHtml('' . $URL . ''); } elseif (!headers_sent()) { - //* DEBUG: */ debug_report_bug("URL={$URL}"); // Clear own output buffer $GLOBALS['output'] = ''; @@ -1379,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."*
"); @@ -1473,7 +1488,7 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = if (ereg('Y', $display) || (empty($display))) { // Generate year selection - $OUT .= " \n"; for ($idx = '0'; $idx <= 10; $idx++) { $OUT .= "