<?php
$ip = $_SERVER['REMOTE_ADDR'];
$url = "http://ipgeobase.ru:7020/geo?ip=".$ip;
$xmlstr = file_get_contents($url);
$xml = new SimpleXMLElement($xmlstr);
$region = $xml->ip[0]->region;
$city = $xml->ip[0]->city;
if(empty($region))
{
$region = 'какая то область';
$city = 'какой то город';
}
else
{
$region = iconv("utf-8", "utf-8", $region);
$city = iconv("utf-8", "utf-8", $city);
}
$output = $modx->setPlaceholder('output',$region);
$output = $modx->setPlaceholder('output1',$city);
return $output;