By siliconvalley1 on
I know I asked a similar question a little while ago but I thought it through more so I'm wondering if anyone knows how you could make a block display only for specific IP address ranges. The idea is that I want to show certain blocks only for people from certain countries to be able to further customize my user experience to their interests.
Comments
=-=
duplicate of: http://drupal.org/node/256960
usually better practice to flesh out the same thread then to create a new one.
_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )
ok thanks
ok well I found this by searching google:
Does anyone know how I could make it display a block for IP addresses pertaining to a specific country ( a range of IP addresses) rather than just one specific one?
You can grab the IP address
You can grab the IP address of the current user with ip_address().
Here's a function someone wrote to check to see if an IP is in a CIDR block:
http://us.php.net/manual/en/ref.network.php#74656
You would just have to figure out what the range(s) of IPs are for a country in CIDR and check for those.
Thanks for the response, I
Thanks for the response, I also just found this, I learned a new term "geotargeting" so now I have a better idea what I'm searching for:
http://drupal.org/node/43183
Pretty cool, it was right
Pretty cool, it was right under my nose I just didn't know to search for "geotargeting" but came across the term on some other site that wasn't about drupal.
"This snippet uses the hostip.info API to determine the geographical location of the visitor. In the code above, I have 2 ad blocks (yahoo and adbrite). Both of them are disabled by default and only their content is being used."
I need that for an IP
I need that for an IP address, not a country, is that possible?
subscribing
subscribing
How do you do this for a
How do you do this for a specific IP range? Did this ever get figured out?
You can use Symfony HttpFoundation for this
If you're not opposed to adding more dependencies to your project, add symfony/http-foundation to your composer.json file, then you can use \Symfony\Component\HttpFoundation\IpUtils::checkIp($addr, $cidr);
Subscribed
Subscribed. This is good info. Thanks