| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR); |
|---|
| 17 |
|
|---|
| 18 |
if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_Handler'); |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) |
|---|
| 32 |
{ |
|---|
| 33 |
if (error_reporting() == 0) return; |
|---|
| 34 |
switch($fn) { |
|---|
| 35 |
case 'EXECUTE': |
|---|
| 36 |
$sql = $p1; |
|---|
| 37 |
$inputparams = $p2; |
|---|
| 38 |
|
|---|
| 39 |
$s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")\n"; |
|---|
| 40 |
break; |
|---|
| 41 |
|
|---|
| 42 |
case 'PCONNECT': |
|---|
| 43 |
case 'CONNECT': |
|---|
| 44 |
$host = $p1; |
|---|
| 45 |
$database = $p2; |
|---|
| 46 |
|
|---|
| 47 |
$s = "$dbms error: [$errno: $errmsg] in $fn($host, '****', '****', $database)\n"; |
|---|
| 48 |
break; |
|---|
| 49 |
default: |
|---|
| 50 |
$s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n"; |
|---|
| 51 |
break; |
|---|
| 52 |
} |
|---|
| 53 |
|
|---|
| 54 |
* Log connection error somewhere |
|---|
| 55 |
* 0 message is sent to PHP's system logger, using the Operating System's system |
|---|
| 56 |
* logging mechanism or a file, depending on what the error_log configuration |
|---|
| 57 |
* directive is set to. |
|---|
| 58 |
* 1 message is sent by email to the address in the destination parameter. |
|---|
| 59 |
* This is the only message type where the fourth parameter, extra_headers is used. |
|---|
| 60 |
* This message type uses the same internal function as mail() does. |
|---|
| 61 |
* 2 message is sent through the PHP debugging connection. |
|---|
| 62 |
* This option is only available if remote debugging has been enabled. |
|---|
| 63 |
* In this case, the destination parameter specifies the host name or IP address |
|---|
| 64 |
* and optionally, port number, of the socket receiving the debug information. |
|---|
| 65 |
* 3 message is appended to the file destination |
|---|
| 66 |
*/ |
|---|
| 67 |
if (defined('ADODB_ERROR_LOG_TYPE')) { |
|---|
| 68 |
$t = date('Y-m-d H:i:s'); |
|---|
| 69 |
if (defined('ADODB_ERROR_LOG_DEST')) |
|---|
| 70 |
error_log("($t) $s", ADODB_ERROR_LOG_TYPE, ADODB_ERROR_LOG_DEST); |
|---|
| 71 |
else |
|---|
| 72 |
error_log("($t) $s", ADODB_ERROR_LOG_TYPE); |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
trigger_error($s,ADODB_ERROR_HANDLER_TYPE); |
|---|
| 78 |
} |
|---|
| 79 |
?> |
|---|
| 80 |
|
|---|