IP format GB to IP normal (reverse)

Newbie Spellweaver
Joined
Apr 6, 2006
Messages
10
Reaction score
2
PHP:
<?
function ip_address_to_number($IPaddress)
{
    if ($IPaddress == "") {
        return 0;
    } else {
        $ips = split ("\.", "$IPaddress");
        return ($ips[0] + $ips[1] * 256 + $ips[2] * 256 * 256 + $ips[3] * 256 * 256 * 256);
    }
}

function number_to_ip_adress($IPaddress){

	if ($IPaddress == "") {
        return 0;
    } else {
		$hexip = str_pad(base_convert($IPaddress,10,16),8,'0', STR_PAD_LEFT);
		
        $ip1=base_convert($hexip[6].$hexip[7],16,10);
		$ip3=base_convert($hexip[2].$hexip[3],16,10);
		$ip2=base_convert($hexip[4].$hexip[5],16,10);
		$ip4=base_convert($hexip[0].$hexip[1],16,10);
		
		return ($ip1.'.'.$ip2.'.'.$ip3.'.'.$ip4);
    }

}


if(isset($_GET[IP])){
	echo $_GET[IP];
	echo '<br>';
	echo ip_address_to_number($_GET[IP]);
}

if(isset($_GET[NUM])){
	echo $_GET[NUM];
	echo '<br>';
	echo  number_to_ip_adress($_GET[NUM]);
}
?>
HOW TO USE:
IP to IP GB
asasd.com/myscript.php?IP=123.258.254.214

IP GB to IP
asasd.com/myscript.php?NUM=2147483647

uhmmm i need help to restore my "IPBLOCK" table to ban accounts by IP
and make a script to register with automatic Country

help me please =D
 
Last edited:
Back