前言介紹
- 這款 WordPress 外掛「IP-to-Country」是 2010-03-27 上架。
- 目前有 30 個安裝啟用數。
- 上一次更新是 2014-06-24,距離現在已有 3966 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 2.8.0 以上版本才可以安裝。
- 有 1 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
pepak |
外掛標籤
ip | country | invisible | geolocation | ip to country |
內容簡介
提供用於查找 IP 地址所屬國家的 IP-to-Country WordPress 外掛,並不會向使用者提供任何輸出,但其他外掛作者可以使用此外掛快速且輕鬆地查找 IP 地址所屬國家。該外掛使用從 http://ip-to-country.webhosting.info(IPv4 only) 或 http://software77.net/geo-ip/(支援 IPv4 和 IPv6)等數據文件。只要它們具有相同格式:CSV 文件,採用雙引號 "" 標記字段,並使用逗號分隔項目、以 LF (\n) 結尾的行數,即可使用其他數據源。文件包含五列:
- IP 範圍的下界。
- IP 範圍的上界。兩者都表示為一個 32 位整數,可以使用 ip2long() 函數獲取。
- 2 個字母的國家代碼。
- 3 個字母的國家代碼。
- 國家名稱。
注意:為了匯入 IPv6 地址,必須先匯入 IPv4。原因是,IPv6 數據庫不携帶完整的國家信息,而 IPv4 數據庫則携帶。
操作如下:
- 要檢查是否安裝了 IP-to-Country 外掛:$ip2c_available = class_exists('PepakIpToCountry');
- 要查找有關數字 IP 地址的信息:
$country = PepakIpToCountry::IP_to_Country_Full('8.8.8.8'); // 返回 "UNITED STATES"
$country = PepakIpToCountry::IP_to_Country('8.8.8.8');
// 返回 "US"
$country = PepakIpToCountry::IP_to_Country_XX('8.8.8.8'); // 返回 "US"
$country = PepakIpToCountry::IP_to_Country_XXX('8.8.8.8'); // 返回 "USA"
$country = PepakIpToCountry::IP_to_Country_Info('8.8.8.8'); // 返回 Array('iso_name'=>'UNITED STATES', 'iso_code2'=>'US', 'iso_code3'=>'USA')
$image = PepakIpToCountry::IP_to_Country_Flag('8.8.8.8');
您可以將 IP 地址留空,此時將使用當前活躍用戶的 IP 地址。請注意:所有請求都被緩存,因此在讀取 IP_to_Country_Info 和使用 Full、XX 和 XXX 函数各自依次讀取三個信息之間,不應該有明顯的區別。
- 要在 SQL 中將您的插件表和 IP-to-Country 插件表進行接口:
提供了一個 "Subselect" 函數:
$subselect = PepakIpToCountry::Subselect($ip, $countryfield);
其中:
- $ip 是一個包含 IP 地址的字段,形式為一個 32 位數字。
- 如果您以四個用點分隔的數字('127.0.0.1')的方式儲存 IP 地址,可以使用 MySQL 的 INET_ATON 函數。
- 建議使用限定字 (加上表名,用點號分隔):$ip = 'INET_ATON(banlist.ip_address)';
- $countryfield 為您想要返回的字段之一:
- iso_name ─ 返回與PepakIpToCountry:: IP_to_Country_Full(...)相同的字符串。
- iso_code2 ─ 返回與PepakIpToCountry:: IP_to_Country_XX(...)相同的字符串。
- iso_code3 ─ 返回與PepakIpToCountry:: IP_to_Country_XX(...)相同的字符串。
注意:不進行檢查或驗證。
原文外掛簡介
IP-to-Country is a plugin which doesn’t provide any output to users, but which
may be used by plugin authors to quickly and easily find, in which country an
IP address is located.
To do so the plugin uses data files from either http://ip-to-country.webhosting.info
(IPv4 only) or http://software77.net/geo-ip/ (both IPv4 and IPv6).
Other sources are possible as long as they have the same format: CSV file,
fields enclosed with quotes (“) and separated with comma (,), lines ending
with LF (\n). Five columns:
Lower bound of an IP range.
Upper bound of an IP range. Both are represented as one 32-bit integer number,
such as you can get by using funtion ip2long().
2-character country code
3-character country code
Country name
Note: In order to import IPv6 addresses, IPv4 must be imported first. The
reason is, IPv6 database does not carry the full country information with
it, while the IPv4 database does.
Operations:
To detect if IP-to-Country plugin is installed:
$ip2c_available = class_exists(‘PepakIpToCountry’);
To find information about a numeric IP address:
$country = PepakIpToCountry::IP_to_Country_Full(‘8.8.8.8’);
// returns ‘UNITED STATES’
$country = PepakIpToCountry::IP_to_Country(‘8.8.8.8’);
$country = PepakIpToCountry::IP_to_Country_XX(‘8.8.8.8’);
// both return ‘US’
$country = PepakIpToCountry::IP_to_Country_XXX(‘8.8.8.8’);
// returns ‘USA’
$country = PepakIpToCountry::IP_to_Country_Info(‘8.8.8.8’);
// returns Array(‘iso_name’=>’UNITED STATES’, ‘iso_code2’=>’US’, ‘iso_code3’=>’USA’)
$image = PepakIpToCountry::IP_to_Country_Flag(‘8.8.8.8’);
// returns ”
You may leave the IP address empty; in that case, IP address of currently
active user is used instead.
Note: All requests are cached, so there shouldn’t be a noticeable difference
between reading IP_to_Country_Info and reading all three pieces of information
separately using the _Full, _XX and _XXX functions.
To interface your plugin’s tables to IP-to-Country plugin’s tables within SQL,
a function Subselect is published:
$subselect = PepakIpToCountry::Subselect($ip, $countryfield);
$ip is a field that contains IP address in the form of one 32bit number, e.g.
If you store IP addresses in the usual form of four dot-separated
numbers (‘127.0.0.1’), you can use MySQL’s function INET_ATON:
$ip = ‘INET_ATON(my_ip_address_field)’;
It is strongly recommended to use qualified field names (with tablename in
front, separated by a dot):
$ip = ‘INET_ATON(banlist.ip_address)’;
$countryfield is the field you want returned. It can be one of the following:
iso_name – returns the same string as PepakIpToCountry::IP_to_Country_Full(…)
iso_code2 – returns the same string as PepakIpToCountry::IP_to_Country_XX(…)
iso_code3 – returns the same string as PepakIpToCountry::IP_to_Country_XX(…)
Note: No checking or validation is done on either of these parameters. It is assumed
they are field names, NOT strings. DO NOT EVER USE VALUES THAT YOUR USERS CAN
INFLUENCE! This is important! If you let users supply arguments to Subselect(), you
are letting them to do whatever they like with your database!
This function only works with IPv4 addresses.
Example usage:
if (class_exists(‘PepakIpToCountry’))
$field = PepakIpToCountry(“INET_ATON(b.ip_addr)”, ‘iso_code2’);
else
$field = ‘NULL’;
$sql = “SELECT b.*, ${field} country_code FROM ${wpdb->prefix}banlist b WHERE …”;
Note: This plugin requires PHP5. If you want it to work with ZIP files
(e.g. for updating IP-country info from the default location), your PHP
must have extension php_zip enabled.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「IP-to-Country」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
0.01 | 0.02 | 0.03 | 0.04 | 0.05 | 0.06 | 0.08 | trunk |
延伸相關外掛(你可能也想知道)
IP Location Block 》ip位置封鎖外掛能夠根據訪問者的位置封鎖訪問,同時保護你的網站免於惡意攻擊。該外掛提供智能而強大的保護方法,稱為「WP零日漏洞預防」和「WP元數據漏洞保...。
Country Based Payments for WooCommerce 》這款外掛可以讓您選擇哪些付款閘道應該在特定國家或多個國家中提供。, 如果您需要將某些付款閘道提供給所有國家,請不要設置相關選項。, 此 WooCommerce 外掛...。
Admin Block Country 》這是一個易於使用的外掛程序,可通過國家地區屏蔽您的 WordPress 管理區。它使用 geoip-api-php 作為庫,以確定訪問者的國家。。
SVG Flags – Beautiful Scalable Flags For All Countries! 》SVG Flags of the world 可以讓您在幾秒內在WordPress網站上添加高質量的美麗旗幟。您可以以任何比例顯示一個或多個旗幟,而不會失去品質並且具有固定的長寬...。
Product Visibility by Country for WooCommerce 》「Product Visibility by Country for WooCommerce」外掛可讓你依據客戶的國家,決定是否顯示/隱藏 WooCommerce 的商品。外掛會自動透過 IP偵測客戶所在地。,...。
Polylang – Country Detection 》Polylang 多語言外掛是一個完美的 WordPress 插件。使用 Polylang 擴展可以根據訪問者國家來偵測其首選語言。, 如果您的網站使用相同語言但不同區域 (例如德...。
IP Locator 》定位器是 WordPress 的國家和語言檢測工具。它快速、可靠且即插即用。, 它可以檢測和呈現每位訪客的國家、主要語言和國旗。它提供:, , 強大、準確和超快速的...。
country-redirect 》這個外掛對於像 Alfa Romeo、Bosch、Biir 和 Siemens 這樣的公司和擁有不同網站的部落格(針對來自不同國家的非登入訪客)非常有用。, 它在 WordPress 的管理...。
Advanced Country Blocker 》總結:Advanced Country Blocker 外掛能夠透過依據訪客的地理位置(國家)或IP位址來限制存取,進而幫助您加強 WordPress 網站的安全性。提供多項功能,包括自...。
WooCommerce Sales by Country 》WooCommerce Sales by Country 是一個外掛,可以添加一個報告頁面,顯示特定國家的產品銷售報告。這個外掛還帶有一個額外的報告頁面,讓您可以按國家顯示銷售...。
WooCommerce Country Based Bank Accounts 》這是一個 WooCommerce 擴充套件,允許您將 BACS(直接銀行轉帳)銀行帳戶分配給不同的國家。根據選擇的帳單國家,只有相應的銀行帳戶才會顯示在「感謝您」頁...。
Country Caching For WP Super Cache 》由於個人情況,我無法再開發或支援此外掛。如果您有興趣接手此外掛,請參閱 https://developer.wordpress.org/plugins/wordpress-org/take-over-an-existing-...。
Category Country Aware WordPress 》由於個人原因,我不能再繼續開發或支援此外掛。如果您有興趣接手此外掛,請參閱 https://developer.wordpress.org/plugins/wordpress-org/take-over-an-exist...。
ACF City Selector 》ACF城市選擇器是進階自訂欄位外掛Advanced Custom Fields的擴充套件,它會新增一個欄位,讓你可以選擇城市,依據所在的國家和省份/州。, 新增欄位, 3個下拉式...。
WP Country 》使用 WP Country 外掛程式在你的佈景主題或插件中,請在你的佈景主題或插件 PHP 檔中添加 global $wp_country;,, 然後:, , , $wp_country->countries_li...。