| @@ 860-900 (lines=41) @@ | ||
| 857 | * @param int $line What line of $file the code which generated the error is on |
|
| 858 | * @return void|array Returns an array with the file and line if $error_type is 'return' |
|
| 859 | */ |
|
| 860 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
|
| 861 | { |
|
| 862 | if (empty($log_message)) |
|
| 863 | $log_message = $error_message; |
|
| 864 | ||
| 865 | foreach (debug_backtrace() as $step) |
|
| 866 | { |
|
| 867 | // Found it? |
|
| 868 | 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) |
|
| 869 | { |
|
| 870 | $log_message .= '<br>Function: ' . $step['function']; |
|
| 871 | break; |
|
| 872 | } |
|
| 873 | ||
| 874 | if (isset($step['line'])) |
|
| 875 | { |
|
| 876 | $file = $step['file']; |
|
| 877 | $line = $step['line']; |
|
| 878 | } |
|
| 879 | } |
|
| 880 | ||
| 881 | // A special case - we want the file and line numbers for debugging. |
|
| 882 | if ($error_type == 'return') |
|
| 883 | return array($file, $line); |
|
| 884 | ||
| 885 | // Is always a critical error. |
|
| 886 | if (function_exists('log_error')) |
|
| 887 | log_error($log_message, 'critical', $file, $line); |
|
| 888 | ||
| 889 | if (function_exists('fatal_error')) |
|
| 890 | { |
|
| 891 | fatal_error($error_message, $error_type); |
|
| 892 | ||
| 893 | // Cannot continue... |
|
| 894 | exit; |
|
| 895 | } |
|
| 896 | elseif ($error_type) |
|
| 897 | trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 898 | else |
|
| 899 | trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 900 | } |
|
| 901 | ||
| 902 | /** |
|
| 903 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
|
| @@ 843-883 (lines=41) @@ | ||
| 840 | * @param int $line What line of $file the code which generated the error is on |
|
| 841 | * @return void|array Returns an array with the file and line if $error_type is 'return' |
|
| 842 | */ |
|
| 843 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
|
| 844 | { |
|
| 845 | if (empty($log_message)) |
|
| 846 | $log_message = $error_message; |
|
| 847 | ||
| 848 | foreach (debug_backtrace() as $step) |
|
| 849 | { |
|
| 850 | // Found it? |
|
| 851 | 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) |
|
| 852 | { |
|
| 853 | $log_message .= '<br>Function: ' . $step['function']; |
|
| 854 | break; |
|
| 855 | } |
|
| 856 | ||
| 857 | if (isset($step['line'])) |
|
| 858 | { |
|
| 859 | $file = $step['file']; |
|
| 860 | $line = $step['line']; |
|
| 861 | } |
|
| 862 | } |
|
| 863 | ||
| 864 | // A special case - we want the file and line numbers for debugging. |
|
| 865 | if ($error_type == 'return') |
|
| 866 | return array($file, $line); |
|
| 867 | ||
| 868 | // Is always a critical error. |
|
| 869 | if (function_exists('log_error')) |
|
| 870 | log_error($log_message, 'critical', $file, $line); |
|
| 871 | ||
| 872 | if (function_exists('fatal_error')) |
|
| 873 | { |
|
| 874 | fatal_error($error_message, false); |
|
| 875 | ||
| 876 | // Cannot continue... |
|
| 877 | exit; |
|
| 878 | } |
|
| 879 | elseif ($error_type) |
|
| 880 | trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 881 | else |
|
| 882 | trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 883 | } |
|
| 884 | ||
| 885 | /** |
|
| 886 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
|