web development

Some IP Parsing Fun Using ColdFusion

I know some of you have been dying for code (yeah, right) so here's a small function I made for parsing an IP address. I needed the last byte to determine if the machine calling the page was a developer's machine or not.

<cfoutput>
<cfset BegPos = 1>
<cfset EndPos = 1>
<cfset ip = #CGI.REMOTE_ADDR#>
<cfset ByteArray = ArrayNew(1)>

<cfloop index="i" from="1" to="4">
<cfset EndPos = #FIND(".", ip, BegPos)#>
<cfif EndPos GT 0>
<cfset ByteArray[i] =