CREATE FUNCTION `ip_encode`(`ip` VARCHAR(25)) RETURNS char(8) CHARSET utf8 NO SQL return concat( conv(SUBSTRING_INDEX( ip , '.', 1 ),10,16 ) , conv(SUBSTRING_INDEX(SUBSTRING_INDEX( ip , '.', 2 ),'.',-1) ,10,16), conv(SUBSTRING_INDEX(SUBSTRING_INDEX( ip , '.', -2 ),'.',1) ,10,16), conv(SUBSTRING_INDEX( ip , '.', -1 ),10,16 )
MYSQL Function to decode ip (HEX to IP)
CREATE FUNCTION `ip_decode`(`session_ip` VARCHAR(25)) RETURNS char(50) CHARSET utf8 DETERMINISTIC RETURN concat_ws('.', CONV(substr(session_ip,1,2),16,10), CONV(substr(session_ip,3,2),16,10), CONV(substr(session_ip,5,2),16,10), CONV(substr(session_ip,7,2),16,10), CONV(substr(session_ip,9,2),16,10))
No comments:
Post a Comment