CodeIgniter Forums
CIDR Lookup? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: CIDR Lookup? (/thread-26229.html)



CIDR Lookup? - El Forum - 01-08-2010

[eluser]Eric Brown[/eluser]
I'm trying to take a user's X-Forwarded-For header and do an IP lookup from a table of values I have for CIDR ranges. I did a search but did not find anything on this forum.

Has anyone done anything like this with CI? or can you point me to the right forum post if addressed under another topic?

Thanks. I look forward to learning and contributing as I get up to speed with this framework.


CIDR Lookup? - El Forum - 01-10-2010

[eluser]Sean Gates[/eluser]
I did this, but with a third party service. Sorry I'm not much more help.

What specific problem or error are you running into?


CIDR Lookup? - El Forum - 01-10-2010

[eluser]Eric Brown[/eluser]
Thanks for the reply. I haven't really run into a problem. It's the math and technical execution that I am uncertain of.

I have an IP database. What I can't seem to figure out how to do is, convert the user-ip into a value that can be compared against the CIDR block.

By the way, what third party did you use? Did you buy the database and script or do you connect through and API?

Thanks again.


CIDR Lookup? - El Forum - 01-10-2010

[eluser]Sean Gates[/eluser]
We used a 3rd party database and API that did the lookup for us. We were restricting our site based on non-US IP addresses because we were selling music (copyright freaks in the US ban you from selling to foreigners).

I have to go back and find out who it was, but we basically used the PHP code that they supplied to us, and it was as easy as setting up a PHP object to grab the user's IP data.

-- Sean