CFLib.org – Common Function Library Project

IP4r(ip4)

Last updated November 18, 2004

Version: 2 | Requires: ColdFusion 5 | Library: NetLib

 
Rated 2 time(s). Average Rating: 2.5

Description:
IP4R Takes a common IP address (like 192.168.0.1) and converts it to it's IP4r equivalent. (in this case, it'd be 1.0.168.192) This is used by mack DNS based black lists, and mail server software to check DNS based black lists.

Return Values:
Returns a string.

Example:

view plain print about
<cfscript>
 variables.ip_to_convert = '192.168.0.1';
 writeoutput("The IP4r of " & variables.ip_to_convert & " is " & ip4r(variables.ip_to_convert));
</cfscript>

Parameters:

Name Description Required
ip4 IP address. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * IP4r converts standard dotted IP addresses to their reversed IP4r equivalent.
 * 
 * @param ip4      IP address. (Required)
 * @return Returns a string. 
 * @author Scott Glassbrook (cflib@vox.phydiux.com) 
 * @version 2, November 18, 2004 
 */

function ip4r(ip4) {
    return ReReplaceNoCase(ip4,  "([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})",  "\4.\3.\2.\1");
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
4 day(s) ago

Will Belden Will Belden added
longTime
9 day(s) ago

James Sleeman James Sleeman added
quickSort
19 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
22 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson