<Files index.php>
order allow,deny
deny from 62.93.69.0/24
</Files>
<Files admin.php>
order allow,deny
deny from 188.117.192.0/23
</Files>
RewriteCond %{REQUEST_URI} fileYouWantToProtect
RewriteCond %{REMOTE_ADDR} ^62\.93\.69\.0$
RewriteRule fileYouWantToProtect fileToBeDirectedTo
<?php
include("/path/to/geoip.inc");
//open the database
$GeoIPDatabase = geoip_open("/path/to/GeoIP.dat", GEOIP_STANDARD);
//to get the country code (2 letters)
geoip_country_code_by_addr($GeoIPDatabase, $IP);
//to get the full country name
geoip_country_name_by_addr($GeoIPDatabase, $IP);
//close the database
geoip_close($GeoIPDatabase);
?>
ErrorWell first you need to download the GeoLite Country database in binary format.
this code with a name to saveNext, upload it to your server. Afterward, download the http://geolite.maxmind.com/download/geoip/api/php/geoip.inc file and save it on your server as well.
this code with a name to save and where to set this code to be alone or in any of the pagesFinally, in your application, use the code below (you can modify it):
PHP:<?php include("/path/to/geoip.inc"); //open the database $GeoIPDatabase = geoip_open("/path/to/GeoIP.dat", GEOIP_STANDARD); //to get the country code (2 letters) geoip_country_code_by_addr($GeoIPDatabase, $IP); //to get the full country name geoip_country_name_by_addr($GeoIPDatabase, $IP); //close the database geoip_close($GeoIPDatabase); ?>
Well first you need to download the GeoLite Country database in binary format. Next, upload it to your server. Afterward, download the http://geolite.maxmind.com/download/geoip/api/php/geoip.inc file and save it on your server as well.
Finally, in your application, use the code below (you can modify it):
PHP:<?php include("/path/to/geoip.inc"); //open the database $GeoIPDatabase = geoip_open("/path/to/GeoIP.dat", GEOIP_STANDARD); //to get the country code (2 letters) geoip_country_code_by_addr($GeoIPDatabase, $IP); //to get the full country name geoip_country_name_by_addr($GeoIPDatabase, $IP); //close the database geoip_close($GeoIPDatabase); ?>