function cot_select_location($country = '', $region = 0, $city = 0, $userdefault = false)
{
    global $cfg, $L, $R, $usr;
    $countriesfilter = array();
    if (!empty($cfg['plugin']['locationselector']['countriesfilter']) && $cfg['plugin']['locationselector']['countriesfilter'] != 'all') {
        $countriesfilter = str_replace(' ', '', $cfg['plugin']['locationselector']['countriesfilter']);
        $countriesfilter = explode(',', $countriesfilter);
        $disabled = count($countriesfilter) == 1 ? 'disabled="disabled" ' : '';
        $country = count($countriesfilter) == 1 ? $countriesfilter[0] : $country;
    }
    if ($userdefault && $usr['id'] > 0 && $country == '' && $region == 0 && $city == 0) {
        $country = $usr['profile']['user_country'];
        $region = $usr['profile']['user_region'];
        $city = $usr['profile']['user_city'];
    }
    $countries = cot_getcountries($countriesfilter);
    if ($countries) {
        $countries = array(0 => $L['select_country']) + $countries;
        $country_selectbox = cot_selectbox($country, 'country', array_keys($countries), array_values($countries), false, $disabled . 'class="locselectcountry form-control" id="locselectcountry"');
        $country_selectbox .= count($countriesfilter) == 1 ? cot_inputbox('hidden', 'country', $country) : '';
        $region = $country == '' || count($countries) < 2 ? 0 : $region;
        $regions = !empty($country) ? cot_getregions($country) : array();
        $regions = array(0 => $L['select_region']) + $regions;
        $disabled = empty($country) || count($regions) < 2 ? 'disabled="disabled" ' : '';
        $region_selectbox = cot_selectbox($region, 'region', array_keys($regions), array_values($regions), false, $disabled . 'class="locselectregion form-control" id="locselectregion"');
        $city = $region == 0 || count($regions) < 2 ? 0 : $city;
        $cities = !empty($region) ? cot_getcities($region) : array();
        $cities = array(0 => $L['select_city']) + $cities;
        $disabled = empty($region) || count($cities) < 2 ? 'disabled="disabled" ' : '';
        $city_selectbox = cot_selectbox($city, 'city', array_keys($cities), array_values($cities), false, $disabled . 'class="locselectcity form-control" id="locselectcity"');
        $result = cot_rc('input_location', array('country' => $country_selectbox, 'region' => $region_selectbox, 'city' => $city_selectbox));
        return $result;
    } else {
        return false;
    }
}
 * [BEGIN_COT_EXT]
 * Hooks=ajax
 * [END_COT_EXT]
 */
/**
 * Location Selector for Cotonti
 *
 * @package locationselector
 * @version 2.0.0
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL.');
$country = cot_import('country', 'R', 'TXT');
$region = cot_import('region', 'R', 'INT');
cot_sendheaders();
if (isset($_REQUEST['country'])) {
    $regions = array();
    if ($country != '0') {
        $regions = cot_getregions($country);
    }
    $region_selectbox = array('regions' => array(0 => $L['select_region']) + $regions, 'disabled' => empty($country) || count($regions) == 0 ? 1 : 0);
    echo json_encode($region_selectbox);
    exit;
} else {
    $cities = !empty($region) ? cot_getcities($region) : array();
    $city_selectbox = array('cities' => array(0 => $L['select_city']) + $cities, 'disabled' => !$region || count($cities) == 0 ? 1 : 0);
    echo json_encode($city_selectbox);
    exit;
}
/**
 * [BEGIN_COT_EXT]
 * Hooks=ajax
 * [END_COT_EXT]
 */
/**
 * Location Selector for Cotonti
 *
 * @package locationselector
 * @version 2.0.0
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL.');
$country = cot_import('country', 'R', 'TXT');
$region = cot_import('region', 'R', 'INT');
cot_sendheaders();
if (isset($_REQUEST['country'])) {
    $regions = !empty($country) ? cot_getregions($country) : array();
    $regions = array(0 => $L['select_region']) + $regions;
    $disabled = empty($country) || count($regions) < 2 ? 'disabled="disabled" ' : '';
    $region_selectbox = cot_selectbox($regions, 'region', array_keys($regions), array_values($regions), false, $disabled . 'class="locselectregion form-control" id="locselectregion"');
    echo $region_selectbox;
} else {
    $cities = !empty($region) ? cot_getcities($region) : array();
    $cities = array(0 => $L['select_city']) + $cities;
    $disabled = empty($region) || count($cities) < 2 ? 'disabled="disabled" ' : '';
    $city_selectbox = cot_selectbox($regions, 'city', array_keys($cities), array_values($cities), false, $disabled . 'class="locselectcity form-control" id="locselectcity"');
    echo $city_selectbox;
}