| @@ 881-921 (lines=41) @@ | ||
| 878 | * @param int $line What line of $file the code which generated the error is on |
|
| 879 | * @return void|array Returns an array with the file and line if $error_type is 'return' |
|
| 880 | */ |
|
| 881 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
|
| 882 | { |
|
| 883 | if (empty($log_message)) |
|
| 884 | $log_message = $error_message; |
|
| 885 | ||
| 886 | foreach (debug_backtrace() as $step) |
|
| 887 | { |
|
| 888 | // Found it? |
|
| 889 | 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) |
|
| 890 | { |
|
| 891 | $log_message .= '<br>Function: ' . $step['function']; |
|
| 892 | break; |
|
| 893 | } |
|
| 894 | ||
| 895 | if (isset($step['line'])) |
|
| 896 | { |
|
| 897 | $file = $step['file']; |
|
| 898 | $line = $step['line']; |
|
| 899 | } |
|
| 900 | } |
|
| 901 | ||
| 902 | // A special case - we want the file and line numbers for debugging. |
|
| 903 | if ($error_type == 'return') |
|
| 904 | return array($file, $line); |
|
| 905 | ||
| 906 | // Is always a critical error. |
|
| 907 | if (function_exists('log_error')) |
|
| 908 | log_error($log_message, 'critical', $file, $line); |
|
| 909 | ||
| 910 | if (function_exists('fatal_error')) |
|
| 911 | { |
|
| 912 | fatal_error($error_message, false); |
|
| 913 | ||
| 914 | // Cannot continue... |
|
| 915 | exit; |
|
| 916 | } |
|
| 917 | elseif ($error_type) |
|
| 918 | trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 919 | else |
|
| 920 | trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 921 | } |
|
| 922 | ||
| 923 | /** |
|
| 924 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
|
| @@ 824-864 (lines=41) @@ | ||
| 821 | * @param int $line What line of $file the code which generated the error is on |
|
| 822 | * @return void|array Returns an array with the file and line if $error_type is 'return' |
|
| 823 | */ |
|
| 824 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
|
| 825 | { |
|
| 826 | if (empty($log_message)) |
|
| 827 | $log_message = $error_message; |
|
| 828 | ||
| 829 | foreach (debug_backtrace() as $step) |
|
| 830 | { |
|
| 831 | // Found it? |
|
| 832 | 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) |
|
| 833 | { |
|
| 834 | $log_message .= '<br>Function: ' . $step['function']; |
|
| 835 | break; |
|
| 836 | } |
|
| 837 | ||
| 838 | if (isset($step['line'])) |
|
| 839 | { |
|
| 840 | $file = $step['file']; |
|
| 841 | $line = $step['line']; |
|
| 842 | } |
|
| 843 | } |
|
| 844 | ||
| 845 | // A special case - we want the file and line numbers for debugging. |
|
| 846 | if ($error_type == 'return') |
|
| 847 | return array($file, $line); |
|
| 848 | ||
| 849 | // Is always a critical error. |
|
| 850 | if (function_exists('log_error')) |
|
| 851 | log_error($log_message, 'critical', $file, $line); |
|
| 852 | ||
| 853 | if (function_exists('fatal_error')) |
|
| 854 | { |
|
| 855 | fatal_error($error_message, $error_type); |
|
| 856 | ||
| 857 | // Cannot continue... |
|
| 858 | exit; |
|
| 859 | } |
|
| 860 | elseif ($error_type) |
|
| 861 | trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 862 | else |
|
| 863 | trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 864 | } |
|
| 865 | ||
| 866 | /** |
|
| 867 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
|