X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ftemplate-functions.php;h=418888d0336638fc1a1a58023eb8e9cee443c884;hp=55a4e8299e76071a4a285ba9fdd93fd8a83c3754;hb=16f0ea892c6537f1eff6549ab9a3baf1d6756a13;hpb=e41922487c1c0ef1ed3294e31e5fee7d776876fd diff --git a/inc/template-functions.php b/inc/template-functions.php index 55a4e8299e..418888d033 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -112,7 +112,7 @@ function outputHtml ($htmlCode, $newLine = TRUE) { // That's why you don't need any \n at the end of your HTML code... :-) if ($newLine === TRUE) { - outputRawCode(chr(10)); + outputRawCode(PHP_EOL); } // END - if } else { // Render mode for old or lame servers... @@ -120,7 +120,7 @@ function outputHtml ($htmlCode, $newLine = TRUE) { // That's why you don't need any \n at the end of your HTML code... :-) if ($newLine === TRUE) { - $GLOBALS['__output'] .= chr(10); + $GLOBALS['__output'] .= PHP_EOL; } // END - if } break; @@ -135,7 +135,7 @@ function outputHtml ($htmlCode, $newLine = TRUE) { // The same as above... ^ outputRawCode($htmlCode); if ($newLine === TRUE) { - outputRawCode(chr(10)); + outputRawCode(PHP_EOL); } // END - if break; @@ -184,8 +184,11 @@ function compileFinalOutput () { addPageHeaderFooter(); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '__output(length)=' . strlen($GLOBALS['__output']) . ' - After addPageHeaderFooter() call.'); - // Do the final compilation - $GLOBALS['__output'] = compileUriCode(doFinalCompilation($GLOBALS['__output'])); + // Do the final (general) compilation + $GLOBALS['__output'] = doFinalCompilation($GLOBALS['__output']); + + // Compile any other things out + $GLOBALS['__output'] = compileUriCode($GLOBALS['__output']); // Extension 'rewrite' installed? if ((isExtensionActive('rewrite')) && (!isCssOutputMode())) { @@ -335,20 +338,25 @@ function loadTemplate ($template, $return = FALSE, $content = array(), $compileC $code = '' . $GLOBALS['template_content']['html'][$template] . ''; // Prepare eval() command + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!'); $GLOBALS['template_eval']['html'][$template] = '$ret = "' . getColorSwitchCode($template) . compileCode(escapeQuotes($code), FALSE, TRUE, TRUE, $compileCode) . '";'; } elseif (substr($template, 0, 3) == 'js_') { // JavaScripts don't like entities, dollar signs and timings + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!'); $GLOBALS['template_eval']['html'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeJavaScriptQuotes($GLOBALS['template_content']['html'][$template]), FALSE, TRUE, TRUE, $compileCode) . '");'; } else { // Prepare eval() command, other output doesn't like entities, maybe + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!'); $GLOBALS['template_eval']['html'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeQuotes($GLOBALS['template_content']['html'][$template]), FALSE, TRUE, TRUE, $compileCode) . '");'; } } elseif (isHtmlOutputMode()) { // Add surrounding HTML comments to help finding bugs faster $ret = '' . $GLOBALS['template_content']['html'][$template] . ''; + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!'); $GLOBALS['template_eval']['html'][$template] = '$ret = "' . getColorSwitchCode($template) . compileRawCode(escapeQuotes($ret), FALSE, TRUE, TRUE, $compileCode) . '";'; } else { // JavaScript again + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!'); $GLOBALS['template_eval']['html'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeJavaScriptQuotes($GLOBALS['template_content']['html'][$template]), FALSE, TRUE, TRUE, $compileCode) . '");'; } // END - if } elseif ((isAdmin()) || ((isInstalling()) && (!isInstalled()))) { @@ -536,7 +544,7 @@ function loadEmailTemplate ($template, $content = array(), $userid = NULL, $load // Are there some content? if (empty($newContent)) { // Compiling failed - $newContent = "Compiler error for template " . $template . " !\nUncompiled content:\n" . $GLOBALS['template_content']['email'][$template]; + $newContent = "Compiler error for template " . $template . " !\nUncompiled content:\n" . $GLOBALS['template_eval']['email'][$template]; // Add last error if the required function exists if (function_exists('error_get_last')) { @@ -1370,7 +1378,7 @@ function compileUriCode ($code, $simple = TRUE) { } // END - if // Compile QUOT and other non-HTML codes - $code = str_replace($charsCompile['from'], $charsCompile['to'], decodeEntities($code)); + $code = str_replace($charsCompile['from'], $charsCompile['to'], $code); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'code=' . $code); // Return compiled code @@ -1468,11 +1476,11 @@ function generateExtensionInactiveNotInstalledMessage ($ext_name) { // Is the extension not installed or just deactivated? switch (isExtensionInstalled($ext_name)) { - case true; // Deactivated! + case TRUE; // Deactivated! $message = generateExtensionInactiveMessage($ext_name); break; - case false; // Not installed! + case FALSE; // Not installed! $message = generateExtensionNotInstalledMessage($ext_name); break; @@ -1493,7 +1501,7 @@ function linenumberCode ($code) { if (!is_array($code)) { // We need an array, so try it with the new-line character - $codeE = explode(chr(10), $code); + $codeE = explode(PHP_EOL, $code); } // END - if $count_lines = count($codeE); @@ -1651,7 +1659,7 @@ function escapeQuotes ($str, $single = FALSE) { $str = str_replace(array("\\'", '"', "\\\\"), array(chr(39), "\\\"", chr(92)), $str); } - // Return the escaped string + // Return the escape'd string return $str; } @@ -1694,16 +1702,16 @@ function sendModeMails ($mod, $modes) { switch ($mode) { case 'normal': break; // Do not add any special lines case 'email': // Email was changed! - $content['message'] = '{--MEMBER_CHANGED_EMAIL--}' . ': ' . postRequestElement('old_email') . chr(10); + $content['message'] = '{--MEMBER_CHANGED_EMAIL--}' . ': ' . postRequestElement('old_email') . PHP_EOL; break; case 'password': // Password was changed - $content['message'] = '{--MEMBER_CHANGED_PASS--}' . chr(10); + $content['message'] = '{--MEMBER_CHANGED_PASS--}' . PHP_EOL; break; default: logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown mode %s detected.", $mode)); - $content['message'] = '{--MEMBER_UNKNOWN_MODE--}' . ': ' . $mode . "\n\n"; + $content['message'] = '{--MEMBER_UNKNOWN_MODE--}' . ': ' . $mode . PHP_EOL . PHP_EOL; break; } // END - switch } // END - foreach @@ -2075,7 +2083,7 @@ function doTemplateExtensionRegistrationLink ($templateName, $clear, $ext_name) $OUT = '---'; } elseif (isExtensionProductive($ext_name)) { // Productive code - $OUT = '{--ADMIN_REGISTER_EXTENSION--}'; + $OUT = '{--ADMIN_REGISTER_EXTENSION--}'; } // Return code @@ -2231,6 +2239,18 @@ function doTemplatePointsPaymentMethodSelectionBox ($templateName, $clear = FALS return $content; } +// Template helper function to create a deferrer code if URL is not empty +function doTemplateDereferrerUrl ($templateName, $clear = FALSE, $url = NULL) { + // Is the URL not NULL and not empty? + if ((!is_null($url)) && (!empty($url))) { + // Set HTML with EL code + $url = '{--ADMIN_TEST_URL--}'; + } // END - if + + // Return URL (or content) or dashes if empty + return fixEmptyContentToDashes($url); +} + // Tries to anonymize some sensitive data (e.g. IP address, user agent, referrer, etc.) function anonymizeSensitiveData ($data) { // Trim it @@ -2275,7 +2295,7 @@ function anonymizeSensitiveData ($data) { */ function compactContent ($uncompactedContent) { // First, remove all tab/new-line/revert characters - $compactedContent = str_replace(chr(9), '', str_replace(chr(10), '', str_replace(chr(13), '', $uncompactedContent))); + $compactedContent = str_replace(chr(9), '', str_replace(PHP_EOL, '', str_replace(chr(13), '', $uncompactedContent))); // Then regex all comments like away preg_match_all('//', $compactedContent, $matches);