'; } else { $emailHeaders = 'From: noreply@domain.com'; } $emailBody = 'Occurred: ' . date('l jS F Y, G:i:s') . "\n"; $emailBody .= 'Website: ' . $website . "\n"; $emailBody .= 'Request: ' . $request . "\n"; $emailBody .= 'Referer: ' . $referer . "\n"; $emailBody .= 'Remote: ' . $remote . "\n"; $emailBody .= 'Message:- ' . "\n\n"; $emailBody .= preg_replace('/^/m', ' ', $message) . "\n"; if (!is_array($GLOBALS['emailError'])) { $GLOBALS['emailError'] = array($GLOBALS['emailError']); } foreach ($GLOBALS['emailError'] as $emailAddress) { mail($emailAddress, $emailSubject, $emailBody, $emailHeaders); } } //-------------------------------------------------- // Add report to the database if (is_file(ROOT . '/a/php/database.php') && isset($GLOBALS['db'])) { $db = $GLOBALS['db']; $db->query('INSERT INTO ' . DB_PREFIX . 'report ( id, type, created, message, request, referer, ip ) VALUES ( "", "' . $db->escape($type) . '", "' . $db->escape(date('Y-m-d H:i:s')) . '", "' . $db->escape($message) . '", "' . $db->escape($request) . '", "' . $db->escape($referer) . '", "' . $db->escape($remote) . '" )'); } } //-------------------------------------------------- // Function to call when a serious error occurs function exit_with_error($message, $hiddenInfo = NULL, $type = 'error') { //-------------------------------------------------- // Report the error $errorReport = $message; if ($hiddenInfo !== NULL) { $errorReport .= "\n\n--------------------------------------------------\n\n"; $errorReport .= $hiddenInfo; } addReport($errorReport, $type); //-------------------------------------------------- // Return the primary contacts email address. if (isset($GLOBALS['emailError'])) { if (is_array($GLOBALS['emailError'])) { $contactEmail = reset($GLOBALS['emailError']); } else { $contactEmail = $GLOBALS['emailError']; } } else { $contactEmail = ''; } //-------------------------------------------------- // Override the pageId... don't want page specific // styles playing havoc! $GLOBALS['tplPageId'] = 'pError'; //-------------------------------------------------- // Tell the user if (php_sapi_name() == 'cli') { echo "\n" . '--------------------------------------------------' . "\n\n"; echo 'Error:' . "\n\n"; echo $message . "\n\n"; if ($hiddenInfo !== NULL && $contactEmail == '') { echo $hiddenInfo . "\n\n"; } echo '--------------------------------------------------' . "\n\n"; } else { if (!headers_sent()) { header('HTTP/1.0 500 Internal Server Error'); setMimeType('text/html'); } if (is_file(ROOT . '/a/inc/global/pageTop.php')) { require_once(ROOT . '/a/inc/global/pageTop.php'); } else if (is_file(ROOT . '/a/inc/pageTop.php')) { require_once(ROOT . '/a/inc/pageTop.php'); } echo '

Error

' . nl2br(html($message)) . '

Sorry, this should not have happened, and is not your fault. The admin has been informed, and will try to fix the problem soon' . ($contactEmail == '' ? '.' : ', but please can you help by sending an email to ' . html($contactEmail) . ' with details of what you were doing at the time.') . '

'; if ($hiddenInfo !== NULL && $contactEmail == '') { echo '

' . nl2br(html($hiddenInfo)) . '

'; } if (is_file(ROOT . '/a/inc/global/pageBottom.php')) { require_once(ROOT . '/a/inc/global/pageBottom.php'); } else if (is_file(ROOT . '/a/inc/pageBottom.php')) { require_once(ROOT . '/a/inc/pageBottom.php'); } } //-------------------------------------------------- // Exit script execution exit(); } ?>