- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
class geo extends db {
public function ip2Country($ip, $id=false)
{
$result=$this->doQuery("SELECT `eng`, `ID_parent`, `type`, `id` FROM cngeo_geo WHERE id=(
SELECT ID_geo FROM cngeo_ip WHERE IP_bi <= INET_ATON(?) ORDER BY IP_bi DESC LIMIT 1)", array('0' => array('s' => $ip)), array(0 => 'ID_parent', 1 => 'type', 2 => 'nac', 3 => 'id'));
if($result!=NULL)
{
while($result[0][2]!='c')
{
$result=$this->doQuery("SELECT `eng`, `ID_parent`, `type`, `id` FROM cngeo_geo WHERE `id`=?", array('0' => array('i' => $result[0][1])), array(0 => 'ID_parent', 1 => 'type', 2 => 'nac', 3 => 'id'));
if($result==NULL) break;
}
//echo $result[0][0];
if( $id )
return $result[0][3];
return $result[0][0];
}
}
}