@@ -2,24 +2,24 @@ |
||
2 | 2 | |
3 | 3 | class General |
4 | 4 | { |
5 | - public function logged_in() |
|
6 | - { |
|
7 | - return(isset($_SESSION['loginid'])) ? true : false; |
|
8 | - } |
|
5 | + public function logged_in() |
|
6 | + { |
|
7 | + return(isset($_SESSION['loginid'])) ? true : false; |
|
8 | + } |
|
9 | 9 | |
10 | - public function logged_in_protect() |
|
11 | - { |
|
12 | - if ($this->logged_in() === true) { |
|
13 | - header('Location: home.php'); |
|
14 | - exit(); |
|
15 | - } |
|
16 | - } |
|
10 | + public function logged_in_protect() |
|
11 | + { |
|
12 | + if ($this->logged_in() === true) { |
|
13 | + header('Location: home.php'); |
|
14 | + exit(); |
|
15 | + } |
|
16 | + } |
|
17 | 17 | |
18 | - public function logged_out_protect() |
|
19 | - { |
|
20 | - if ($this->logged_in() === false) { |
|
21 | - header('Location: index.php'); |
|
22 | - exit(); |
|
23 | - } |
|
24 | - } |
|
18 | + public function logged_out_protect() |
|
19 | + { |
|
20 | + if ($this->logged_in() === false) { |
|
21 | + header('Location: index.php'); |
|
22 | + exit(); |
|
23 | + } |
|
24 | + } |
|
25 | 25 | } |
@@ -2,195 +2,195 @@ |
||
2 | 2 | |
3 | 3 | class Customers |
4 | 4 | { |
5 | - private $db; |
|
6 | - |
|
7 | - public function __construct($database) |
|
8 | - { |
|
9 | - $this->db = $database; |
|
10 | - } |
|
11 | - |
|
12 | - public function customer_exists($customername) |
|
13 | - { |
|
14 | - $query = $this->db->prepare('SELECT COUNT(`id`) FROM `customers` WHERE `customername`= ?'); |
|
15 | - $query->bindValue(1, $customername); |
|
16 | - |
|
17 | - try { |
|
18 | - $query->execute(); |
|
19 | - $rows = $query->fetchColumn(); |
|
20 | - if ($rows == 1) { |
|
21 | - return true; |
|
22 | - } else { |
|
23 | - return false; |
|
24 | - } |
|
25 | - } catch (PDOException $e) { |
|
26 | - die($e->getMessage()); |
|
27 | - } |
|
28 | - } |
|
29 | - |
|
30 | - public function email_exists($email) |
|
31 | - { |
|
32 | - $query = $this->db->prepare('SELECT COUNT(`id`) FROM `customers` WHERE `email`= ?'); |
|
33 | - $query->bindValue(1, $email); |
|
34 | - |
|
35 | - try { |
|
36 | - $query->execute(); |
|
37 | - $rows = $query->fetchColumn(); |
|
38 | - if ($rows == 1) { |
|
39 | - return true; |
|
40 | - } else { |
|
41 | - return false; |
|
42 | - } |
|
43 | - } catch (PDOException $e) { |
|
44 | - die($e->getMessage()); |
|
45 | - } |
|
46 | - } |
|
47 | - |
|
48 | - public function add_customer($namacustomer, $alamat, $Telp, $email, $PIC, $selesperson, $customerproduct) |
|
49 | - { |
|
50 | - $time = time(); |
|
51 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
52 | - $query = $this->db->prepare('INSERT INTO `customers` (`namacustomer`, `alamat`, `Telp`, `email`, `PIC`,`selesperson`, `customerproduct`, `time`, `ip`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'); |
|
53 | - $query->bindValue(1, $namacustomer); |
|
54 | - $query->bindValue(2, $alamat); |
|
55 | - $query->bindValue(3, $Telp); |
|
56 | - $query->bindValue(4, $email); |
|
57 | - $query->bindValue(5, $PIC); |
|
58 | - $query->bindValue(6, $selesperson); |
|
59 | - $query->bindValue(7, $customerproduct); |
|
60 | - $query->bindValue(8, $time); |
|
61 | - $query->bindValue(9, $ip); |
|
62 | - |
|
63 | - try { |
|
64 | - $query->execute(); |
|
65 | - } catch (PDOException $e) { |
|
66 | - die($e->getMessage()); |
|
67 | - } |
|
68 | - } |
|
69 | - |
|
70 | - public function update_customer($idcustomer, $namacustomer, $alamat, $Telp, $email, $PIC, $selesperson, $customerproduct) |
|
71 | - { |
|
72 | - $time = time(); |
|
73 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
74 | - $query = $this->db->prepare('UPDATE `customers` SET `namacustomer` = ? , `alamat` = ? , `Telp` = ? , `email` = ? , `PIC` = ? , `selesperson` = ? ,`customerproduct` = ? ,`ip` = ? , `time` = ? WHERE `idcustomer` = ?'); |
|
75 | - $query->bindValue(1, $namacustomer); |
|
76 | - $query->bindValue(2, $alamat); |
|
77 | - $query->bindValue(3, $Telp); |
|
78 | - $query->bindValue(4, $email); |
|
79 | - $query->bindValue(5, $PIC); |
|
80 | - $query->bindValue(6, $selesperson); |
|
81 | - $query->bindValue(7, $customerproduct); |
|
82 | - $query->bindValue(8, $ip); |
|
83 | - $query->bindValue(9, $time); |
|
84 | - $query->bindValue(10, $idcustomer); |
|
85 | - |
|
86 | - try { |
|
87 | - $query->execute(); |
|
88 | - } catch (PDOException $e) { |
|
89 | - die($e->getMessage()); |
|
90 | - } |
|
91 | - } |
|
92 | - |
|
93 | - public function delete($id) |
|
94 | - { |
|
95 | - $sql = 'DELETE FROM `customers` WHERE `idcustomer` = ?'; |
|
96 | - $query = $this->db->prepare($sql); |
|
97 | - $query->bindValue(1, $id); |
|
98 | - |
|
99 | - try { |
|
100 | - $query->execute(); |
|
101 | - } catch (PDOException $e) { |
|
102 | - die($e->getMessage()); |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - public function activate($email, $email_code) |
|
107 | - { |
|
108 | - $query = $this->db->prepare('SELECT COUNT(`id`) FROM `customers` WHERE `email` = ? AND `email_code` = ? AND `confirmed` = ?'); |
|
109 | - $query->bindValue(1, $email); |
|
110 | - $query->bindValue(2, $email_code); |
|
111 | - $query->bindValue(3, 0); |
|
112 | - |
|
113 | - try { |
|
114 | - $query->execute(); |
|
115 | - $rows = $query->fetchColumn(); |
|
116 | - if ($rows == 1) { |
|
117 | - $query_2 = $this->db->prepare('UPDATE `customers` SET `confirmed` = ? WHERE `email` = ?'); |
|
118 | - $query_2->bindValue(1, 1); |
|
119 | - $query_2->bindValue(2, $email); |
|
120 | - $query_2->execute(); |
|
121 | - |
|
122 | - return true; |
|
123 | - } else { |
|
124 | - return false; |
|
125 | - } |
|
126 | - } catch (PDOException $e) { |
|
127 | - die($e->getMessage()); |
|
128 | - } |
|
129 | - } |
|
130 | - |
|
131 | - public function email_confirmed($username) |
|
132 | - { |
|
133 | - $query = $this->db->prepare('SELECT COUNT(`id`) FROM `customers` WHERE `username`= ? AND `confirmed` = ?'); |
|
134 | - $query->bindValue(1, $username); |
|
135 | - $query->bindValue(2, 1); |
|
136 | - |
|
137 | - try { |
|
138 | - $query->execute(); |
|
139 | - $rows = $query->fetchColumn(); |
|
140 | - if ($rows == 1) { |
|
141 | - return true; |
|
142 | - } else { |
|
143 | - return false; |
|
144 | - } |
|
145 | - } catch (PDOException $e) { |
|
146 | - die($e->getMessage()); |
|
147 | - } |
|
148 | - } |
|
149 | - |
|
150 | - public function login_customer($username, $password) |
|
151 | - { |
|
152 | - $query = $this->db->prepare('SELECT `email`, `ticket_id` FROM `customers` WHERE `email` = ?'); |
|
153 | - $query->bindValue(1, $username); |
|
154 | - |
|
155 | - try { |
|
156 | - $query->execute(); |
|
157 | - $data = $query->fetch(); |
|
158 | - $stored_password = $data['password']; |
|
159 | - $id = $data['id']; |
|
160 | - if ($stored_password === sha1($password)) { |
|
161 | - return $id; |
|
162 | - } else { |
|
163 | - return false; |
|
164 | - } |
|
165 | - } catch (PDOException $e) { |
|
166 | - die($e->getMessage()); |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - public function customer_data($id) |
|
171 | - { |
|
172 | - $query = $this->db->prepare('SELECT * FROM `customers` WHERE `idcustomer`= ?'); |
|
173 | - $query->bindValue(1, $id); |
|
174 | - |
|
175 | - try { |
|
176 | - $query->execute(); |
|
177 | - |
|
178 | - return $query->fetch(); |
|
179 | - } catch (PDOException $e) { |
|
180 | - die($e->getMessage()); |
|
181 | - } |
|
182 | - } |
|
183 | - |
|
184 | - public function get_customers() |
|
185 | - { |
|
186 | - $query = $this->db->prepare('SELECT * FROM `customers` ORDER BY `namacustomer` ASC'); |
|
187 | - |
|
188 | - try { |
|
189 | - $query->execute(); |
|
190 | - } catch (PDOException $e) { |
|
191 | - die($e->getMessage()); |
|
192 | - } |
|
193 | - |
|
194 | - return $query->fetchAll(); |
|
195 | - } |
|
5 | + private $db; |
|
6 | + |
|
7 | + public function __construct($database) |
|
8 | + { |
|
9 | + $this->db = $database; |
|
10 | + } |
|
11 | + |
|
12 | + public function customer_exists($customername) |
|
13 | + { |
|
14 | + $query = $this->db->prepare('SELECT COUNT(`id`) FROM `customers` WHERE `customername`= ?'); |
|
15 | + $query->bindValue(1, $customername); |
|
16 | + |
|
17 | + try { |
|
18 | + $query->execute(); |
|
19 | + $rows = $query->fetchColumn(); |
|
20 | + if ($rows == 1) { |
|
21 | + return true; |
|
22 | + } else { |
|
23 | + return false; |
|
24 | + } |
|
25 | + } catch (PDOException $e) { |
|
26 | + die($e->getMessage()); |
|
27 | + } |
|
28 | + } |
|
29 | + |
|
30 | + public function email_exists($email) |
|
31 | + { |
|
32 | + $query = $this->db->prepare('SELECT COUNT(`id`) FROM `customers` WHERE `email`= ?'); |
|
33 | + $query->bindValue(1, $email); |
|
34 | + |
|
35 | + try { |
|
36 | + $query->execute(); |
|
37 | + $rows = $query->fetchColumn(); |
|
38 | + if ($rows == 1) { |
|
39 | + return true; |
|
40 | + } else { |
|
41 | + return false; |
|
42 | + } |
|
43 | + } catch (PDOException $e) { |
|
44 | + die($e->getMessage()); |
|
45 | + } |
|
46 | + } |
|
47 | + |
|
48 | + public function add_customer($namacustomer, $alamat, $Telp, $email, $PIC, $selesperson, $customerproduct) |
|
49 | + { |
|
50 | + $time = time(); |
|
51 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
52 | + $query = $this->db->prepare('INSERT INTO `customers` (`namacustomer`, `alamat`, `Telp`, `email`, `PIC`,`selesperson`, `customerproduct`, `time`, `ip`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'); |
|
53 | + $query->bindValue(1, $namacustomer); |
|
54 | + $query->bindValue(2, $alamat); |
|
55 | + $query->bindValue(3, $Telp); |
|
56 | + $query->bindValue(4, $email); |
|
57 | + $query->bindValue(5, $PIC); |
|
58 | + $query->bindValue(6, $selesperson); |
|
59 | + $query->bindValue(7, $customerproduct); |
|
60 | + $query->bindValue(8, $time); |
|
61 | + $query->bindValue(9, $ip); |
|
62 | + |
|
63 | + try { |
|
64 | + $query->execute(); |
|
65 | + } catch (PDOException $e) { |
|
66 | + die($e->getMessage()); |
|
67 | + } |
|
68 | + } |
|
69 | + |
|
70 | + public function update_customer($idcustomer, $namacustomer, $alamat, $Telp, $email, $PIC, $selesperson, $customerproduct) |
|
71 | + { |
|
72 | + $time = time(); |
|
73 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
74 | + $query = $this->db->prepare('UPDATE `customers` SET `namacustomer` = ? , `alamat` = ? , `Telp` = ? , `email` = ? , `PIC` = ? , `selesperson` = ? ,`customerproduct` = ? ,`ip` = ? , `time` = ? WHERE `idcustomer` = ?'); |
|
75 | + $query->bindValue(1, $namacustomer); |
|
76 | + $query->bindValue(2, $alamat); |
|
77 | + $query->bindValue(3, $Telp); |
|
78 | + $query->bindValue(4, $email); |
|
79 | + $query->bindValue(5, $PIC); |
|
80 | + $query->bindValue(6, $selesperson); |
|
81 | + $query->bindValue(7, $customerproduct); |
|
82 | + $query->bindValue(8, $ip); |
|
83 | + $query->bindValue(9, $time); |
|
84 | + $query->bindValue(10, $idcustomer); |
|
85 | + |
|
86 | + try { |
|
87 | + $query->execute(); |
|
88 | + } catch (PDOException $e) { |
|
89 | + die($e->getMessage()); |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | + public function delete($id) |
|
94 | + { |
|
95 | + $sql = 'DELETE FROM `customers` WHERE `idcustomer` = ?'; |
|
96 | + $query = $this->db->prepare($sql); |
|
97 | + $query->bindValue(1, $id); |
|
98 | + |
|
99 | + try { |
|
100 | + $query->execute(); |
|
101 | + } catch (PDOException $e) { |
|
102 | + die($e->getMessage()); |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + public function activate($email, $email_code) |
|
107 | + { |
|
108 | + $query = $this->db->prepare('SELECT COUNT(`id`) FROM `customers` WHERE `email` = ? AND `email_code` = ? AND `confirmed` = ?'); |
|
109 | + $query->bindValue(1, $email); |
|
110 | + $query->bindValue(2, $email_code); |
|
111 | + $query->bindValue(3, 0); |
|
112 | + |
|
113 | + try { |
|
114 | + $query->execute(); |
|
115 | + $rows = $query->fetchColumn(); |
|
116 | + if ($rows == 1) { |
|
117 | + $query_2 = $this->db->prepare('UPDATE `customers` SET `confirmed` = ? WHERE `email` = ?'); |
|
118 | + $query_2->bindValue(1, 1); |
|
119 | + $query_2->bindValue(2, $email); |
|
120 | + $query_2->execute(); |
|
121 | + |
|
122 | + return true; |
|
123 | + } else { |
|
124 | + return false; |
|
125 | + } |
|
126 | + } catch (PDOException $e) { |
|
127 | + die($e->getMessage()); |
|
128 | + } |
|
129 | + } |
|
130 | + |
|
131 | + public function email_confirmed($username) |
|
132 | + { |
|
133 | + $query = $this->db->prepare('SELECT COUNT(`id`) FROM `customers` WHERE `username`= ? AND `confirmed` = ?'); |
|
134 | + $query->bindValue(1, $username); |
|
135 | + $query->bindValue(2, 1); |
|
136 | + |
|
137 | + try { |
|
138 | + $query->execute(); |
|
139 | + $rows = $query->fetchColumn(); |
|
140 | + if ($rows == 1) { |
|
141 | + return true; |
|
142 | + } else { |
|
143 | + return false; |
|
144 | + } |
|
145 | + } catch (PDOException $e) { |
|
146 | + die($e->getMessage()); |
|
147 | + } |
|
148 | + } |
|
149 | + |
|
150 | + public function login_customer($username, $password) |
|
151 | + { |
|
152 | + $query = $this->db->prepare('SELECT `email`, `ticket_id` FROM `customers` WHERE `email` = ?'); |
|
153 | + $query->bindValue(1, $username); |
|
154 | + |
|
155 | + try { |
|
156 | + $query->execute(); |
|
157 | + $data = $query->fetch(); |
|
158 | + $stored_password = $data['password']; |
|
159 | + $id = $data['id']; |
|
160 | + if ($stored_password === sha1($password)) { |
|
161 | + return $id; |
|
162 | + } else { |
|
163 | + return false; |
|
164 | + } |
|
165 | + } catch (PDOException $e) { |
|
166 | + die($e->getMessage()); |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + public function customer_data($id) |
|
171 | + { |
|
172 | + $query = $this->db->prepare('SELECT * FROM `customers` WHERE `idcustomer`= ?'); |
|
173 | + $query->bindValue(1, $id); |
|
174 | + |
|
175 | + try { |
|
176 | + $query->execute(); |
|
177 | + |
|
178 | + return $query->fetch(); |
|
179 | + } catch (PDOException $e) { |
|
180 | + die($e->getMessage()); |
|
181 | + } |
|
182 | + } |
|
183 | + |
|
184 | + public function get_customers() |
|
185 | + { |
|
186 | + $query = $this->db->prepare('SELECT * FROM `customers` ORDER BY `namacustomer` ASC'); |
|
187 | + |
|
188 | + try { |
|
189 | + $query->execute(); |
|
190 | + } catch (PDOException $e) { |
|
191 | + die($e->getMessage()); |
|
192 | + } |
|
193 | + |
|
194 | + return $query->fetchAll(); |
|
195 | + } |
|
196 | 196 | } |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | $rows = $query->fetchColumn(); |
20 | 20 | if ($rows == 1) { |
21 | 21 | return true; |
22 | - } else { |
|
22 | + }else { |
|
23 | 23 | return false; |
24 | 24 | } |
25 | - } catch (PDOException $e) { |
|
25 | + }catch (PDOException $e) { |
|
26 | 26 | die($e->getMessage()); |
27 | 27 | } |
28 | 28 | } |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | $rows = $query->fetchColumn(); |
38 | 38 | if ($rows == 1) { |
39 | 39 | return true; |
40 | - } else { |
|
40 | + }else { |
|
41 | 41 | return false; |
42 | 42 | } |
43 | - } catch (PDOException $e) { |
|
43 | + }catch (PDOException $e) { |
|
44 | 44 | die($e->getMessage()); |
45 | 45 | } |
46 | 46 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | try { |
64 | 64 | $query->execute(); |
65 | - } catch (PDOException $e) { |
|
65 | + }catch (PDOException $e) { |
|
66 | 66 | die($e->getMessage()); |
67 | 67 | } |
68 | 68 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | try { |
87 | 87 | $query->execute(); |
88 | - } catch (PDOException $e) { |
|
88 | + }catch (PDOException $e) { |
|
89 | 89 | die($e->getMessage()); |
90 | 90 | } |
91 | 91 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | try { |
100 | 100 | $query->execute(); |
101 | - } catch (PDOException $e) { |
|
101 | + }catch (PDOException $e) { |
|
102 | 102 | die($e->getMessage()); |
103 | 103 | } |
104 | 104 | } |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | $query_2->execute(); |
121 | 121 | |
122 | 122 | return true; |
123 | - } else { |
|
123 | + }else { |
|
124 | 124 | return false; |
125 | 125 | } |
126 | - } catch (PDOException $e) { |
|
126 | + }catch (PDOException $e) { |
|
127 | 127 | die($e->getMessage()); |
128 | 128 | } |
129 | 129 | } |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | $rows = $query->fetchColumn(); |
140 | 140 | if ($rows == 1) { |
141 | 141 | return true; |
142 | - } else { |
|
142 | + }else { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | - } catch (PDOException $e) { |
|
145 | + }catch (PDOException $e) { |
|
146 | 146 | die($e->getMessage()); |
147 | 147 | } |
148 | 148 | } |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | $id = $data['id']; |
160 | 160 | if ($stored_password === sha1($password)) { |
161 | 161 | return $id; |
162 | - } else { |
|
162 | + }else { |
|
163 | 163 | return false; |
164 | 164 | } |
165 | - } catch (PDOException $e) { |
|
165 | + }catch (PDOException $e) { |
|
166 | 166 | die($e->getMessage()); |
167 | 167 | } |
168 | 168 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $query->execute(); |
177 | 177 | |
178 | 178 | return $query->fetch(); |
179 | - } catch (PDOException $e) { |
|
179 | + }catch (PDOException $e) { |
|
180 | 180 | die($e->getMessage()); |
181 | 181 | } |
182 | 182 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | |
188 | 188 | try { |
189 | 189 | $query->execute(); |
190 | - } catch (PDOException $e) { |
|
190 | + }catch (PDOException $e) { |
|
191 | 191 | die($e->getMessage()); |
192 | 192 | } |
193 | 193 |
@@ -2,274 +2,274 @@ |
||
2 | 2 | |
3 | 3 | class Users |
4 | 4 | { |
5 | - private $db; |
|
6 | - |
|
7 | - public function __construct($database) |
|
8 | - { |
|
9 | - $this->db = $database; |
|
10 | - } |
|
11 | - |
|
12 | - public function user_exists($username) |
|
13 | - { |
|
14 | - $query = $this->db->prepare('SELECT COUNT(`id`) FROM `users` WHERE `username`= ?'); |
|
15 | - $query->bindValue(1, $username); |
|
16 | - |
|
17 | - try { |
|
18 | - $query->execute(); |
|
19 | - $rows = $query->fetchColumn(); |
|
20 | - if ($rows == 1) { |
|
21 | - return true; |
|
22 | - } else { |
|
23 | - return false; |
|
24 | - } |
|
25 | - } catch (PDOException $e) { |
|
26 | - die($e->getMessage()); |
|
27 | - } |
|
28 | - } |
|
29 | - |
|
30 | - public function email_exists($email) |
|
31 | - { |
|
32 | - $query = $this->db->prepare('SELECT COUNT(`id`) FROM `users` WHERE `email`= ?'); |
|
33 | - $query->bindValue(1, $email); |
|
34 | - |
|
35 | - try { |
|
36 | - $query->execute(); |
|
37 | - $rows = $query->fetchColumn(); |
|
38 | - if ($rows == 1) { |
|
39 | - return true; |
|
40 | - } else { |
|
41 | - return false; |
|
42 | - } |
|
43 | - } catch (PDOException $e) { |
|
44 | - die($e->getMessage()); |
|
45 | - } |
|
46 | - } |
|
47 | - |
|
48 | - public function register($username, $password, $email, $fullname, $Telp, $level, $locked) |
|
49 | - { |
|
50 | - $time = time(); |
|
51 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
52 | - $email_code = sha1($username + microtime()); |
|
53 | - $password = sha1($password); |
|
54 | - $query = $this->db->prepare('INSERT INTO `users` (`username`,`level`, `password`, `fullname`, `email`, `Telp`,`ip`, `time`, `email_code`, `confirmed`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?,?)'); |
|
55 | - $query->bindValue(1, $username); |
|
56 | - $query->bindValue(2, $level); |
|
57 | - $query->bindValue(3, $password); |
|
58 | - $query->bindValue(4, $fullname); |
|
59 | - $query->bindValue(5, $email); |
|
60 | - $query->bindValue(6, $Telp); |
|
61 | - $query->bindValue(7, $ip); |
|
62 | - $query->bindValue(8, $time); |
|
63 | - $query->bindValue(9, $email_code); |
|
64 | - $query->bindValue(10, 1); |
|
65 | - |
|
66 | - try { |
|
67 | - $query->execute(); |
|
68 | - } catch (PDOException $e) { |
|
69 | - die($e->getMessage()); |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - public function update($id, $username, $password, $email, $fullname, $Telp, $level, $locked) |
|
74 | - { |
|
75 | - $time = time(); |
|
76 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
77 | - $email_code = sha1($username + microtime()); |
|
78 | - $password = sha1($password); |
|
79 | - $query = $this->db->prepare('UPDATE `users` SET `level` = ? , `password` = ? , `fullname` = ? , `email` = ? , `Telp` = ? ,`ip` = ? , `time` = ? , `email_code` = ? ,`confirmed` = ? WHERE `id` = ?'); |
|
80 | - $query->bindValue(1, $level); |
|
81 | - $query->bindValue(2, $password); |
|
82 | - $query->bindValue(3, $fullname); |
|
83 | - $query->bindValue(4, $email); |
|
84 | - $query->bindValue(5, $Telp); |
|
85 | - $query->bindValue(6, $ip); |
|
86 | - $query->bindValue(7, $time); |
|
87 | - $query->bindValue(8, $email_code); |
|
88 | - $query->bindValue(9, $locked); |
|
89 | - $query->bindValue(10, $id); |
|
90 | - |
|
91 | - try { |
|
92 | - $query->execute(); |
|
93 | - } catch (PDOException $e) { |
|
94 | - die($e->getMessage()); |
|
95 | - } |
|
96 | - } |
|
97 | - |
|
98 | - public function changepwd($id, $password) |
|
99 | - { |
|
100 | - $password = sha1($password); |
|
101 | - $query = $this->db->prepare('UPDATE `users` SET `password` = ? WHERE `id` = ?'); |
|
102 | - $query->bindValue(1, $password); |
|
103 | - $query->bindValue(2, $id); |
|
104 | - |
|
105 | - try { |
|
106 | - $query->execute(); |
|
107 | - } catch (PDOException $e) { |
|
108 | - die($e->getMessage()); |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - public function delete($id) |
|
113 | - { |
|
114 | - $sql = 'DELETE FROM `users` WHERE `id` = ?'; |
|
115 | - $query = $this->db->prepare($sql); |
|
116 | - $query->bindValue(1, $id); |
|
117 | - |
|
118 | - try { |
|
119 | - $query->execute(); |
|
120 | - } catch (PDOException $e) { |
|
121 | - die($e->getMessage()); |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - public function activate($email, $email_code) |
|
126 | - { |
|
127 | - $query = $this->db->prepare('SELECT COUNT(`id`) FROM `users` WHERE `email` = ? AND `email_code` = ? AND `confirmed` = ?'); |
|
128 | - $query->bindValue(1, $email); |
|
129 | - $query->bindValue(2, $email_code); |
|
130 | - $query->bindValue(3, 0); |
|
131 | - |
|
132 | - try { |
|
133 | - $query->execute(); |
|
134 | - $rows = $query->fetchColumn(); |
|
135 | - if ($rows == 1) { |
|
136 | - $query_2 = $this->db->prepare('UPDATE `users` SET `confirmed` = ? WHERE `email` = ?'); |
|
137 | - $query_2->bindValue(1, 1); |
|
138 | - $query_2->bindValue(2, $email); |
|
139 | - $query_2->execute(); |
|
140 | - |
|
141 | - return true; |
|
142 | - } else { |
|
143 | - return false; |
|
144 | - } |
|
145 | - } catch (PDOException $e) { |
|
146 | - die($e->getMessage()); |
|
147 | - } |
|
148 | - } |
|
149 | - |
|
150 | - public function email_confirmed($username) |
|
151 | - { |
|
152 | - $query = $this->db->prepare('SELECT COUNT(`id`) FROM `users` WHERE `username`= ? AND `confirmed` = ?'); |
|
153 | - $query->bindValue(1, $username); |
|
154 | - $query->bindValue(2, 1); |
|
155 | - |
|
156 | - try { |
|
157 | - $query->execute(); |
|
158 | - $rows = $query->fetchColumn(); |
|
159 | - if ($rows == 1) { |
|
160 | - return true; |
|
161 | - } else { |
|
162 | - return false; |
|
163 | - } |
|
164 | - } catch (PDOException $e) { |
|
165 | - die($e->getMessage()); |
|
166 | - } |
|
167 | - } |
|
168 | - |
|
169 | - public function login($username, $password) |
|
170 | - { |
|
171 | - $query = $this->db->prepare('SELECT `password`, `id` FROM `users` WHERE `username` = ?'); |
|
172 | - $query->bindValue(1, $username); |
|
173 | - |
|
174 | - try { |
|
175 | - $query->execute(); |
|
176 | - $data = $query->fetch(); |
|
177 | - $stored_password = $data['password']; |
|
178 | - $id = $data['id']; |
|
179 | - if ($stored_password === sha1($password)) { |
|
180 | - return $id; |
|
181 | - } else { |
|
182 | - return false; |
|
183 | - } |
|
184 | - } catch (PDOException $e) { |
|
185 | - die($e->getMessage()); |
|
186 | - } |
|
187 | - } |
|
188 | - |
|
189 | - public function userdata($id) |
|
190 | - { |
|
191 | - $query = $this->db->prepare('SELECT * FROM `users` WHERE `id`= ?'); |
|
192 | - $query->bindValue(1, $id); |
|
193 | - |
|
194 | - try { |
|
195 | - $query->execute(); |
|
196 | - |
|
197 | - return $query->fetch(); |
|
198 | - } catch (PDOException $e) { |
|
199 | - die($e->getMessage()); |
|
200 | - } |
|
201 | - } |
|
202 | - |
|
203 | - public function get_user_by_id($id) |
|
204 | - { |
|
205 | - $query = $this->db->prepare('SELECT * FROM `users` WHERE `id`= ?'); |
|
206 | - $query->bindValue(1, $id); |
|
207 | - |
|
208 | - try { |
|
209 | - $query->execute(); |
|
210 | - |
|
211 | - return $query->fetch(); |
|
212 | - } catch (PDOException $e) { |
|
213 | - die($e->getMessage()); |
|
214 | - } |
|
215 | - } |
|
216 | - |
|
217 | - public function get_user_by_level($level) |
|
218 | - { |
|
219 | - $query = $this->db->prepare('SELECT * FROM `users` WHERE `level`= ?'); |
|
220 | - $query->bindValue(1, $level); |
|
221 | - |
|
222 | - try { |
|
223 | - $query->execute(); |
|
224 | - } catch (PDOException $e) { |
|
225 | - die($e->getMessage()); |
|
226 | - } |
|
227 | - |
|
228 | - return $query->fetchAll(); |
|
229 | - } |
|
230 | - |
|
231 | - public function get_users() |
|
232 | - { |
|
233 | - $query = $this->db->prepare('SELECT * FROM `users` ORDER BY `time` DESC'); |
|
234 | - |
|
235 | - try { |
|
236 | - $query->execute(); |
|
237 | - } catch (PDOException $e) { |
|
238 | - die($e->getMessage()); |
|
239 | - } |
|
240 | - |
|
241 | - return $query->fetchAll(); |
|
242 | - } |
|
243 | - |
|
244 | - public function log_users($iduser, $log) |
|
245 | - { |
|
246 | - $time = time(); |
|
247 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
248 | - $browser = $_SERVER['HTTP_USER_AGENT']; |
|
249 | - $query = $this->db->prepare('INSERT INTO `log_users` (`iduser`,`time`,`ip`,`browser`,`log`) VALUES (?, ?, ?, ?, ?)'); |
|
250 | - $query->bindValue(1, $iduser); |
|
251 | - $query->bindValue(2, $time); |
|
252 | - $query->bindValue(3, $ip); |
|
253 | - $query->bindValue(4, $browser); |
|
254 | - $query->bindValue(5, $log); |
|
255 | - |
|
256 | - try { |
|
257 | - $query->execute(); |
|
258 | - } catch (PDOException $e) { |
|
259 | - die($e->getMessage()); |
|
260 | - } |
|
261 | - } |
|
262 | - |
|
263 | - public function get_users_log() |
|
264 | - { |
|
265 | - $query = $this->db->prepare('SELECT * FROM `log_users` ORDER BY `time` DESC'); |
|
266 | - |
|
267 | - try { |
|
268 | - $query->execute(); |
|
269 | - } catch (PDOException $e) { |
|
270 | - die($e->getMessage()); |
|
271 | - } |
|
272 | - |
|
273 | - return $query->fetchAll(); |
|
274 | - } |
|
5 | + private $db; |
|
6 | + |
|
7 | + public function __construct($database) |
|
8 | + { |
|
9 | + $this->db = $database; |
|
10 | + } |
|
11 | + |
|
12 | + public function user_exists($username) |
|
13 | + { |
|
14 | + $query = $this->db->prepare('SELECT COUNT(`id`) FROM `users` WHERE `username`= ?'); |
|
15 | + $query->bindValue(1, $username); |
|
16 | + |
|
17 | + try { |
|
18 | + $query->execute(); |
|
19 | + $rows = $query->fetchColumn(); |
|
20 | + if ($rows == 1) { |
|
21 | + return true; |
|
22 | + } else { |
|
23 | + return false; |
|
24 | + } |
|
25 | + } catch (PDOException $e) { |
|
26 | + die($e->getMessage()); |
|
27 | + } |
|
28 | + } |
|
29 | + |
|
30 | + public function email_exists($email) |
|
31 | + { |
|
32 | + $query = $this->db->prepare('SELECT COUNT(`id`) FROM `users` WHERE `email`= ?'); |
|
33 | + $query->bindValue(1, $email); |
|
34 | + |
|
35 | + try { |
|
36 | + $query->execute(); |
|
37 | + $rows = $query->fetchColumn(); |
|
38 | + if ($rows == 1) { |
|
39 | + return true; |
|
40 | + } else { |
|
41 | + return false; |
|
42 | + } |
|
43 | + } catch (PDOException $e) { |
|
44 | + die($e->getMessage()); |
|
45 | + } |
|
46 | + } |
|
47 | + |
|
48 | + public function register($username, $password, $email, $fullname, $Telp, $level, $locked) |
|
49 | + { |
|
50 | + $time = time(); |
|
51 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
52 | + $email_code = sha1($username + microtime()); |
|
53 | + $password = sha1($password); |
|
54 | + $query = $this->db->prepare('INSERT INTO `users` (`username`,`level`, `password`, `fullname`, `email`, `Telp`,`ip`, `time`, `email_code`, `confirmed`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?,?)'); |
|
55 | + $query->bindValue(1, $username); |
|
56 | + $query->bindValue(2, $level); |
|
57 | + $query->bindValue(3, $password); |
|
58 | + $query->bindValue(4, $fullname); |
|
59 | + $query->bindValue(5, $email); |
|
60 | + $query->bindValue(6, $Telp); |
|
61 | + $query->bindValue(7, $ip); |
|
62 | + $query->bindValue(8, $time); |
|
63 | + $query->bindValue(9, $email_code); |
|
64 | + $query->bindValue(10, 1); |
|
65 | + |
|
66 | + try { |
|
67 | + $query->execute(); |
|
68 | + } catch (PDOException $e) { |
|
69 | + die($e->getMessage()); |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + public function update($id, $username, $password, $email, $fullname, $Telp, $level, $locked) |
|
74 | + { |
|
75 | + $time = time(); |
|
76 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
77 | + $email_code = sha1($username + microtime()); |
|
78 | + $password = sha1($password); |
|
79 | + $query = $this->db->prepare('UPDATE `users` SET `level` = ? , `password` = ? , `fullname` = ? , `email` = ? , `Telp` = ? ,`ip` = ? , `time` = ? , `email_code` = ? ,`confirmed` = ? WHERE `id` = ?'); |
|
80 | + $query->bindValue(1, $level); |
|
81 | + $query->bindValue(2, $password); |
|
82 | + $query->bindValue(3, $fullname); |
|
83 | + $query->bindValue(4, $email); |
|
84 | + $query->bindValue(5, $Telp); |
|
85 | + $query->bindValue(6, $ip); |
|
86 | + $query->bindValue(7, $time); |
|
87 | + $query->bindValue(8, $email_code); |
|
88 | + $query->bindValue(9, $locked); |
|
89 | + $query->bindValue(10, $id); |
|
90 | + |
|
91 | + try { |
|
92 | + $query->execute(); |
|
93 | + } catch (PDOException $e) { |
|
94 | + die($e->getMessage()); |
|
95 | + } |
|
96 | + } |
|
97 | + |
|
98 | + public function changepwd($id, $password) |
|
99 | + { |
|
100 | + $password = sha1($password); |
|
101 | + $query = $this->db->prepare('UPDATE `users` SET `password` = ? WHERE `id` = ?'); |
|
102 | + $query->bindValue(1, $password); |
|
103 | + $query->bindValue(2, $id); |
|
104 | + |
|
105 | + try { |
|
106 | + $query->execute(); |
|
107 | + } catch (PDOException $e) { |
|
108 | + die($e->getMessage()); |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + public function delete($id) |
|
113 | + { |
|
114 | + $sql = 'DELETE FROM `users` WHERE `id` = ?'; |
|
115 | + $query = $this->db->prepare($sql); |
|
116 | + $query->bindValue(1, $id); |
|
117 | + |
|
118 | + try { |
|
119 | + $query->execute(); |
|
120 | + } catch (PDOException $e) { |
|
121 | + die($e->getMessage()); |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + public function activate($email, $email_code) |
|
126 | + { |
|
127 | + $query = $this->db->prepare('SELECT COUNT(`id`) FROM `users` WHERE `email` = ? AND `email_code` = ? AND `confirmed` = ?'); |
|
128 | + $query->bindValue(1, $email); |
|
129 | + $query->bindValue(2, $email_code); |
|
130 | + $query->bindValue(3, 0); |
|
131 | + |
|
132 | + try { |
|
133 | + $query->execute(); |
|
134 | + $rows = $query->fetchColumn(); |
|
135 | + if ($rows == 1) { |
|
136 | + $query_2 = $this->db->prepare('UPDATE `users` SET `confirmed` = ? WHERE `email` = ?'); |
|
137 | + $query_2->bindValue(1, 1); |
|
138 | + $query_2->bindValue(2, $email); |
|
139 | + $query_2->execute(); |
|
140 | + |
|
141 | + return true; |
|
142 | + } else { |
|
143 | + return false; |
|
144 | + } |
|
145 | + } catch (PDOException $e) { |
|
146 | + die($e->getMessage()); |
|
147 | + } |
|
148 | + } |
|
149 | + |
|
150 | + public function email_confirmed($username) |
|
151 | + { |
|
152 | + $query = $this->db->prepare('SELECT COUNT(`id`) FROM `users` WHERE `username`= ? AND `confirmed` = ?'); |
|
153 | + $query->bindValue(1, $username); |
|
154 | + $query->bindValue(2, 1); |
|
155 | + |
|
156 | + try { |
|
157 | + $query->execute(); |
|
158 | + $rows = $query->fetchColumn(); |
|
159 | + if ($rows == 1) { |
|
160 | + return true; |
|
161 | + } else { |
|
162 | + return false; |
|
163 | + } |
|
164 | + } catch (PDOException $e) { |
|
165 | + die($e->getMessage()); |
|
166 | + } |
|
167 | + } |
|
168 | + |
|
169 | + public function login($username, $password) |
|
170 | + { |
|
171 | + $query = $this->db->prepare('SELECT `password`, `id` FROM `users` WHERE `username` = ?'); |
|
172 | + $query->bindValue(1, $username); |
|
173 | + |
|
174 | + try { |
|
175 | + $query->execute(); |
|
176 | + $data = $query->fetch(); |
|
177 | + $stored_password = $data['password']; |
|
178 | + $id = $data['id']; |
|
179 | + if ($stored_password === sha1($password)) { |
|
180 | + return $id; |
|
181 | + } else { |
|
182 | + return false; |
|
183 | + } |
|
184 | + } catch (PDOException $e) { |
|
185 | + die($e->getMessage()); |
|
186 | + } |
|
187 | + } |
|
188 | + |
|
189 | + public function userdata($id) |
|
190 | + { |
|
191 | + $query = $this->db->prepare('SELECT * FROM `users` WHERE `id`= ?'); |
|
192 | + $query->bindValue(1, $id); |
|
193 | + |
|
194 | + try { |
|
195 | + $query->execute(); |
|
196 | + |
|
197 | + return $query->fetch(); |
|
198 | + } catch (PDOException $e) { |
|
199 | + die($e->getMessage()); |
|
200 | + } |
|
201 | + } |
|
202 | + |
|
203 | + public function get_user_by_id($id) |
|
204 | + { |
|
205 | + $query = $this->db->prepare('SELECT * FROM `users` WHERE `id`= ?'); |
|
206 | + $query->bindValue(1, $id); |
|
207 | + |
|
208 | + try { |
|
209 | + $query->execute(); |
|
210 | + |
|
211 | + return $query->fetch(); |
|
212 | + } catch (PDOException $e) { |
|
213 | + die($e->getMessage()); |
|
214 | + } |
|
215 | + } |
|
216 | + |
|
217 | + public function get_user_by_level($level) |
|
218 | + { |
|
219 | + $query = $this->db->prepare('SELECT * FROM `users` WHERE `level`= ?'); |
|
220 | + $query->bindValue(1, $level); |
|
221 | + |
|
222 | + try { |
|
223 | + $query->execute(); |
|
224 | + } catch (PDOException $e) { |
|
225 | + die($e->getMessage()); |
|
226 | + } |
|
227 | + |
|
228 | + return $query->fetchAll(); |
|
229 | + } |
|
230 | + |
|
231 | + public function get_users() |
|
232 | + { |
|
233 | + $query = $this->db->prepare('SELECT * FROM `users` ORDER BY `time` DESC'); |
|
234 | + |
|
235 | + try { |
|
236 | + $query->execute(); |
|
237 | + } catch (PDOException $e) { |
|
238 | + die($e->getMessage()); |
|
239 | + } |
|
240 | + |
|
241 | + return $query->fetchAll(); |
|
242 | + } |
|
243 | + |
|
244 | + public function log_users($iduser, $log) |
|
245 | + { |
|
246 | + $time = time(); |
|
247 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
248 | + $browser = $_SERVER['HTTP_USER_AGENT']; |
|
249 | + $query = $this->db->prepare('INSERT INTO `log_users` (`iduser`,`time`,`ip`,`browser`,`log`) VALUES (?, ?, ?, ?, ?)'); |
|
250 | + $query->bindValue(1, $iduser); |
|
251 | + $query->bindValue(2, $time); |
|
252 | + $query->bindValue(3, $ip); |
|
253 | + $query->bindValue(4, $browser); |
|
254 | + $query->bindValue(5, $log); |
|
255 | + |
|
256 | + try { |
|
257 | + $query->execute(); |
|
258 | + } catch (PDOException $e) { |
|
259 | + die($e->getMessage()); |
|
260 | + } |
|
261 | + } |
|
262 | + |
|
263 | + public function get_users_log() |
|
264 | + { |
|
265 | + $query = $this->db->prepare('SELECT * FROM `log_users` ORDER BY `time` DESC'); |
|
266 | + |
|
267 | + try { |
|
268 | + $query->execute(); |
|
269 | + } catch (PDOException $e) { |
|
270 | + die($e->getMessage()); |
|
271 | + } |
|
272 | + |
|
273 | + return $query->fetchAll(); |
|
274 | + } |
|
275 | 275 | } |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | $rows = $query->fetchColumn(); |
20 | 20 | if ($rows == 1) { |
21 | 21 | return true; |
22 | - } else { |
|
22 | + }else { |
|
23 | 23 | return false; |
24 | 24 | } |
25 | - } catch (PDOException $e) { |
|
25 | + }catch (PDOException $e) { |
|
26 | 26 | die($e->getMessage()); |
27 | 27 | } |
28 | 28 | } |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | $rows = $query->fetchColumn(); |
38 | 38 | if ($rows == 1) { |
39 | 39 | return true; |
40 | - } else { |
|
40 | + }else { |
|
41 | 41 | return false; |
42 | 42 | } |
43 | - } catch (PDOException $e) { |
|
43 | + }catch (PDOException $e) { |
|
44 | 44 | die($e->getMessage()); |
45 | 45 | } |
46 | 46 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | try { |
67 | 67 | $query->execute(); |
68 | - } catch (PDOException $e) { |
|
68 | + }catch (PDOException $e) { |
|
69 | 69 | die($e->getMessage()); |
70 | 70 | } |
71 | 71 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | try { |
92 | 92 | $query->execute(); |
93 | - } catch (PDOException $e) { |
|
93 | + }catch (PDOException $e) { |
|
94 | 94 | die($e->getMessage()); |
95 | 95 | } |
96 | 96 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | try { |
106 | 106 | $query->execute(); |
107 | - } catch (PDOException $e) { |
|
107 | + }catch (PDOException $e) { |
|
108 | 108 | die($e->getMessage()); |
109 | 109 | } |
110 | 110 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | try { |
119 | 119 | $query->execute(); |
120 | - } catch (PDOException $e) { |
|
120 | + }catch (PDOException $e) { |
|
121 | 121 | die($e->getMessage()); |
122 | 122 | } |
123 | 123 | } |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | $query_2->execute(); |
140 | 140 | |
141 | 141 | return true; |
142 | - } else { |
|
142 | + }else { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | - } catch (PDOException $e) { |
|
145 | + }catch (PDOException $e) { |
|
146 | 146 | die($e->getMessage()); |
147 | 147 | } |
148 | 148 | } |
@@ -158,10 +158,10 @@ discard block |
||
158 | 158 | $rows = $query->fetchColumn(); |
159 | 159 | if ($rows == 1) { |
160 | 160 | return true; |
161 | - } else { |
|
161 | + }else { |
|
162 | 162 | return false; |
163 | 163 | } |
164 | - } catch (PDOException $e) { |
|
164 | + }catch (PDOException $e) { |
|
165 | 165 | die($e->getMessage()); |
166 | 166 | } |
167 | 167 | } |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | $id = $data['id']; |
179 | 179 | if ($stored_password === sha1($password)) { |
180 | 180 | return $id; |
181 | - } else { |
|
181 | + }else { |
|
182 | 182 | return false; |
183 | 183 | } |
184 | - } catch (PDOException $e) { |
|
184 | + }catch (PDOException $e) { |
|
185 | 185 | die($e->getMessage()); |
186 | 186 | } |
187 | 187 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $query->execute(); |
196 | 196 | |
197 | 197 | return $query->fetch(); |
198 | - } catch (PDOException $e) { |
|
198 | + }catch (PDOException $e) { |
|
199 | 199 | die($e->getMessage()); |
200 | 200 | } |
201 | 201 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $query->execute(); |
210 | 210 | |
211 | 211 | return $query->fetch(); |
212 | - } catch (PDOException $e) { |
|
212 | + }catch (PDOException $e) { |
|
213 | 213 | die($e->getMessage()); |
214 | 214 | } |
215 | 215 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | try { |
223 | 223 | $query->execute(); |
224 | - } catch (PDOException $e) { |
|
224 | + }catch (PDOException $e) { |
|
225 | 225 | die($e->getMessage()); |
226 | 226 | } |
227 | 227 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | try { |
236 | 236 | $query->execute(); |
237 | - } catch (PDOException $e) { |
|
237 | + }catch (PDOException $e) { |
|
238 | 238 | die($e->getMessage()); |
239 | 239 | } |
240 | 240 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | |
256 | 256 | try { |
257 | 257 | $query->execute(); |
258 | - } catch (PDOException $e) { |
|
258 | + }catch (PDOException $e) { |
|
259 | 259 | die($e->getMessage()); |
260 | 260 | } |
261 | 261 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | try { |
268 | 268 | $query->execute(); |
269 | - } catch (PDOException $e) { |
|
269 | + }catch (PDOException $e) { |
|
270 | 270 | die($e->getMessage()); |
271 | 271 | } |
272 | 272 |
@@ -2,133 +2,133 @@ |
||
2 | 2 | |
3 | 3 | class Projects |
4 | 4 | { |
5 | - private $db; |
|
6 | - |
|
7 | - public function __construct($database) |
|
8 | - { |
|
9 | - $this->db = $database; |
|
10 | - } |
|
11 | - |
|
12 | - public function project_exists($projectid) |
|
13 | - { |
|
14 | - $query = $this->db->prepare('SELECT COUNT(`id`) FROM `projects` WHERE `projectid`= ?'); |
|
15 | - $query->bindValue(1, $projectid); |
|
16 | - |
|
17 | - try { |
|
18 | - $query->execute(); |
|
19 | - $rows = $query->fetchColumn(); |
|
20 | - if ($rows == 1) { |
|
21 | - return true; |
|
22 | - } else { |
|
23 | - return false; |
|
24 | - } |
|
25 | - } catch (PDOException $e) { |
|
26 | - die($e->getMessage()); |
|
27 | - } |
|
28 | - } |
|
29 | - |
|
30 | - public function add_project($projectname, $idcustomer, $deliverybegin, $deliveryend, $installbegin, $installend, $uatbegin, $uatend, $billstartdate, $billduedate, $warrantyperiod, $contractstartdate, $contractperiod) |
|
31 | - { |
|
32 | - $querystring = 'INSERT INTO `projects` (`projectname`,`idcustomer`, `deliverybegin`, `deliveryend`, `installbegin`, `installend`,`uatbegin`,`uatend`,`billstartdate`, `billduedate`, `warrantyperiod`, `contractstartdate`, `contractperiod`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; |
|
33 | - $query = $this->db->prepare($querystring); |
|
34 | - $query->bindValue(1, $projectname); |
|
35 | - $query->bindValue(2, $idcustomer); |
|
36 | - $query->bindValue(3, $deliverybegin); |
|
37 | - $query->bindValue(4, $deliveryend); |
|
38 | - $query->bindValue(5, $installbegin); |
|
39 | - $query->bindValue(6, $installend); |
|
40 | - $query->bindValue(7, $uatbegin); |
|
41 | - $query->bindValue(8, $uatend); |
|
42 | - $query->bindValue(9, $billstartdate); |
|
43 | - $query->bindValue(10, $billduedate); |
|
44 | - $query->bindValue(11, $warrantyperiod); |
|
45 | - $query->bindValue(12, $contractstartdate); |
|
46 | - $query->bindValue(13, $contractperiod); |
|
47 | - |
|
48 | - try { |
|
49 | - $query->execute(); |
|
50 | - } catch (PDOException $e) { |
|
51 | - die($e->getMessage()); |
|
52 | - } |
|
53 | - } |
|
54 | - |
|
55 | - public function update_project($projectid, $projectname, $idcustomer, $deliverybegin, $deliveryend, $installbegin, $installend, $uatbegin, $uatend, $billstartdate, $billduedate, $warrantyperiod, $contractstartdate, $contractperiod) |
|
56 | - { |
|
57 | - $querystring = 'UPDATE `projects` SET `projectname` = ? , `idcustomer` = ? , `deliverybegin` = ? , `deliveryend` = ? , `installbegin` = ? ,`installend` = ? , `uatbegin` = ? , `uatend` = ? ,`billstartdate` = ?, `billduedate` = ? , `warrantyperiod` = ? ,`contractstartdate` = ?,`contractperiod` = ? WHERE `projectid` = ?'; |
|
58 | - $query = $this->db->prepare($querystring); |
|
59 | - $query->bindValue(1, $projectname); |
|
60 | - $query->bindValue(2, $idcustomer); |
|
61 | - $query->bindValue(3, $deliverybegin); |
|
62 | - $query->bindValue(4, $deliveryend); |
|
63 | - $query->bindValue(5, $installbegin); |
|
64 | - $query->bindValue(6, $installend); |
|
65 | - $query->bindValue(7, $uatbegin); |
|
66 | - $query->bindValue(8, $uatend); |
|
67 | - $query->bindValue(9, $billstartdate); |
|
68 | - $query->bindValue(10, $billduedate); |
|
69 | - $query->bindValue(11, $warrantyperiod); |
|
70 | - $query->bindValue(12, $contractstartdate); |
|
71 | - $query->bindValue(13, $contractperiod); |
|
72 | - $query->bindValue(14, $projectid); |
|
73 | - |
|
74 | - try { |
|
75 | - $query->execute(); |
|
76 | - } catch (PDOException $e) { |
|
77 | - die($e->getMessage()); |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - public function delete($id) |
|
82 | - { |
|
83 | - $sql = 'DELETE FROM `projects` WHERE `projectid` = ?'; |
|
84 | - $query = $this->db->prepare($sql); |
|
85 | - $query->bindValue(1, $id); |
|
86 | - |
|
87 | - try { |
|
88 | - $query->execute(); |
|
89 | - } catch (PDOException $e) { |
|
90 | - die($e->getMessage()); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - public function project_data($id) |
|
95 | - { |
|
96 | - $query = $this->db->prepare('SELECT * FROM `projects` WHERE `projectid`= ?'); |
|
97 | - $query->bindValue(1, $id); |
|
98 | - |
|
99 | - try { |
|
100 | - $query->execute(); |
|
101 | - |
|
102 | - return $query->fetch(); |
|
103 | - } catch (PDOException $e) { |
|
104 | - die($e->getMessage()); |
|
105 | - } |
|
106 | - } |
|
107 | - |
|
108 | - public function get_projects() |
|
109 | - { |
|
110 | - $query = $this->db->prepare('SELECT * FROM `projects` ORDER BY `projectid` DESC'); |
|
111 | - |
|
112 | - try { |
|
113 | - $query->execute(); |
|
114 | - } catch (PDOException $e) { |
|
115 | - die($e->getMessage()); |
|
116 | - } |
|
117 | - |
|
118 | - return $query->fetchAll(); |
|
119 | - } |
|
120 | - |
|
121 | - public function get_project_customer($id) //get project_data by idcustomer |
|
122 | - { |
|
123 | - $query = $this->db->prepare('SELECT * FROM `projects` WHERE `idcustomer`= ? ORDER BY `contractstartdate` DESC LIMIT 1'); |
|
124 | - $query->bindValue(1, $id); |
|
125 | - |
|
126 | - try { |
|
127 | - $query->execute(); |
|
128 | - |
|
129 | - return $query->fetch(); |
|
130 | - } catch (PDOException $e) { |
|
131 | - die($e->getMessage()); |
|
132 | - } |
|
133 | - } |
|
5 | + private $db; |
|
6 | + |
|
7 | + public function __construct($database) |
|
8 | + { |
|
9 | + $this->db = $database; |
|
10 | + } |
|
11 | + |
|
12 | + public function project_exists($projectid) |
|
13 | + { |
|
14 | + $query = $this->db->prepare('SELECT COUNT(`id`) FROM `projects` WHERE `projectid`= ?'); |
|
15 | + $query->bindValue(1, $projectid); |
|
16 | + |
|
17 | + try { |
|
18 | + $query->execute(); |
|
19 | + $rows = $query->fetchColumn(); |
|
20 | + if ($rows == 1) { |
|
21 | + return true; |
|
22 | + } else { |
|
23 | + return false; |
|
24 | + } |
|
25 | + } catch (PDOException $e) { |
|
26 | + die($e->getMessage()); |
|
27 | + } |
|
28 | + } |
|
29 | + |
|
30 | + public function add_project($projectname, $idcustomer, $deliverybegin, $deliveryend, $installbegin, $installend, $uatbegin, $uatend, $billstartdate, $billduedate, $warrantyperiod, $contractstartdate, $contractperiod) |
|
31 | + { |
|
32 | + $querystring = 'INSERT INTO `projects` (`projectname`,`idcustomer`, `deliverybegin`, `deliveryend`, `installbegin`, `installend`,`uatbegin`,`uatend`,`billstartdate`, `billduedate`, `warrantyperiod`, `contractstartdate`, `contractperiod`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; |
|
33 | + $query = $this->db->prepare($querystring); |
|
34 | + $query->bindValue(1, $projectname); |
|
35 | + $query->bindValue(2, $idcustomer); |
|
36 | + $query->bindValue(3, $deliverybegin); |
|
37 | + $query->bindValue(4, $deliveryend); |
|
38 | + $query->bindValue(5, $installbegin); |
|
39 | + $query->bindValue(6, $installend); |
|
40 | + $query->bindValue(7, $uatbegin); |
|
41 | + $query->bindValue(8, $uatend); |
|
42 | + $query->bindValue(9, $billstartdate); |
|
43 | + $query->bindValue(10, $billduedate); |
|
44 | + $query->bindValue(11, $warrantyperiod); |
|
45 | + $query->bindValue(12, $contractstartdate); |
|
46 | + $query->bindValue(13, $contractperiod); |
|
47 | + |
|
48 | + try { |
|
49 | + $query->execute(); |
|
50 | + } catch (PDOException $e) { |
|
51 | + die($e->getMessage()); |
|
52 | + } |
|
53 | + } |
|
54 | + |
|
55 | + public function update_project($projectid, $projectname, $idcustomer, $deliverybegin, $deliveryend, $installbegin, $installend, $uatbegin, $uatend, $billstartdate, $billduedate, $warrantyperiod, $contractstartdate, $contractperiod) |
|
56 | + { |
|
57 | + $querystring = 'UPDATE `projects` SET `projectname` = ? , `idcustomer` = ? , `deliverybegin` = ? , `deliveryend` = ? , `installbegin` = ? ,`installend` = ? , `uatbegin` = ? , `uatend` = ? ,`billstartdate` = ?, `billduedate` = ? , `warrantyperiod` = ? ,`contractstartdate` = ?,`contractperiod` = ? WHERE `projectid` = ?'; |
|
58 | + $query = $this->db->prepare($querystring); |
|
59 | + $query->bindValue(1, $projectname); |
|
60 | + $query->bindValue(2, $idcustomer); |
|
61 | + $query->bindValue(3, $deliverybegin); |
|
62 | + $query->bindValue(4, $deliveryend); |
|
63 | + $query->bindValue(5, $installbegin); |
|
64 | + $query->bindValue(6, $installend); |
|
65 | + $query->bindValue(7, $uatbegin); |
|
66 | + $query->bindValue(8, $uatend); |
|
67 | + $query->bindValue(9, $billstartdate); |
|
68 | + $query->bindValue(10, $billduedate); |
|
69 | + $query->bindValue(11, $warrantyperiod); |
|
70 | + $query->bindValue(12, $contractstartdate); |
|
71 | + $query->bindValue(13, $contractperiod); |
|
72 | + $query->bindValue(14, $projectid); |
|
73 | + |
|
74 | + try { |
|
75 | + $query->execute(); |
|
76 | + } catch (PDOException $e) { |
|
77 | + die($e->getMessage()); |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + public function delete($id) |
|
82 | + { |
|
83 | + $sql = 'DELETE FROM `projects` WHERE `projectid` = ?'; |
|
84 | + $query = $this->db->prepare($sql); |
|
85 | + $query->bindValue(1, $id); |
|
86 | + |
|
87 | + try { |
|
88 | + $query->execute(); |
|
89 | + } catch (PDOException $e) { |
|
90 | + die($e->getMessage()); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + public function project_data($id) |
|
95 | + { |
|
96 | + $query = $this->db->prepare('SELECT * FROM `projects` WHERE `projectid`= ?'); |
|
97 | + $query->bindValue(1, $id); |
|
98 | + |
|
99 | + try { |
|
100 | + $query->execute(); |
|
101 | + |
|
102 | + return $query->fetch(); |
|
103 | + } catch (PDOException $e) { |
|
104 | + die($e->getMessage()); |
|
105 | + } |
|
106 | + } |
|
107 | + |
|
108 | + public function get_projects() |
|
109 | + { |
|
110 | + $query = $this->db->prepare('SELECT * FROM `projects` ORDER BY `projectid` DESC'); |
|
111 | + |
|
112 | + try { |
|
113 | + $query->execute(); |
|
114 | + } catch (PDOException $e) { |
|
115 | + die($e->getMessage()); |
|
116 | + } |
|
117 | + |
|
118 | + return $query->fetchAll(); |
|
119 | + } |
|
120 | + |
|
121 | + public function get_project_customer($id) //get project_data by idcustomer |
|
122 | + { |
|
123 | + $query = $this->db->prepare('SELECT * FROM `projects` WHERE `idcustomer`= ? ORDER BY `contractstartdate` DESC LIMIT 1'); |
|
124 | + $query->bindValue(1, $id); |
|
125 | + |
|
126 | + try { |
|
127 | + $query->execute(); |
|
128 | + |
|
129 | + return $query->fetch(); |
|
130 | + } catch (PDOException $e) { |
|
131 | + die($e->getMessage()); |
|
132 | + } |
|
133 | + } |
|
134 | 134 | } |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | $rows = $query->fetchColumn(); |
20 | 20 | if ($rows == 1) { |
21 | 21 | return true; |
22 | - } else { |
|
22 | + }else { |
|
23 | 23 | return false; |
24 | 24 | } |
25 | - } catch (PDOException $e) { |
|
25 | + }catch (PDOException $e) { |
|
26 | 26 | die($e->getMessage()); |
27 | 27 | } |
28 | 28 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | try { |
49 | 49 | $query->execute(); |
50 | - } catch (PDOException $e) { |
|
50 | + }catch (PDOException $e) { |
|
51 | 51 | die($e->getMessage()); |
52 | 52 | } |
53 | 53 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | try { |
75 | 75 | $query->execute(); |
76 | - } catch (PDOException $e) { |
|
76 | + }catch (PDOException $e) { |
|
77 | 77 | die($e->getMessage()); |
78 | 78 | } |
79 | 79 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | try { |
88 | 88 | $query->execute(); |
89 | - } catch (PDOException $e) { |
|
89 | + }catch (PDOException $e) { |
|
90 | 90 | die($e->getMessage()); |
91 | 91 | } |
92 | 92 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $query->execute(); |
101 | 101 | |
102 | 102 | return $query->fetch(); |
103 | - } catch (PDOException $e) { |
|
103 | + }catch (PDOException $e) { |
|
104 | 104 | die($e->getMessage()); |
105 | 105 | } |
106 | 106 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | try { |
113 | 113 | $query->execute(); |
114 | - } catch (PDOException $e) { |
|
114 | + }catch (PDOException $e) { |
|
115 | 115 | die($e->getMessage()); |
116 | 116 | } |
117 | 117 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $query->execute(); |
128 | 128 | |
129 | 129 | return $query->fetch(); |
130 | - } catch (PDOException $e) { |
|
130 | + }catch (PDOException $e) { |
|
131 | 131 | die($e->getMessage()); |
132 | 132 | } |
133 | 133 | } |
@@ -2,102 +2,102 @@ |
||
2 | 2 | |
3 | 3 | class SLA |
4 | 4 | { |
5 | - private $db; |
|
6 | - |
|
7 | - public function __construct($database) |
|
8 | - { |
|
9 | - $this->db = $database; |
|
10 | - } |
|
11 | - |
|
12 | - public function sla_exists($slaid) |
|
13 | - { |
|
14 | - $query = $this->db->prepare('SELECT COUNT(`slaid`) FROM `sla` WHERE `slaid`= ?'); |
|
15 | - $query->bindValue(1, $slaid); |
|
16 | - |
|
17 | - try { |
|
18 | - $query->execute(); |
|
19 | - $rows = $query->fetchColumn(); |
|
20 | - if ($rows == 1) { |
|
21 | - return true; |
|
22 | - } else { |
|
23 | - return false; |
|
24 | - } |
|
25 | - } catch (PDOException $e) { |
|
26 | - die($e->getMessage()); |
|
27 | - } |
|
28 | - } |
|
29 | - |
|
30 | - public function add_sla($slaid, $namasla, $responsetime, $resolutiontime, $slawarning) |
|
31 | - { |
|
32 | - $querystring = 'INSERT INTO `sla` (`slaid`,`namasla`,`responsetime`, `resolutiontime`, `slawarning`) VALUES (?, ?, ?, ?, ?)'; |
|
33 | - $query = $this->db->prepare($querystring); |
|
34 | - $query->bindValue(1, $slaid); |
|
35 | - $query->bindValue(2, $namasla); |
|
36 | - $query->bindValue(3, $responsetime); |
|
37 | - $query->bindValue(4, $resolutiontime); |
|
38 | - $query->bindValue(5, $slawarning); |
|
39 | - |
|
40 | - try { |
|
41 | - $query->execute(); |
|
42 | - } catch (PDOException $e) { |
|
43 | - die($e->getMessage()); |
|
44 | - } |
|
45 | - } |
|
46 | - |
|
47 | - public function update_sla($slaid, $namasla, $responsetime, $resolutiontime, $slawarning) |
|
48 | - { |
|
49 | - $querystring = 'UPDATE `sla` SET `namasla` = ? , `responsetime` = ? , `resolutiontime` = ?, `slawarning` = ? WHERE `slaid` = ?'; |
|
50 | - $query = $this->db->prepare($querystring); |
|
51 | - $query->bindValue(1, $namasla); |
|
52 | - $query->bindValue(2, $responsetime); |
|
53 | - $query->bindValue(3, $resolutiontime); |
|
54 | - $query->bindValue(4, $slawarning); |
|
55 | - $query->bindValue(5, $slaid); |
|
56 | - |
|
57 | - try { |
|
58 | - $query->execute(); |
|
59 | - } catch (PDOException $e) { |
|
60 | - die($e->getMessage()); |
|
61 | - } |
|
62 | - } |
|
63 | - |
|
64 | - public function delete($id) |
|
65 | - { |
|
66 | - $sql = 'DELETE FROM `sla` WHERE `slaid` = ?'; |
|
67 | - $query = $this->db->prepare($sql); |
|
68 | - $query->bindValue(1, $id); |
|
69 | - |
|
70 | - try { |
|
71 | - $query->execute(); |
|
72 | - } catch (PDOException $e) { |
|
73 | - die($e->getMessage()); |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - public function sla_data($slaid) |
|
78 | - { |
|
79 | - $query = $this->db->prepare('SELECT * FROM `sla` WHERE `slaid`= ?'); |
|
80 | - $query->bindValue(1, $slaid); |
|
81 | - |
|
82 | - try { |
|
83 | - $query->execute(); |
|
84 | - |
|
85 | - return $query->fetch(); |
|
86 | - } catch (PDOException $e) { |
|
87 | - die($e->getMessage()); |
|
88 | - } |
|
89 | - } |
|
90 | - |
|
91 | - public function get_sla() |
|
92 | - { |
|
93 | - $query = $this->db->prepare('SELECT * FROM `sla` ORDER BY `slaid` ASC'); |
|
94 | - |
|
95 | - try { |
|
96 | - $query->execute(); |
|
97 | - } catch (PDOException $e) { |
|
98 | - die($e->getMessage()); |
|
99 | - } |
|
100 | - |
|
101 | - return $query->fetchAll(); |
|
102 | - } |
|
5 | + private $db; |
|
6 | + |
|
7 | + public function __construct($database) |
|
8 | + { |
|
9 | + $this->db = $database; |
|
10 | + } |
|
11 | + |
|
12 | + public function sla_exists($slaid) |
|
13 | + { |
|
14 | + $query = $this->db->prepare('SELECT COUNT(`slaid`) FROM `sla` WHERE `slaid`= ?'); |
|
15 | + $query->bindValue(1, $slaid); |
|
16 | + |
|
17 | + try { |
|
18 | + $query->execute(); |
|
19 | + $rows = $query->fetchColumn(); |
|
20 | + if ($rows == 1) { |
|
21 | + return true; |
|
22 | + } else { |
|
23 | + return false; |
|
24 | + } |
|
25 | + } catch (PDOException $e) { |
|
26 | + die($e->getMessage()); |
|
27 | + } |
|
28 | + } |
|
29 | + |
|
30 | + public function add_sla($slaid, $namasla, $responsetime, $resolutiontime, $slawarning) |
|
31 | + { |
|
32 | + $querystring = 'INSERT INTO `sla` (`slaid`,`namasla`,`responsetime`, `resolutiontime`, `slawarning`) VALUES (?, ?, ?, ?, ?)'; |
|
33 | + $query = $this->db->prepare($querystring); |
|
34 | + $query->bindValue(1, $slaid); |
|
35 | + $query->bindValue(2, $namasla); |
|
36 | + $query->bindValue(3, $responsetime); |
|
37 | + $query->bindValue(4, $resolutiontime); |
|
38 | + $query->bindValue(5, $slawarning); |
|
39 | + |
|
40 | + try { |
|
41 | + $query->execute(); |
|
42 | + } catch (PDOException $e) { |
|
43 | + die($e->getMessage()); |
|
44 | + } |
|
45 | + } |
|
46 | + |
|
47 | + public function update_sla($slaid, $namasla, $responsetime, $resolutiontime, $slawarning) |
|
48 | + { |
|
49 | + $querystring = 'UPDATE `sla` SET `namasla` = ? , `responsetime` = ? , `resolutiontime` = ?, `slawarning` = ? WHERE `slaid` = ?'; |
|
50 | + $query = $this->db->prepare($querystring); |
|
51 | + $query->bindValue(1, $namasla); |
|
52 | + $query->bindValue(2, $responsetime); |
|
53 | + $query->bindValue(3, $resolutiontime); |
|
54 | + $query->bindValue(4, $slawarning); |
|
55 | + $query->bindValue(5, $slaid); |
|
56 | + |
|
57 | + try { |
|
58 | + $query->execute(); |
|
59 | + } catch (PDOException $e) { |
|
60 | + die($e->getMessage()); |
|
61 | + } |
|
62 | + } |
|
63 | + |
|
64 | + public function delete($id) |
|
65 | + { |
|
66 | + $sql = 'DELETE FROM `sla` WHERE `slaid` = ?'; |
|
67 | + $query = $this->db->prepare($sql); |
|
68 | + $query->bindValue(1, $id); |
|
69 | + |
|
70 | + try { |
|
71 | + $query->execute(); |
|
72 | + } catch (PDOException $e) { |
|
73 | + die($e->getMessage()); |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + public function sla_data($slaid) |
|
78 | + { |
|
79 | + $query = $this->db->prepare('SELECT * FROM `sla` WHERE `slaid`= ?'); |
|
80 | + $query->bindValue(1, $slaid); |
|
81 | + |
|
82 | + try { |
|
83 | + $query->execute(); |
|
84 | + |
|
85 | + return $query->fetch(); |
|
86 | + } catch (PDOException $e) { |
|
87 | + die($e->getMessage()); |
|
88 | + } |
|
89 | + } |
|
90 | + |
|
91 | + public function get_sla() |
|
92 | + { |
|
93 | + $query = $this->db->prepare('SELECT * FROM `sla` ORDER BY `slaid` ASC'); |
|
94 | + |
|
95 | + try { |
|
96 | + $query->execute(); |
|
97 | + } catch (PDOException $e) { |
|
98 | + die($e->getMessage()); |
|
99 | + } |
|
100 | + |
|
101 | + return $query->fetchAll(); |
|
102 | + } |
|
103 | 103 | } |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | $rows = $query->fetchColumn(); |
20 | 20 | if ($rows == 1) { |
21 | 21 | return true; |
22 | - } else { |
|
22 | + }else { |
|
23 | 23 | return false; |
24 | 24 | } |
25 | - } catch (PDOException $e) { |
|
25 | + }catch (PDOException $e) { |
|
26 | 26 | die($e->getMessage()); |
27 | 27 | } |
28 | 28 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | try { |
41 | 41 | $query->execute(); |
42 | - } catch (PDOException $e) { |
|
42 | + }catch (PDOException $e) { |
|
43 | 43 | die($e->getMessage()); |
44 | 44 | } |
45 | 45 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | try { |
58 | 58 | $query->execute(); |
59 | - } catch (PDOException $e) { |
|
59 | + }catch (PDOException $e) { |
|
60 | 60 | die($e->getMessage()); |
61 | 61 | } |
62 | 62 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | try { |
71 | 71 | $query->execute(); |
72 | - } catch (PDOException $e) { |
|
72 | + }catch (PDOException $e) { |
|
73 | 73 | die($e->getMessage()); |
74 | 74 | } |
75 | 75 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $query->execute(); |
84 | 84 | |
85 | 85 | return $query->fetch(); |
86 | - } catch (PDOException $e) { |
|
86 | + }catch (PDOException $e) { |
|
87 | 87 | die($e->getMessage()); |
88 | 88 | } |
89 | 89 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | try { |
96 | 96 | $query->execute(); |
97 | - } catch (PDOException $e) { |
|
97 | + }catch (PDOException $e) { |
|
98 | 98 | die($e->getMessage()); |
99 | 99 | } |
100 | 100 |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $config = [ |
4 | - 'host' => 'localhost', |
|
5 | - 'username' => 'root', |
|
6 | - 'password' => 'root', |
|
7 | - 'dbname' => 'helpdesk', |
|
4 | + 'host' => 'localhost', |
|
5 | + 'username' => 'root', |
|
6 | + 'password' => 'root', |
|
7 | + 'dbname' => 'helpdesk', |
|
8 | 8 | ]; |
9 | 9 | |
10 | 10 | $db = new PDO('mysql:host='.$config['host'].';dbname='.$config['dbname'], $config['username'], $config['password']); |
@@ -5,20 +5,20 @@ |
||
5 | 5 | require_once 'connect/database.php'; |
6 | 6 | function my_autoload($class) |
7 | 7 | { |
8 | - $filename = 'classes/'.$class.'.php'; |
|
9 | - include_once $filename; |
|
8 | + $filename = 'classes/'.$class.'.php'; |
|
9 | + include_once $filename; |
|
10 | 10 | } |
11 | 11 | spl_autoload_register('my_autoload'); |
12 | 12 | |
13 | 13 | try { |
14 | - $general = new General(); |
|
15 | - $users = new Users($db); |
|
16 | - $customers = new Customers($db); |
|
17 | - $projects = new Projects($db); |
|
18 | - $tickets = new Tickets($db); |
|
19 | - $hdnews = new HDNews($db); |
|
20 | - $slas = new SLA($db); |
|
21 | - $emails = new Emails($db); |
|
14 | + $general = new General(); |
|
15 | + $users = new Users($db); |
|
16 | + $customers = new Customers($db); |
|
17 | + $projects = new Projects($db); |
|
18 | + $tickets = new Tickets($db); |
|
19 | + $hdnews = new HDNews($db); |
|
20 | + $slas = new SLA($db); |
|
21 | + $emails = new Emails($db); |
|
22 | 22 | } catch (Exception $e) { |
23 | - echo 'Caught exception: ', $e->getMessage(), "\n"; |
|
23 | + echo 'Caught exception: ', $e->getMessage(), "\n"; |
|
24 | 24 | } |
@@ -19,6 +19,6 @@ |
||
19 | 19 | $hdnews = new HDNews($db); |
20 | 20 | $slas = new SLA($db); |
21 | 21 | $emails = new Emails($db); |
22 | -} catch (Exception $e) { |
|
23 | - echo 'Caught exception: ', $e->getMessage(), "\n"; |
|
22 | +}catch (Exception $e) { |
|
23 | + echo 'Caught exception: ', $e->getMessage(), "\n"; |
|
24 | 24 | } |
@@ -4,16 +4,16 @@ discard block |
||
4 | 4 | $general->logged_out_protect(); |
5 | 5 | $user = $users->userdata($_SESSION['loginid']); |
6 | 6 | if ($user['level'] != 'Admin') { |
7 | - exit("You don't have permission to access this page!"); |
|
7 | + exit("You don't have permission to access this page!"); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | if (isset($_POST['submit'])) { |
11 | - echo 'Sending email queue... Please wait!'; |
|
12 | - //$result=$emails->send_new_ticket(); |
|
13 | - //$result=$emails->send_sla_remainder(); |
|
14 | - //header('Location: emailqueue.php?process'); |
|
15 | - //sleep(5); |
|
16 | - header('Location: emailqueue.php?success'); |
|
11 | + echo 'Sending email queue... Please wait!'; |
|
12 | + //$result=$emails->send_new_ticket(); |
|
13 | + //$result=$emails->send_sla_remainder(); |
|
14 | + //header('Location: emailqueue.php?process'); |
|
15 | + //sleep(5); |
|
16 | + header('Location: emailqueue.php?success'); |
|
17 | 17 | } |
18 | 18 | $logs = $emails->get_email_queue(); |
19 | 19 | $emailqueue_count = count($logs); |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | </form> |
61 | 61 | <span class="textmsg"> |
62 | 62 | <?php |
63 | - if (isset($_GET['process']) && empty($_GET['process'])) { |
|
64 | - echo 'Sending email queue... Please wait!'; |
|
65 | - } |
|
66 | - if (isset($_GET['success']) && empty($_GET['success'])) { |
|
67 | - echo 'Sending email queue is done!'; |
|
68 | - } |
|
69 | - ?></span> |
|
63 | + if (isset($_GET['process']) && empty($_GET['process'])) { |
|
64 | + echo 'Sending email queue... Please wait!'; |
|
65 | + } |
|
66 | + if (isset($_GET['success']) && empty($_GET['success'])) { |
|
67 | + echo 'Sending email queue is done!'; |
|
68 | + } |
|
69 | + ?></span> |
|
70 | 70 | </p> |
71 | 71 | <table id="datatables" class="display"> |
72 | 72 | <thead> |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | </thead> |
81 | 81 | <tbody> |
82 | 82 | <?php |
83 | - foreach ($logs as $log) { |
|
84 | - $idemail = $log['idemail']; |
|
85 | - echo '<tr><td><a href="emailsend.php?id='.$idemail.'">'.date('d-M-Y H:i', $log['senddate']).'</a></td>'. |
|
86 | - '<td>'.$log['emailto'].'</td>'. |
|
87 | - '<td>'.$log['emailcc'].'</td>'. |
|
88 | - '<td>'.$log['emailsubject'].'</td>'. |
|
89 | - '<td>'.$log['emailstatus'].'</td></tr>'; |
|
90 | - } |
|
91 | - ?> |
|
83 | + foreach ($logs as $log) { |
|
84 | + $idemail = $log['idemail']; |
|
85 | + echo '<tr><td><a href="emailsend.php?id='.$idemail.'">'.date('d-M-Y H:i', $log['senddate']).'</a></td>'. |
|
86 | + '<td>'.$log['emailto'].'</td>'. |
|
87 | + '<td>'.$log['emailcc'].'</td>'. |
|
88 | + '<td>'.$log['emailsubject'].'</td>'. |
|
89 | + '<td>'.$log['emailstatus'].'</td></tr>'; |
|
90 | + } |
|
91 | + ?> |
|
92 | 92 | </tbody> |
93 | 93 | </table> |
94 | 94 | </body> |
@@ -49,17 +49,17 @@ |
||
49 | 49 | </thead> |
50 | 50 | <tbody> |
51 | 51 | <?php |
52 | - foreach ($tickets as $ticket) { |
|
53 | - $sla = $slas->sla_data($ticket['sla']); |
|
54 | - $customer = $customers->customer_data($ticket['idcustomer']); |
|
55 | - echo '<tr><td>'.$customer['namacustomer'].'</td>'. |
|
56 | - '<td>'.date('d-M-Y', $ticket['reporteddate']).'</td>'. |
|
57 | - '<td>'.$ticket['problemsummary'].'</td>'. |
|
58 | - '<td>'.$ticket['problemdetail'].'</td>'. |
|
59 | - '<td>'.$ticket['resolution'].'</td>'. |
|
60 | - '<td>'.$ticket['resolvedby'].'</td></tr>'; |
|
61 | - } |
|
62 | - ?> |
|
52 | + foreach ($tickets as $ticket) { |
|
53 | + $sla = $slas->sla_data($ticket['sla']); |
|
54 | + $customer = $customers->customer_data($ticket['idcustomer']); |
|
55 | + echo '<tr><td>'.$customer['namacustomer'].'</td>'. |
|
56 | + '<td>'.date('d-M-Y', $ticket['reporteddate']).'</td>'. |
|
57 | + '<td>'.$ticket['problemsummary'].'</td>'. |
|
58 | + '<td>'.$ticket['problemdetail'].'</td>'. |
|
59 | + '<td>'.$ticket['resolution'].'</td>'. |
|
60 | + '<td>'.$ticket['resolvedby'].'</td></tr>'; |
|
61 | + } |
|
62 | + ?> |
|
63 | 63 | </tbody> |
64 | 64 | </table> |
65 | 65 | <p> </p> |