| @@ 868-908 (lines=41) @@ | ||
| 865 | * @param int $line What line of $file the code which generated the error is on |
|
| 866 | * @return void|array Returns an array with the file and line if $error_type is 'return' |
|
| 867 | */ |
|
| 868 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
|
| 869 | { |
|
| 870 | if (empty($log_message)) |
|
| 871 | $log_message = $error_message; |
|
| 872 | ||
| 873 | foreach (debug_backtrace() as $step) |
|
| 874 | { |
|
| 875 | // Found it? |
|
| 876 | if (strpos($step['function'], 'query') === false && !in_array(substr($step['function'], 0, 7), array('smf_db_', 'preg_re', 'db_erro', 'call_us')) && strpos($step['function'], '__') !== 0) |
|
| 877 | { |
|
| 878 | $log_message .= '<br>Function: ' . $step['function']; |
|
| 879 | break; |
|
| 880 | } |
|
| 881 | ||
| 882 | if (isset($step['line'])) |
|
| 883 | { |
|
| 884 | $file = $step['file']; |
|
| 885 | $line = $step['line']; |
|
| 886 | } |
|
| 887 | } |
|
| 888 | ||
| 889 | // A special case - we want the file and line numbers for debugging. |
|
| 890 | if ($error_type == 'return') |
|
| 891 | return array($file, $line); |
|
| 892 | ||
| 893 | // Is always a critical error. |
|
| 894 | if (function_exists('log_error')) |
|
| 895 | log_error($log_message, 'critical', $file, $line); |
|
| 896 | ||
| 897 | if (function_exists('fatal_error')) |
|
| 898 | { |
|
| 899 | fatal_error($error_message, false); |
|
| 900 | ||
| 901 | // Cannot continue... |
|
| 902 | exit; |
|
| 903 | } |
|
| 904 | elseif ($error_type) |
|
| 905 | trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 906 | else |
|
| 907 | trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 908 | } |
|
| 909 | ||
| 910 | /** |
|
| 911 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
|
| @@ 882-922 (lines=41) @@ | ||
| 879 | * @param int $line What line of $file the code which generated the error is on |
|
| 880 | * @return void|array Returns an array with the file and line if $error_type is 'return' |
|
| 881 | */ |
|
| 882 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
|
| 883 | { |
|
| 884 | if (empty($log_message)) |
|
| 885 | $log_message = $error_message; |
|
| 886 | ||
| 887 | foreach (debug_backtrace() as $step) |
|
| 888 | { |
|
| 889 | // Found it? |
|
| 890 | if (strpos($step['function'], 'query') === false && !in_array(substr($step['function'], 0, 7), array('smf_db_', 'preg_re', 'db_erro', 'call_us')) && strpos($step['function'], '__') !== 0) |
|
| 891 | { |
|
| 892 | $log_message .= '<br>Function: ' . $step['function']; |
|
| 893 | break; |
|
| 894 | } |
|
| 895 | ||
| 896 | if (isset($step['line'])) |
|
| 897 | { |
|
| 898 | $file = $step['file']; |
|
| 899 | $line = $step['line']; |
|
| 900 | } |
|
| 901 | } |
|
| 902 | ||
| 903 | // A special case - we want the file and line numbers for debugging. |
|
| 904 | if ($error_type == 'return') |
|
| 905 | return array($file, $line); |
|
| 906 | ||
| 907 | // Is always a critical error. |
|
| 908 | if (function_exists('log_error')) |
|
| 909 | log_error($log_message, 'critical', $file, $line); |
|
| 910 | ||
| 911 | if (function_exists('fatal_error')) |
|
| 912 | { |
|
| 913 | fatal_error($error_message, $error_type); |
|
| 914 | ||
| 915 | // Cannot continue... |
|
| 916 | exit; |
|
| 917 | } |
|
| 918 | elseif ($error_type) |
|
| 919 | trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 920 | else |
|
| 921 | trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 922 | } |
|
| 923 | ||
| 924 | /** |
|
| 925 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
|