{"id":574,"date":"2013-12-05T08:51:32","date_gmt":"2013-12-05T08:51:32","guid":{"rendered":"http:\/\/www.advancedwebhelp.com\/blog\/?p=574"},"modified":"2013-12-05T08:51:32","modified_gmt":"2013-12-05T08:51:32","slug":"finding-the-location-of-an-ip-address","status":"publish","type":"post","link":"https:\/\/www.advancedwebhelp.com\/blog\/2013\/finding-the-location-of-an-ip-address","title":{"rendered":"Finding the location of an IP Address"},"content":{"rendered":"<p>The following is a quick and simple way to find the general location of an IP Address.  This tool only locates the region the IP Address is located in, not the exact location of the visitor.  This identifies the location of the ISP that hosts the visitor.  However, this can be useful.<\/p>\n<p>[evalphp]<br \/>\n  function theLocation($user_ip) {<br \/>\n    $meta_tags =<br \/>\n        get_meta_tags(&#8216;http:\/\/www.geobytes.com\/IPLocator.htm?GetLocation&#038;template=php3.txt&#038;IPAddress=&#8217; . $user_ip) or die(&#8216;Error getting meta tags&#8217;);<br \/>\n    $city = $meta_tags[&#8216;city&#8217;];<br \/>\n    $state = $meta_tags[&#8216;regioncode&#8217;];<br \/>\n    $country = $meta_tags[&#8216;fips104&#8217;];<br \/>\n    $lat = $meta_tags[&#8216;latitude&#8217;];<br \/>\n    $lng = $meta_tags[&#8216;longitude&#8217;];<br \/>\n    return array($city, $state, $country, $lat, $lng ) ;<br \/>\n  }<br \/>\n  $visitor = $_SERVER[&#8220;REMOTE_ADDR&#8221;];<\/p>\n<p>  list($city, $state, $country, $lat, $lng) = theLocation($visitor) ;<\/p>\n<p>  echo &#8220;<\/p>\n<p style='padding: 30px ; border:1px solid black ; margin-bottom: 40px ;'> Your Info: &#8221; . $visitor . &#8221; &rArr; &#8221; . $city . &#8220;, &#8221; . $state . &#8220;, &#8221; . $country , &#8220;<\/p>\n<p>&#8221; ;<br \/>\n[\/evalphp]<\/p>\n<pre><code>\r\n\r\n    function theLocation($user_ip) {\r\n        &dollar;meta_tags = get_meta_tags(\r\n             'http:\/\/www.geobytes.com\/IPLocator.htm?\r\n             GetLocation&template=php3.txt&IPAddress=' . \r\n             &dollar;user_ip) or \r\n             die('Error getting meta tags');\r\n        &dollar;city = &dollar;meta_tags['city'];\r\n        &dollar;state = &dollar;meta_tags['regioncode'];\r\n        &dollar;country = &dollar;meta_tags['fips104'];\r\n        &dollar;lat = &dollar;meta_tags['latitude'];\r\n        &dollar;long = &dollar;meta_tags['longitude'];\r\n        return array(&dollar;city, &dollar;state, &dollar;country, &dollar;lat, &dollar;lng ) ;\r\n    }\r\n\r\n    &dollar;visitor = &dollar;_SERVER[\"REMOTE_ADDR\"];\r\n  \r\n    list(&dollar;city, &dollar;state, &dollar;country, &dollar;lat, &dollar;lng) = \r\n        theLocation(&dollar;visitor) ;\r\n    &#101;&#99;&#104;o \"&lt;p&gt;Your Info: \" . $visitor . \r\n            \" &amp;rArr; \" . &dollar;city . \", \" . \r\n            &dollar;state . \", \" . &dollar;country , \"&lt;\/p&gt;\" ;\r\n\r\n<\/code><\/pre>\n<div style=\"clear:both ;\"> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>The following is a quick and simple way to find the general location of an IP Address. This tool only locates the region the IP Address is located in, not the exact location of the visitor. This identifies the location of the ISP that hosts the visitor. However, this can be useful. [evalphp] function theLocation($user_ip) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-574","post","type-post","status-publish","format-standard","hentry","category-php"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/posts\/574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/comments?post=574"}],"version-history":[{"count":2,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/posts\/574\/revisions"}],"predecessor-version":[{"id":583,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/posts\/574\/revisions\/583"}],"wp:attachment":[{"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/media?parent=574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/categories?post=574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/tags?post=574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}