Alright, i think this topic has been discussed again and again but i still find some users having hard time time installing GeoIP in their hosts.
No problem guys, you are not alone. At first i installing GeoIP, i feeling so difficult too. but based on my experience from trying in many codes, you can try these codes in your website to block a country or many countries. Im promise with these codes you will be success to block a country even if you use a share host.
Okey i will give you step by step to use this GeoIP.
1. Download : geoip.inc and geoip.dat(search a link Download the latest GeoLite Country Binary Format) from MaxMind
2. Create a new folder “GeoIP“ in your phproxy/website main folder contain geoip.inc and geoip.dat. (Remember geoip.dat not geoip.dat.rar)
3. Copy this code and paste in your index.php, Put this at the top of index.php
<?PHP include('GeoIP/geoip.inc'); //this file must exist in your directory $gi = geoip_open('GeoIP/GeoIP.dat',GEOIP_STANDARD); // get the ip of the visitor $addr = getenv('REMOTE_ADDR'); // translate his ip to a country code $country = geoip_country_code_by_addr($gi, $addr); // close the geo database geoip_close($gi); $badcountry = array('Example','Example','Example','Example'); // You can change the example with any countries that you want to block // redirect them if they suck if(in_array($country, $badcountry)) header('Location: http://www.whateva.com'); //enter a url or page on your site ?>
4. OPTIONAL-IF YOU GET ERROR LIKE THIS
Fatal error: Cannot redeclare geoip_country_code_by_name() in /home/blablabla/public_html/GeoIP/geoip.inc on line 347
OPEN your geoip.inc in your geoip directory and search line 347.
you will find these codes :
function geoip_country_code_by_name($gi, $name) { $country_id = geoip_country_id_by_name($gi,$name); if ($country_id !== false) { return $gi->GEOIP_COUNTRY_CODES[$country_id]; } return false; } function geoip_country_name_by_name($gi, $name) { $country_id = geoip_country_id_by_name($gi,$name); if ($country_id !== false) { return $gi->GEOIP_COUNTRY_NAMES[$country_id]; } return false; }
replace with this codes :
/*
function geoip_country_code_by_name($gi, $name) {
$country_id = geoip_country_id_by_name($gi,$name);
if ($country_id !== false) {
return $gi->GEOIP_COUNTRY_CODES[$country_id];
}
return false;
}
function geoip_country_name_by_name($gi, $name) {
$country_id = geoip_country_id_by_name($gi,$name);
if ($country_id !== false) {
return $gi->GEOIP_COUNTRY_NAMES[$country_id];
}
return false;
}
*/Have done…but remember !!! you may take step 4 if you getting error.
Enjoy with that codes…thanks
PS: This is not my original codes.
Source: http://www.netbuilders.org/ and xrvel.com
RSS feed for comments on this post. TrackBack URL
October 16th, 2009 at 1:46 am (Quote)
nice info mate
thanks for sharing
October 16th, 2009 at 4:12 am (Quote)
wonderfull tips, i will use your tips.
What’s is some country that must be blocked ? Please share it with us
Thanks
October 16th, 2009 at 4:29 am (Quote)
Yeah thanks for read the post too..
hum…its depend with your needs..i will give an example :
if you want to block China you can types CN. if you want block India you can types
IN…(those just an example)
October 16th, 2009 at 6:30 am (Quote)
My next question :
what country that need to block in web proxy business ?
October 16th, 2009 at 8:17 am (Quote)
Sip bro, I will try this.
Nice Thanks
October 18th, 2009 at 10:45 am (Quote)
Ow..you want success in proxies business? Alright i have a friend, his name was Henry El maybe you can talk with him about proxy. He got much dollars from proxies. hehe
If you very interested in this business ill make some post related this post again.
October 21st, 2009 at 12:02 pm (Quote)
October 22nd, 2009 at 8:50 am (Quote)
Hahahaha…alrite bro…ill contact him too about proxy..heheh lol