Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
/**
3
 * ADOdb Default Error Handler.
4
 *
5
 * This file is part of ADOdb, a Database Abstraction Layer library for PHP.
6
 *
7
 * @package ADOdb
8
 * @link https://adodb.org Project's web site and documentation
9
 * @link https://github.com/ADOdb/ADOdb Source code and issue tracker
10
 *
11
 * The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
12
 * and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
13
 * any later version. This means you can use it in proprietary products.
14
 * See the LICENSE.md file distributed with this source code for details.
15
 * @license BSD-3-Clause
16
 * @license LGPL-2.1-or-later
17
 *
18
 * @copyright 2000-2013 John Lim
19
 * @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
20
 */
21
 
22
// added Claudio Bustos  clbustos#entelchile.net
23
if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
24
 
25
if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_Handler');
26
 
27
/**
28
* Default Error Handler. This will be called with the following params
29
*
30
* @param $dbms		the RDBMS you are connecting to
31
* @param $fn		the name of the calling function (in uppercase)
32
* @param $errno		the native error number from the database
33
* @param $errmsg	the native error msg from the database
34
* @param $p1		$fn specific parameter - see below
35
* @param $p2		$fn specific parameter - see below
36
* @param $thisConn	$current connection object - can be false if no connection object created
37
*/
38
function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection)
39
{
40
	// Do not throw if errors are suppressed by @ operator
41
	// error_reporting() value for suppressed errors changed in PHP 8.0.0
42
	$suppressed = version_compare(PHP_VERSION, '8.0.0', '<')
43
		? 0
44
		: E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE;
45
	if (error_reporting() == $suppressed) {
46
		return;
47
	}
48
	switch($fn) {
49
	case 'EXECUTE':
50
		$sql = $p1;
51
		$inputparams = $p2;
52
 
53
		$s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")\n";
54
		break;
55
 
56
	case 'PCONNECT':
57
	case 'CONNECT':
58
		$host = $p1;
59
		$database = $p2;
60
 
61
		$s = "$dbms error: [$errno: $errmsg] in $fn($host, '****', '****', $database)\n";
62
		break;
63
	default:
64
		$s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
65
		break;
66
	}
67
	/*
68
	* Log connection error somewhere
69
	*	0 message is sent to PHP's system logger, using the Operating System's system
70
	*		logging mechanism or a file, depending on what the error_log configuration
71
	*		directive is set to.
72
	*	1 message is sent by email to the address in the destination parameter.
73
	*		This is the only message type where the fourth parameter, extra_headers is used.
74
	*		This message type uses the same internal function as mail() does.
75
	*	2 message is sent through the PHP debugging connection.
76
	*		This option is only available if remote debugging has been enabled.
77
	*		In this case, the destination parameter specifies the host name or IP address
78
	*		and optionally, port number, of the socket receiving the debug information.
79
	*	3 message is appended to the file destination
80
	*/
81
	if (defined('ADODB_ERROR_LOG_TYPE')) {
82
		$t = date('Y-m-d H:i:s');
83
		if (defined('ADODB_ERROR_LOG_DEST'))
84
			error_log("($t) $s", ADODB_ERROR_LOG_TYPE, ADODB_ERROR_LOG_DEST);
85
		else
86
			error_log("($t) $s", ADODB_ERROR_LOG_TYPE);
87
	}
88
 
89
 
90
	//print "<p>$s</p>";
91
	trigger_error($s,ADODB_ERROR_HANDLER_TYPE);
92
}