{"id":281,"date":"2007-04-12T15:23:28","date_gmt":"2007-04-12T07:23:28","guid":{"rendered":"http:\/\/www.jason695.idv.tw:81\/wordpress\/?p=281"},"modified":"2016-08-04T13:41:55","modified_gmt":"2016-08-04T05:41:55","slug":"%e4%bd%bf%e7%94%a8-ip2nation-%e5%8f%96%e5%be%97-ip-%e4%bd%8d%e5%9d%80%e6%89%80%e5%9c%a8%e7%9a%84%e5%9c%8b%e5%ae%b6%e5%88%a5","status":"publish","type":"post","link":"https:\/\/jason695.why3s.tw\/wordpress\/2007\/04\/12\/%e4%bd%bf%e7%94%a8-ip2nation-%e5%8f%96%e5%be%97-ip-%e4%bd%8d%e5%9d%80%e6%89%80%e5%9c%a8%e7%9a%84%e5%9c%8b%e5%ae%b6%e5%88%a5\/","title":{"rendered":"\u4f7f\u7528 ip2nation \u53d6\u5f97 IP \u4f4d\u5740\u6240\u5728\u7684\u570b\u5bb6\u5225"},"content":{"rendered":"<p>http:\/\/www.neo.com.tw\/archives\/000980.html<\/p>\n<p><font size=\"2\">ip2nation \u5df2\u7d93\u628a IP \u6240\u5728\u7684\u570b\u5225\u6574\u7406\u6210 SQL \u8a9e\u6cd5\uff0c\u53ea\u8981\u4e0b\u8f09\u4e0b\u4f86\u653e\u9032\u8cc7\u6599\u5eab\u5373\u53ef:<br \/>\nhttp:\/\/www.ip2nation.com\/ip2nation\/Download<\/font><\/p>\n<p><font size=\"2\"><a name=\"more\"><\/a> <\/font><font size=\"2\"><br \/>\n(IP \u8cc7\u6599\u5eab\u6700\u5f8c\u66f4\u65b0\u65e5\u671f\u662f\u4e0a\u500b\u6708\uff0c\u61c9\u8a72\u6709\u5728\u6301\u7e8c\u66f4\u65b0)<\/font><\/p>\n<p><font size=\"2\">\u653e\u9032\u8cc7\u6599\u5eab\u4e4b\u5f8c\uff0c\u8981\u4f7f\u7528\u7684\u8a71\u5fc5\u9808\u628a IP \u8f49\u70ba\u6578\u5b57\u9032\u884c\u67e5\u8a62\uff0cip2nation \u6709\u63d0\u4f9b PHP \u7684\u7bc4\u4f8b:<\/font><\/p>\n<blockquote><p><font size=\"2\">$server   = &#8221;; \/\/ MySQL hostname<br \/>\n$username = &#8221;; \/\/ MySQL username<br \/>\n$password = &#8221;; \/\/ MySQL password<br \/>\n$dbname   = &#8221;; \/\/ MySQL db name<\/p>\n<p>$db = mysql_connect($server, $username, $password) or die(mysql_error());<br \/>\nmysql_select_db($dbname) or die(mysql_error());<\/p>\n<p>$sql = &#8216;SELECT c.country<br \/>\nFROM   ip2nationCountries c, ip2nation i<br \/>\nWHERE<br \/>\ni.ip &lt; <\/font><font color=\"red\">INET_ATON(&#8220;&#8216;.$_SERVER[&#8216;REMOTE_ADDR&#8217;].'&#8221;)<\/font><br \/>\nAND c.code = i.country<br \/>\nORDER BY i.ip DESC LIMIT 0,1&#8242;;<\/p>\n<p>list($countryName) = mysql_fetch_row(mysql_query($sql));<\/p>\n<p>\/\/ Output full country name<br \/>\necho $countryName;\t\t <\/p><\/blockquote>\n<p><font size=\"2\">\t (\u4f7f\u7528 MySQL \u7684 INET_ATON() \u51fd\u5f0f\u628a IP \u8f49\u70ba\u6578\u5b57)  <\/font><font size=\"2\">\u5982\u679c\u4e0d\u662f\u7528 MySQL \u5c31\u5fc5\u9808\u81ea\u884c\u505a IP \u8f49\u63db\u7684\u8a08\u7b97\uff0c\u8a08\u7b97\u7684\u65b9\u5f0f\u4ee5 261.230.14.128 \u70ba\u4f8b:<br \/>\n261\u00d7256<sup>3<\/sup> + 230\u00d7256<sup>2<\/sup> + 14\u00d7256 + 128 <\/font><\/p>\n<p><font size=\"2\">PHP \u7684\u8f49\u63db\u7bc4\u4f8b:<br \/>\n<\/font><\/p>\n<blockquote><p><font size=\"2\">$ip = split (&#8220;\\.&#8221;, &#8220;261.230.14.128&#8221;);<br \/>\necho $ip[3] + $ip[2]*256 + $ip[1]*256*256 + $ip[0]*256*256*256;<br \/>\n<\/font><\/p><\/blockquote>\n<p><font size=\"2\">ip2nation \u7db2\u5740:<br \/>\nhttp:\/\/www.ip2nation.com\/<\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/www.neo.com.tw\/archives\/000980.html ip2nation \u5df2\u7d93 &hellip; <a href=\"https:\/\/jason695.why3s.tw\/wordpress\/2007\/04\/12\/%e4%bd%bf%e7%94%a8-ip2nation-%e5%8f%96%e5%be%97-ip-%e4%bd%8d%e5%9d%80%e6%89%80%e5%9c%a8%e7%9a%84%e5%9c%8b%e5%ae%b6%e5%88%a5\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587 <span class=\"screen-reader-text\">\u4f7f\u7528 ip2nation \u53d6\u5f97 IP \u4f4d\u5740\u6240\u5728\u7684\u570b\u5bb6\u5225<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[29],"tags":[],"class_list":["post-281","post","type-post","status-publish","format-standard","hentry","category-29","no-featured-image"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/posts\/281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/comments?post=281"}],"version-history":[{"count":0,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/posts\/281\/revisions"}],"wp:attachment":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/media?parent=281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/categories?post=281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/tags?post=281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}