SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: Blocking A User

  1. #1
    SitePoint Addict
    Join Date
    Sep 2011
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Blocking A User

    Hi,

    I need to block various countries from accessing my site (for reasons i won't go into right now... other than being compliant and meeting regulations with my payment provider... please don't make this the topic).

    I am not sure if it is best / easiest to block all of the my site or just certain page from these countries... anyway, my question is... what is the best way to block specfic countries...

    I have the GEO MaxMind database feeding into my site, however would querying each users IP address against my GEO database pull a lot of resources out of my site... can anyone suggest a better way to achieve this (if there is one...), thanks in advance...

  2. #2
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    681
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Query GEO database ONCE and build an array of blocked IP's. Then compare visitors IP to this array using in_array() and act accordingly.

  3. #3
    SitePoint Addict
    Join Date
    Sep 2011
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good thinking and then just rebuild that array every month to keep the IP database in sync

  4. #4
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    681
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    There seems to be many sites talking about this issue. It might be easier to block a country if that's what your after. Web search for "Block IP from country" brings up lot of results. Never tried it personally but worth looking into.

  5. #5
    SitePoint Addict
    Join Date
    Sep 2011
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, sorry i may have not explained it correctly... yes i need to block countries and not individual users / IPs

  6. #6
    SitePoint Addict
    Join Date
    Sep 2011
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there any site that will allow you to access a site from another country so that you can test your site against blocked countries?

  7. #7
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,178
    Mentioned
    64 Post(s)
    Tagged
    2 Thread(s)
    PHP PECL has a library for this: http://php.net/manual/en/book.geoip.php

    Keep in mind, that people can still use proxies...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •