mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Bugtracker #4069 - improve handling of IPV6 addresses
This commit is contained in:
@@ -11,9 +11,9 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/encrypt_handler.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/encrypt_handler.php,v $
|
||||||
| $Revision: 1.1.1.1 $
|
| $Revision: 1.2 $
|
||||||
| $Date: 2006-12-02 04:33:44 $
|
| $Date: 2007-09-29 17:48:27 $
|
||||||
| $Author: mcfly_e107 $
|
| $Author: e107steved $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -21,12 +21,14 @@ if (!defined('e107_INIT')) { exit; }
|
|||||||
|
|
||||||
function encode_ip($ip)
|
function encode_ip($ip)
|
||||||
{
|
{
|
||||||
|
if (strpos($ip,':') !== FALSE) return $ip; // IPV6 addresses - return unaltered
|
||||||
$ipa = explode('.', $ip);
|
$ipa = explode('.', $ip);
|
||||||
return sprintf('%02x%02x%02x%02x', $ipa[0], $ipa[1], $ipa[2], $ipa[3]);
|
return sprintf('%02x%02x%02x%02x', $ipa[0], $ipa[1], $ipa[2], $ipa[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function decode_ip($encodedIP)
|
function decode_ip($encodedIP)
|
||||||
{
|
{
|
||||||
|
if (strpos($encodedIP,':') !== FALSE) return $encodedIP; // IPV6 addresses - return unaltered
|
||||||
$hexip = explode('.', chunk_split($encodedIP, 2, '.'));
|
$hexip = explode('.', chunk_split($encodedIP, 2, '.'));
|
||||||
return hexdec($hexip[0]). '.' . hexdec($hexip[1]) . '.' . hexdec($hexip[2]) . '.' . hexdec($hexip[3]);
|
return hexdec($hexip[0]). '.' . hexdec($hexip[1]) . '.' . hexdec($hexip[2]) . '.' . hexdec($hexip[3]);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user