Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Country Detection

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #44303
    nosecreek
    Member

    I’m finding I get a lot of email and telephone spam from Indian businesses that want me to outsource to them. I don’t want to totally block anyone in India from seeing my site, but since I primarily cater to local businesses, I thought it might make sense to not show my phone number and email address to visitors from India. Can anyone suggest how this might be done using PHP? Most examples I can find through Google rely on third party APIs, which I don’t want to do as it could impact page load times. Is there a database of IPs for each country I could find somewhere and then check each user’s IP against that list?

    #132762
    CrocoDillon
    Participant

    I’m not familiar with IP lookups but you could go for the accepted languages header. Not bulletproof though, just a brainfart:

    $request = getallheaders();
    if (preg_match(‘/hi-IN/’, $request)) { … }

    #132769
    nosecreek
    Member

    Thanks for the idea. Unfortunately, google analytics tells me that they have their language set as english.

    #132772
    nosecreek
    Member

    Looks like I found my solution here: http://dev.maxmind.com/geoip/geolite

    They have a simple PHP api and a downloadable database of ip addresses for every city/country. Now to see if this helps cut down the spam, or if they are all hiding behind proxies.

    **Update (almost two weeks later)**: So far so good. Haven’t received any emails (except for via my contact form which is expected) or phone calls from anyone wanting me to outsource in the last couple of weeks. I hope it lasts.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.