ip block country

vlatkomk

New Member
Messages
11
Reaction score
0
Points
0
Hi
I want to restrict a page where someone comes from abroad to show another page and when the national network to the actual page opens.
I'm not familiar so much for help.
Thank you
 

driveflexfuel

New Member
Messages
159
Reaction score
0
Points
0
The only way to accomplish this is to run a database which converts the IP address into a latitude, longitude and then country. These databases would run you about $1000 and are very large, about 150meg+.
 

vlatkomk

New Member
Messages
11
Reaction score
0
Points
0
Is there a code and how to do that my question was not what takes place
 

driveflexfuel

New Member
Messages
159
Reaction score
0
Points
0
Im guessing what you meant is you have two index pages.

if someone is from your country you want it to display say country_mine.html

and if someone is from another country you want to display country_other.html


There is no way to do this without a sql database. If you had the database it would be a simple 10-15 lines of php.
 
Last edited:

vlatkomk

New Member
Messages
11
Reaction score
0
Points
0
We have such a code, ie . htaccess

example

<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>

I need a code that directs it to the pages
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Code:
RewriteCond %{REQUEST_URI}   fileYouWantToProtect
RewriteCond %{REMOTE_ADDR} ^62\.93\.69\.0$
RewriteRule  fileYouWantToProtect   fileToBeDirectedTo

Or something similar sounds like what you want to do.
The second condition can be adjusted to do ranges of ip's. But then you need a new Condition for each range of ips.
 

vlatkomk

New Member
Messages
11
Reaction score
0
Points
0
Make example code I have placed above it would look like there are set exemplary page

Thank you
 

vlatkomk

New Member
Messages
11
Reaction score
0
Points
0
It is okay but I need code like this will really work.
Above wrote that not understand so much love together to invent something like this did not understand.
Thanks a lot
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
You could also go through the http parameters, but that is a way more complex and unsure method.
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
Actually, I just found a quite interesting product on MaxMind: GeoLite Country. Then you use the Pure PHP API to query the country database.
 
Last edited:

vlatkomk

New Member
Messages
11
Reaction score
0
Points
0
Give some examples why I want to know what to say or where to read

thanks
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
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);

?>
 

vlatkomk

New Member
Messages
11
Reaction score
0
Points
0
Well first you need to download the GeoLite Country database in binary format.
Error
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.
this code with a name to save

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);

?>
this code with a name to save and where to set this code to be alone or in any of the pages

thank you
 
Last edited:

Tariqul Islam

New Member
Messages
182
Reaction score
0
Points
0
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);

?>

Many many thanks to you.
 

vlatkomk

New Member
Messages
11
Reaction score
0
Points
0
Tell how to use this code do not understand why these things.

Thank you
 
Top