@@ -14,8 +14,7 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @package MyDb |
16 | 16 | */ |
17 | -class Loader |
|
18 | -{ |
|
17 | +class Loader { |
|
19 | 18 | /* public: connection parameters */ |
20 | 19 | public $Type = 'mysqli'; |
21 | 20 | public $host = 'localhost'; |
@@ -55,8 +54,7 @@ discard block |
||
55 | 54 | * @param string $host Optional The hostname where the server is, or default to localhost |
56 | 55 | * @param string $query Optional query to perform immediately |
57 | 56 | */ |
58 | - public function __construct($Type = '', $database = '', $user = '', $password = '', $host = 'localhost', $query = '') |
|
59 | - { |
|
57 | + public function __construct($Type = '', $database = '', $user = '', $password = '', $host = 'localhost', $query = '') { |
|
60 | 58 | $this->Type = $Type; |
61 | 59 | if (!defined('db')) { |
62 | 60 | switch ($this->Type) { |
@@ -97,24 +95,21 @@ discard block |
||
97 | 95 | * @param string $line |
98 | 96 | * @param string $file |
99 | 97 | */ |
100 | - public function log($message, $line = '', $file = '') |
|
101 | - { |
|
98 | + public function log($message, $line = '', $file = '') { |
|
102 | 99 | error_log($message); |
103 | 100 | } |
104 | 101 | |
105 | 102 | /** |
106 | 103 | * @return int |
107 | 104 | */ |
108 | - public function linkId() |
|
109 | - { |
|
105 | + public function linkId() { |
|
110 | 106 | return $this->linkId; |
111 | 107 | } |
112 | 108 | |
113 | 109 | /** |
114 | 110 | * @return int |
115 | 111 | */ |
116 | - public function queryId() |
|
117 | - { |
|
112 | + public function queryId() { |
|
118 | 113 | return $this->queryId; |
119 | 114 | } |
120 | 115 | |
@@ -122,8 +117,7 @@ discard block |
||
122 | 117 | * @param $str |
123 | 118 | * @return string |
124 | 119 | */ |
125 | - public function dbAddslashes($str) |
|
126 | - { |
|
120 | + public function dbAddslashes($str) { |
|
127 | 121 | if (!isset($str) || $str == '') { |
128 | 122 | return ''; |
129 | 123 | } |
@@ -141,8 +135,7 @@ discard block |
||
141 | 135 | * @param string $file optionally pass __FILE__ calling the query for logging |
142 | 136 | * @return mixed FALSE if no rows, if a single row it returns that, if multiple it returns an array of rows, associative responses only |
143 | 137 | */ |
144 | - public function qr($query, $line = '', $file = '') |
|
145 | - { |
|
138 | + public function qr($query, $line = '', $file = '') { |
|
146 | 139 | return $this->queryReturn($query, $line, $file); |
147 | 140 | } |
148 | 141 | |
@@ -154,8 +147,7 @@ discard block |
||
154 | 147 | * @param string $file |
155 | 148 | * @return void |
156 | 149 | */ |
157 | - public function halt($msg, $line = '', $file = '') |
|
158 | - { |
|
150 | + public function halt($msg, $line = '', $file = '') { |
|
159 | 151 | $this->unlock(false); |
160 | 152 | |
161 | 153 | if ($this->haltOnError == 'no') { |
@@ -181,8 +173,7 @@ discard block |
||
181 | 173 | /** |
182 | 174 | * @param $msg |
183 | 175 | */ |
184 | - public function haltmsg($msg) |
|
185 | - { |
|
176 | + public function haltmsg($msg) { |
|
186 | 177 | $this->log("Database error: $msg", __LINE__, __FILE__); |
187 | 178 | if ($this->Errno != '0' || $this->Error != '()') { |
188 | 179 | $this->log('SQL Error: '.$this->Errno.' ('.$this->Error.')', __LINE__, __FILE__); |
@@ -192,8 +183,7 @@ discard block |
||
192 | 183 | /** |
193 | 184 | * @return array |
194 | 185 | */ |
195 | - public function indexNames() |
|
196 | - { |
|
186 | + public function indexNames() { |
|
197 | 187 | return []; |
198 | 188 | } |
199 | 189 | } |
@@ -12,8 +12,7 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * Class Generic |
14 | 14 | */ |
15 | -abstract class Generic |
|
16 | -{ |
|
15 | +abstract class Generic { |
|
17 | 16 | /* public: connection parameters */ |
18 | 17 | public $host = 'localhost'; |
19 | 18 | public $database = ''; |
@@ -63,8 +62,7 @@ discard block |
||
63 | 62 | * @param string $host Optional The hostname where the server is, or default to localhost |
64 | 63 | * @param string $query Optional query to perform immediately |
65 | 64 | */ |
66 | - public function __construct($database = '', $user = '', $password = '', $host = 'localhost', $query = '') |
|
67 | - { |
|
65 | + public function __construct($database = '', $user = '', $password = '', $host = 'localhost', $query = '') { |
|
68 | 66 | $this->database = $database; |
69 | 67 | $this->user = $user; |
70 | 68 | $this->password = $password; |
@@ -81,24 +79,21 @@ discard block |
||
81 | 79 | * @param string $file |
82 | 80 | * @return void |
83 | 81 | */ |
84 | - public function log($message, $line = '', $file = '', $level = 'info') |
|
85 | - { |
|
82 | + public function log($message, $line = '', $file = '', $level = 'info') { |
|
86 | 83 | error_log($message); |
87 | 84 | } |
88 | 85 | |
89 | 86 | /** |
90 | 87 | * @return int|object |
91 | 88 | */ |
92 | - public function linkId() |
|
93 | - { |
|
89 | + public function linkId() { |
|
94 | 90 | return $this->linkId; |
95 | 91 | } |
96 | 92 | |
97 | 93 | /** |
98 | 94 | * @return int|object |
99 | 95 | */ |
100 | - public function queryId() |
|
101 | - { |
|
96 | + public function queryId() { |
|
102 | 97 | return $this->queryId; |
103 | 98 | } |
104 | 99 | |
@@ -106,8 +101,7 @@ discard block |
||
106 | 101 | * @param $string |
107 | 102 | * @return string |
108 | 103 | */ |
109 | - public function real_escape($string = '') |
|
110 | - { |
|
104 | + public function real_escape($string = '') { |
|
111 | 105 | if ((!is_resource($this->linkId) || $this->linkId == 0) && !$this->connect()) { |
112 | 106 | return $this->escape($string); |
113 | 107 | } |
@@ -118,8 +112,7 @@ discard block |
||
118 | 112 | * @param $string |
119 | 113 | * @return string |
120 | 114 | */ |
121 | - public function escape($string = '') |
|
122 | - { |
|
115 | + public function escape($string = '') { |
|
123 | 116 | //if (function_exists('mysql_escape_string')) |
124 | 117 | //return mysql_escape_string($string); |
125 | 118 | return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $string); |
@@ -129,8 +122,7 @@ discard block |
||
129 | 122 | * @param mixed $str |
130 | 123 | * @return string |
131 | 124 | */ |
132 | - public function dbAddslashes($str = '') |
|
133 | - { |
|
125 | + public function dbAddslashes($str = '') { |
|
134 | 126 | if (!isset($str) || $str == '') { |
135 | 127 | return ''; |
136 | 128 | } |
@@ -142,8 +134,7 @@ discard block |
||
142 | 134 | * @param mixed $epoch |
143 | 135 | * @return bool|string |
144 | 136 | */ |
145 | - public function toTimestamp($epoch) |
|
146 | - { |
|
137 | + public function toTimestamp($epoch) { |
|
147 | 138 | return date('Y-m-d H:i:s', $epoch); |
148 | 139 | } |
149 | 140 | |
@@ -152,8 +143,7 @@ discard block |
||
152 | 143 | * @param mixed $timestamp |
153 | 144 | * @return bool|int|mixed |
154 | 145 | */ |
155 | - public function fromTimestamp($timestamp) |
|
156 | - { |
|
146 | + public function fromTimestamp($timestamp) { |
|
157 | 147 | if (preg_match('/([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})/', $timestamp, $parts)) { |
158 | 148 | $time = mktime($parts[4], $parts[5], $parts[6], $parts[2], $parts[3], $parts[1]); |
159 | 149 | } elseif (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $timestamp, $parts)) { |
@@ -179,8 +169,7 @@ discard block |
||
179 | 169 | * @param string $file |
180 | 170 | * @return mixed |
181 | 171 | */ |
182 | - public function limitQuery($queryString, $numRows = '', $offset = 0, $line = '', $file = '') |
|
183 | - { |
|
172 | + public function limitQuery($queryString, $numRows = '', $offset = 0, $line = '', $file = '') { |
|
184 | 173 | if (!$numRows) { |
185 | 174 | $numRows = $this->maxMatches; |
186 | 175 | } |
@@ -207,8 +196,7 @@ discard block |
||
207 | 196 | * @param string $file optionally pass __FILE__ calling the query for logging |
208 | 197 | * @return mixed FALSE if no rows, if a single row it returns that, if multiple it returns an array of rows, associative responses only |
209 | 198 | */ |
210 | - public function qr($query, $line = '', $file = '') |
|
211 | - { |
|
199 | + public function qr($query, $line = '', $file = '') { |
|
212 | 200 | return $this->queryReturn($query, $line, $file); |
213 | 201 | } |
214 | 202 | |
@@ -219,8 +207,7 @@ discard block |
||
219 | 207 | * @param string $stripSlashes |
220 | 208 | * @return string |
221 | 209 | */ |
222 | - public function f($name, $stripSlashes = '') |
|
223 | - { |
|
210 | + public function f($name, $stripSlashes = '') { |
|
224 | 211 | if ($stripSlashes || ($this->autoStripslashes && !$stripSlashes)) { |
225 | 212 | return stripslashes($this->Record[$name]); |
226 | 213 | } else { |
@@ -236,8 +223,7 @@ discard block |
||
236 | 223 | * @param string $file |
237 | 224 | * @return void |
238 | 225 | */ |
239 | - public function halt($msg, $line = '', $file = '') |
|
240 | - { |
|
226 | + public function halt($msg, $line = '', $file = '') { |
|
241 | 227 | $this->unlock(false); |
242 | 228 | /* Just in case there is a table currently locked */ |
243 | 229 | |
@@ -265,8 +251,7 @@ discard block |
||
265 | 251 | * @param string $file |
266 | 252 | * @return mixed|void |
267 | 253 | */ |
268 | - public function logBackTrace($msg, $line = '', $file = '') |
|
269 | - { |
|
254 | + public function logBackTrace($msg, $line = '', $file = '') { |
|
270 | 255 | $backtrace = (function_exists('debug_backtrace') ? debug_backtrace() : []); |
271 | 256 | $this->log( |
272 | 257 | ('' !== getenv('REQUEST_URI') ? ' '.getenv('REQUEST_URI') : ''). |
@@ -293,8 +278,7 @@ discard block |
||
293 | 278 | } |
294 | 279 | } |
295 | 280 | |
296 | - public function emailError($queryString, $error, $line, $file) |
|
297 | - { |
|
281 | + public function emailError($queryString, $error, $line, $file) { |
|
298 | 282 | $email = $this->type." Error<br>\n".'Query: '.$queryString."<br>\n".$error."<br>\n".'Line: '.$line."<br>\n".'File: '.$file."<br>\n".(isset($GLOBALS['tf']) ? 'User: '.$GLOBALS['tf']->session->account_id."<br>\n" : ''); |
299 | 283 | $email .= '<br><br>Request Variables:<br>'.print_r($_REQUEST, true); |
300 | 284 | $email .= '<br><br>Server Variables:<br>'.print_r($_SERVER, true); |
@@ -315,8 +299,7 @@ discard block |
||
315 | 299 | * @param string $file |
316 | 300 | * @return mixed|void |
317 | 301 | */ |
318 | - public function haltmsg($msg, $line = '', $file = '') |
|
319 | - { |
|
302 | + public function haltmsg($msg, $line = '', $file = '') { |
|
320 | 303 | $this->log("Database error: $msg", $line, $file, 'error'); |
321 | 304 | if ($this->Errno != '0' || !in_array($this->Error, ['', '()'])) { |
322 | 305 | $sqlstate = mysqli_sqlstate($this->linkId); |
@@ -328,8 +311,7 @@ discard block |
||
328 | 311 | /** |
329 | 312 | * @return array |
330 | 313 | */ |
331 | - public function indexNames() |
|
332 | - { |
|
314 | + public function indexNames() { |
|
333 | 315 | return []; |
334 | 316 | } |
335 | 317 | } |