CFLib.org – Common Function Library Project

long2ip(longip)

Last updated January 9, 2009
Download UDF

author

Troy Pullis Troy Pullis

Version: 0 | Requires: ColdFusion 8 | Library: NetLib

 
Rated 0 time(s). Average Rating: 0

Description:
Generates an (IPv4) Internet Protocol dotted address (aaa.bbb.ccc.ddd) from the proper address representation. Returns 0 if error occurs.

Return Values:
Returns the IP as a string.

Example:

long2ip(3401190660) = 202.186.13.4

Parameters:

Name Description Required
longip Numeric version of IP address. Yes

Full UDF Source:

<cfscript>
/**
* Generates an (IPv4) Internet Protocol dotted address (aaa.bbb.ccc.ddd) from the proper address representation.
*
* @param longip      Numeric version of IP address. (Required)
* @return Returns the IP as a string.
* @author Troy Pullis (tpullis@yahoo.com)
* @version 0, January 9, 2009
*/

function long2ip(longip) {
    var ip = "";
    var i = "";
if (longip
< 0 || longip > 4294967295)
        return 0;
for (i=3;i>
=0;i--) {
ip = ip & int(longip / 256^i);
longip = longip - int(longip / 256^i) * 256^i;
if (i>0)
            ip = ip & ".";
}
return ip;
}
</cfscript>

Search CFLib.org


Latest Additions

Shawn Porter Shawn Porter added
DeMoronize
2 hour(s) ago

Chris Carey Chris Carey added
readPropertiesFi...
1 day(s) ago

Randy Johnson Randy Johnson added
lastDayofWeek
3 day(s) ago

Frank Marion Frank Marion added
sitemapPing
7 day(s) ago

Top Rated

James Sleeman                                     QuickSort
Rated 5.0, 3 time(s)

Barney Boisvert indentXml
Rated 5.0, 3 time(s)

Nathan Dintenfass                                 queryColumnsToSt...
Rated 5.0, 3 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson