![]() |
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. |
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 |
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. |
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 |
Re: How to block IP countries with php? Note that if anyone is using proxy it can avoid IP filtering. |
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. |