aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrubencm <rubencm@gmail.com>2019-10-30 22:40:01 +0000
committerrubencm <rubencm@gmail.com>2019-11-01 10:30:41 +0000
commit00682db8a625e40f720c513c72267395c4354766 (patch)
treed7b119bb5627d0814a0177070bf12ba15c939f15
parent0a7e98951b27e63fa94d28f4a836f7b55f4b9bd7 (diff)
downloadforums-00682db8a625e40f720c513c72267395c4354766.tar
forums-00682db8a625e40f720c513c72267395c4354766.tar.gz
forums-00682db8a625e40f720c513c72267395c4354766.tar.bz2
forums-00682db8a625e40f720c513c72267395c4354766.tar.xz
forums-00682db8a625e40f720c513c72267395c4354766.zip
[ticket/16189] Make wrappers call native functions
PHPBB3-16189
-rw-r--r--phpBB/includes/functions_compatibility.php116
1 files changed, 2 insertions, 114 deletions
diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php
index 1c9b26d8f3..2578290875 100644
--- a/phpBB/includes/functions_compatibility.php
+++ b/phpBB/includes/functions_compatibility.php
@@ -639,60 +639,7 @@ function phpbb_checkdnsrr($host, $type = 'MX')
*/
function phpbb_inet_ntop($in_addr)
{
- $in_addr = bin2hex($in_addr);
-
- switch (strlen($in_addr))
- {
- case 8:
- return implode('.', array_map('hexdec', str_split($in_addr, 2)));
-
- case 32:
- if (substr($in_addr, 0, 24) === '00000000000000000000ffff')
- {
- return phpbb_inet_ntop(pack('H*', substr($in_addr, 24)));
- }
-
- $parts = str_split($in_addr, 4);
- $parts = preg_replace('/^0+(?!$)/', '', $parts);
- $ret = implode(':', $parts);
-
- $matches = array();
- preg_match_all('/(?<=:|^)(?::?0){2,}/', $ret, $matches, PREG_OFFSET_CAPTURE);
- $matches = $matches[0];
-
- if (empty($matches))
- {
- return $ret;
- }
-
- $longest_match = '';
- $longest_match_offset = 0;
- foreach ($matches as $match)
- {
- if (strlen($match[0]) > strlen($longest_match))
- {
- $longest_match = $match[0];
- $longest_match_offset = $match[1];
- }
- }
-
- $ret = substr_replace($ret, '', $longest_match_offset, strlen($longest_match));
-
- if ($longest_match_offset == strlen($ret))
- {
- $ret .= ':';
- }
-
- if ($longest_match_offset == 0)
- {
- $ret = ':' . $ret;
- }
-
- return $ret;
-
- default:
- return false;
- }
+ return inet_ntop($in_addr);
}
/**
@@ -710,64 +657,5 @@ function phpbb_inet_ntop($in_addr)
*/
function phpbb_inet_pton($address)
{
- $ret = '';
- if (preg_match(get_preg_expression('ipv4'), $address))
- {
- foreach (explode('.', $address) as $part)
- {
- $ret .= ($part <= 0xF ? '0' : '') . dechex($part);
- }
-
- return pack('H*', $ret);
- }
-
- if (preg_match(get_preg_expression('ipv6'), $address))
- {
- $parts = explode(':', $address);
- $missing_parts = 8 - count($parts) + 1;
-
- if (substr($address, 0, 2) === '::')
- {
- ++$missing_parts;
- }
-
- if (substr($address, -2) === '::')
- {
- ++$missing_parts;
- }
-
- $embedded_ipv4 = false;
- $last_part = end($parts);
-
- if (preg_match(get_preg_expression('ipv4'), $last_part))
- {
- $parts[count($parts) - 1] = '';
- $last_part = phpbb_inet_pton($last_part);
- $embedded_ipv4 = true;
- --$missing_parts;
- }
-
- foreach ($parts as $i => $part)
- {
- if (strlen($part))
- {
- $ret .= str_pad($part, 4, '0', STR_PAD_LEFT);
- }
- else if ($i && $i < count($parts) - 1)
- {
- $ret .= str_repeat('0000', $missing_parts);
- }
- }
-
- $ret = pack('H*', $ret);
-
- if ($embedded_ipv4)
- {
- $ret .= $last_part;
- }
-
- return $ret;
- }
-
- return false;
+ return inet_pton($address);
}