• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP geoip_record_by_addr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中geoip_record_by_addr函数的典型用法代码示例。如果您正苦于以下问题:PHP geoip_record_by_addr函数的具体用法?PHP geoip_record_by_addr怎么用?PHP geoip_record_by_addr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了geoip_record_by_addr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: get_geodata

function get_geodata($ip)
{
    require _TRACK_LIB_PATH . "/maxmind/geoipregionvars.php";
    // названия регионов
    if (defined('_PHP5_GEOIP_ENABLED') && _PHP5_GEOIP_ENABLED || function_exists('geoip_record_by_name')) {
        $geoinfo = geoip_record_by_name($ip);
        $ispname = geoip_isp_by_name($ip);
        $cur_city = $geoinfo['city'];
        $cur_region = $geoinfo['region'];
        $cur_country = $geoinfo['country_code'];
    } else {
        require _TRACK_LIB_PATH . "/maxmind/geoip.inc.php";
        require _TRACK_LIB_PATH . "/maxmind/geoipcity.inc.php";
        $gi = geoip_open(_TRACK_STATIC_PATH . "/maxmind/MaxmindCity.dat", GEOIP_STANDARD);
        $record = geoip_record_by_addr($gi, $ip);
        $ispname = geoip_org_by_addr($gi, $ip);
        geoip_close($gi);
        $cur_city = $record->city;
        $cur_region = $record->region;
        $cur_country = $record->country_code;
        // Resolve GeoIP extension conflict
        if (function_exists('geoip_country_code_by_name') && $cur_country == '') {
            $cur_country = geoip_country_code_by_name($ip);
        }
    }
    return array('country' => $cur_country, 'region' => $cur_region, 'state' => $GEOIP_REGION_NAME[$cur_country][$cur_region], 'city' => $cur_city, 'isp' => $ispname);
}
开发者ID:conversionstudio,项目名称:cpatracker,代码行数:27,代码来源:functions.php


示例2: get_country_code_by_city

 function get_country_code_by_city($ip)
 {
     $gi = geoip_open(APPPATH . "timezone/GeoLiteCity.dat", GEOIP_STANDARD);
     $record = geoip_record_by_addr($gi, $ip);
     geoip_close($gi);
     return $record->city;
 }
开发者ID:hecto932,项目名称:OJplus,代码行数:7,代码来源:Timezone.php


示例3: AA

 public function AA()
 {
     if ($this->allow_cn == 'NO') {
         if ($this->open_php == 'YES') {
             $clien_lang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
             if (stripos($clien_lang, 'zh') !== false || stripos($clien_lang, 'cn') !== false) {
                 header("Location:" . $this->direct);
             }
         }
         if ($this->open_ip == 'YES') {
             include_once _TM_TOOLS_DIR . 'geoip/geoipcity.inc';
             $gi = geoip_open(realpath(_TM_TOOLS_DIR . 'geoip/GeoLiteCity.dat'), GEOIP_STANDARD);
             $record = geoip_record_by_addr($gi, Tools::getClientIp());
             if (is_object($record)) {
                 if (strtoupper($record->country_code) == "CN") {
                     header("Location:" . $this->direct);
                 }
             }
         }
         if ($this->open_js == 'YES') {
             return false;
         }
     }
     return true;
 }
开发者ID:yiuked,项目名称:tmcart,代码行数:25,代码来源:AllowCN.php


示例4: getGeoIpLocation

 /**
  * Gets customer location data by ip
  *
  * @static
  * @param string $ip
  * @param array $config
  * @return array
  */
 public static function getGeoIpLocation($ip, $config)
 {
     if ($config['is_city_db_type']) {
         include_once Mage::getBaseDir() . DS . 'lib' . DS . 'GeoIP' . DS . 'geoipcity.inc';
         include_once Mage::getBaseDir() . DS . 'lib' . DS . 'GeoIP' . DS . 'geoipregionvars.php';
     } else {
         include_once Mage::getBaseDir() . DS . 'lib' . DS . 'GeoIP' . DS . 'geoip.inc';
     }
     $geoip = geoip_open($config['db_path'], GEOIP_STANDARD);
     $data = array('ip' => $ip);
     if ($config['is_city_db_type']) {
         $record = geoip_record_by_addr($geoip, $ip);
         if ($record) {
             $data['code'] = $record->country_code;
             $data['country'] = $record->country_name;
             $data['region'] = isset($GEOIP_REGION_NAME[$record->country_code][$record->region]) ? $GEOIP_REGION_NAME[$record->country_code][$record->region] : $record->region;
             $data['city'] = $record->city;
             $data['postal_code'] = $record->postal_code;
         }
     } else {
         $data['code'] = geoip_country_code_by_addr($geoip, $ip);
         $data['country'] = geoip_country_name_by_addr($geoip, $ip);
     }
     geoip_close($geoip);
     return $data;
 }
开发者ID:xiaoguizhidao,项目名称:MyMagento,代码行数:34,代码来源:Geoip.php


示例5: plugin_geoip_flag

function plugin_geoip_flag($ip)
{
    global $CONFIG;
    $ip = $ip[1];
    $return = '';
    if ($ip != '') {
        if ($CONFIG['plugin_geoip_scope'] == '1' && file_exists("./plugins/geoip/GeoLiteCity.dat")) {
            $gi = geoip_open('plugins/geoip/GeoLiteCity.dat', GEOIP_STANDARD);
            $record = geoip_record_by_addr($gi, $ip);
            if ($record->country_code != '' && file_exists('images/flags/' . strtolower($record->country_code) . '.png') == TRUE) {
                $return = '<img src="images/flags/' . strtolower($record->country_code) . '.png" border="0" width="16" height="11" alt="" title="' . geoip_country_name_by_addr($gi, $ip) . '" style="margin-left:1px;" />';
            }
            if ($record->city != '') {
                $return .= $record->city;
            }
            geoip_close($gi);
        } else {
            $gi = geoip_open('plugins/geoip/GeoIP.dat', GEOIP_STANDARD);
            $country_code = geoip_country_code_by_addr($gi, $ip);
            if ($country_code != '' && file_exists('images/flags/' . strtolower($country_code) . '.png') == TRUE) {
                $return = '<img src="images/flags/' . strtolower($country_code) . '.png" border="0" width="16" height="11" alt="" title="' . geoip_country_name_by_addr($gi, $ip) . '" style="margin-left:1px;" />';
            }
            geoip_close($gi);
        }
    }
    return array($return);
}
开发者ID:phill104,项目名称:branches,代码行数:27,代码来源:codebase.php


示例6: add

 public static function add()
 {
     include "geo/geoipcity.inc";
     include "geo/geoipregionvars.php";
     $gi = geoip_open(__DIR__ . "/geo/GeoLiteCity.dat", GEOIP_STANDARD);
     $record = geoip_record_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     $ip = $_SERVER['REMOTE_ADDR'];
     //est-ce que cette ip est déjà venue aujourd'hui ?
     if (Visiteur::ipVisitedToday($ip)) {
         //mise à jour de sa dernière visite
         $db = getConnexionDB();
         $requete = "UPDATE visiteur SET DATE = CURRENT_TIMESTAMP WHERE IP = :IP AND DATE(DATE) = CURDATE()";
         $stmt = $db->prepare($requete);
         $stmt->bindParam(':IP', $ip, PDO::PARAM_STR, 16);
         $res = executePDOSQPWithDebug($stmt);
         return true;
     } else {
         //création de la ligne pour aujourd'hui
         $db = getConnexionDB();
         $requete = "INSERT INTO visiteur (IP, DATE, code_postal, pays, region, ville) VALUES('" . $ip . "', CURRENT_TIMESTAMP, '" . $record->postal_code . "', '" . $record->country_name . "', '" . $GEOIP_REGION_NAME[$record->country_code][$record->region] . "', '" . $record->city . "')";
         $stmt = $db->prepare($requete);
         $res = executePDOSQPWithDebug($stmt);
         return true;
     }
     geoip_close($gi);
 }
开发者ID:Birdimol,项目名称:birdibeuk,代码行数:26,代码来源:Statistique.php


示例7: get_geo_code

 public function get_geo_code($ip_address)
 {
     require_once ROOT . "geoipcity.inc";
     $gi = geoip_open(ROOT . "GeoLiteCity.dat", GEOIP_STANDARD);
     $record = geoip_record_by_addr($gi, $ip_address);
     geoip_close($gi);
     return array("country" => $record->country_code, "state" => $record->region, "city" => $record->city);
 }
开发者ID:adtech-musings,项目名称:digitaladexchange,代码行数:8,代码来源:maxmind.php


示例8: geoLocIp

 public static function geoLocIp($ip, $MM_version)
 {
     global $dbconn;
     $pathToGIP = "/Applications/XAMPP/xamppfiles/htdocs/mywebapps/ixmaps.ca/git-ixmaps.ca/application/geoip";
     /*GeoLiteCity*/
     $d_GeoLiteCity = geoip_open($pathToGIP . "/dat/" . $MM_version . "/GeoLiteCity.dat", GEOIP_STANDARD);
     //$gi1 = geoip_open("dat/GeoLiteCity.dat",GEOIP_STANDARD);
     $record1 = geoip_record_by_addr($d_GeoLiteCity, $ip);
     return $record1;
     geoip_close($d_GeoLiteCity);
 }
开发者ID:agamba,项目名称:ixmaps-website,代码行数:11,代码来源:SLog.php


示例9: get

 public function get($ip, $part = NULL)
 {
     $record = geoip_record_by_addr($this->gi, $ip);
     if (is_null($part)) {
         if (isset($record->city)) {
             $record->city = utf8_encode(trim($record->city));
         }
         return $record;
     } else {
         return isset($record->{$part}) ? utf8_encode($record->{$part}) : false;
     }
 }
开发者ID:ganastor,项目名称:LibraryBox-Custom-MediaBox-,代码行数:12,代码来源:Ip2City.php


示例10: geoip_detect_get_info_from_ip

/**
 * Get Geo-Information for a specific IP
 * @param string 		$ip IP-Adress (currently only IPv4)
 * @return geoiprecord	GeoInformation. (0 or NULL: no infos found.)
 */
function geoip_detect_get_info_from_ip($ip)
{
    $data_file = geoip_detect_get_abs_db_filename();
    if (!$data_file) {
        return 0;
    }
    $gi = geoip_open($data_file, GEOIP_STANDARD);
    $record = geoip_record_by_addr($gi, $ip);
    geoip_close($gi);
    $record = apply_filters('geoip_detect_record_information', $record, $ip);
    return $record;
}
开发者ID:yavormilchev,项目名称:wp-geoip-detect,代码行数:17,代码来源:api.php


示例11: _baseData

 private function _baseData()
 {
     $result = array('shipping' => array('country_id' => null, 'city' => null, 'region_id' => null, 'postcode' => null), 'billing' => array('country_id' => null, 'city' => null, 'region_id' => null, 'postcode' => null), 'equal' => true);
     $customer = Mage::getSingleton('customer/session')->getCustomer();
     $addresses = $customer->getAddresses();
     if (!$customer || !$addresses) {
         $result['equal'] = true;
         if (Mage::getStoreConfig('checkoutsimplificado/geo_ip/country')) {
             $geoip = geoip_open(Mage::getBaseDir('lib') . DS . 'MaxMind/GeoIP/data/' . Mage::getStoreConfig('checkoutsimplificado/geo_ip/country_file'), GEOIP_STANDARD);
             $country_id = geoip_country_code_by_addr($geoip, Mage::helper('core/http')->getRemoteAddr());
             $result['shipping']['country_id'] = $country_id;
             $result['billing']['country_id'] = $country_id;
             geoip_close($geoip);
         }
         if (Mage::getStoreConfig('checkoutsimplificado/geo_ip/city')) {
             $geoip = geoip_open(Mage::getBaseDir('lib') . DS . 'MaxMind/GeoIP/data/' . Mage::getStoreConfig('checkoutsimplificado/geo_ip/city_file'), GEOIP_STANDARD);
             $record = geoip_record_by_addr($geoip, Mage::helper('core/http')->getRemoteAddr());
             $result['shipping']['city'] = $record->city;
             $result['billing']['city'] = $record->city;
             $result['shipping']['postcode'] = $record->postal_code;
             $result['billing']['postcode'] = $record->postal_code;
             geoip_close($geoip);
         }
         if (empty($result['shipping']['country_id'])) {
             $country_id = Mage::getStoreConfig('checkoutsimplificado/general/country');
             $result['shipping']['country_id'] = $country_id;
             $result['billing']['country_id'] = $country_id;
         }
     } else {
         $bill_addr = $customer->getPrimaryBillingAddress();
         if (!$bill_addr) {
             foreach ($addresses as $address) {
                 $bill_addr = $address;
                 break;
             }
         }
         $ship_addr = $customer->getPrimaryShippingAddress();
         if (!$ship_addr) {
             foreach ($addresses as $address) {
                 $ship_addr = $address;
                 break;
             }
         }
         $result['shipping']['country_id'] = $ship_addr->getCountryId();
         $result['billing']['country_id'] = $bill_addr->getCountryId();
         $eq = false;
         if ($ship_addr->getId() === $bill_addr->getId()) {
             $eq = true;
         }
         $result['equal'] = $eq;
     }
     return $result;
 }
开发者ID:Evandro-correia,项目名称:one_step_checkout_simplificado,代码行数:53,代码来源:Geo.php


示例12: getGeoLocation

 /**
  * Return country code and city name for the passed
  * ip address.
  * @param $ip string
  * @return array
  */
 public function getGeoLocation($ip)
 {
     // If no geolocation tool, the geo database file is missing.
     if (!$this->_geoLocationTool) {
         return array(null, null, null);
     }
     $record = geoip_record_by_addr($this->_geoLocationTool, $ip);
     $regionName = null;
     if (isset($this->_regionName[$record->country_code][$record->region])) {
         $regionName = $this->_regionName[$record->country_code][$record->region];
     }
     return array($record->country_code, utf8_encode($record->city), $record->region);
 }
开发者ID:laelnasan,项目名称:UTFPR-ojs,代码行数:19,代码来源:GeoLocationTool.inc.php


示例13: __construct

 public function __construct()
 {
     $gi = geoip_open(dirname(__FILE__) . "/GeoLiteCity.dat", GEOIP_STANDARD);
     $this->record = geoip_record_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     //		print $record->country_code . " " . $record->country_code3 . " " . $record->country_name . "\n";
     //		print $record->region . " " . $GEOIP_REGION_NAME[$record->country_code][$record->region] . "\n";
     //		print $record->city . "\n";
     //		print $record->postal_code . "\n";
     //		print $record->latitude . "\n";
     //		print $record->longitude . "\n";
     //		print $record->metro_code . "\n";
     //		print $record->area_code . "\n";
     //		print $record->continent_code . "\n";
     geoip_close($gi);
 }
开发者ID:jordone,项目名称:diyonline,代码行数:15,代码来源:GeoipHelper.php


示例14: get_geodata

 function get_geodata($ip)
 {
     require_once _TRACK_LIB_PATH . "/maxmind/geoip.inc.php";
     require_once _TRACK_LIB_PATH . "/maxmind/geoipcity.inc.php";
     require_once _TRACK_LIB_PATH . "/maxmind/geoipregionvars.php";
     $gi = geoip_open(_TRACK_STATIC_PATH . "/maxmind/MaxmindCity.dat", GEOIP_STANDARD);
     $record = geoip_record_by_addr($gi, $ip);
     $isp = geoip_org_by_addr($gi, $ip);
     geoip_close($gi);
     $cur_country = $record->country_code;
     // Resolve GeoIP extension conflict
     if (function_exists('geoip_country_code_by_name') && $cur_country == '') {
         $cur_country = geoip_country_code_by_name($ip);
     }
     return array('country' => $cur_country, 'state' => $GEOIP_REGION_NAME[$record->country_code][$record->region], 'city' => $record->city, 'region' => $record->region, 'isp' => $isp);
 }
开发者ID:conversionstudio,项目名称:cpatracker,代码行数:16,代码来源:track_direct.php


示例15: localize

 public function localize()
 {
     include_once ROOT_DIR . '/libraries/geoloc/geoipcity.inc';
     include_once ROOT_DIR . '/libraries/geoloc/geoipregionvars.php';
     $gi = geoip_open(realpath(ROOT_DIR . '/libraries/geoloc/GeoLiteCity.dat'), GEOIP_STANDARD);
     $record = geoip_record_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     /*
             echo $record->country_name . "\n";
             echo $GEOIP_REGION_NAME[$record->country_code][$record->region] . "\n";
             echo $record->city . "\n";
             echo $record->postal_code . "\n";
             echo $record->latitude . "\n";
             echo $record->longitude . "\n";*/
     geoip_close($gi);
     return $record;
 }
开发者ID:aricci95,项目名称:metallink,代码行数:16,代码来源:GeolocService.php


示例16: GEOIP_City

function GEOIP_City($IP)
{
    global $SYS;
    $gi = geoip_open($SYS["BASE"] . "/Framework/Extensions/GeoIP/GeoLiteCity.dat", GEOIP_STANDARD);
    $record = geoip_record_by_addr($gi, $IP);
    ob_start();
    print $record->country_code . " " . $record->country_code3 . " " . $record->country_name . "\n";
    print $record->region . " " . $GEOIP_REGION_NAME[$record->country_code][$record->region] . "\n";
    print $record->city . "\n";
    print $record->postal_code . "\n";
    print $record->latitude . "\n";
    print $record->longitude . "\n";
    print $record->dma_code . "\n";
    print $record->area_code . "\n";
    geoip_close($gi);
    $data = ob_get_clean();
    return $data;
}
开发者ID:BackupTheBerlios,项目名称:ascore,代码行数:18,代码来源:lib_geoip.php


示例17: __index

 public function __index()
 {
     include WWW_ROOT . '/t/geoip.inc';
     include WWW_ROOT . '/t/geoipcity.inc';
     include WWW_ROOT . '/t/geoipregionvars.php';
     $geodb = geoip_open(WWW_ROOT . 't/GeoLiteCity.dat', GEOIP_STANDARD);
     $visitors = $this->Visitor->find('all', array('conditions' => array('Visitor.country_code' => ''), 'limit' => 1000));
     foreach ($visitors as $visitor) {
         $geo = geoip_record_by_addr($geodb, $visitor['Visitor']['ip']);
         $data['Visitor']['id'] = $visitor['Visitor']['id'];
         $data['Visitor']['country_code'] = $geo->country_code;
         $data['Visitor']['region'] = $geo->region;
         $data['Visitor']['city'] = $geo->city;
         $this->Visitor->save($data, false);
         //			print_r($data);
     }
     die('vege');
 }
开发者ID:beyondkeysystem,项目名称:testone,代码行数:18,代码来源:VisitorsController.php


示例18: testCity

 public function testCity()
 {
     global $GEOIP_REGION_NAME;
     $gi = geoip_open("tests/data/GeoIPCity.dat", GEOIP_STANDARD);
     $record = geoip_record_by_addr($gi, "64.17.254.216");
     $this->assertEquals(310, $record->area_code);
     $this->assertEquals('El Segundo', $record->city);
     $this->assertEquals('US', $record->country_code);
     $this->assertEquals('USA', $record->country_code3);
     $this->assertEquals('United States', $record->country_name);
     $this->assertEquals(803, $record->dma_code);
     $this->assertEquals(33.91, $record->latitude, '', 0.01);
     $this->assertEquals(-118.4, $record->longitude, '', 0.01);
     $this->assertEquals(803, $record->metro_code);
     $this->assertEquals('90245', $record->postal_code);
     $this->assertEquals('CA', $record->region);
     $this->assertEquals('California', $GEOIP_REGION_NAME[$record->country_code][$record->region]);
     $this->assertEquals('America/Los_Angeles', get_time_zone($record->country_code, $record->region));
 }
开发者ID:Alambos,项目名称:geoip-api-php,代码行数:19,代码来源:CityTest.php


示例19: __construct

 public function __construct($db)
 {
     $this->db = $db;
     # Testing Puroses Only: $ip = '66.87.83.245';
     $ip = getenv('HTTP_CLIENT_IP') ?: getenv('HTTP_X_FORWARDED_FOR') ?: getenv('HTTP_X_FORWARDED') ?: getenv('HTTP_FORWARDED_FOR') ?: getenv('HTTP_FORWARDED') ?: getenv('REMOTE_ADDR');
     $this->ip_address = $ip;
     require_once GEOIP_DIR . 'geoipcity.inc';
     require_once GEOIP_DIR . 'geoipregionvars.php';
     $gi = geoip_open(GEOIP_DIR . "GeoLiteCity.dat", GEOIP_STANDARD);
     $this->record = geoip_record_by_addr($gi, $this->ip_address);
     $this->city = $this->record->city;
     $this->state = $this->record->region;
     $this->state_code = $this->record->region;
     // Two letter abbreviation
     $this->latitude = $this->record->latitude;
     $this->longitude = $this->record->longitude;
     $this->zipcode = $this->record->postal_code;
     geoip_close($gi);
 }
开发者ID:arout,项目名称:halcyon,代码行数:19,代码来源:Geoip.php


示例20: setIp

 /**
  * Set Ip address
  * 
  * @param string $ipaddr ipaddress
  * 
  * @return void
  */
 public function setIp($ipaddr)
 {
     require_once dirname(__FILE__) . "/../third_party/geoip/geoip.inc";
     require_once dirname(__FILE__) . "/../third_party/geoip/geoipcity.inc";
     if (!isset($GEOIP_REGION_NAME)) {
         require_once dirname(__FILE__) . "/../third_party/geoip/geoipregionvars.php";
     }
     $gi = geoip_open(dirname(__FILE__) . "/../third_party/geoip/GeoLiteCity.dat", GEOIP_STANDARD);
     $record = geoip_record_by_addr($gi, $ipaddr);
     if (isset($record->country_name) && $record->country_name != '') {
         $this->country = $record->country_name;
     }
     if (isset($record->country_code) && isset($record->region) && isset($GEOIP_REGION_NAME[$record->country_code][$record->region]) && $GEOIP_REGION_NAME[$record->country_code][$record->region] != '') {
         $this->region = $GEOIP_REGION_NAME[$record->country_code][$record->region];
     }
     if (isset($record->city) && $record->city != '') {
         $this->city = $record->city;
     }
 }
开发者ID:BellyWong,项目名称:razor,代码行数:26,代码来源:GeoIpLibrary.php



注:本文中的geoip_record_by_addr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP geoip_record_by_name函数代码示例发布时间:2022-05-15
下一篇:
PHP geoip_open函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap