|
|
|
@ -24,6 +24,25 @@ class Index extends CI_Controller
|
|
|
|
|
echo json_encode($data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据 IP 判断是否是欧盟国家
|
|
|
|
|
* http://localhost:8003/index.php/apps/ip2location/index/is_eu_country?ip_address=159.8.126.74
|
|
|
|
|
*/
|
|
|
|
|
public function is_eu_country() {
|
|
|
|
|
$european_counties = array('Russia', 'Ukraine', 'France');
|
|
|
|
|
$ip_address = $this->input->get_post('ip_address');
|
|
|
|
|
if (empty($ip_address)) {
|
|
|
|
|
$ip_address = $this->input->ip_address();
|
|
|
|
|
}
|
|
|
|
|
$ip_number = $this->Dot2LongIP($ip_address);
|
|
|
|
|
$country_name = $this->Ip2location_db1_model->get_country_name($ip_number);
|
|
|
|
|
$is_eu_country = 'false';
|
|
|
|
|
if (in_array($country_name, $european_counties)) {
|
|
|
|
|
$is_eu_country = 'true';
|
|
|
|
|
}
|
|
|
|
|
echo json_encode($is_eu_country);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Dot2LongIP($IPaddr)
|
|
|
|
|
{
|
|
|
|
|
if ($IPaddr == "") {
|
|
|
|
|