PHP: Determination of the country by IP
Determination of the country by IP using geoplugin.net OR ipinfodb.com. Will return the country code in "Alpha-2 ISO 3166-1" format (a two-char code) ... Показать код
Храните, отслеживайте и делитесь с друзьями вашими сниппетами
Determination of the country by IP using geoplugin.net OR ipinfodb.com. Will return the country code in "Alpha-2 ISO 3166-1" format (a two-char code) ... Показать код
- function get_country($ip_addr) {
- $curlopt_useragent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0';
- $url = 'http://www.geoplugin.net/php.gp?ip=' . $ip_addr;
- $ch1 = curl_init();
- curl_setopt($ch1, CURLOPT_URL, $url);
- curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
- $result = curl_exec($ch1);
- $geoplugin = unserialize($result);
- if ($geoplugin[geoplugin_countryCode] != '') {
- return $geoplugin[geoplugin_countryCode];
- } else {
- $url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip_addr);
- $ch = curl_init();
- $curl_opt = array(
- CURLOPT_FOLLOWLOCATION => 1,
- CURLOPT_HEADER => 0,
- CURLOPT_RETURNTRANSFER => 1,
- CURLOPT_USERAGENT => $curlopt_useragent,
- CURLOPT_URL => $url,
- CURLOPT_TIMEOUT => 1,
- CURLOPT_REFERER => 'http://' . $_SERVER['HTTP_HOST'],
- );
- curl_setopt_array($ch, $curl_opt);
- $content = curl_exec($ch);
- if (!is_null($curl_info)) {
- $curl_info = curl_getinfo($ch);
- }
- curl_close($ch);
- if (preg_match('{
- Country : ([^<]*)}i', $content, $regs))
- $country = $regs[1];
- return $country;
- }
- }
World countries and their ISO 3166-1 codes ... Показать код
- DROP TABLE IF EXISTS `list_countries`;
- CREATE TABLE `list_countries` (
- `id` int(11) NOT NULL auto_increment,
- `country_short_name` varchar(2) NOT NULL,
- `country_name` varchar(24) NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Afghanistan', 'AF');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Aland Islands', 'AX');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Albania', 'AL');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Algeria', 'DZ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('American Samoa', 'AS');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Andorra', 'AD');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Angola', 'AO');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Anguilla', 'AI');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Antarctica', 'AQ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Antigua and Barbuda', 'AG');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Argentina', 'AR');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Armenia', 'AM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Aruba', 'AW');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Australia', 'AU');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Austria', 'AT');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Azerbaijan', 'AZ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Bahamas', 'BS');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Bahrain', 'BH');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Bangladesh', 'BD');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Barbados', 'BB');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Belarus', 'BY');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Belgium', 'BE');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Belize', 'BZ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Benin', 'BJ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Bermuda', 'BM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Bhutan', 'BT');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Bolivia', 'BO');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Bonaire Sint Eustatius and Saba', 'BQ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Bosnia and Herzegovina', 'BA');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Botswana', 'BW');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Bouvet Island', 'BV');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Brazil', 'BR');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('British Indian Ocean Territory', 'IO');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Brunei Darussalam', 'BN');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Bulgaria', 'BG');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Burkina Faso', 'BF');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Burundi', 'BI');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Cambodia', 'KH');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Cameroon', 'CM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Canada', 'CA');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Cape Verde', 'CV');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Cayman Islands', 'KY');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Central African Republic', 'CF');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Chad', 'TD');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Chile', 'CL');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('China', 'CN');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Christmas Island', 'CX');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Cocos Islands', 'CC');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Colombia', 'CO');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Comoros', 'KM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Congo', 'CG');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Congo', 'CD');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Cook Islands', 'CK');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Costa Rica', 'CR');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Cote d\'Ivoire', 'CI');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Croatia', 'HR');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Cuba', 'CU');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Curacao', 'CW');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Cyprus', 'CY');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Czech Republic', 'CZ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Denmark', 'DK');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Djibouti', 'DJ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Dominica', 'DM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Dominican Republic', 'DO');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Ecuador', 'EC');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Egypt', 'EG');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('El Salvador', 'SV');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Equatorial Guinea', 'GQ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Eritrea', 'ER');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Estonia', 'EE');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Ethiopia', 'ET');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Falkland Islands', 'FK');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Faroe Islands', 'FO');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Fiji', 'FJ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Finland', 'FI');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('France', 'FR');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('French Guiana', 'GF');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('French Polynesia', 'PF');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('French Southern Territories', 'TF');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Gabon', 'GA');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Gambia', 'GM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Georgia', 'GE');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Germany', 'DE');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Ghana', 'GH');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Gibraltar', 'GI');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Greece', 'GR');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Greenland', 'GL');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Grenada', 'GD');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Guadeloupe', 'GP');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Guam', 'GU');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Guatemala', 'GT');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Guernsey', 'GG');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Guinea', 'GN');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Guinea-Bissau', 'GW');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Guyana', 'GY');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Haiti', 'HT');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Heard Island and McDonald Islands', 'HM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Vatican City', 'VA');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Honduras', 'HN');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Hong Kong', 'HK');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Hungary', 'HU');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Iceland', 'IS');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('India', 'IN');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Indonesia', 'ID');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Iran', 'IR');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Iraq', 'IQ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Ireland', 'IE');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Isle of Man', 'IM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Israel', 'IL');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Italy', 'IT');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Jamaica', 'JM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Japan', 'JP');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Jersey', 'JE');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Jordan', 'JO');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Kazakhstan', 'KZ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Kenya', 'KE');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Kiribati', 'KI');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Korea', 'KP');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('South Korea', 'KR');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Kuwait', 'KW');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Kyrgyzstan', 'KG');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Lao', 'LA');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Latvia', 'LV');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Lebanon', 'LB');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Lesotho', 'LS');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Liberia', 'LR');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Libya', 'LY');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Liechtenstein', 'LI');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Lithuania', 'LT');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Luxembourg', 'LU');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Macao', 'MO');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Macedonia', 'MK');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Madagascar', 'MG');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Malawi', 'MW');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Malaysia', 'MY');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Maldives', 'MV');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Mali', 'ML');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Malta', 'MT');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Marshall Islands', 'MH');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Martinique', 'MQ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Mauritania', 'MR');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Mauritius', 'MU');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Mayotte', 'YT');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Mexico', 'MX');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Micronesia', 'FM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Moldova', 'MD');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Monaco', 'MC');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Mongolia', 'MN');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Montenegro', 'ME');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Montserrat', 'MS');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Morocco', 'MA');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Mozambique', 'MZ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Myanmar', 'MM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Namibia', 'NA');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Nauru', 'NR');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Nepal', 'NP');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Netherlands', 'NL');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('New Caledonia', 'NC');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('New Zealand', 'NZ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Nicaragua', 'NI');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Niger', 'NE');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Nigeria', 'NG');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Niue', 'NU');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Norfolk Island', 'NF');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Northern Mariana Islands', 'MP');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Norway', 'NO');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Oman', 'OM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Pakistan', 'PK');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Palau', 'PW');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Palestine', 'PS');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Panama', 'PA');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Papua New Guinea', 'PG');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Paraguay', 'PY');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Peru', 'PE');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Philippines', 'PH');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Pitcairn', 'PN');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Poland', 'PL');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Portugal', 'PT');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Puerto Rico', 'PR');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Qatar', 'QA');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Reunion', 'RE');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Romania', 'RO');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Russian Federation', 'RU');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Rwanda', 'RW');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Saint Barthelemy', 'BL');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Saint Helena Ascension and Tristan da Cunha', 'SH');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Saint Kitts and Nevis', 'KN');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Saint Lucia', 'LC');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Saint Martin (French part)', 'MF');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Saint Pierre and Miquelon', 'PM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Saint Vincent and the Grenadines', 'VC');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Samoa', 'WS');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('San Marino', 'SM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Sao Tome and Principe', 'ST');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Saudi Arabia', 'SA');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Senegal', 'SN');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Serbia', 'RS');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Seychelles', 'SC');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Sierra Leone', 'SL');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Singapore', 'SG');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Sint Maarten (Dutch part)', 'SX');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Slovakia', 'SK');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Slovenia', 'SI');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Solomon Islands', 'SB');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Somalia', 'SO');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('South Africa', 'ZA');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('South Georgia and the South Sandwich Islands', 'GS');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('South Sudan', 'SS');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Spain', 'ES');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Sri Lanka', 'LK');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Sudan', 'SD');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Suriname', 'SR');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Svalbard and Jan Mayen', 'SJ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Swaziland', 'SZ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Sweden', 'SE');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Switzerland', 'CH');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Syrian Arab Republic', 'SY');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Taiwan Province of China', 'TW');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Tajikistan', 'TJ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Tanzania', 'TZ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Thailand', 'TH');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Timor-Leste', 'TL');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Togo', 'TG');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Tokelau', 'TK');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Tonga', 'TO');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Trinidad and Tobago', 'TT');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Tunisia', 'TN');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Turkey', 'TR');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Turkmenistan', 'TM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Turks and Caicos Islands', 'TC');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Tuvalu', 'TV');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Uganda', 'UG');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Ukraine', 'UA');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('United Arab Emirates', 'AE');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('United Kingdom', 'GB');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('United States', 'US');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('United States Minor Outlying Islands', 'UM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Uruguay', 'UY');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Uzbekistan', 'UZ');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Vanuatu', 'VU');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Venezuela', 'VE');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Viet Nam', 'VN');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Virgin Islands British', 'VG');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Virgin Islands U.S.', 'VI');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Wallis and Futuna', 'WF');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Western Sahara', 'EH');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Yemen', 'YE');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Zambia', 'ZM');
- INSERT INTO `list_countries` (`country_name`, `country_short_name`) VALUES ('Zimbabwe', 'ZW');
Данный сниппет позволяет быстро получить не только координаты пользователя, но также его физический адрес.
Внимание! Требуется подключённая на страницу библиотека API 2.0 яндекс.карт.
Пример работы: http://jsfiddle.net/bnRus/ ... Показать код
- navigator.geolocation.getCurrentPosition(function(geopos) {
- ymaps.geocode([geopos.coords.latitude,geopos.coords.longitude]).then(function(res){
- var result = res.geoObjects.get(0);
- if(result) {
- console.log(result.properties.get('name'));
- }
- })
- });