]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Add slashes instead of SQL_ESCAPE()
[mailer.git] / inc / functions.php
index a52770e945268a7f3031c3c348bee40c18b73f06..25610ef39c4263cbded07e7e7d4ddf3acc22c15c 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)) {
@@ -115,7 +116,7 @@ function outputHtml ($htmlCode, $newLine = true) {
                sendHeader('Content-language: ' . getLanguage());
 
                // Extension 'rewrite' installed?
-               if ((isExtensionActive('rewrite')) && (getOutputMode() != '1')) {
+               if ((isExtensionActive('rewrite')) && (getOutputMode() != 1)) {
                        $GLOBALS['output'] = rewriteLinksInCode($GLOBALS['output']);
                } // END - if
 
@@ -123,7 +124,7 @@ function outputHtml ($htmlCode, $newLine = true) {
                $cnt = 0;
 
                // Compile and run finished rendered HTML code
-               while (((strpos($GLOBALS['output'], '{!') > 0) || (strpos($GLOBALS['output'], '{?') > 0)) && ($cnt < 3)) {
+               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,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;
 
@@ -147,7 +148,7 @@ function outputHtml ($htmlCode, $newLine = true) {
                outputRawCode($GLOBALS['output']);
        } elseif ((getConfig('OUTPUT_MODE') == 'render') && (!empty($GLOBALS['output']))) {
                // Rewrite links when rewrite extension is active
-               if ((isExtensionActive('rewrite')) && (getOutputMode() != '1')) {
+               if ((isExtensionActive('rewrite')) && (getOutputMode() != 1)) {
                        $GLOBALS['output'] = rewriteLinksInCode($GLOBALS['output']);
                } // END - if
 
@@ -240,7 +241,7 @@ function loadTemplate ($template, $return=false, $content=array()) {
                if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = 0;
 
                // Generate date/time string
-               $date_time = generateDateTime(time(), '1');
+               $date_time = generateDateTime(time(), 1);
 
                // Is content an array
                if (is_array($content)) $content['date_time'] = $date_time;
@@ -409,7 +410,7 @@ function loadTemplate ($template, $return=false, $content=array()) {
 }
 
 // Loads an email template and compiles it
-function loadEmailTemplate ($template, $content = array(), $UID = '0') {
+function loadEmailTemplate ($template, $content = array(), $UID = 0) {
        global $DATA;
 
        // Our configuration is kept non-global here
@@ -526,10 +527,9 @@ function loadEmailTemplate ($template, $content = array(), $UID = '0') {
        if (isFileReadable($FQFN)) {
                // The local file does exists so we load it. :)
                $GLOBALS['tpl_content'] = readFromFile($FQFN);
-               $GLOBALS['tpl_content'] = SQL_ESCAPE($GLOBALS['tpl_content']);
 
                // Run code
-               $GLOBALS['tpl_content'] = "\$newContent = decodeEntities(\"".compileCode($GLOBALS['tpl_content'])."\");";
+               $GLOBALS['tpl_content'] = "\$newContent = decodeEntities(\"".compileCode(smartAddSlashes($GLOBALS['tpl_content']))."\");";
                eval($GLOBALS['tpl_content']);
        } elseif (!empty($template)) {
                // Template file not found!
@@ -559,8 +559,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
@@ -631,12 +635,12 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = '
        if (empty($isHtml)) $isHtml = 'N';
        if (isDebugModeEnabled()) {
                // In debug mode we want to display the mail instead of sending it away so we can debug this part
-               outputHtml("<pre>
-".htmlentities(trim($mailHeader))."
-To      : " . $toEmail."
-Subject : " . $subject."
-Message : " . $message."
-</pre>\n");
+               outputHtml('<pre>
+Headers : ' . str_replace('<', '&lt', str_replace('>', '&gt;', htmlentities(trim($mailHeader)))) . '
+To      : ' . $toEmail . '
+Subject : ' . $subject . '
+Message : ' . $message . '
+</pre>');
        } elseif (($isHtml == 'Y') && (isExtensionActive('html_mail'))) {
                // Send mail as HTML away
                sendHtmlEmail($toEmail, $subject, $message, $mailHeader);
@@ -726,7 +730,7 @@ function generatePassword ($length = 0) {
 }
 
 // Generates a human-readable timestamp from the Uni* stamp
-function generateDateTime ($time, $mode = '0') {
+function generateDateTime ($time, $mode = 0) {
        // Filter out numbers
        $time = bigintval($time);
 
@@ -739,10 +743,10 @@ function generateDateTime ($time, $mode = '0') {
        switch (getLanguage()) {
                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 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;
                                default:
                                        logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
                                        break;
@@ -751,10 +755,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;
@@ -803,7 +807,7 @@ function translatePoolType ($type) {
 // Translates the american decimal dot into a german comma
 function translateComma ($dotted, $cut = true, $max = 0) {
        // Default is 3 you can change this in admin area "Misc -> Misc Options"
-       if (!isConfigEntrySet('max_comma')) setConfigEntry('max_comma', '3');
+       if (!isConfigEntrySet('max_comma')) setConfigEntry('max_comma', 3);
 
        // Use from config is default
        $maxComma = getConfig('max_comma');
@@ -889,7 +893,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
@@ -930,18 +934,25 @@ function countSelection ($array) {
 
 // Generate XHTML code for the CAPTCHA
 function generateCaptchaCode ($code, $type, $DATA, $userid) {
-       return '<IMG border="0" alt="Code" src="{?URL?}/mailid_top.php?userid=' . $userid . '&amp;' . $type . '=' . $DATA . '&amp;mode=img&amp;code=' . $code . '" />';
+       return '<img border="0" alt="Code ' . $code . '" src="{?URL?}/mailid_top.php?userid=' . $userid . '&amp;' . $type . '=' . $DATA . '&amp;mode=img&amp;code=' . $code . '" />';
 }
 
 // Generates a timestamp (some wrapper for mktime())
-function makeTime ($H, $M, $S, $stamp) {
+function makeTime ($hours, $minutes, $seconds, $stamp) {
        // Extract day, month and year from given timestamp
-       $day   = date('d', $stamp);
-       $month = date('m', $stamp);
-       $year  = date('Y', $stamp);
+       $days   = date('d', $stamp);
+       $months = date('m', $stamp);
+       $years  = date('Y', $stamp);
 
        // Create timestamp for wished time which depends on extracted date
-       return mktime($H, $M, $S, $month, $day, $year);
+       return mktime(
+               $hours,
+               $minutes,
+               $seconds,
+               $months,
+               $days,
+               $years
+       );
 }
 
 // Redirects to an URL and if neccessarry extends it with own base URL
@@ -1153,7 +1164,7 @@ function array_pk_sort (&$array, $a_sort, $primary_key = 0, $order = -1, $nums =
 }
 
 //
-function addSelectionBox ($type, $default, $prefix = '', $id = '0') {
+function addSelectionBox ($type, $default, $prefix = '', $id = 0) {
        $OUT = '';
 
        if ($type == 'yn') {
@@ -1238,7 +1249,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0') {
                case 'sec':
                case 'min':
                        for ($idx = 0; $idx < 60; $idx+=5) {
-                               if (strlen($idx) == 1) $idx = '0' . $idx;
+                               if (strlen($idx) == 1) $idx = 0 . $idx;
                                $OUT .= "<option value=\"" . $idx."\"";
                                if ($default == $idx) $OUT .= ' selected="selected"';
                                $OUT .= ">" . $idx."</option>\n";
@@ -1247,7 +1258,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0') {
 
                case 'hour':
                        for ($idx = 0; $idx < 24; $idx++) {
-                               if (strlen($idx) == 1) $idx = '0' . $idx;
+                               if (strlen($idx) == 1) $idx = 0 . $idx;
                                $OUT .= "<option value=\"" . $idx."\"";
                                if ($default == $idx) $OUT .= ' selected="selected"';
                                $OUT .= ">" . $idx."</option>\n";
@@ -1325,7 +1336,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;
@@ -1650,7 +1661,7 @@ function addEmailNavigation ($PAGES, $offset, $show_form, $colspan, $return=fals
        $NAV = '';
        for ($page = 1; $page <= $PAGES; $page++) {
                // Is the page currently selected or shall we generate a link to it?
-               if (($page == getRequestElement('page')) || ((!isGetRequestElementSet('page')) && ($page == '1'))) {
+               if (($page == getRequestElement('page')) || ((!isGetRequestElementSet('page')) && ($page == 1))) {
                        // Is currently selected, so only highlight it
                        $NAV .= '<strong>-';
                } else {
@@ -1664,7 +1675,7 @@ function addEmailNavigation ($PAGES, $offset, $show_form, $colspan, $return=fals
                        $NAV .= '">';
                }
                $NAV .= $page;
-               if (($page == getRequestElement('page')) || ((!isGetRequestElementSet('page')) && ($page == '1'))) {
+               if (($page == getRequestElement('page')) || ((!isGetRequestElementSet('page')) && ($page == 1))) {
                        // Is currently selected, so only highlight it
                        $NAV .= '-</strong>';
                } else {
@@ -1730,10 +1741,25 @@ function extractHostnameFromUrl (&$script) {
 }
 
 // Send a GET request
-function sendGetRequest ($script) {
+function sendGetRequest ($script, $data = array()) {
        // Extract host name from script
        $host = extractHostnameFromUrl($script);
 
+       // Add data
+       $scriptData = http_build_query($data, '', '&');
+
+       // Do we have a question-mark in the script?
+       if (strpos($script, '?') === false) {
+               // No, so first char must be question mark
+               $scriptData = '?' . $scriptData;
+       } else {
+               // Ok, add &
+               $scriptData = '&' . $scriptData;
+       }
+
+       // Add script data
+       $script .= $scriptData;
+
        // Generate GET request header
        $request  = 'GET /' . trim($script) . ' HTTP/1.1' . getConfig('HTTP_EOL');
        $request .= 'Host: ' . $host . getConfig('HTTP_EOL');
@@ -1770,7 +1796,7 @@ function sendPostRequest ($script, $postData) {
        $host = extractHostnameFromUrl($script);
 
        // Construct request
-       $data = http_build_query($postData, '','&');
+       $data = http_build_query($postData, '', '&');
 
        // Generate POST request header
        $request  = 'POST /' . trim($script) . ' HTTP/1.1' . getConfig('HTTP_EOL');
@@ -2009,7 +2035,7 @@ function generateEmailLink ($email, $table = 'admins') {
 // Generate a hash for extra-security for all passwords
 function generateHash ($plainText, $salt = '') {
        // Is the required extension 'sql_patches' there and a salt is not given?
-       if (((isExtensionInstalledAndOlder('sql_patches', '0.3.6')) || (!isExtensionActive('sql_patches'))) && (empty($salt))) {
+       if (((isExtensionInstalledAndOlder('sql_patches', '0.3.6')) || (!isExtensionActive('sql_patches')) || (!isExtensionInstalledAndNewer('other', '0.2.5'))) && (empty($salt))) {
                // Extension sql_patches is missing/outdated so we hash the plain text with MD5
                return md5($plainText);
        } // END - if
@@ -2141,7 +2167,7 @@ function generatePassString ($passHash) {
        $ret = $passHash;
 
        // Is a secret key and master salt already initialized?
-       if ((isExtensionInstalled('sql_patches')) && (isConfigEntrySet('secret_key')) && (isConfigEntrySet('master_salt'))) {
+       if ((isExtensionInstalled('sql_patches')) && (isConfigEntrySet('_PRIME')) && (isConfigEntrySet('secret_key')) && (isConfigEntrySet('master_salt'))) {
                // Only calculate when the secret key is generated
                $newHash = ''; $start = 9;
                for ($idx = 0; $idx < 10; $idx++) {
@@ -2154,7 +2180,7 @@ function generatePassString ($passHash) {
                                $mod = dechex(sqrt(($part2 - $part1) * getConfig('_PRIME') / pi()));
                        }
                        $mod = substr(round($mod), 0, 4);
-                       $mod = str_repeat('0', 4-strlen($mod)) . $mod;
+                       $mod = str_repeat(0, 4-strlen($mod)) . $mod;
                        //* DEBUG: */ outputHtml("*" . $start.'=' . $mod."*<br />");
                        $start += 4;
                        $newHash .= $mod;
@@ -2283,7 +2309,7 @@ function getCurrentTheme () {
        $ret = 'default';
 
        // Load default theme if not empty from configuration
-       if (getConfig('default_theme') != '') $ret = getConfig('default_theme');
+       if ((isConfigEntrySet('default_theme')) && (getConfig('default_theme') != '')) $ret = getConfig('default_theme');
 
        if (!isSessionVariableSet('mxchange_theme')) {
                // Set default theme
@@ -2592,6 +2618,17 @@ function debug_get_printable_backtrace () {
 
 // Output a debug backtrace to the user
 function debug_report_bug ($message = '') {
+       // Is this already called?
+       if (isset($GLOBALS[__FUNCTION__])) {
+               // Other backtrace
+               print 'Message:'.$message.'<br />Backtrace:<pre>';
+               debug_print_backtrace();
+               die('</pre>');
+       } // END - if
+
+       // Set this function as called
+       $GLOBALS[__FUNCTION__] = true;
+
        // Init message
        $debug = '';
 
@@ -2649,7 +2686,7 @@ function getMessageFromErrorCode ($code) {
                case getCode('OVERLENGTH')       : $message = getMessage('MEMBER_TEXT_OVERLENGTH'); break;
                case getCode('URL_FOUND')        : $message = getMessage('MEMBER_TEXT_CONTAINS_URL'); break;
                case getCode('SUBJ_URL')         : $message = getMessage('MEMBER_SUBJ_CONTAINS_URL'); break;
-               case getCode('BLIST_URL')        : $message = "{--MEMBER_URL_BLACK_LISTED--}<br />\n{--MEMBER_BLIST_TIME--}: ".generateDateTime(getRequestElement('blist'), '0'); break;
+               case getCode('BLIST_URL')        : $message = "{--MEMBER_URL_BLACK_LISTED--}<br />\n{--MEMBER_BLIST_TIME--}: ".generateDateTime(getRequestElement('blist'), 0); break;
                case getCode('NO_RECS_LEFT')     : $message = getMessage('MEMBER_SELECTED_MORE_RECS'); break;
                case getCode('INVALID_TAGS')     : $message = getMessage('MEMBER_HTML_INVALID_TAGS'); break;
                case getCode('MORE_POINTS')      : $message = getMessage('MEMBER_MORE_POINTS_NEEDED'); break;
@@ -2680,7 +2717,7 @@ function getMessageFromErrorCode ($code) {
 
                        // Load timestamp from last order
                        list($timestamp) = SQL_FETCHROW($result);
-                       $timestamp = generateDateTime($timestamp, '1');
+                       $timestamp = generateDateTime($timestamp, 1);
 
                        // Free memory
                        SQL_FREERESULT($result);
@@ -2907,7 +2944,7 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
        return false;
 }
 // Send notification to admin
-function sendAdminNotification ($subject, $templateName, $content=array(), $userid = '0') {
+function sendAdminNotification ($subject, $templateName, $content=array(), $userid = 0) {
        if (getExtensionVersion('admins') >= '0.4.1') {
                // Send new way
                sendAdminsEmails($subject, $templateName, $content, $userid);
@@ -3035,7 +3072,7 @@ function handleLoginFailtures ($accessLevel) {
                        //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):accessLevel={$accessLevel}<br />");
                        $content = array(
                                'login_failures' => getSession('mxchange_' . $accessLevel.'_failures'),
-                               'last_failure'   => generateDateTime(getSession('mxchange_' . $accessLevel.'_last_fail'), '2')
+                               'last_failure'   => generateDateTime(getSession('mxchange_' . $accessLevel.'_last_fail'), 2)
                        );
 
                        // Load template
@@ -3144,7 +3181,7 @@ function addNewBonusMail ($data, $mode = '', $output=true) {
 // Determines referal id and sets it
 function determineReferalId () {
        // Skip this in non-html-mode
-       if (getOutputMode() != '0') return false;
+       if (getOutputMode() != 0) return false;
 
        // Check if refid is set
        if ((isset($GLOBALS['refid'])) && ($GLOBALS['refid'] > 0)) {
@@ -3176,7 +3213,7 @@ function determineReferalId () {
        }
 
        // Set cookie when default refid > 0
-       if (!isSessionVariableSet('refid') || (!empty($GLOBALS['refid'])) || ((getSession('refid') == '0') && (getConfig('def_refid') > 0))) {
+       if (!isSessionVariableSet('refid') || (!empty($GLOBALS['refid'])) || ((getSession('refid') == 0) && (isConfigEntrySet('def_refid')) && (getConfig('def_refid') > 0))) {
                // Set cookie
                setSession('refid', $GLOBALS['refid']);
        } // END - if
@@ -3464,8 +3501,25 @@ function mapModuleToTable ($moduleName) {
 
 // Add SQL debug data to array for later output
 function addSqlToDebug ($result, $sqlString, $timing, $F, $L) {
-       // Don't execute anything here if we don't need
-       if (getConfig('display_debug_sqls') != 'Y') return;
+       // Already executed?
+       if (isset($GLOBALS['debug_sqls'][$F][$L][$sqlString])) {
+               // Then abort here, we don't need to profile a query twice
+               return;
+       } // END - if
+
+       // Remeber this as profiled (or not, but we don't care here)
+       $GLOBALS['debug_sqls'][$F][$L][$sqlString] = true;
+
+       // Do we have cache?
+       if (!isset($GLOBALS['debug_sql_available'])) {
+               // Check it and cache it in $GLOBALS
+               $GLOBALS['debug_sql_available'] = ((isConfigurationLoaded()) && (isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
+       } // END - if
+       
+       // Don't execute anything here if we don't need or ext-other is missing
+       if ($GLOBALS['debug_sql_available'] === false) {
+               return;
+       } // END - if
 
        // Generate record
        $record = array(
@@ -3490,7 +3544,7 @@ function initCacheInstance () {
        $GLOBALS['cache_instance'] = new CacheSystem();
        if ($GLOBALS['cache_instance']->getStatus() != 'done') {
                // Failed to initialize cache sustem
-               addFatalMessage(__FILE__, __LINE__, "(<font color=\"#0000aa\">".__LINE__."</font>): ".getMessage('CACHE_CANNOT_INITIALIZE'));
+               addFatalMessage(__FILE__, __LINE__, '(<font color="#0000aa">' . __LINE__ . '</font>): ' . getMessage('CACHE_CANNOT_INITIALIZE'));
        } // END - if
 }
 
@@ -3509,89 +3563,31 @@ function getMessageFromIndexedArray ($message, $pos, $array) {
        return $ret;
 }
 
-// Handles fatal errors
-function handleFatalErrors () {
-       // Do we have errors to handle and right output mode?
-       if ((getTotalFatalErrors() == 0) || (getOutputMode() != 0)) {
-               // Abort executing here
-               return false;
-       } // END - if
-
-       // Set content type
-       setContentType('text/html');
-
-       // Load config here
-       loadIncludeOnce('inc/load_config.php');
-
-       // Set unset variable
-       if (empty($check)) $check = '';
-
-       // Default is none
-       $content = '';
-
-       // Installation phase or regular mode?
-       if ((isInstallationPhase())) {
-               // While we are installing ouput other header than while it is installed... :-)
-               $OUT = '';
-               foreach (getFatalArray() as $key => $value) {
-                       // Prepare content for the template
-                       $content = array(
-                               'key'   => ($key + 1),
-                               'value' => $value
-                       );
-
-                       // Load row template
-                       $OUT .= loadTemplate('install_fatal_row', true, $content);
-               }
+// Print code with line numbers
+function linenumberCode ($code)    {
+       if (!is_array($code)) $codeE = explode("\n", $code); else $codeE = $code;
+       $count_lines = count($codeE);
 
-               // Load main template
-               $content = loadTemplate('install_fatal_table', true, $OUT);
-       } elseif (isInstalled()) {
-               // Display all runtime fatal errors
-               $OUT = '';
-               foreach (getFatalArray() as $key => $value) {
-                       // Prepare content for the template
-                       $content = array(
-                               'key'   => ($key + 1),
-                               'value' => $value
-                       );
-
-                       // Load row template
-                       $OUT .= loadTemplate('runtime_fatal_row', true, $content);
+       $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>|';
 
-               // Load main template
-               $content = loadTemplate('runtime_fatal_table', true, $OUT);
+               // Add code
+               $r .= '<span class="linetext">' . htmlentities($c) . '</span></div>';
        }
 
-       // Message to regular users (non-admin)
-       $CORR = getMessage('FATAL_REPORT_ERRORS');
-
-       // PHP warnings fixed
-       if ($check == 'done') {
-               if (isAdmin()) $CORR = getMessage('FATAL_CORRECT_ERRORS');
-       } // END - if
-
-       // Remember all in array
-       $content = array(
-               'rows' => $content,
-               'corr' => $CORR
-       );
-
-       // Load footer
-       loadIncludeOnce('inc/header.php');
-
-       // Load main template
-       loadTemplate('fatal_errors', false, $content);
-
-       // Delete all to prevent double-display
-       initFatalMessages();
-
-       // Load footer
-       loadIncludeOnce('inc/footer.php');
+       return '<div class="code">' . $r . '</div>';
+}
 
-       // Abort here
-       shutdown();
+// Convert ';' to ', ' for e.g. receiver list
+function convertReceivers ($old) {
+       return str_replace(';', ', ', $old);
 }
 
 //////////////////////////////////////////////////
@@ -3607,5 +3603,29 @@ if (!function_exists('html_entity_decode')) {
        }
 } // END - if
 
+if (!function_exists('http_build_query')) {
+       // Taken from documentation on www.php.net, credits to Marco K. (Germany)
+       function http_build_query($data, $prefix='', $sep='', $key='') {
+               $ret = array();
+               foreach ((array)$data as $k => $v) {
+                       if (is_int($k) && $prefix != null) {
+                               $k = urlencode($prefix . $k);
+                       } // END - if
+
+                       if ((!empty($key)) || ($key === 0))  $k = $key.'['.urlencode($k).']';
+
+                       if (is_array($v) || is_object($v)) {
+                               array_push($ret, http_build_query($v, '', $sep, $k));
+                       } else {
+                               array_push($ret, $k.'='.urlencode($v));
+                       }
+               } // END - foreach
+
+               if (empty($sep)) $sep = ini_get('arg_separator.output');
+
+               return implode($sep, $ret);
+       }
+}// // END - if
+
 // [EOF]
 ?>