* Update: 2004-04-12 03:44 * * This script shows a banner, based on the country associated with the visitor's address. * */ // we use this to initialise a connection with our database require_once(FRAMEWORK_ROOT.'mysql.php'); // at the maxmind.com site you find a php driver, geoip.inc require_once(FRAMEWORK_ROOT.'geoip.inc'); // lookup the country for the visitor's address $address = $_SERVER['REMOTE_ADDR']; $gi = geoip_open(FRAMEWORK_ROOT.'GeoIP.dat',GEOIP_STANDARD); $country = geoip_country_code_by_addr($gi,$address); geoip_close($gi); // lookup the url for the country $result = mysql_query("SELECT url FROM partnerbanners WHERE country='$country'"); if ($row = mysql_fetch_assoc($result)) { // we have found an url for the country $url = $row['url']; } else { // we haven't found an url for the country, so we lookup the default url $result = mysql_query("SELECT url FROM partnerbanners WHERE country='DEFAULT'"); $row = mysql_fetch_assoc($result); $url = $row['url']; } // redirect to the url header('Location: '.$url); ?>