From ac3397c0f5247023fa59c10faab4d872e30afb23 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Mon, 12 Oct 2015 18:27:32 +0200 Subject: [PATCH] refactored utility functions ip2int, int2four, four2int, int2ip --- web/Obj/brisk.phh | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index f221518..29c563c 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -347,16 +347,35 @@ $G_PG_cons_n = 345; function ip2int($s) { - $v = ip2long($s); + return (ip2long($s)); +} + +function int2ip($i) +{ + return (long2ip($i)); +} + +function int2four($l) +{ if (PHP_INT_SIZE == 4) - return ($v); + return ($l); - return ( ($v & 0x80000000 ? 0xffffffff00000000 : 0x00) | $v ); + return ( ($l & 0x80000000 ? 0xffffffff00000000 : 0x00) | $l ); } -function int2ip($i) +function four2int($s) +{ + return ($s & 0xffffffff); +} + +function ip2four($s) +{ + return int2four( ip2int($s) ); +} + +function four2ip($i) { - return long2ip($i & 0xffffffff); + return int2ip( four2int($i) ); } function nickserv_msg($dt, $msg) { -- 2.17.1