|
|
|
@ -13,6 +13,33 @@ class Ip2location_db1_model extends CI_Model
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function get_country_by_ip($ip_address)
|
|
|
|
|
{
|
|
|
|
|
$sql = "
|
|
|
|
|
SELECT TOP 1 ipdb.country_code, ipdb.country_name
|
|
|
|
|
FROM ip2location_db1 ipdb
|
|
|
|
|
WHERE ? BETWEEN ipdb.ip_from AND ipdb.ip_to
|
|
|
|
|
";
|
|
|
|
|
$query = $this->INFO->query($sql, array($ip_address));
|
|
|
|
|
|
|
|
|
|
$country = array(
|
|
|
|
|
'country_code' => '',
|
|
|
|
|
'country_name' => ''
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ($query->num_rows() > 0) {
|
|
|
|
|
$row = $query->row();
|
|
|
|
|
$country = [
|
|
|
|
|
'ip_address' => $ip_address,
|
|
|
|
|
'country_code' => $row->country_code,
|
|
|
|
|
'country_name' => $row->country_name
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $country;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function get_country_code($ip_number)
|
|
|
|
|
{
|
|
|
|
|
$sql = "
|
|
|
|
|