function ip2long ( ip_address ) {
var output = false;
if ( ip_address.match ( /^d{1,3}.d{1,3}.d{1,3}.d{1,3}$/ ) ) {
var parts = ip_address.split ( '.' );
var output = 0;
output = ( parts [ 0 ] * Math.pow ( 256, 3 ) ) +
( parts [ 1 ] * Math.pow ( 256, 2 ) ) +
( parts [ 2 ] * Math.pow ( 256, 1 ) ) +
( parts [ 3 ] * Math.pow ( 256, 0 ) );
}
return output<<0;
}
function long2ip ( proper_address ) {
proper_address = proper_address>>>0;
var output = false; //
www.jb200.com
if ( !isNaN ( proper_address ) && ( proper_address >= 0 || proper_address <= 4294967295 ) ) {
output = Math.floor (proper_address / Math.pow ( 256, 3 ) ) + '.' +
Math.floor ( ( proper_address % Math.pow ( 256, 3 ) ) / Math.pow ( 256, 2 ) ) + '.' +
Math.floor ( ( ( proper_address % Math.pow ( 256, 3 ) ) % Math.pow ( 256, 2 ) ) /
Math.pow ( 256, 1 ) ) + '.' +
Math.floor ( ( ( ( proper_address % Math.pow ( 256, 3 ) ) % Math.pow ( 256, 2 ) ) %
Math.pow ( 256, 1 ) ) / Math.pow ( 256, 0 ) );
}
return output;
}