2 /* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
3 and is published under the AGPL license. */
5 class Syj_Controller_Action_Helper_SyjGeoip extends Zend_Controller_Action_Helper_Abstract
8 public function direct ($ip) {
9 $db = Zend_Db_Table_Abstract::getDefaultAdapter();
10 $select = $db->select(null)->from('geoip', null)->where('geoip.begin_ip <= inet_to_bigint(?)', (string)$ip)
11 ->where('geoip.end_ip >= inet_to_bigint(?)', (string)$ip)
13 ->join('geonames', 'geonames.country = geoip.country', array(
14 'geonames.minlon', 'geonames.minlat', 'geonames.maxlon', 'geonames.maxlat'
17 $stmt = $db->query($select);
18 $row = $db->query($select)->fetch();
19 } catch (Exception $e) {
23 $row = Zend_Controller_Front::getInstance()->getParam('defaultloc');
25 return array_map(function($elem) { return (float)$elem;},$row);