login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Handige scripts > Land dmv IP

Land dmv IP

Auteur: XenoX - 24 december 2004 - 17:11 - Gekeurd door: Dennisvb - Hits: 10212 - Aantal punten: 4.68 (14 stemmen)




Met deze functie kan je het land ophalen met een ip adres.

Zo kan je het land van bezoekers ophalen.

Code:
  1. <?php
  2. $landen = array (
  3. "ad" => "Andorra",
  4. "ae" => "United Arab Emirates",
  5. "af" => "Afghanistan",
  6. "ag" => "Antigua en Barbuda",
  7. "ai" => "Anguilla",
  8. "al" => "Albania",
  9. "am" => "Armenië",
  10. "an" => "Nederlands Antille",
  11. "ao" => "Angola",
  12. "aq" => "Antartica",
  13. "ar" => "Argentinië",
  14. "as" => "American Samoa",
  15. "at" => "Austria",
  16. "au" => "Australië",
  17. "aw" => "Aruba",
  18. "az" => "Azerbaijan",
  19. "ba" => "Bosnia Herzegovina",
  20. "bb" => "Barbados",
  21. "bd" => "Bangladesh",
  22. "be" => "België",
  23. "bf" => "Burkina Faso",
  24. "bg" => "Bulgarijë",
  25. "bh" => "Bahrain",
  26. "bi" => "Burundi",
  27. "bj" => "Benin",
  28. "bm" => "Bermuda",
  29. "bn" => "Brunei Darussalam",
  30. "bo" => "Bolivia",
  31. "br" => "Brazil",
  32. "bs" => "Bahamas",
  33. "bt" => "Bhutan",
  34. "bv" => "Bouvet Eilanden",
  35. "bw" => "Botswana",
  36. "by" => "Belarus",
  37. "bz" => "Belize",
  38. "ca" => "Canada",
  39. "cc" => "Cocos (Keeling) Islands",
  40. "cf" => "Central African Republic",
  41. "cg" => "Kongo",
  42. "ch" => "Zwitserland",
  43. "ci" => "Cote DIvoire",
  44. "ck" => "Cook Eilanden",
  45. "cl" => "Chile",
  46. "cm" => "Kameroen",
  47. "cn" => "China",
  48. "co" => "Colombië",
  49. "cr" => "Costa Rica",
  50. "cs" => "Czechoslovakia",
  51. "cu" => "Cuba",
  52. "cv" => "Cape Verde",
  53. "cx" => "Kerstmis Eilnaden",
  54. "cy" => "Cyprus",
  55. "cz" => "Czech Republic",
  56. "de" => "Duitsland",
  57. "dj" => "Djibouti",
  58. "dk" => "Denemarken",
  59. "dm" => "Dominica",
  60. "do" => "Dominicaanse Republiek",
  61. "dz" => "Algeria",
  62. "ec" => "Ecuador",
  63. "ee" => "Estonia",
  64. "eg" => "Egypte",
  65. "eh" => "West Sahara",
  66. "er" => "Eritrea",
  67. "es" => "Spanje",
  68. "et" => "Ethiopia",
  69. "fi" => "Finland",
  70. "fj" => "Fiji",
  71. "fk" => "Falkland Eilanden (Malvinas)",
  72. "fm" => "Micronesia",
  73. "fo" => "Faroe Eilanden",
  74. "fr" => "Frankrijk",
  75. "fx" => "Frankrijk (Metropolitan)",
  76. "ga" => "Gabon",
  77. "gb" => "Groot Britannië (UK)",
  78. "gd" => "Grenada",
  79. "ge" => "Georgië",
  80. "gf" => "Frans Guinea",
  81. "gh" => "Ghana",
  82. "gi" => "Gibraltar",
  83. "gl" => "Groenland",
  84. "gm" => "Gambia",
  85. "gn" => "Guinea",
  86. "gp" => "Guadeloupe",
  87. "gq" => "Equatorial Guinea",
  88. "gr" => "Griekenland",
  89. "gs" => "S. Georgia en S. Sandwich Eilanden",
  90. "gt" => "Guatemala",
  91. "gu" => "Guam",
  92. "gw" => "Guinea-Bissau",
  93. "gy" => "Guyana",
  94. "hk" => "Hong Kong",
  95. "hm" => "Heard en McDonald Eilanden",
  96. "hn" => "Honduras",
  97. "hr" => "Kroatië",
  98. "ht" => "Haiti",
  99. "hu" => "Hongarijë",
  100. "id" => "Indonesia",
  101. "ie" => "Ireland",
  102. "il" => "Israël",
  103. "in" => "India",
  104. "io" => "British Indian Ocean Territory",
  105. "iq" => "Irak",
  106. "ir" => "Iran",
  107. "is" => "Ijsland",
  108. "it" => "Italy",
  109. "jm" => "Jamaica",
  110. "jo" => "Jordanië",
  111. "jp" => "Japan",
  112. "ke" => "Kenya",
  113. "kg" => "Kyrgyzstan",
  114. "kh" => "Cambodia",
  115. "ki" => "Kiribati",
  116. "km" => "Comoros",
  117. "kn" => "Saint Kitts and Nevis",
  118. "kp" => "Noord Korea",
  119. "kr" => "Zuid Korea",
  120. "kw" => "Kuwait",
  121. "ky" => "Kaaiman Eilanden",
  122. "kz" => "Kazakhstan",
  123. "la" => "Laos",
  124. "lb" => "Libanon",
  125. "lc" => "Saint Lucia",
  126. "li" => "Liechtenstein",
  127. "lk" => "Sri Lanka",
  128. "lr" => "Liberia",
  129. "ls" => "Lesotho",
  130. "lt" => "Lithuania",
  131. "lu" => "Luxemburg",
  132. "lv" => "Latvia",
  133. "ly" => "Libya",
  134. "ma" => "Morocco",
  135. "mc" => "Monaco",
  136. "md" => "Moldova",
  137. "mg" => "Madagascar",
  138. "mh" => "Marshall Islands",
  139. "mk" => "Macedonia",
  140. "ml" => "Mali",
  141. "mm" => "Myanmar",
  142. "mn" => "Mongolia",
  143. "mo" => "Macau",
  144. "mp" => "Northern Mariana Eilanden",
  145. "mq" => "Martinique",
  146. "mr" => "Mauritania",
  147. "ms" => "Montserrat",
  148. "mt" => "Malta",
  149. "mu" => "Mauritius",
  150. "mv" => "Maldives",
  151. "mw" => "Malawi",
  152. "mx" => "Mexico",
  153. "my" => "Malaysia",
  154. "mz" => "Mozambique",
  155. "na" => "Namibia",
  156. "nc" => "New Caledonia",
  157. "ne" => "Niger",
  158. "nf" => "Norfolk Island",
  159. "ng" => "Nigeria",
  160. "ni" => "Nicaragua",
  161. "nl" => "Nederland",
  162. "no" => "Norway",
  163. "np" => "Nepal",
  164. "nr" => "Nauru",
  165. "nt" => "Neutral Zone",
  166. "nu" => "Niue",
  167. "nz" => "New Zealand (Aotearoa)",
  168. "om" => "Oman",
  169. "pa" => "Panama",
  170. "pe" => "Peru",
  171. "pf" => "French Polynesia",
  172. "pg" => "Papua New Guinea",
  173. "ph" => "Philippines",
  174. "pk" => "Pakistan",
  175. "pl" => "Poland",
  176. "pm" => "St. Pierre en Miquelon",
  177. "pn" => "Pitcairn",
  178. "pr" => "Puerto Rico",
  179. "pt" => "Portugal",
  180. "pw" => "Palau",
  181. "py" => "Paraguay",
  182. "qa" => "Qatar",
  183. "re" => "Reunion",
  184. "ro" => "Romenië",
  185. "ru" => "Rusland",
  186. "rw" => "Rwanda",
  187. "sa" => "Saudi Arabia",
  188. "sb" => "Salamon Eilanden",
  189. "sc" => "Seychelles",
  190. "sd" => "Sudan",
  191. "se" => "Sweden",
  192. "sg" => "Singapore",
  193. "sh" => "St. Helena",
  194. "si" => "Slovenia",
  195. "sj" => "Svalbard en Jan Mayen Eilanden",
  196. "sk" => "Slovaakse Republiek",
  197. "sl" => "Sierra Leone",
  198. "sm" => "San Marino",
  199. "sn" => "Senegal",
  200. "so" => "Somalia",
  201. "sr" => "Suriname",
  202. "st" => "Sao Tome en Principe",
  203. "su" => "USSR (Former)",
  204. "sv" => "El Salvador",
  205. "sy" => "Syria",
  206. "sz" => "Swaziland",
  207. "tc" => "Turkse en Caicos Eilanden",
  208. "td" => "Chad",
  209. "tf" => "Franse Zuidelijke Teretoriums",
  210. "tg" => "Togo",
  211. "th" => "Thailand",
  212. "tj" => "Tajikistan",
  213. "tk" => "Tokelau",
  214. "tm" => "Turkmenistan",
  215. "tn" => "Tunisia",
  216. "to" => "Tonga",
  217. "tp" => "Oost Timor",
  218. "tr" => "Turkeije",
  219. "tt" => "Trinidad and Tobago",
  220. "tv" => "Tuvalu",
  221. "tw" => "Taiwan",
  222. "tz" => "Tanzania",
  223. "ua" => "Ukraine",
  224. "ug" => "Uganda",
  225. "uk" => "Vereningde Staten",
  226. "um" => "US Minor Outlying Eilanden",
  227. "us" => "United States",
  228. "uy" => "Uruguay",
  229. "uz" => "Uzbekistan",
  230. "va" => "Vatican City State (Holy See)",
  231. "vc" => "Saint Vincent and the Grenadines",
  232. "ve" => "Venezuela",
  233. "vg" => "Virgin Islands (British)",
  234. "vi" => "Virgin Islands (US)",
  235. "vn" => "Vietnam",
  236. "vu" => "Vanuatu",
  237. "wf" => "Wallis and Futuna Islands",
  238. "ws" => "Samoa",
  239. "ye" => "Yemen",
  240. "yt" => "Mayotte",
  241. "yu" => "Yugoslavia",
  242. "za" => "South Africa",
  243. "zm" => "Zambia",
  244. "zr" => "Zaire",
  245. "zw" => "Zimbabwe",
  246. "com" => "US Commercieel",
  247. "edu" => "US Educatie",
  248. "gov" => "US Regering",
  249. "int" => "Internationaal",
  250. "mil" => "US Leger",
  251. "net" => "Netwerk",
  252. "org" => "Non-Profit Organizatien",
  253. "arpa" => "Old-Style Arpanet",
  254. "nato" => "NATO Field"
  255. );
  256.  
  257. function getCountry( $ip )
  258. {
  259. global $landen; // Landen array ophalen zodat we die kunne gebruiken
  260.  
  261. $host = gethostbyaddr( $ip ); // Host ophalen d.m.v. het ip adres
  262.  
  263. if( $host == $ip )
  264. {
  265. // De host is hetzelfde als het ip adres dus land is Onbekend
  266. return "Onbekend";
  267. }
  268.  
  269. $hostsplit = explode( ".", $host ); // Hak de host in stukjes op de punt
  270.  
  271. $ext = array_pop( $hostsplit ); // Pak het laatste item
  272.  
  273. if( IsSet( $landen[$ext] ) )
  274. {
  275. // Het land staat in de array
  276. $land = $landen[$ext];
  277. }
  278. else
  279. {
  280. // Het land staat niet in de array
  281. $land = "Onbekend";
  282. }
  283.  
  284. return $land; // Return het land
  285. }
  286.  
  287. echo getCountry( $_SERVER['REMOTE_ADDR'] );
  288. ?>
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (11)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.064s