-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.php
More file actions
64 lines (57 loc) · 1.61 KB
/
errors.php
File metadata and controls
64 lines (57 loc) · 1.61 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
<?php
class Errors {
private $conf;
private $DB;
private $lang;
private $auth;
private $current_errors;
private $error_occurred;
public function __construct(&$conf) {
$this->conf =& $conf;
$this->DB = false;
$this->lang = false;
$this->auth = false;
$this->current_errors['display'] = array();
$this->current_errors['admin'] = array();
$this->error_occurred = false;
}
public function register_db($DB) {
$this->DB = $DB;
}
public function register_lang($lang) {
$this->lang = $lang;
}
public function register_auth($auth) {
$this->auth = $auth;
foreach($this->current_errors['display'] AS $key => $display_msg) {
$admin_msg = $this->current_errors['admin'][$key];
$userid = $this->auth->get_userid();
$record_error_qry = "INSERT INTO errors SET admin_msg='$admin_msg', display_msg='$display_msg', userid='$userid';";
$this->DB->db_query_no_data($record_error_qry);
}
}
public function record_error($admin_msg,$display_msg, $fatal = false) {
$this->error_occurred = true;
$this->current_errors['display'][] = $display_msg;
$this->current_errors['admin'][] = $display_msg;
if($this->auth) {
$userid = $this->auth->get_userid();
$record_error_qry = "INSERT INTO errors SET admin_msg='$admin_msg', display_msg='$display_msg', userid='$userid';";
$this->DB->db_query_no_data($record_error_qry);
}
if($fatal) {
echo get_errors();
die();
}
}
public function errors_occurred() {
return $this->error_occurred;
}
public function get_errors() {
if($this->error_occured)
return implode("<br />\n",$this->current_errors['disp']);
else
return "";
}
}
?>