$IP = $_SERVER['REMOTE_ADDR'];
$SSID = htmlentities(SID);
// If IP address exists
// Get country (and City) via api.hostip.info
if (!empty($IP)) {
$country=file_get_contents('[URL unfurl="true"]http://api.hostip.info/get_html.php?ip='.$IP);[/URL]
// Reformat the data returned (Keep only country and country abbr.
list ($_country) = explode ("\n", $country);
$_country = str_replace("Country: ", "", $_country);
}