I did it in php.. Here's the code. <?php
header("Content-type: image/png");
include('mysql.php');
$link = mysql_connect("xxx", $user, $pass) or die(mysql_error());
mysql_select_db('xxx') or die("Could not select database");
$im = @imagecreate(300, 50) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 255, 128, 0);
$ip = $_SERVER['REMOTE_ADDR'];
$query = "SELECT country FROM iptoc WHERE ipFrom<=inet_aton('$ip') AND ipTo>=inet_aton('$ip')";
$result = mysql_query($query);
$line = mysql_fetch_array($result);
if ($line['country'] == "")
$country = "n/a";
else
$country = $line['country'];
$ord = explode(" ", $line['country']);
$i = 0;
$country = '';
while ($i <= count($ord) - 1)
{
$country .= ucfirst(strtolower($ord[$i])) . " ";
$i++;
}
imagestring($im, 20, 25, 15, $country . "rocks!", $text_color);
imagepng($im);
imagedestroy($im);
mysql_close($link);
?>