Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   How to block IP countries with php? (https://www.warriorforum.com/programming/814584-how-block-ip-countries-php.html)

bbcrew 15th July 2013 01:06 AM

How to block IP countries with php?
 
I try to do following Blocking Website Access by Country with PHP | Azulia Designs but when I check my site with my country ip it still access and error occur because it not found .php in ip_files folder.

So, I want to know other methods that easy and works fine.

Thank you very much.

h4x0r 15th July 2013 06:49 PM

Re: How to block IP countries with php?
 
Well try to find an API, you can find a public one easily that can tell you what country is of IP and then you can write php code to let allow to redirect it somewhere. Google for public api's to get country by IP

Beatinest 18th July 2013 05:06 PM

Re: How to block IP countries with php?
 
I do it via htaccess instead of php. If you can't get the php to work it's an option for you.

skillboyz 18th July 2013 08:58 PM

Re: How to block IP countries with php?
 
You can do it usign htaccess or you should have a IP to country database and then you can restrict using php script

1stranked 19th July 2013 01:56 AM

Re: How to block IP countries with php?
 
Note that if anyone is using proxy it can avoid IP filtering.

sktthemes 19th July 2013 06:20 AM

Re: How to block IP countries with php?
 
You can use xforwarded for header info:

if($_SERVER["HTTP_X_FORWARDED_FOR"] != ""){ $IP = $_SERVER["HTTP_X_FORWARDED_FOR"]; $proxy = $_SERVER["REMOTE_ADDR"]; $host = @gethostbyaddr($_SERVER["HTTP_X_FORWARDED_FOR"]); }else{ $IP = $_SERVER["REMOTE_ADDR"]; $proxy = "No proxy detected"; $host = @gethostbyaddr($_SERVER["REMOTE_ADDR"]); }


All times are GMT -6. The time now is 04:57 AM.