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…

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.

Good thinking and then just rebuild that array every month to keep the IP database in sync

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.

Hi, sorry i may have not explained it correctly… yes i need to block countries and not individual users / IPs

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?

PHP PECL has a library for this: http://php.net/manual/en/book.geoip.php

Keep in mind, that people can still use proxies…