-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.php
50 lines (42 loc) · 998 Bytes
/
errors.php
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
<?php
define('E_SUCCESS', 200);
define('E_NOTFOUND', 404);
define('E_FORBIDDEN', 403);
define('E_SERVFAIL', 500);
define('E_NOTIMPLEMENTED', 510);
define('E_FATAL', 599);
$ERRORS_STACK = array();
function error($message, $CODE = E_UNKNOWN) {
global $ERRORS_STACK;
array_push($ERRORS_STACK, $message);
return $CODE;
}
function errmsg($err = NULL) {
global $ERRORS_STACK;
static $ERRORS = array(
E_NOTIMPLEMENTED => 'Function not implemented',
E_NOTFOUND => 'Not found',
E_SUCCESS => 'Success',
E_FORBIDDEN => 'Access denied',
E_SERVFAIL => 'Server Failure'
);
return ($err?$ERRORS[$err]:'').array_pop($ERRORS_STACK);;
}
function succeeds($err) {
return defuzz_error($err, 200, 299);
}
function fatal($err) {
return defuzz_error($err, 500, 599);
}
function defuzz_error($err, $low, $high) {
if(is_int($err)) {
if($err >= $low and $err <= $high) {
return TRUE;
} else {
return FALSE;
}
} else {
return $err;
}
}
?>