Jump to content

[SOLVED] GeoIP redirection script.


liberty

Recommended Posts

I need some help with my GeoIP script. BTw! I couldn't get into this site for some reason. It said I was banned :'(

 

<?php
include('geo_ip/geoip.inc');
$gi = geoip_open('geo_ip/geoip.dat',GEOIP_STANDARD);
$addr = getenv('REMOTE_ADDR');
$country = geoip_country_name_by_addr($gi, $addr);
geoip_close($gi);
$ifgerman = array('Germany','Austria','Liechtenstein','Switzerland','Luxembourg');
if(in_array($country, $ifgerman))
header('Location: /de/')
?>

okay basically I want to make some if statements that checks for each country regions.

So First I'm checking there German (or german speaking) this redirect them to /de/

 

I wanted to next see if there Asia region or middle eat region.

So I tried this.

 

<?php
include('geo_ip/geoip.inc');
$gi = geoip_open('geo_ip/geoip.dat',GEOIP_STANDARD);
$addr = getenv('REMOTE_ADDR');
$country = geoip_country_name_by_addr($gi, $addr);
geoip_close($gi);
$ifgerman = array('Germany','Austria','Liechtenstein','Switzerland','Luxembourg');
$ifasia = array('China','Iran','UAE','Iraq','India','Malaysia','Japan','Isreal');
if(in_array($country, $ifgerman)){
header('Location: /de/')
}
if(in_array($country, $ifasia)){
header('Location: /ar-as/')
}
?>

 

It didn't work however, it threw an error

Parse error: syntax error, unexpected '}'. Which I don't understand I thought the IF statement is supposed to have the }  {  things :?

 

 

Link to comment
https://forums.phpfreaks.com/topic/109666-solved-geoip-redirection-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.