]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Further fixes for wrong getMaskedMessage() usage in 'compiled' code
[mailer.git] / inc / functions.php
index bac7b16a82c2a885ece8cd0f7738929d43bf0ecf..5e7d2962d2adabc3e0a022d89c4b4fe8ff30dfc3 100644 (file)
@@ -171,14 +171,14 @@ function compileFinalOutput () {
 
 // Main compilation loop
 function doFinalCompilation ($code, $insertComments = true) {
-       // Insert comments?
+       // Insert comments? (Only valid with HTML templates, of course)
        enableTemplateHtml($insertComments);
 
        // Init counter
        $cnt = 0;
 
        // Compile all out
-       while (((strpos($code, '{--') !== false) || (strpos($code, '{DQUOTE}') !== false) || (strpos($code, '{!') !== false) || (strpos($code, '{?') !== false) || (strpos($code, '{%') !== false)) && ($cnt < 3)) {
+       while (((strpos($code, '{--') !== false) || (strpos($code, '{DQUOTE}') !== false) || (strpos($code, '{?') !== false) || (strpos($code, '{%') !== false)) && ($cnt < 3)) {
                // Init common variables
                $content = array();
                $newContent = '';
@@ -186,7 +186,7 @@ function doFinalCompilation ($code, $insertComments = true) {
                // Compile it
                //* DEBUG: */ print '<pre>'.htmlentities($code).'</pre>';
                $eval = '$newContent = "' . str_replace('{DQUOTE}', '"', compileCode(escapeQuotes($code))) . '";';
-               //* DEBUG: */ die('<pre>'.htmlentities($eval).'</pre>');
+               //* DEBUG: */ if ($insertComments) die('<pre>'.linenumberCode($eval).'</pre>');
                eval($eval);
                //* DEBUG: */ die('<pre>'.htmlentities($newContent).'</pre>');
 
@@ -306,7 +306,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) || (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)) {
                                // Normal HTML output?
                                if (getOutputMode() == '0') {
                                        // Add surrounding HTML comments to help finding bugs faster
@@ -607,7 +607,7 @@ Message : ' . htmlentities(utf8_decode($message)) . '
        }
 
        // Why did we end up here? This should not happen
-       debug_report_bug('Ending up: template=' . $template);
+       debug_report_bug(__FUNCTION__, __LINE__, 'Ending up: template=' . $template);
 }
 
 // Check to use wether legacy mail() command or PHPMailer class
@@ -880,7 +880,7 @@ function translateMenuVisibleLocked ($content, $prefix = '') {
                case 'N': $content[$prefix . 'visible_css'] = $prefix . 'menu_invisible'; break;
                default:
                        // Please report this
-                       debug_report_bug('Unsupported visible value detected. content=<pre>'.print_r($content, true).'</pre>');
+                       debug_report_bug(__FUNCTION__, __LINE__, 'Unsupported visible value detected. content=<pre>'.print_r($content, true).'</pre>');
                        break;
        } // END - switch
 
@@ -891,7 +891,7 @@ function translateMenuVisibleLocked ($content, $prefix = '') {
                case 'N': $content[$prefix . 'locked_css'] = $prefix . 'menu_unlocked'; break;
                default:
                        // Please report this
-                       debug_report_bug('Unsupported locked value detected. content=<pre>'.print_r($content, true).'</pre>');
+                       debug_report_bug(__FUNCTION__, __LINE__, 'Unsupported locked value detected. content=<pre>'.print_r($content, true).'</pre>');
                        break;
        } // END - switch
 
@@ -987,6 +987,9 @@ function redirectToUrl ($URL, $allowSpider = true) {
 
        // Simple probe for bots/spiders from search engines
        if ((isSpider()) && ($allowSpider === true)) {
+               // Set HTTP-Status
+               setHttpStatus('200 OK');
+
                // Set content-type here to fix a missing array element
                setContentType('text/html');
 
@@ -1049,7 +1052,7 @@ function compileCode ($code, $simple = false, $constants = true, $full = true) {
 }
 
 // Compiles the code (use compileCode() only for HTML because of the comments)
-// @TODO $simple is deprecated
+// @TODO $simple/$constants are deprecated
 function compileRawCode ($code, $simple = false, $constants = true, $full = true) {
        // Is the code a string?
        if (!is_string($code)) {
@@ -1066,16 +1069,8 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true
        // Compile more through a filter
        $code = runFilterChain('compile_code', $code);
 
-       // Compile constants
-       if ($constants === true) {
-               // BEFORE 0.2.1 : Language and data constants
-               // WITH 0.2.1+  : Only language constants
-               $code = str_replace('{--', "{DQUOTE} . getMessage('", str_replace('--}', "') . {DQUOTE}", $code));
-
-               // BEFORE 0.2.1 : Not used
-               // WITH 0.2.1+  : Data constants
-               $code = str_replace('{!', "{DQUOTE} . constant('", str_replace('!}', "') . {DQUOTE}", $code));
-       } // END - if
+       // Compile message strings
+       $code = str_replace('{--', '{%message,', str_replace('--}', '%}', $code));
 
        // Compile QUOT and other non-HTML codes
        foreach ($secChars['to'] as $k => $to) {
@@ -3487,7 +3482,7 @@ function initCacheInstance () {
        $GLOBALS['cache_instance'] = new CacheSystem();
        if ($GLOBALS['cache_instance']->getStatus() != 'done') {
                // Failed to initialize cache sustem
-               addFatalMessage(__FUNCTION__, __LINE__, '(<font color="#0000aa">' . __LINE__ . '</font>): ' . getMessage('CACHE_CANNOT_INITIALIZE'));
+               addFatalMessage(__FUNCTION__, __LINE__, '(<font color="#0000aa">' . __LINE__ . '</font>): {--CACHE_CANNOT_INITIALIZE--}');
        } // END - if
 }
 
@@ -3871,9 +3866,6 @@ function isSpider () {
 
 // Prepares the header for HTML output
 function loadHtmlHeader () {
-       // Enable HTML templates
-       enableTemplateHtml();
-
        // Run two filters:
        // 1.) pre_page_header (mainly loads the page_header template and includes
        //     meta description)