This repository was archived by the owner on Dec 29, 2020. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathError.php
More file actions
87 lines (86 loc) · 2.16 KB
/
Copy pathError.php
File metadata and controls
87 lines (86 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* Error class
*
* PHP Version 5.3.6
*
* @category Class
* @package DOMenhancer
* @author Pierre Rudloff <contact@rudloff.pro>
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
* @link https://svn.strasweb.fr/
*/
/**
* Custom error handler
*
* PHP Version 5.3.6
*
* @category Class
* @package DOMenhancer
* @author Pierre Rudloff <contact@rudloff.pro>
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
* @link https://svn.strasweb.fr/
*/
class DOMenhancer_Error
{
/**
* HTML tag to add the error to
* */
static $tag;
/**
* Enable debug mode
* */
static $debug=false;
/**
* Custom error handler function
* Displays the error only if $debug is true
*
* @param int $errno Error type
* @param string $errstr Error message
* @param string $errfile Error file (not used)
* @param string $errline Error line (not used)
*
* @return bool
* */
static function errorHandler($errno, $errstr, $errfile, $errline)
{
if ($errno==E_USER_WARNING
|| $errno==E_USER_ERROR
|| $errno==E_USER_NOTICE
) {
self::displayError($errstr, $errno);
}
if (self::$debug) {
return false;
} else {
return true;
}
}
/**
* Displays an error
* (in HTML if possible, in plain text if not)
*
* @param string $errstr Error message
* @param int $errno Error type
*
* @return void
* */
static function displayError($errstr, $errno)
{
global $dom;
if (isset($dom) && isset(self::$tag)) {
if ($errno==E_USER_WARNING || $errno==E_USER_ERROR) {
$class="error";
} else if ($errno==E_USER_NOTICE) {
$class="modified";
} else {
$class="unknownError";
}
self::$tag->addElement("div", $errstr, array("class"=>$class));
} else {
print(htmlentities($errstr));
}
}
}
set_error_handler("DOMenhancer_Error::errorHandler");
?>