{"id":8582,"date":"2010-03-28T06:28:46","date_gmt":"2010-03-28T06:28:46","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/ip-to-country\/"},"modified":"2014-06-24T18:21:47","modified_gmt":"2014-06-24T18:21:47","slug":"ip-to-country","status":"publish","type":"plugin","link":"https:\/\/km.wordpress.org\/plugins\/ip-to-country\/","author":4883633,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"0.08","stable_tag":"0.08","tested":"3.0.5","requires":"2.8.0","requires_php":"","requires_plugins":"","header_name":"IP-to-Country","header_author":"Pepak","header_description":"","assets_banners_color":"","last_updated":"2014-06-24 18:21:47","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"http:\/\/www.pepak.net\/wordpress\/ip-to-country-plugin","header_author_uri":"http:\/\/www.pepak.net","rating":2,"author_block_rating":0,"active_installs":20,"downloads":6379,"num_ratings":1,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":"1","2":0,"3":"1","4":0,"5":0},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["0.01","0.02","0.03","0.04","0.05","0.06","0.08"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":"1538967","resolution":"1","location":"plugin"}},"screenshots":{"1":"Administrative options"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[3751,4124,3983,1493,37295],"plugin_category":[49],"plugin_contributors":[85666],"plugin_business_model":[],"class_list":["post-8582","plugin","type-plugin","status-publish","hentry","plugin_tags-country","plugin_tags-geolocation","plugin_tags-invisible","plugin_tags-ip","plugin_tags-ip-to-country","plugin_category-maps-and-location","plugin_contributors-pepak","plugin_committers-pepaknet"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/ip-to-country.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/ip-to-country\/trunk\/screenshot-1.png?rev=1538967","caption":"Administrative options"}],"raw_content":"<!--section=description-->\n<p>IP-to-Country is a plugin which doesn't provide any output to users, but which\nmay be used by plugin authors to quickly and easily find, in which country an\nIP address is located.<\/p>\n\n<p>To do so the plugin uses data files from either http:\/\/ip-to-country.webhosting.info\n(IPv4 only) or http:\/\/software77.net\/geo-ip\/ (both IPv4 and IPv6).\nOther sources are possible as long as they have the same format: CSV file, \nfields enclosed with quotes (\") and separated with comma (,), lines ending\nwith LF (\\n). Five columns:<\/p>\n\n<ul>\n<li>Lower bound of an IP range.<\/li>\n<li>Upper bound of an IP range. Both are represented as one 32-bit integer number,\nsuch as you can get by using funtion ip2long().<\/li>\n<li>2-character country code<\/li>\n<li>3-character country code<\/li>\n<li>Country name<\/li>\n<\/ul>\n\n<p>Note: In order to import IPv6 addresses, IPv4 must be imported first. The \nreason is, IPv6 database does not carry the full country information with\nit, while the IPv4 database does.<\/p>\n\n<p>Operations:<\/p>\n\n<ul>\n<li><p>To detect if IP-to-Country plugin is installed:<\/p>\n\n<p>$ip2c_available = class_exists('PepakIpToCountry');<\/p><\/li>\n<li><p>To find information about a numeric IP address:<\/p>\n\n<p>$country = PepakIpToCountry::IP_to_Country_Full('8.8.8.8');\n    \/\/ returns 'UNITED STATES'\n    $country = PepakIpToCountry::IP_to_Country('8.8.8.8');\n    $country = PepakIpToCountry::IP_to_Country_XX('8.8.8.8');\n    \/\/ both return 'US'\n    $country = PepakIpToCountry::IP_to_Country_XXX('8.8.8.8');\n    \/\/ returns 'USA'\n    $country = PepakIpToCountry::IP_to_Country_Info('8.8.8.8');\n    \/\/ returns Array('iso_name'=&gt;'UNITED STATES', 'iso_code2'=&gt;'US', 'iso_code3'=&gt;'USA')\n$image = PepakIpToCountry::IP_to_Country_Flag('8.8.8.8');\n\/\/ returns ''<\/p>\n\n<p>You may leave the IP address empty; in that case, IP address of currently\nactive user is used instead.<\/p>\n\n<p>Note: All requests are cached, so there shouldn't be a noticeable difference\nbetween reading IP_to_Country_Info and reading all three pieces of information\nseparately using the _Full, _XX and _XXX functions.<\/p><\/li>\n<li><p>To interface your plugin's tables to IP-to-Country plugin's tables within SQL, \na function <code>Subselect<\/code> is published:<\/p>\n\n<p>$subselect = PepakIpToCountry::Subselect($ip, $countryfield);<\/p>\n\n<ul>\n<li><code>$ip<\/code> is a field that contains IP address in the form of one 32bit number, e.g.<\/li>\n<\/ul>\n\n<ol>\n<li>If you store IP addresses in the usual form of four dot-separated\nnumbers ('127.0.0.1'), you can use MySQL's function INET_ATON:\n$ip = 'INET_ATON(my_ip_address_field)';\nIt is strongly recommended to use qualified field names (with tablename in\nfront, separated by a dot):\n$ip = 'INET_ATON(banlist.ip_address)';<\/li>\n<\/ol>\n\n<ul>\n<li><code>$countryfield<\/code> is the field you want returned. It can be one of the following:\niso_name - returns the same string as PepakIpToCountry::IP_to_Country_Full(...)\niso_code2 - returns the same string as PepakIpToCountry::IP_to_Country_XX(...)\niso_code3 - returns the same string as PepakIpToCountry::IP_to_Country_XX(...)<\/li>\n<\/ul>\n\n<p>Note: No checking or validation is done on either of these parameters. It is assumed\nthey are <em>field names<\/em>, <strong>NOT<\/strong> strings. DO NOT EVER USE VALUES THAT YOUR USERS CAN\nINFLUENCE! This is important! If you let users supply arguments to Subselect(), you\nare letting them to do whatever they like with your database!<\/p>\n\n<p>This function only works with IPv4 addresses.<\/p>\n\n<p>Example usage:<\/p>\n\n<p>if (class_exists('PepakIpToCountry'))\n      $field = PepakIpToCountry(\"INET_ATON(b.ip_addr)\", 'iso_code2');\n    else\n      $field = 'NULL';\n    $sql = \"SELECT b.*, ${field} country_code FROM ${wpdb-&gt;prefix}banlist b WHERE ...\";<\/p><\/li>\n<\/ul>\n\n<p>Note: This plugin <em>requires<\/em> PHP5. If you want it to work with ZIP files\n(e.g. for updating IP-country info from the default location), your PHP\nmust have extension php_zip enabled.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Create a subdirectory in your '\/wp-content\/plugins\/' directory and extract the plugin\nthere. The plugin subdirectory can be anything you like - I use 'ip-to-country', but \nthe plugin should accept any name.<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress.<\/li>\n<li>You will see a 'IP-to-Country' item in your 'Settings' menu. It lets you choose\nthe source of IP-country info and update the database with it. Please do so, as the\nnecessary tables start empty after installation.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt>I am having some problem with this plugin. Where can I get help?<\/dt>\n<dd><p>On my webpage I have a support forum http:\/\/forum.pepak.net with english section\nwhere you can ask. At the time of writing, the forum is open for everybody without\nregistration.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>0.08<\/h4>\n\n<ul>\n<li>Ukrainian translation by Michael Yunat.<\/li>\n<\/ul>\n\n<h4>0.07<\/h4>\n\n<ul>\n<li>Updated the Serbo-Croatian translation.<\/li>\n<\/ul>\n\n<h4>0.06<\/h4>\n\n<ul>\n<li>Serbo-Croatian translation by Andrijana Nikolic.<\/li>\n<li>Fixed warnings in WordPress 3.5 and newer.<\/li>\n<\/ul>\n\n<h4>0.05<\/h4>\n\n<ul>\n<li>Romanian translation by Alexander Ovsov.<\/li>\n<\/ul>\n\n<h4>0.04<\/h4>\n\n<ul>\n<li>Country name was added to atribute TITLE (until now it only appeared in ALT).<\/li>\n<\/ul>\n\n<h4>0.03<\/h4>\n\n<ul>\n<li>Fixed a bug with some IPv4 addresses (signed vs. unsigned numbers), as \nreported by Andrea.<\/li>\n<li>Added method IP_to_Country_Flag which returns an '' tag suitable for\ndisplaying a small country flag. Icons come from http:\/\/www.famfamfam.com.<\/li>\n<li>Support for IPv6, using data from http:\/\/software77.net\/geo-ip\/.<\/li>\n<\/ul>\n\n<h4>0.02<\/h4>\n\n<ul>\n<li>Added error reporting for imports.<\/li>\n<li>Removed memory-intensive preg_match_all and replaced with strpos\/substr.<\/li>\n<\/ul>\n\n<h4>0.01<\/h4>\n\n<ul>\n<li>Initial version.<\/li>\n<\/ul>","raw_excerpt":"Provide a simple interface for plugin authors to determine, in which country an IP is located.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/8582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=8582"}],"author":[{"embeddable":true,"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/pepaknet"}],"wp:attachment":[{"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=8582"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=8582"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=8582"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=8582"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=8582"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/km.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=8582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}