Fixes for POST setter, template and others
[mailer.git] / inc / functions.php
index fd2eab7f3dd216f1fccbe8b94ec91c072ea06f23..c55b421dd3eb12a381c5c75e3caaea541276aa23 100644 (file)
@@ -119,8 +119,11 @@ function outputHtml ($htmlCode, $newLine = true) {
                        $GLOBALS['output'] = rewriteLinksInCode($GLOBALS['output']);
                } // END - if
 
+               // Init counter
+               $cnt = 0;
+
                // Compile and run finished rendered HTML code
-               while ((strpos($GLOBALS['output'], '{!') > 0) || (strpos($GLOBALS['output'], '{?') > 0)) {
+               while (((strpos($GLOBALS['output'], '{--') > 0) || (strpos($GLOBALS['output'], '{!') > 0) || (strpos($GLOBALS['output'], '{?') > 0)) && ($cnt < 3)) {
                        // Prepare the content and eval() it...
                        $content = array();
                        $newContent = '';
@@ -135,6 +138,9 @@ function outputHtml ($htmlCode, $newLine = true) {
                                debug_report_bug('Evaluation error:<pre>' . htmlentities($eval) . '</pre>');
                        } // END - if
                        $GLOBALS['output'] = $newContent;
+
+                       // Count round
+                       $cnt++;
                } // END - while
 
                // Output code here, DO NOT REMOVE! ;-)
@@ -191,6 +197,7 @@ function addFatalMessage ($F, $L, $message, $extra='') {
        $GLOBALS['fatal_messages'][] = $message;
 
        // Log fatal messages away
+       debug_report_bug($message);
        logDebugMessage($F, $L, " message={$message}");
 }
 
@@ -356,8 +363,9 @@ function loadTemplate ($template, $return=false, $content=array()) {
                                        $eval = '$ret = "' . compileCode(smartAddSlashes($GLOBALS['tpl_content'])) . '";';
                                }
                        } else {
-                               // Simply return loaded code
-                               $eval = '$ret = $GLOBALS[\'tpl_content\'];';
+                               // Add surrounding HTML comments to help finding bugs faster
+                               $ret = "<!-- Template " . $template . " - Start -->\n" . $GLOBALS['tpl_content'] . "<!-- Template " . $template . " - End -->\n";
+                               $eval = '$ret = "' . smartAddSlashes($ret) . '";';
                        } // END - if
 
                        // Cache the eval() command here
@@ -732,9 +740,9 @@ function generateDateTime ($time, $mode = '0') {
                case 'de': // German date / time format
                        switch ($mode) {
                                case '0': $ret = date("d.m.Y \u\m H:i \U\h\\r", $time); break;
-                               case '1': $ret = strtolower(date("d.m.Y - H:i", $time)); break;
-                               case '2': $ret = date("d.m.Y|H:i", $time); break;
-                               case '3': $ret = date("d.m.Y", $time); break;
+                               case '1': $ret = strtolower(date('d.m.Y - H:i', $time)); break;
+                               case '2': $ret = date('d.m.Y|H:i', $time); break;
+                               case '3': $ret = date('d.m.Y', $time); break;
                                default:
                                        logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
                                        break;
@@ -743,10 +751,10 @@ function generateDateTime ($time, $mode = '0') {
 
                default: // Default is the US date / time format!
                        switch ($mode) {
-                               case '0': $ret = date("r", $time); break;
-                               case '1': $ret = date("Y-m-d - g:i A", $time); break;
-                               case '2': $ret = date("y-m-d|H:i", $time); break;
-                               case '3': $ret = date("y-m-d", $time); break;
+                               case '0': $ret = date('r', $time); break;
+                               case '1': $ret = date('Y-m-d - g:i A', $time); break;
+                               case '2': $ret = date('y-m-d|H:i', $time); break;
+                               case '3': $ret = date('y-m-d', $time); break;
                                default:
                                        logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
                                        break;
@@ -760,7 +768,7 @@ function generateDateTime ($time, $mode = '0') {
 // Translates Y/N to yes/no
 function translateYesNo ($yn) {
        // Default
-       $translated = "??? (" . $yn.')';
+       $translated = '??? (' . $yn . ')';
        switch ($yn) {
                case 'Y': $translated = getMessage('YES'); break;
                case 'N': $translated = getMessage('NO'); break;
@@ -881,7 +889,7 @@ function generateDerefererUrl ($URL) {
        // Don't de-refer our own links!
        if (substr($URL, 0, strlen(getConfig('URL'))) != getConfig('URL')) {
                // De-refer this link
-               $URL = 'modules.php?module=loader&amp;url=' . encodeString(compileUriCode($URL));
+               $URL = '{?URL?}/modules.php?module=loader&amp;url=' . encodeString(compileUriCode($URL));
        } // END - if
 
        // Return link
@@ -1317,7 +1325,7 @@ function generateRandomCode ($length, $code, $userid, $DATA = '') {
 // Does only allow numbers
 function bigintval ($num, $castValue = true) {
        // Filter all numbers out
-       $ret = preg_replace("/[^0123456789]/", '', $num);
+       $ret = preg_replace('/[^0123456789]/', '', $num);
 
        // Shall we cast?
        if ($castValue) $ret = (double)$ret;
@@ -3053,7 +3061,7 @@ function rebuildCacheFile ($cache, $inc = '', $force = false) {
                // Rebuild cache
                if ($GLOBALS['cache_instance']->loadCacheFile($cache)) {
                        // Destroy it
-                       $GLOBALS['cache_instance']->removeCacheFile(false, $force);
+                       $GLOBALS['cache_instance']->removeCacheFile($force);
                } // END - if
 
                // Include file given?