Пример #1
0
 /**
  * @return array
  */
 public function getCountry()
 {
     if (!$this->SxGeo) {
         $this->loadSxGeo();
     }
     return $this->SxGeo->getCountry($this->getUserIp());
 }
Пример #2
0
/**
 * Return country name code by IP
 * @param string $ip IP address in xxx.xxx.xxx.xxx notation
 * @return string Country name in CMS lang as defined countries.*.lang.php file
 */
function sx_getCountry($ip = null)
{
    global $SxCountry, $sx_bulkmode, $sx_country, $sx_ip, $cot_countries;
    if (is_null($ip)) {
        $ip = $sx_ip;
    }
    if (!$SxCountry) {
        $SxCountry = new SxGeo('plugins/sxgeo/data/SxGeo.dat');
    }
    // Определяем страну c БД содержащими страны
    $sx_country['iso'] = $iso_code = @$SxCountry->getCountry($ip);
    // возвращает двухзначный ISO-код страны
    // must use @ to discard nulled result error in some cases
    if ($iso_code) {
        $sx_country['name'] = $country_name = $cot_countries[mb_strtolower($iso_code)];
    }
    if (!$sx_bulkmode) {
        unset($SxCountry);
    }
    // Если нужно освободить ресурсы - удаляем объект
    if ($country_name) {
        return $country_name;
    } else {
        return $iso_code;
    }
}
Пример #3
0
$save_marker = isset($_COOKIE['marker']) ? trim(strip_tags($_COOKIE['marker'])) : '';
if (@trim($_POST['marker']) != $save_marker) {
    die(json_encode('marker'));
}
// открытие во фрейме это плохо:
if (@trim($_POST['iframe']) != '0') {
    die(json_encode('iframe'));
}
// метод (GET или POST)
if (@$_POST['method'] != 'GET') {
    die(json_encode('method'));
}
// получаем страну юзера:
include 'SxGeo.php';
$SxGeo = new SxGeo('SxGeo.dat', SXGEO_FILE);
$country = @mb_strtolower($SxGeo->getCountry($ip), 'utf-8');
// детектируем AdBlock
if (@$_POST['adb'] == '1') {
    $save_adblock = '1';
} else {
    $save_adblock = '0';
}
// язык браузера
$save_language = @trim(strip_tags($_POST['language']));
// поддерживается ли куки
if (@$_POST['cookietrue'] == 'true') {
    $save_cookietrue = '1';
} else {
    $save_cookietrue = '0';
}
// ширина монитора
Пример #4
0
 /**
  * @param string $ip
  *
  * @return mixed
  */
 public function getCountry($ip = '')
 {
     return $this->sxGeo->getCountry($this->getIp($ip));
 }
Пример #5
0
 /**
  * @return array
  */
 public function getCountry()
 {
     return $this->SxGeo->getCountry($this->getUserIp());
 }