Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks
Author Message
guidyy
Worker
Worker


Joined: Nov 22, 2004
Posts: 208
Location: Italy

PostPosted: Wed Jun 21, 2006 12:00 pm Reply with quote

hi I need to Geo-target the content of a block
I alredy have a variable $countrycode from nsnst_ip2country table

So what i need is

If $countrycode = US or CA or UK or AU show thisstuff (links to pages in diff languages)
if $counrtycode = FR or BE show thisother
if $countrycode = DE or NL show thisone
else show whatever i need to there...

easyest way?
Thanks
Guido
 
View user's profile Send private message Visit poster's website MSN Messenger
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9449
Location: Arizona

PostPosted: Thu Jun 22, 2006 6:09 am Reply with quote

Just to make absolutely sure here, are you saying that you have already written code that takes the user's remote IP address and does a look-up on the nsnst_ip2country table to get his/her c2c value? I want to make sure, because that, to me, is the most difficult task at hand.

Because, once you have the $countrycode variable, it is simply a matter of checking it with IF statements possibly like this:

Code:


if ($countrycode = 'US' OR $countrycode = 'CA' OR $countrycode = 'UK' OR $countrycode = 'AU') {
   <<show this stuff>>
} elseif ($countrycode = 'FR' or $countrycode = 'BE') {
  <<show thisother>>
} elseif ($countrycode = 'DE' or $countrycode = 'NL') {
  <<show thisone>>
} else {
  <<show whatever i need to there>>
}

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
guidyy
PostPosted: Thu Jun 22, 2006 6:22 am Reply with quote

Thanks!
I dont know why I was stuck thinking of an array with countrycodes..
Didn't even think of a simple if

anyway this is the code to get c2c form ip2country:


Code:


$ip = $_SERVER['REMOTE_ADDR'];
$res = mysql_query("SELECT c2c,country FROM nuke_nsnst_ip2country WHERE ip_lo<=inet_aton('$ip') AND ip_hi>=inet_aton('$ip')");//look up IP address
 
$Codes = mysql_fetch_array($res); //get result
$CountryCode = $Codes['c2c']; //two-letter country code
$CountryName = $Codes['country']; //full country name




I stole it from another script and adapted to the nuke database Smile

Guido
 
montego
PostPosted: Thu Jun 22, 2006 7:01 am Reply with quote

Too funny! I was originally working up that code and stole most of it from nukesentinel.php! Then, I reread your message and realized you might already have it.
 
guidyy
PostPosted: Thu Jun 22, 2006 7:30 am Reply with quote

It's common for me to Bang Head trying to make a little script, or a function and then realize I already had it done inside another one....
That's why I love forums LOL
 
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6792
Location: Ha Noi, Viet Nam

PostPosted: Thu Jun 22, 2006 9:51 am Reply with quote

Excellent stuff!
 
View user's profile Send private message Send e-mail
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©