Extension for Cotonti CMF. Integration of SxGeo IP base (geo names supplied in Russian and English)
Authors: Andrey Matsovkin, Kalnov Alexey
Github: https://github.com/Cotonti-Extensions/sxgeo
Integration of SxGeoIP database in Cotonti CMF. This DB contains Geo coordinates related to user IP-address. SxGeoIP created, developed and maintained by https://sypexgeo.net/ and distributed under BSD licence.
You can view demo page at https://sypexgeo.net/ site.
Current version requires Cotonti Siena v0.9.23 and newer.
Plugin works out from the box. For better results check config settings in admin panel.
Extension use GeoIP data packed in SxGeoIP format files. Country and city info stored in separate files. More info about SxGeoIP format you can find on https://sypexgeo.net/.
Administration panel → Extensions
)Administration panel → Extensions → sxgeo → Configuration
).
You can use this extension data in 2 ways:
1) Through functions call for sx_getCity($ip)
and sx_getCountry($ip)
. These functions return string with Country and City name respectively. You can ommit IP address. In this case you get info according to current user info.
Examples:
{PHP|sx_getCity('8.8.8.8')}
{PHP.usr.ip|sx_getCountry($this)}
Important notes! Country names are always geted in current Cotonti locale (user selected language), according to countries.*.lang.php
file. City names are returned by plugin in english or russian (as it sored in SxGeoIP DB).
2) You can turn on Auto initialization mode
, so you can use direct values for current user country and city info.
Data format:
/**
* Contains data for country code and id from last sx_getCountry*() call.
*/
$sx_country = [
'iso' => '', // ISO 3166-1 code in appear case
'name' => '', // Country name with Cotonti locale as defined in countries.*.lang.php file
'id' => 0, // Country ID used in SxGeoIP base
];
/**
* Contains info about city from last sx_getCity*() call.
*/
$sx_city = [
'info' => [], // basic info, see sx_getCity() function for details
'ext_info' => [], //extended info, see sx_getCityExt() function for details
];
Use this calls in TPL:
city - {PHP.sx_city.info.city}
country - {PHP.sx_country.name}
Distributed under BSD license.
Andrey Matsovkin - author of Cotonti extension. All other rights belongs to https://sypexgeo.net/ as DB creator.
Bedankt: 7 tijden
Спасибо!
Добавил файл для comments.loop и стало просто замечательно :)