@@ -51,34 +51,38 @@ discard block |
||
51 | 51 | $ignored_members = explode(',', $row['pm_ignore_list']); |
52 | 52 | |
53 | 53 | // If the user is in group 1 anywhere, they can see everything anyway. |
54 | - if (in_array(1, $groups) || count(array_intersect($allowed, $groups)) != 0) |
|
55 | - $author = $row['id_member']; |
|
54 | + if (in_array(1, $groups) || count(array_intersect($allowed, $groups)) != 0) { |
|
55 | + $author = $row['id_member']; |
|
56 | + } |
|
56 | 57 | } |
57 | 58 | $smcFunc['db_free_result']($request); |
58 | - } |
|
59 | - else |
|
59 | + } else |
|
60 | 60 | { |
61 | 61 | // This isn't something we know natively how to support. Call the hooks, if they're dealing with it, return false, otherwise return the user id. |
62 | 62 | $hook_results = call_integration_hook('integrate_find_like_author', array($this->_details['content_type'], $this->_details['content_id'])); |
63 | - foreach ($hook_results as $result) |
|
64 | - if (!empty($result)) |
|
63 | + foreach ($hook_results as $result) { |
|
64 | + if (!empty($result)) |
|
65 | 65 | { |
66 | 66 | $author = $result; |
67 | + } |
|
67 | 68 | break; |
68 | 69 | } |
69 | 70 | } |
70 | 71 | |
71 | 72 | // If we didn't have a member... leave. |
72 | - if (empty($author)) |
|
73 | - return true; |
|
73 | + if (empty($author)) { |
|
74 | + return true; |
|
75 | + } |
|
74 | 76 | |
75 | 77 | // If the person who sent the notification is the person whose content it is, do nothing. |
76 | - if ($author == $this->_details['sender_id']) |
|
77 | - return true; |
|
78 | + if ($author == $this->_details['sender_id']) { |
|
79 | + return true; |
|
80 | + } |
|
78 | 81 | |
79 | 82 | // If the person who sent the notification is on this person's ignore list, do nothing. |
80 | - if (!empty($ignored_members) && in_array($this->_details['sender_id'], $ignored_members)) |
|
81 | - return true; |
|
83 | + if (!empty($ignored_members) && in_array($this->_details['sender_id'], $ignored_members)) { |
|
84 | + return true; |
|
85 | + } |
|
82 | 86 | |
83 | 87 | require_once($sourcedir . '/Subs-Notify.php'); |
84 | 88 | $prefs = getNotifyPrefs($author, $this->_details['content_type'] . '_like', true); |
@@ -87,8 +91,9 @@ discard block |
||
87 | 91 | // As a result, the value should really just be non empty. |
88 | 92 | |
89 | 93 | // Check the value. If no value or it's empty, they didn't want alerts, oh well. |
90 | - if (empty($prefs[$author][$this->_details['content_type'] . '_like'])) |
|
91 | - return true; |
|
94 | + if (empty($prefs[$author][$this->_details['content_type'] . '_like'])) { |
|
95 | + return true; |
|
96 | + } |
|
92 | 97 | |
93 | 98 | // Don't spam the alerts: if there is an existing unread alert of the |
94 | 99 | // requested type for the target user from the sender, don't make a new one. |
@@ -108,8 +113,9 @@ discard block |
||
108 | 113 | ) |
109 | 114 | ); |
110 | 115 | |
111 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
112 | - return true; |
|
116 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
117 | + return true; |
|
118 | + } |
|
113 | 119 | $smcFunc['db_free_result']($request); |
114 | 120 | |
115 | 121 | // Issue, update, move on. |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Maps the implementations in this file (smf_db_function_name) |
@@ -33,8 +34,8 @@ discard block |
||
33 | 34 | global $smcFunc; |
34 | 35 | |
35 | 36 | // Map some database specific functions, only do this once. |
36 | - if (!isset($smcFunc['db_fetch_assoc'])) |
|
37 | - $smcFunc += array( |
|
37 | + if (!isset($smcFunc['db_fetch_assoc'])) { |
|
38 | + $smcFunc += array( |
|
38 | 39 | 'db_query' => 'smf_db_query', |
39 | 40 | 'db_quote' => 'smf_db_quote', |
40 | 41 | 'db_fetch_assoc' => 'mysqli_fetch_assoc', |
@@ -63,9 +64,11 @@ discard block |
||
63 | 64 | 'db_error_insert' => 'smf_db_error_insert', |
64 | 65 | 'db_custom_order' => 'smf_db_custom_order', |
65 | 66 | ); |
67 | + } |
|
66 | 68 | |
67 | - if (!empty($db_options['persist'])) |
|
68 | - $db_server = 'p:' . $db_server; |
|
69 | + if (!empty($db_options['persist'])) { |
|
70 | + $db_server = 'p:' . $db_server; |
|
71 | + } |
|
69 | 72 | |
70 | 73 | $connection = mysqli_init(); |
71 | 74 | |
@@ -75,24 +78,27 @@ discard block |
||
75 | 78 | |
76 | 79 | if ($connection) |
77 | 80 | { |
78 | - if (!empty($db_options['port'])) |
|
79 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, null, $db_options['port'], null, $flags); |
|
80 | - else |
|
81 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, null, 0, null, $flags); |
|
81 | + if (!empty($db_options['port'])) { |
|
82 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, null, $db_options['port'], null, $flags); |
|
83 | + } else { |
|
84 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, null, 0, null, $flags); |
|
85 | + } |
|
82 | 86 | } |
83 | 87 | |
84 | 88 | // Something's wrong, show an error if its fatal (which we assume it is) |
85 | 89 | if ($success === false) |
86 | 90 | { |
87 | - if (!empty($db_options['non_fatal'])) |
|
88 | - return null; |
|
89 | - else |
|
90 | - display_db_error(); |
|
91 | + if (!empty($db_options['non_fatal'])) { |
|
92 | + return null; |
|
93 | + } else { |
|
94 | + display_db_error(); |
|
95 | + } |
|
91 | 96 | } |
92 | 97 | |
93 | 98 | // Select the database, unless told not to |
94 | - if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) |
|
95 | - display_db_error(); |
|
99 | + if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) { |
|
100 | + display_db_error(); |
|
101 | + } |
|
96 | 102 | |
97 | 103 | mysqli_query($connection, 'SET SESSION sql_mode = \'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\''); |
98 | 104 | |
@@ -165,34 +171,42 @@ discard block |
||
165 | 171 | global $db_callback, $user_info, $db_prefix, $smcFunc; |
166 | 172 | |
167 | 173 | list ($values, $connection) = $db_callback; |
168 | - if (!is_object($connection)) |
|
169 | - display_db_error(); |
|
174 | + if (!is_object($connection)) { |
|
175 | + display_db_error(); |
|
176 | + } |
|
170 | 177 | |
171 | - if ($matches[1] === 'db_prefix') |
|
172 | - return $db_prefix; |
|
178 | + if ($matches[1] === 'db_prefix') { |
|
179 | + return $db_prefix; |
|
180 | + } |
|
173 | 181 | |
174 | - if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) |
|
175 | - return $user_info[$matches[1]]; |
|
182 | + if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) { |
|
183 | + return $user_info[$matches[1]]; |
|
184 | + } |
|
176 | 185 | |
177 | - if ($matches[1] === 'empty') |
|
178 | - return '\'\''; |
|
186 | + if ($matches[1] === 'empty') { |
|
187 | + return '\'\''; |
|
188 | + } |
|
179 | 189 | |
180 | - if (!isset($matches[2])) |
|
181 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
190 | + if (!isset($matches[2])) { |
|
191 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
192 | + } |
|
182 | 193 | |
183 | - if ($matches[1] === 'literal') |
|
184 | - return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
194 | + if ($matches[1] === 'literal') { |
|
195 | + return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
196 | + } |
|
185 | 197 | |
186 | - if (!isset($values[$matches[2]])) |
|
187 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
198 | + if (!isset($values[$matches[2]])) { |
|
199 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
200 | + } |
|
188 | 201 | |
189 | 202 | $replacement = $values[$matches[2]]; |
190 | 203 | |
191 | 204 | switch ($matches[1]) |
192 | 205 | { |
193 | 206 | case 'int': |
194 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
195 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
207 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
208 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
209 | + } |
|
196 | 210 | return (string) (int) $replacement; |
197 | 211 | break; |
198 | 212 | |
@@ -204,65 +218,73 @@ discard block |
||
204 | 218 | case 'array_int': |
205 | 219 | if (is_array($replacement)) |
206 | 220 | { |
207 | - if (empty($replacement)) |
|
208 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
221 | + if (empty($replacement)) { |
|
222 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
223 | + } |
|
209 | 224 | |
210 | 225 | foreach ($replacement as $key => $value) |
211 | 226 | { |
212 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
213 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
227 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
228 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
229 | + } |
|
214 | 230 | |
215 | 231 | $replacement[$key] = (string) (int) $value; |
216 | 232 | } |
217 | 233 | |
218 | 234 | return implode(', ', $replacement); |
235 | + } else { |
|
236 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
219 | 237 | } |
220 | - else |
|
221 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
222 | 238 | |
223 | 239 | break; |
224 | 240 | |
225 | 241 | case 'array_string': |
226 | 242 | if (is_array($replacement)) |
227 | 243 | { |
228 | - if (empty($replacement)) |
|
229 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
244 | + if (empty($replacement)) { |
|
245 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
246 | + } |
|
230 | 247 | |
231 | - foreach ($replacement as $key => $value) |
|
232 | - $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
248 | + foreach ($replacement as $key => $value) { |
|
249 | + $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
250 | + } |
|
233 | 251 | |
234 | 252 | return implode(', ', $replacement); |
253 | + } else { |
|
254 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
235 | 255 | } |
236 | - else |
|
237 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
238 | 256 | break; |
239 | 257 | |
240 | 258 | case 'date': |
241 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
242 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
243 | - else |
|
244 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
259 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
260 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
261 | + } else { |
|
262 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
263 | + } |
|
245 | 264 | break; |
246 | 265 | |
247 | 266 | case 'time': |
248 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
249 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
250 | - else |
|
251 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
267 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
268 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
269 | + } else { |
|
270 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
271 | + } |
|
252 | 272 | break; |
253 | 273 | |
254 | 274 | case 'datetime': |
255 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
|
256 | - return 'str_to_date('. |
|
275 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) { |
|
276 | + return 'str_to_date('. |
|
257 | 277 | sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
258 | 278 | ',\'%Y-%m-%d %h:%i:%s\')'; |
259 | - else |
|
260 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
279 | + } else { |
|
280 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
281 | + } |
|
261 | 282 | break; |
262 | 283 | |
263 | 284 | case 'float': |
264 | - if (!is_numeric($replacement)) |
|
265 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
285 | + if (!is_numeric($replacement)) { |
|
286 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
287 | + } |
|
266 | 288 | return (string) (float) $replacement; |
267 | 289 | break; |
268 | 290 | |
@@ -276,32 +298,37 @@ discard block |
||
276 | 298 | break; |
277 | 299 | |
278 | 300 | case 'inet': |
279 | - if ($replacement == 'null' || $replacement == '') |
|
280 | - return 'null'; |
|
281 | - if (!isValidIP($replacement)) |
|
282 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
301 | + if ($replacement == 'null' || $replacement == '') { |
|
302 | + return 'null'; |
|
303 | + } |
|
304 | + if (!isValidIP($replacement)) { |
|
305 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
306 | + } |
|
283 | 307 | //we don't use the native support of mysql > 5.6.2 |
284 | 308 | return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement))); |
285 | 309 | |
286 | 310 | case 'array_inet': |
287 | 311 | if (is_array($replacement)) |
288 | 312 | { |
289 | - if (empty($replacement)) |
|
290 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
313 | + if (empty($replacement)) { |
|
314 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
315 | + } |
|
291 | 316 | |
292 | 317 | foreach ($replacement as $key => $value) |
293 | 318 | { |
294 | - if ($replacement == 'null' || $replacement == '') |
|
295 | - $replacement[$key] = 'null'; |
|
296 | - if (!isValidIP($value)) |
|
297 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
319 | + if ($replacement == 'null' || $replacement == '') { |
|
320 | + $replacement[$key] = 'null'; |
|
321 | + } |
|
322 | + if (!isValidIP($value)) { |
|
323 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
324 | + } |
|
298 | 325 | $replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value))); |
299 | 326 | } |
300 | 327 | |
301 | 328 | return implode(', ', $replacement); |
329 | + } else { |
|
330 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
302 | 331 | } |
303 | - else |
|
304 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
305 | 332 | break; |
306 | 333 | |
307 | 334 | default: |
@@ -372,18 +399,20 @@ discard block |
||
372 | 399 | // One more query.... |
373 | 400 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
374 | 401 | |
375 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
376 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
402 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
403 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
404 | + } |
|
377 | 405 | |
378 | 406 | // Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By |
379 | 407 | if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string)) |
380 | 408 | { |
381 | 409 | // Add before LIMIT |
382 | - if ($pos = strpos($db_string, 'LIMIT ')) |
|
383 | - $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
384 | - else |
|
385 | - // Append it. |
|
410 | + if ($pos = strpos($db_string, 'LIMIT ')) { |
|
411 | + $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
412 | + } else { |
|
413 | + // Append it. |
|
386 | 414 | $db_string .= "\n\t\t\tORDER BY null"; |
415 | + } |
|
387 | 416 | } |
388 | 417 | |
389 | 418 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
@@ -409,17 +438,18 @@ discard block |
||
409 | 438 | while (true) |
410 | 439 | { |
411 | 440 | $pos = strpos($db_string_1, '\'', $pos + 1); |
412 | - if ($pos === false) |
|
413 | - break; |
|
441 | + if ($pos === false) { |
|
442 | + break; |
|
443 | + } |
|
414 | 444 | $clean .= substr($db_string_1, $old_pos, $pos - $old_pos); |
415 | 445 | |
416 | 446 | while (true) |
417 | 447 | { |
418 | 448 | $pos1 = strpos($db_string_1, '\'', $pos + 1); |
419 | 449 | $pos2 = strpos($db_string_1, '\\', $pos + 1); |
420 | - if ($pos1 === false) |
|
421 | - break; |
|
422 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
450 | + if ($pos1 === false) { |
|
451 | + break; |
|
452 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
423 | 453 | { |
424 | 454 | $pos = $pos1; |
425 | 455 | break; |
@@ -435,16 +465,19 @@ discard block |
||
435 | 465 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
436 | 466 | |
437 | 467 | // Comments? We don't use comments in our queries, we leave 'em outside! |
438 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
439 | - $fail = true; |
|
468 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
469 | + $fail = true; |
|
470 | + } |
|
440 | 471 | // Trying to change passwords, slow us down, or something? |
441 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
442 | - $fail = true; |
|
443 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
444 | - $fail = true; |
|
472 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
473 | + $fail = true; |
|
474 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
475 | + $fail = true; |
|
476 | + } |
|
445 | 477 | |
446 | - if (!empty($fail) && function_exists('log_error')) |
|
447 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
478 | + if (!empty($fail) && function_exists('log_error')) { |
|
479 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
480 | + } |
|
448 | 481 | } |
449 | 482 | |
450 | 483 | // Debugging. |
@@ -454,8 +487,9 @@ discard block |
||
454 | 487 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
455 | 488 | |
456 | 489 | // Initialize $db_cache if not already initialized. |
457 | - if (!isset($db_cache)) |
|
458 | - $db_cache = array(); |
|
490 | + if (!isset($db_cache)) { |
|
491 | + $db_cache = array(); |
|
492 | + } |
|
459 | 493 | |
460 | 494 | if (!empty($_SESSION['debug_redirect'])) |
461 | 495 | { |
@@ -471,17 +505,20 @@ discard block |
||
471 | 505 | $db_cache[$db_count]['s'] = ($st = microtime(true)) - $time_start; |
472 | 506 | } |
473 | 507 | |
474 | - if (empty($db_unbuffered)) |
|
475 | - $ret = @mysqli_query($connection, $db_string); |
|
476 | - else |
|
477 | - $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
508 | + if (empty($db_unbuffered)) { |
|
509 | + $ret = @mysqli_query($connection, $db_string); |
|
510 | + } else { |
|
511 | + $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
512 | + } |
|
478 | 513 | |
479 | - if ($ret === false && empty($db_values['db_error_skip'])) |
|
480 | - $ret = smf_db_error($db_string, $connection); |
|
514 | + if ($ret === false && empty($db_values['db_error_skip'])) { |
|
515 | + $ret = smf_db_error($db_string, $connection); |
|
516 | + } |
|
481 | 517 | |
482 | 518 | // Debugging. |
483 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
484 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
519 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
520 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
521 | + } |
|
485 | 522 | |
486 | 523 | return $ret; |
487 | 524 | } |
@@ -528,12 +565,13 @@ discard block |
||
528 | 565 | // Decide which connection to use |
529 | 566 | $connection = $connection === null ? $db_connection : $connection; |
530 | 567 | |
531 | - if ($type == 'begin') |
|
532 | - return @mysqli_query($connection, 'BEGIN'); |
|
533 | - elseif ($type == 'rollback') |
|
534 | - return @mysqli_query($connection, 'ROLLBACK'); |
|
535 | - elseif ($type == 'commit') |
|
536 | - return @mysqli_query($connection, 'COMMIT'); |
|
568 | + if ($type == 'begin') { |
|
569 | + return @mysqli_query($connection, 'BEGIN'); |
|
570 | + } elseif ($type == 'rollback') { |
|
571 | + return @mysqli_query($connection, 'ROLLBACK'); |
|
572 | + } elseif ($type == 'commit') { |
|
573 | + return @mysqli_query($connection, 'COMMIT'); |
|
574 | + } |
|
537 | 575 | |
538 | 576 | return false; |
539 | 577 | } |
@@ -571,8 +609,9 @@ discard block |
||
571 | 609 | // 1213: Deadlock found. |
572 | 610 | |
573 | 611 | // Log the error. |
574 | - if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) |
|
575 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
612 | + if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) { |
|
613 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
614 | + } |
|
576 | 615 | |
577 | 616 | // Database error auto fixing ;). |
578 | 617 | if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1')) |
@@ -581,8 +620,9 @@ discard block |
||
581 | 620 | $old_cache = @$modSettings['cache_enable']; |
582 | 621 | $modSettings['cache_enable'] = '1'; |
583 | 622 | |
584 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
585 | - $db_last_error = max(@$db_last_error, $temp); |
|
623 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
624 | + $db_last_error = max(@$db_last_error, $temp); |
|
625 | + } |
|
586 | 626 | |
587 | 627 | if (@$db_last_error < time() - 3600 * 24 * 3) |
588 | 628 | { |
@@ -598,8 +638,9 @@ discard block |
||
598 | 638 | foreach ($tables as $table) |
599 | 639 | { |
600 | 640 | // Now, it's still theoretically possible this could be an injection. So backtick it! |
601 | - if (trim($table) != '') |
|
602 | - $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
641 | + if (trim($table) != '') { |
|
642 | + $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
643 | + } |
|
603 | 644 | } |
604 | 645 | } |
605 | 646 | |
@@ -608,8 +649,9 @@ discard block |
||
608 | 649 | // Table crashed. Let's try to fix it. |
609 | 650 | elseif ($query_errno == 1016) |
610 | 651 | { |
611 | - if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) |
|
612 | - $fix_tables = array('`' . $match[1] . '`'); |
|
652 | + if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) { |
|
653 | + $fix_tables = array('`' . $match[1] . '`'); |
|
654 | + } |
|
613 | 655 | } |
614 | 656 | // Indexes crashed. Should be easy to fix! |
615 | 657 | elseif ($query_errno == 1034 || $query_errno == 1035) |
@@ -628,13 +670,15 @@ discard block |
||
628 | 670 | |
629 | 671 | // Make a note of the REPAIR... |
630 | 672 | cache_put_data('db_last_error', time(), 600); |
631 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
632 | - updateSettingsFile(array('db_last_error' => time())); |
|
673 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
674 | + updateSettingsFile(array('db_last_error' => time())); |
|
675 | + } |
|
633 | 676 | |
634 | 677 | // Attempt to find and repair the broken table. |
635 | - foreach ($fix_tables as $table) |
|
636 | - $smcFunc['db_query']('', " |
|
678 | + foreach ($fix_tables as $table) { |
|
679 | + $smcFunc['db_query']('', " |
|
637 | 680 | REPAIR TABLE $table", false, false); |
681 | + } |
|
638 | 682 | |
639 | 683 | // And send off an email! |
640 | 684 | sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror'); |
@@ -643,11 +687,12 @@ discard block |
||
643 | 687 | |
644 | 688 | // Try the query again...? |
645 | 689 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
646 | - if ($ret !== false) |
|
647 | - return $ret; |
|
690 | + if ($ret !== false) { |
|
691 | + return $ret; |
|
692 | + } |
|
693 | + } else { |
|
694 | + $modSettings['cache_enable'] = $old_cache; |
|
648 | 695 | } |
649 | - else |
|
650 | - $modSettings['cache_enable'] = $old_cache; |
|
651 | 696 | |
652 | 697 | // Check for the "lost connection" or "deadlock found" errors - and try it just one more time. |
653 | 698 | if (in_array($query_errno, array(1205, 1213))) |
@@ -660,24 +705,27 @@ discard block |
||
660 | 705 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
661 | 706 | |
662 | 707 | $new_errno = mysqli_errno($db_connection); |
663 | - if ($ret !== false || in_array($new_errno, array(1205, 1213))) |
|
664 | - break; |
|
708 | + if ($ret !== false || in_array($new_errno, array(1205, 1213))) { |
|
709 | + break; |
|
710 | + } |
|
665 | 711 | } |
666 | 712 | |
667 | 713 | // If it failed again, shucks to be you... we're not trying it over and over. |
668 | - if ($ret !== false) |
|
669 | - return $ret; |
|
714 | + if ($ret !== false) { |
|
715 | + return $ret; |
|
716 | + } |
|
670 | 717 | } |
671 | 718 | } |
672 | 719 | // Are they out of space, perhaps? |
673 | 720 | elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false)) |
674 | 721 | { |
675 | - if (!isset($txt)) |
|
676 | - $query_error .= ' - check database storage space.'; |
|
677 | - else |
|
722 | + if (!isset($txt)) { |
|
723 | + $query_error .= ' - check database storage space.'; |
|
724 | + } else |
|
678 | 725 | { |
679 | - if (!isset($txt['mysql_error_space'])) |
|
680 | - loadLanguage('Errors'); |
|
726 | + if (!isset($txt['mysql_error_space'])) { |
|
727 | + loadLanguage('Errors'); |
|
728 | + } |
|
681 | 729 | |
682 | 730 | $query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space']; |
683 | 731 | } |
@@ -685,15 +733,17 @@ discard block |
||
685 | 733 | } |
686 | 734 | |
687 | 735 | // Nothing's defined yet... just die with it. |
688 | - if (empty($context) || empty($txt)) |
|
689 | - die($query_error); |
|
736 | + if (empty($context) || empty($txt)) { |
|
737 | + die($query_error); |
|
738 | + } |
|
690 | 739 | |
691 | 740 | // Show an error message, if possible. |
692 | 741 | $context['error_title'] = $txt['database_error']; |
693 | - if (allowedTo('admin_forum')) |
|
694 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
695 | - else |
|
696 | - $context['error_message'] = $txt['try_again']; |
|
742 | + if (allowedTo('admin_forum')) { |
|
743 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
744 | + } else { |
|
745 | + $context['error_message'] = $txt['try_again']; |
|
746 | + } |
|
697 | 747 | |
698 | 748 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
699 | 749 | { |
@@ -725,8 +775,9 @@ discard block |
||
725 | 775 | $return_var = null; |
726 | 776 | |
727 | 777 | // With nothing to insert, simply return. |
728 | - if (empty($data)) |
|
729 | - return; |
|
778 | + if (empty($data)) { |
|
779 | + return; |
|
780 | + } |
|
730 | 781 | |
731 | 782 | // Replace the prefix holder with the actual prefix. |
732 | 783 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -736,23 +787,26 @@ discard block |
||
736 | 787 | if (!empty($keys) && (count($keys) > 0) && $returnmode > 0) |
737 | 788 | { |
738 | 789 | $with_returning = true; |
739 | - if ($returnmode == 2) |
|
740 | - $return_var = array(); |
|
790 | + if ($returnmode == 2) { |
|
791 | + $return_var = array(); |
|
792 | + } |
|
741 | 793 | } |
742 | 794 | |
743 | 795 | // Inserting data as a single row can be done as a single array. |
744 | - if (!is_array($data[array_rand($data)])) |
|
745 | - $data = array($data); |
|
796 | + if (!is_array($data[array_rand($data)])) { |
|
797 | + $data = array($data); |
|
798 | + } |
|
746 | 799 | |
747 | 800 | // Create the mold for a single row insert. |
748 | 801 | $insertData = '('; |
749 | 802 | foreach ($columns as $columnName => $type) |
750 | 803 | { |
751 | 804 | // Are we restricting the length? |
752 | - if (strpos($type, 'string-') !== false) |
|
753 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
754 | - else |
|
755 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
805 | + if (strpos($type, 'string-') !== false) { |
|
806 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
807 | + } else { |
|
808 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
809 | + } |
|
756 | 810 | } |
757 | 811 | $insertData = substr($insertData, 0, -2) . ')'; |
758 | 812 | |
@@ -761,8 +815,9 @@ discard block |
||
761 | 815 | |
762 | 816 | // Here's where the variables are injected to the query. |
763 | 817 | $insertRows = array(); |
764 | - foreach ($data as $dataRow) |
|
765 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
818 | + foreach ($data as $dataRow) { |
|
819 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
820 | + } |
|
766 | 821 | |
767 | 822 | // Determine the method of insertion. |
768 | 823 | $queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT'); |
@@ -781,8 +836,7 @@ discard block |
||
781 | 836 | ), |
782 | 837 | $connection |
783 | 838 | ); |
784 | - } |
|
785 | - else //special way for ignore method with returning |
|
839 | + } else //special way for ignore method with returning |
|
786 | 840 | { |
787 | 841 | $count = count($insertRows); |
788 | 842 | $ai = 0; |
@@ -802,19 +856,21 @@ discard block |
||
802 | 856 | ); |
803 | 857 | $new_id = $smcFunc['db_insert_id'](); |
804 | 858 | |
805 | - if ($last_id != $new_id) //the inserted value was new |
|
859 | + if ($last_id != $new_id) { |
|
860 | + //the inserted value was new |
|
806 | 861 | { |
807 | 862 | $ai = $new_id; |
808 | 863 | } |
809 | - else // the inserted value already exists we need to find the pk |
|
864 | + } else // the inserted value already exists we need to find the pk |
|
810 | 865 | { |
811 | 866 | $where_string = ''; |
812 | 867 | $count2 = count($indexed_columns); |
813 | 868 | for ($x = 0; $x < $count2; $x++) |
814 | 869 | { |
815 | 870 | $where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x]; |
816 | - if (($x + 1) < $count2) |
|
817 | - $where_string += ' AND '; |
|
871 | + if (($x + 1) < $count2) { |
|
872 | + $where_string += ' AND '; |
|
873 | + } |
|
818 | 874 | } |
819 | 875 | |
820 | 876 | $request = $smcFunc['db_query']('',' |
@@ -830,25 +886,27 @@ discard block |
||
830 | 886 | } |
831 | 887 | } |
832 | 888 | |
833 | - if ($returnmode == 1) |
|
834 | - $return_var = $ai; |
|
835 | - else if ($returnmode == 2) |
|
836 | - $return_var[] = $ai; |
|
889 | + if ($returnmode == 1) { |
|
890 | + $return_var = $ai; |
|
891 | + } else if ($returnmode == 2) { |
|
892 | + $return_var[] = $ai; |
|
893 | + } |
|
837 | 894 | } |
838 | 895 | } |
839 | 896 | |
840 | 897 | |
841 | 898 | if ($with_returning) |
842 | 899 | { |
843 | - if ($returnmode == 1 && empty($return_var)) |
|
844 | - $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
845 | - else if ($returnmode == 2 && empty($return_var)) |
|
900 | + if ($returnmode == 1 && empty($return_var)) { |
|
901 | + $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
902 | + } else if ($returnmode == 2 && empty($return_var)) |
|
846 | 903 | { |
847 | 904 | $return_var = array(); |
848 | 905 | $count = count($insertRows); |
849 | 906 | $start = smf_db_insert_id($table, $keys[0]); |
850 | - for ($i = 0; $i < $count; $i++ ) |
|
851 | - $return_var[] = $start + $i; |
|
907 | + for ($i = 0; $i < $count; $i++ ) { |
|
908 | + $return_var[] = $start + $i; |
|
909 | + } |
|
852 | 910 | } |
853 | 911 | return $return_var; |
854 | 912 | } |
@@ -866,8 +924,9 @@ discard block |
||
866 | 924 | */ |
867 | 925 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
868 | 926 | { |
869 | - if (empty($log_message)) |
|
870 | - $log_message = $error_message; |
|
927 | + if (empty($log_message)) { |
|
928 | + $log_message = $error_message; |
|
929 | + } |
|
871 | 930 | |
872 | 931 | foreach (debug_backtrace() as $step) |
873 | 932 | { |
@@ -886,12 +945,14 @@ discard block |
||
886 | 945 | } |
887 | 946 | |
888 | 947 | // A special case - we want the file and line numbers for debugging. |
889 | - if ($error_type == 'return') |
|
890 | - return array($file, $line); |
|
948 | + if ($error_type == 'return') { |
|
949 | + return array($file, $line); |
|
950 | + } |
|
891 | 951 | |
892 | 952 | // Is always a critical error. |
893 | - if (function_exists('log_error')) |
|
894 | - log_error($log_message, 'critical', $file, $line); |
|
953 | + if (function_exists('log_error')) { |
|
954 | + log_error($log_message, 'critical', $file, $line); |
|
955 | + } |
|
895 | 956 | |
896 | 957 | if (function_exists('fatal_error')) |
897 | 958 | { |
@@ -899,12 +960,12 @@ discard block |
||
899 | 960 | |
900 | 961 | // Cannot continue... |
901 | 962 | exit; |
963 | + } elseif ($error_type) { |
|
964 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
965 | + } else { |
|
966 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
967 | + } |
|
902 | 968 | } |
903 | - elseif ($error_type) |
|
904 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
905 | - else |
|
906 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
907 | -} |
|
908 | 969 | |
909 | 970 | /** |
910 | 971 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -921,10 +982,11 @@ discard block |
||
921 | 982 | '\\' => '\\\\', |
922 | 983 | ); |
923 | 984 | |
924 | - if ($translate_human_wildcards) |
|
925 | - $replacements += array( |
|
985 | + if ($translate_human_wildcards) { |
|
986 | + $replacements += array( |
|
926 | 987 | '*' => '%', |
927 | 988 | ); |
989 | + } |
|
928 | 990 | |
929 | 991 | return strtr($string, $replacements); |
930 | 992 | } |
@@ -938,8 +1000,9 @@ discard block |
||
938 | 1000 | */ |
939 | 1001 | function smf_is_resource($result) |
940 | 1002 | { |
941 | - if ($result instanceof mysqli_result) |
|
942 | - return true; |
|
1003 | + if ($result instanceof mysqli_result) { |
|
1004 | + return true; |
|
1005 | + } |
|
943 | 1006 | |
944 | 1007 | return false; |
945 | 1008 | } |
@@ -968,19 +1031,22 @@ discard block |
||
968 | 1031 | static $mysql_error_data_prep; |
969 | 1032 | |
970 | 1033 | // without database we can't do anything |
971 | - if (empty($db_connection)) |
|
972 | - return; |
|
1034 | + if (empty($db_connection)) { |
|
1035 | + return; |
|
1036 | + } |
|
973 | 1037 | |
974 | - if (empty($mysql_error_data_prep)) |
|
975 | - $mysql_error_data_prep = mysqli_prepare($db_connection, |
|
1038 | + if (empty($mysql_error_data_prep)) { |
|
1039 | + $mysql_error_data_prep = mysqli_prepare($db_connection, |
|
976 | 1040 | 'INSERT INTO ' . $db_prefix . 'log_errors(id_member, log_time, ip, url, message, session, error_type, file, line) |
977 | 1041 | VALUES( ?, ?, unhex(?), ?, ?, ?, ?, ?, ?)' |
978 | 1042 | ); |
1043 | + } |
|
979 | 1044 | |
980 | - if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false) |
|
981 | - $error_array[2] = bin2hex(inet_pton($error_array[2])); |
|
982 | - else |
|
983 | - $error_array[2] = null; |
|
1045 | + if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false) { |
|
1046 | + $error_array[2] = bin2hex(inet_pton($error_array[2])); |
|
1047 | + } else { |
|
1048 | + $error_array[2] = null; |
|
1049 | + } |
|
984 | 1050 | mysqli_stmt_bind_param($mysql_error_data_prep, 'iissssssi', |
985 | 1051 | $error_array[0], $error_array[1], $error_array[2], $error_array[3], $error_array[4], $error_array[5], $error_array[6], |
986 | 1052 | $error_array[7], $error_array[8]); |
@@ -1002,8 +1068,9 @@ discard block |
||
1002 | 1068 | $count = count($array_values); |
1003 | 1069 | $then = ($desc ? ' THEN -' : ' THEN '); |
1004 | 1070 | |
1005 | - for ($i = 0; $i < $count; $i++) |
|
1006 | - $return .= 'WHEN ' . (int) $array_values[$i] . $then . $i . ' '; |
|
1071 | + for ($i = 0; $i < $count; $i++) { |
|
1072 | + $return .= 'WHEN ' . (int) $array_values[$i] . $then . $i . ' '; |
|
1073 | + } |
|
1007 | 1074 | |
1008 | 1075 | $return .= 'END'; |
1009 | 1076 | return $return; |