hangi ülkeye ait bir ip adresi kullanıldığını tespit edebilir bunu kullanabilirsiniz.
<?php $ip = "176.10.99.220"; // sabit ip sorgulatabilir // $ip = $_SERVER['REMOTE_ADDR']; //kullanıcı ip adresi sorgulatabilir function rwhois($query){ $fp = fsockopen ("rwhois.arin.net", 4321, $errno, $errstr, 30); if (!$fp) { $ret[] = "$errstr ($errno)\n"; }else{ fputs ($fp, "$query\r\n\r\n"); $count=1; while (!feof($fp) && $count < 17) { $back = fgets ($fp,128); $data = explode(":",$back); $ret[$data[1]] = $data[2]; $count++; } fclose ($fp); } return $ret; } $cLook = rwhois($ip); $host = gethostbyaddr($ip); $ccode = strtolower(trim($cLook['Country-Code'])); switch($ccode) { case "ac": $country = "Ascension Island"; break; case "ad": $country = "Andorra"; break; case "ae": $country = "United Arab Emirates"; break; case "af": $country = "Afghanistan"; break; case "ag": $country = "Antigua and Barbuda"; break; case "ai": $country = "Anguilla"; break; case "al": $country = "Albania"; break; case "am": $country = "Armenia"; break; case "an": $country = "Netherlands Antilles"; break; case "ao": $country = "Angola"; break; case "aq": $country = "Antarctica"; break; case "ar": $country = "Argentina"; break; case "as": $country = "American Samoa"; break; case "at": $country = "Austria"; break; case "au": $country = "Australia"; break; case "aw": $country = "Aruba"; break; case "az": $country = "Azerbaijan"; break; case "ba": $country = "Bosnia and Herzegovina"; break; case "bb": $country = "Barbados"; break; case "bd": $country = "Bangladesh"; break; case "be": $country = "Belgium"; break; case "bf": $country = "Burkina Faso"; break; case "bg": $country = "Bulgaria"; break; case "bh": $country = "Bahrain"; break; case "bi": $country = "Burundi"; break; case "bj": $country = "Benin"; break; case "bm": $country = "Bermuda"; break; case "bn": $country = "Brunei Darussalam"; break; case "bo": $country = "Bolivia"; break; case "br": $country = "Brazil"; break; case "bs": $country = "Bahamas"; break; case "bt": $country = "Bhutan"; break; case "bv": $country = "Bouvet Island"; break; case "bw": $country = "Botswana"; break; case "by": $country = "Belarus"; break; case "bz": $country = "Belize"; break; case "ca": $country = "Canada"; break; case "cc": $country = "Cocos (Keeling) Islands"; break; case "cd": $country = "Congo, Democratic Republic of the"; break; case "cf": $country = "Central African Republic"; break; case "cg": $country = "Congo, Republic of"; break; case "ch": $country = "Switzerland"; break; case "ci": $country = "Cote d'Ivoire"; break; case "ck": $country = "Cook Islands"; break; case "cl": $country = "Chile"; break; case "cm": $country = "Cameroon"; break; case "cn": $country = "China"; break; case "co": $country = "Colombia"; break; case "cr": $country = "Costa Rica"; break; case "cu": $country = "Cuba"; break; case "cv": $country = "Cap Verde"; break; case "cx": $country = "Christmas Island"; break; case "cy": $country = "Cyprus"; break; case "cz": $country = "Czech Republic"; break; case "de": $country = "Germany"; break; case "dj": $country = "Djibouti"; break; case "dk": $country = "Denmark"; break; case "dm": $country = "Dominica"; break; case "do": $country = "Dominican Republic"; break; case "dz": $country = "Algeria"; break; case "ec": $country = "Ecuador"; break; case "ee": $country = "Estonia"; break; case "eg": $country = "Egypt"; break; case "eh": $country = "Western Sahara"; break; case "er": $country = "Eritrea"; break; case "es": $country = "Spain"; break; case "et": $country = "Ethiopia"; break; case "fi": $country = "Finland"; break; case "fj": $country = "Fiji"; break; case "fk": $country = "Falkland Islands (Malvina)"; break; case "fm": $country = "Micronesia, Federal State of"; break; case "fo": $country = "Faroe Islands"; break; case "fr": $country = "France"; break; case "ga": $country = "Gabon"; break; case "gd": $country = "Grenada"; break; case "ge": $country = "Georgia"; break; case "gf": $country = "French Guiana"; break; case "gg": $country = "Guernsey"; break; case "gh": $country = "Ghana"; break; case "gi": $country = "Gibraltar"; break; case "gl": $country = "Greenland"; break; case "gm": $country = "Gambia"; break; case "gn": $country = "Guinea"; break; case "gp": $country = "Guadeloupe"; break; case "gq": $country = "Equatorial Guinea"; break; case "gr": $country = "Greece"; break; case "gs": $country = "South Georgia and the South Sandwich Islands"; break; case "gt": $country = "Guatemala"; break; case "gu": $country = "Guam"; break; case "gw": $country = "Guinea-Bissau"; break; case "gy": $country = "Guyana"; break; case "hk": $country = "Hong Kong"; break; case "hm": $country = "Heard and McDonald Islands"; break; case "hn": $country = "Honduras"; break; case "hr": $country = "Croatia/Hrvatska"; break; case "ht": $country = "Haiti"; break; case "hu": $country = "Hungary"; break; case "id": $country = "Indonesia"; break; case "ie": $country = "Ireland"; break; case "il": $country = "Israel"; break; case "im": $country = "Isle of Man"; break; case "in": $country = "India"; break; case "io": $country = "British Indian Ocean Territory"; break; case "iq": $country = "Iraq"; break; case "ir": $country = "Iran (Islamic Republic of)"; break; case "is": $country = "Iceland"; break; case "it": $country = "Italy"; break; case "je": $country = "Jersey"; break; case "jm": $country = "Jamaica"; break; case "jo": $country = "Jordan"; break; case "jp": $country = "Japan"; break; case "ke": $country = "Kenya"; break; case "kg": $country = "Kyrgyzstan"; break; case "kh": $country = "Cambodia"; break; case "ki": $country = "Kiribati"; break; case "km": $country = "Comoros"; break; case "kn": $country = "Saint Kitts and Nevis"; break; case "kp": $country = "Korea, Democratic People's Republic"; break; case "kr": $country = "Korea, Republic of"; break; case "kw": $country = "Kuwait"; break; case "ky": $country = "Cayman Islands"; break; case "kz": $country = "Kazakhstan"; break; case "la": $country = "Lao People's Democratic Republic"; break; case "lb": $country = "Lebanon"; break; case "lc": $country = "Saint Lucia"; break; case "li": $country = "Liechtenstein"; break; case "lk": $country = "Sri Lanka"; break; case "lr": $country = "Liberia"; break; case "ls": $country = "Lesotho"; break; case "lt": $country = "Lithuania"; break; case "lu": $country = "Luxembourg"; break; case "lv": $country = "Latvia"; break; case "ly": $country = "Libyan Arab Jamahiriya"; break; case "ma": $country = "Morocco"; break; case "mc": $country = "Monaco"; break; case "md": $country = "Moldova, Republic of"; break; case "mg": $country = "Madagascar"; break; case "mh": $country = "Marshall Islands"; break; case "mk": $country = "Macedonia, Former Yugoslav Republic"; break; case "ml": $country = "Mali"; break; case "mm": $country = "Myanmar"; break; case "mn": $country = "Mongolia"; break; case "mo": $country = "Macau"; break; case "mp": $country = "Northern Mariana Islands"; break; case "mq": $country = "Martinique"; break; case "mr": $country = "Mauritania"; break; case "ms": $country = "Montserrat"; break; case "mt": $country = "Malta"; break; case "mu": $country = "Mauritius"; break; case "mv": $country = "Maldives"; break; case "mw": $country = "Malawi"; break; case "mx": $country = "Mexico"; break; case "my": $country = "Malaysia"; break; case "mz": $country = "Mozambique"; break; case "na": $country = "Namibia"; break; case "nc": $country = "New Caledonia"; break; case "ne": $country = "Niger"; break; case "nf": $country = "Norfolk Island"; break; case "ng": $country = "Nigeria"; break; case "ni": $country = "Nicaragua"; break; case "nl": $country = "Netherlands"; break; case "no": $country = "Norway"; break; case "np": $country = "Nepal"; break; case "nr": $country = "Nauru"; break; case "nu": $country = "Niue"; break; case "nz": $country = "New Zealand"; break; case "om": $country = "Oman"; break; case "pa": $country = "Panama"; break; case "pe": $country = "Peru"; break; case "pf": $country = "French Polynesia"; break; case "pg": $country = "Papua New Guinea"; break; case "ph": $country = "Philippines"; break; case "pk": $country = "Pakistan"; break; case "pl": $country = "Poland"; break; case "pm": $country = "St. Pierre and Miquelon"; break; case "pn": $country = "Pitcairn Island"; break; case "pr": $country = "Puerto Rico"; break; case "ps": $country = "Palestinian Territories"; break; case "pt": $country = "Portugal"; break; case "pw": $country = "Palau"; break; case "py": $country = "Paraguay"; break; case "qa": $country = "Qatar"; break; case "re": $country = "Reunion Island"; break; case "ro": $country = "Romania"; break; case "ru": $country = "Russian Federation"; break; case "rw": $country = "Rwanda"; break; case "sa": $country = "Saudi Arabia"; break; case "sb": $country = "Solomon Islands"; break; case "sc": $country = "Seychelles"; break; case "sd": $country = "Sudan"; break; case "se": $country = "Sweden"; break; case "sg": $country = "Singapore"; break; case "sh": $country = "St. Helena"; break; case "si": $country = "Slovenia"; break; case "sj": $country = "Svalbard and Jan Mayen Islands"; break; case "sk": $country = "Slovak Republic"; break; case "sl": $country = "Sierra Leone"; break; case "sm": $country = "San Marino"; break; case "sn": $country = "Senegal"; break; case "so": $country = "Somalia"; break; case "sr": $country = "Suriname"; break; case "st": $country = "Sao Tome and Principe"; break; case "sv": $country = "El Salvador"; break; case "sy": $country = "Syrian Arab Republic"; break; case "sz": $country = "Swaziland"; break; case "tc": $country = "Turks and Caicos Islands"; break; case "td": $country = "Chad"; break; case "tf": $country = "French Southern Territories"; break; case "tg": $country = "Togo"; break; case "th": $country = "Thailand"; break; case "tj": $country = "Tajikistan"; break; case "tk": $country = "Tokelau"; break; case "tm": $country = "Turkmenistan"; break; case "tn": $country = "Tunisia"; break; case "to": $country = "Tonga"; break; case "tp": $country = "East Timor"; break; case "tr": $country = "Turkey"; break; case "tt": $country = "Trinidad and Tobago"; break; case "tv": $country = "Tuvalu"; break; case "tw": $country = "Taiwan"; break; case "tz": $country = "Tanzania"; break; case "ua": $country = "Ukraine"; break; case "ug": $country = "Uganda"; break; case "uk": $country = "United Kingdom"; break; case "um": $country = "US Minor Outlying Islands"; break; case "us": $country = "United States"; break; case "uy": $country = "Uruguay"; break; case "uz": $country = "Uzbekistan"; break; case "va": $country = "Holy See (City Vatican State)"; break; case "vc": $country = "Saint Vincent and the Grenadines"; break; case "ve": $country = "Venezuela"; break; case "vg": $country = "Virgin Islands (British)"; break; case "vi": $country = "Virgin Islands (USA)"; break; case "vn": $country = "Vietnam"; break; case "vu": $country = "Vanuatu"; break; case "wf": $country = "Wallis and Futuna Islands"; break; case "ws": $country = "Western Samoa"; break; case "ye": $country = "Yemen"; break; case "yt": $country = "Mayotte"; break; case "yu": $country = "Yugoslavia"; break; case "za": $country = "South Africa"; break; case "zm": $country = "Zambia"; break; case "zw": $country = "Zimbabwe"; break; default: $country = "Bilinmeyen"; } echo "<font color=\"red\" size=\"2\">$host</font> ip'si <font face=\"verdana,arial,helvetica\" size=\"2\"><b>" . $country . "</b> Ülkesine Ait</font>"; ?>