'conditions' => array(
'startIpNum <=' => $address,
'endIpNum >=' => $address),
'limit' => 1,
On Wednesday, 18 December 2013 05:22:22 UTC+10, advantage+ wrote:
Was hoping someone can point out where I am going wrong here.
Just testing so code is rather sloppy.
Related to GeoIP City / Country Location. (data is in my database, not a web call)
$address = $this->my_ip2long($_SERVER['RE
MOTE_ADDR ']);
Calls this:
private function my_ip2long($ip){
$nums = explode('.', $ip);
$ret = 0;
for ($i=0; $i<4; $i++){
$ret += intval($nums[$i]) * pow(256, 3-$i);
}
return $ret;
}
So $address = (int) 2393010516So far so good.$current_address = ClassRegistry::init('IpCountry' )->__findUserCountry();Produces:array('IpCountry' => array('id' => '38959', 'ip_from' => '2391343104', 'ip_to' => '2394947583', 'country2' => 'CA', 'country3' => 'CAN', 'country' => 'CANADA' Which is correct I am in Canada.So I put that function inside __FindUserCountry(); all good so far.Then$location = ClassRegistry::init('GeoCityBl
ock ')->find('first', array(
'conditions' => array(
'and' => array(
array(
'startIpNum <' => $address,
'endIpNum >' => $address))),
'limit' => 1,
'contain' => array( 'GeoCityLocation'))); And presto time travel :0 I am now in Seoul Korea.array('GeoCityBlock' => array('startIpNum' => '23068672', 'endIpNum' => '24117247', 'locId' => '22883' ),'GeoCityLocation' => array((int) 0 => array( 'locId' => '22883', 'country' => 'KR', 'region' => '11', 'city' => 'Seoul', 'postalCode' => '', 'latitude' => '37.5985', 'longitude' => '126.9783', 'metroCode' => '', 'areaCode' => '' ) )Anyone have any assistance they could provide would be great.Thanks,Dave
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment