]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Several fixes for broken actions (sorry for lame text)
[mailer.git] / inc / functions.php
index c55b421dd3eb12a381c5c75e3caaea541276aa23..9cd97a5890e348df795c823a58f6095aad5697a6 100644 (file)
@@ -44,7 +44,8 @@ if (!defined('__SECURITY')) {
 // Output HTML code directly or 'render' it. You addionally switch the new-line character off
 function outputHtml ($htmlCode, $newLine = true) {
        // Transfer username
-       $username = getUsername();
+       $username = getMessage('USERNAME_UNKNOWN');
+       if (isset($GLOBALS['username'])) $username = getUsername();
 
        // Do we have HTML-Code here?
        if (!empty($htmlCode)) {
@@ -135,7 +136,7 @@ function outputHtml ($htmlCode, $newLine = true) {
                        // Was that eval okay?
                        if (empty($newContent)) {
                                // Something went wrong!
-                               debug_report_bug('Evaluation error:<pre>' . htmlentities($eval) . '</pre>');
+                               debug_report_bug('Evaluation error:<pre>' . linenumberCode($eval) . '</pre>');
                        } // END - if
                        $GLOBALS['output'] = $newContent;
 
@@ -559,8 +560,12 @@ function loadEmailTemplate ($template, $content = array(), $UID = '0') {
        unset($content);
        unset($DATA);
 
-       // Return compiled content
-       return compileCode($newContent);
+       // Compile the code and eval it
+       $eval = '$newContent = "' . compileCode(smartAddSlashes($newContent)) . '";';
+       eval($eval);
+
+       // Return content
+       return $newContent;
 }
 
 // Send mail out to an email address
@@ -3594,6 +3599,28 @@ function handleFatalErrors () {
        shutdown();
 }
 
+// Print code with line numbers
+function linenumberCode ($code)    {
+       if (!is_array($code)) $codeE = explode("\n", $code); else $codeE = $code;
+       $count_lines = count($codeE);
+
+       $r = "Line | Code:<br />";
+       foreach($codeE as $line => $c) {
+               $r .= "<div class=\"line\"><span class=\"linenum\">";
+               if ($count_lines == 1) {
+                       $r .= '1';
+               } else {
+                       $r .= ($line == ($count_lines - 1)) ? '' :  ($line+1);
+               }
+               $r .= "</span>|";
+
+               // Add code
+               $r .= "<span class=\"linetext\">" . htmlentities($c) . "</span></div>";
+       }
+
+       return "<div class=\"code\">" . $r . "</div>\n";
+}
+
 //////////////////////////////////////////////////
 // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //
 //////////////////////////////////////////////////