| @@ 295-314 (lines=20) @@ | ||
| 292 | //we don't use the native support of mysql > 5.6.2 |
|
| 293 | return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement))); |
|
| 294 | ||
| 295 | case 'array_inet': |
|
| 296 | if (is_array($replacement)) |
|
| 297 | { |
|
| 298 | if (empty($replacement)) |
|
| 299 | smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 300 | ||
| 301 | foreach ($replacement as $key => $value) |
|
| 302 | { |
|
| 303 | if ($replacement == 'null' || $replacement == '') |
|
| 304 | $replacement[$key] = 'null'; |
|
| 305 | if (!isValidIP($value)) |
|
| 306 | smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 307 | $replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value))); |
|
| 308 | } |
|
| 309 | ||
| 310 | return implode(', ', $replacement); |
|
| 311 | } |
|
| 312 | else |
|
| 313 | smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 314 | break; |
|
| 315 | ||
| 316 | default: |
|
| 317 | smf_db_error_backtrace('Undefined type used in the database query. (' . $matches[1] . ':' . $matches[2] . ')', '', false, __FILE__, __LINE__); |
|
| @@ 253-272 (lines=20) @@ | ||
| 250 | smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 251 | return sprintf('\'%1$s\'::inet', pg_escape_string($replacement)); |
|
| 252 | ||
| 253 | case 'array_inet': |
|
| 254 | if (is_array($replacement)) |
|
| 255 | { |
|
| 256 | if (empty($replacement)) |
|
| 257 | smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 258 | ||
| 259 | foreach ($replacement as $key => $value) |
|
| 260 | { |
|
| 261 | if ($replacement == 'null' || $replacement == '') |
|
| 262 | $replacement[$key] = 'null'; |
|
| 263 | if (!isValidIP($value)) |
|
| 264 | smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 265 | $replacement[$key] = sprintf('\'%1$s\'::inet', pg_escape_string($value)); |
|
| 266 | } |
|
| 267 | ||
| 268 | return implode(', ', $replacement); |
|
| 269 | } |
|
| 270 | else |
|
| 271 | smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 272 | break; |
|
| 273 | ||
| 274 | default: |
|
| 275 | smf_db_error_backtrace('Undefined type used in the database query. (' . $matches[1] . ':' . $matches[2] . ')', '', false, __FILE__, __LINE__); |
|