]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Debug mails added
[mailer.git] / inc / functions.php
index 3377256d43afc0d8fc52306dd88656375b61d103..3ee5bdff81c5ef7e8ffa360d5047c56ca5987707 100644 (file)
@@ -2546,6 +2546,24 @@ function debug_get_printable_backtrace () {
        return $backtrace;
 }
 
+// A mail-able backtrace
+function debug_get_mailable_backtrace () {
+       // Init variable
+       $backtrace = '';
+
+       // Get and prepare backtrace for output
+       $backtraceArray = debug_backtrace();
+       foreach ($backtraceArray as $key => $trace) {
+               if (!isset($trace['file'])) $trace['file'] = __FUNCTION__;
+               if (!isset($trace['line'])) $trace['line'] = __LINE__;
+               if (!isset($trace['args'])) $trace['args'] = array();
+               $backtrace .= ($key+1) . '.:' . basename($trace['file']) . ':' . $trace['line'] . ', ' . $trace['function'] . '(' . count($trace['args']) . ")\n";
+       } // END - foreach
+
+       // Return the backtrace
+       return $backtrace;
+}
+
 // Output a debug backtrace to the user
 function debug_report_bug ($message = '') {
        // Is this already called?
@@ -2574,11 +2592,21 @@ function debug_report_bug ($message = '') {
        } // END - if
 
        // Add output
-       $debug .= "Please report this bug at <a title=\"Direct link to the bug-tracker\" href=\"http://bugs.mxchange.org\" rel=\"external\" target=\"_blank\">bugs.mxchange.org</a> and include the logfile from <strong>" . str_replace(getConfig('PATH'), '', getConfig('CACHE_PATH')) . "debug.log</strong> in your report (you can now attach files):<pre>";
+       $debug .= "Please report this bug at <a title=\"Direct link to the bug-tracker\" href=\"http://bugs.mxchange.org\" rel=\"external\" target=\"_blank\">http://bugs.mxchange.org</a> and include the logfile from <strong>" . str_replace(getConfig('PATH'), '', getConfig('CACHE_PATH')) . "debug.log</strong> in your report (you can now attach files):<pre>";
        $debug .= debug_get_printable_backtrace();
        $debug .= "</pre>\nRequest-URI: " . getRequestUri()."<br />\n";
        $debug .= "Thank you for finding bugs.";
 
+       // Prepare content
+       $content = array(
+               'message'     => trim($message),
+               'backtrace'   => trim(debug_get_mailable_backtrace()),
+               'request_uri' => trim(getRequestUri())
+       );
+
+       // Send email to webmaster
+       sendAdminNotification(getMessage('DEBUG_REPORT_BUG_SUBJECT'), 'admin_report_bug', $content);
+
        // And abort here
        // @TODO This cannot be rewritten to app_die(), try to find a solution for this.
        die($debug);