<?php
# Copyright 2008 Maxmind LLC All Rights Reserved. Compile and including by AVET

if(!defined('DATALIFEENGINE'))
{
  die("Hacking attempt!");
}
include_once ENGINE_DIR.'/modules/geoip-api/geoipcity.inc';
$gi = geoip_open(ENGINE_DIR."/modules/geoip-api/GeoLiteCity.dat",GEOIP_STANDARD);

$record = geoip_record_by_addr($gi,$row['logged_ip']);
$cflag = $record->country_code . "\n";
$cname = $record->country_name . "\n";
$cityname = $record->city . "\n";
$latitude = $record->latitude . "\n";
$longitude = $record->longitude . "\n";
// Templates
$tpl->set('{cflag}', "<img alt='".$cname."'  title='".$cname."' src='{THEME}/flags/" . $cflag. "0.gif' style='border:0; vertical-align:middle;'/>");
$tpl->set('{cname}', $cname);
$tpl->set('{cityname}', $cityname);
$latitude = str_replace(",",".",$latitude);
$longitude = str_replace(",",".",$longitude);
$tpl->set('{gmaps}', "<a target='_blank' alt='Посмотреть на Google Maps' title='Посмотреть на Google Maps' href='http://maps.google.com/?ie=UTF8&ll=" . $latitude. "," . $longitude. "&z=12'> ". $cityname ." </a>");
$tpl->set('{geodenied}', '');
?>