Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 15th Jul 2013, 01:06 AM   #1
New Warrior Member
 
Join Date: 2008
Location: , , .
Posts: 9
Thanks: 0
Thanked 3 Times in 3 Posts
Default
How to block IP countries with php?
Share on: 
fb share twitter share gplus share more share

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.
bbcrew is offline  
Unread 15th Jul 2013, 06:49 PM   #2
Warrior Member
War Room Member
 
Join Date: 2012
Posts: 16
Thanks: 0
Thanked 3 Times in 3 Posts
Default
Re: How to block IP countries with php?
Share on: 
fb share twitter share gplus share more share

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
h4x0r is offline  
Unread 18th Jul 2013, 05:06 PM   #3
--------------
War Room Member
 
Beatinest's Avatar
 
Join Date: 2012
Posts: 261
Thanks: 33
Thanked 80 Times in 58 Posts
Default
Re: How to block IP countries with php?
Share on: 
fb share twitter share gplus share more share

I do it via htaccess instead of php. If you can't get the php to work it's an option for you.

Beatinest is offline  
Unread 18th Jul 2013, 08:58 PM   #4
Active Warrior
 
skillboyz's Avatar
 
Join Date: 2013
Location: AU
Posts: 57
Thanks: 0
Thanked 1 Time in 1 Post
Default
Re: How to block IP countries with php?
Share on: 
fb share twitter share gplus share more share

You can do it usign htaccess or you should have a IP to country database and then you can restrict using php script
skillboyz is offline  
Unread 19th Jul 2013, 01:56 AM   #5
Active Warrior
 
Join Date: 2011
Posts: 35
Thanks: 1
Thanked 4 Times in 4 Posts
Default
Re: How to block IP countries with php?
Share on: 
fb share twitter share gplus share more share

Note that if anyone is using proxy it can avoid IP filtering.

1stranked is offline  
Unread 19th Jul 2013, 06:20 AM   #6
SKT Wordpress Themes
War Room Member
 
sktthemes's Avatar
 
Join Date: 2013
Location: Nagpur
Posts: 65
Thanks: 5
Thanked 28 Times in 11 Posts
Default
Re: How to block IP countries with php?
Share on: 
fb share twitter share gplus share more share

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"]); }

sktthemes is offline  
Closed Thread


Bookmarks

Tags
block, countries, php


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 07:54 PM.