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

PHP geoip_close函数代码示例

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

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



在下文中一共展示了geoip_close函数的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: testgeoipdatabase

 function testgeoipdatabase($type, $flags, $msg, $numlookups)
 {
     $gi = geoip_open($this->dbfilename[$type], $flags);
     if ($gi == null) {
         print "error: " . $this->dbfilename[$type] . " does not exist\n";
         return;
     }
     $t1 = $this->ftime();
     $i4 = 0;
     for ($i2 = 0; $i2 < $numlookups; $i2++) {
         switch ($type) {
             case GEOIP_COUNTRY_DATABASE:
                 geoip_country_code_by_addr($gi, $this->randomipaddress());
                 break;
             case GEOIP_REGION_DATABASE:
                 geoip_region_by_addr($gi, $this->randomipaddress());
                 break;
             case GEOIP_CITY_DATABASE:
                 GeoIP_record_by_addr($gi, $this->randomipaddress());
                 break;
         }
     }
     $t2 = $this->ftime();
     $t3 = $t2 - $t1;
     print $msg . "\n";
     print $numlookups . " lookups made in " . $t3 . " seconds \n";
     geoip_close($gi);
 }
开发者ID:bestwishforyou95,项目名称:congnghemoitruong,代码行数:28,代码来源:benchmark.php


示例3: 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


示例4: 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


示例5: 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


示例6: onPostDispatchIndexController

 public function onPostDispatchIndexController(Enlight_Event_EventArgs $arguments)
 {
     $controller = $arguments->getSubject();
     $view = $controller->View();
     $view->addTemplateDir($this->Path() . 'Views/');
     $shopLang = Shopware()->Front()->Request()->getCookie('shopLang');
     //        $ip = $_SERVER['REMOTE_ADDR'];
     $ip = '195.149.248.130';
     //BG
     //        $ip = '194.50.69.124'; //DE
     //        $ip = '211.156.198.82'; //CN
     $gi = geoip_open(__DIR__ . '/GeoIp/db/GeoIP.dat', GEOIP_STANDARD);
     $countryCode = geoip_country_code_by_addr($gi, $ip);
     geoip_close($gi);
     if ($shopLang != strtolower($countryCode)) {
         $shopLang = strtolower($countryCode);
         Shopware()->Front()->Response()->setCookie('shopLang', $shopLang, 0);
         $builder = Shopware()->Container()->get('dbal_connection')->createQueryBuilder();
         $shopId = $builder->select('scs.id')->from('s_core_locales', 'scl')->innerJoin('scl', 's_core_shops', 'scs', 'scl.id = scs.locale_id')->where('scl.locale LIKE ?')->setParameter(0, $shopLang . '%')->execute()->fetch();
         if ($shopId) {
             $view->extendsTemplate('frontend/index/change_shop.tpl');
             $view->assign(array('shopId' => $shopId['id']));
         }
     }
 }
开发者ID:dnhsoft,项目名称:swApacheGeoIP,代码行数:25,代码来源:Bootstrap.php


示例7: GetCountry

function GetCountry($bot_ip)
{
    $GI = geoip_open('includes/GeoIP.dat', GEOIP_STANDARD);
    $bot_country = geoip_country_code_by_addr($GI, $bot_ip);
    geoip_close($GI);
    return $bot_country;
}
开发者ID:conjuringtricks,项目名称:Tinba,代码行数:7,代码来源:in.php


示例8: readM

 function readM()
 {
     include 'geoip.inc';
     $gi = geoip_open('resources/GeoIP.dat', GEOIP_STANDARD);
     $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     //$this->data['country_code'] = $country_code;
     $country_name = geoip_country_name_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     //$this->data['country_name'] = $country_name;
     // close the database
     geoip_close($gi);
     $visit = array('id' => NULL, 'negara' => $country_name, 'visit' => 'news');
     $this->model_visit->add($visit);
     $id = $this->uri->segment(4);
     if ($id == "cpagenews") {
         $bh = $this->uri->segment(6);
         redirect('user/cpagenews/ubahBhs/' . $this->uri->segment(6));
     }
     $data['title'] = "news";
     $this->load->view('user/vheader', $data);
     $bhs = $this->session->userdata('EN');
     $data['gambar'] = $this->model_gambar->getGmb();
     $data['berit'] = $this->model_berita->getByMore($id);
     $data['pengunjung'] = $this->model_conter->counAll();
     $data['news'] = $this->model_berita->getSlideNews($bhs);
     $this->load->view('user/vmenu');
     $this->load->view('user/frontend/page/vreadmore', $data);
     $this->load->view('user/vfooter');
 }
开发者ID:adzzie,项目名称:hotel,代码行数:28,代码来源:cpagenews.php


示例9: index

 function index()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     $masuk = TRUE;
     $msk = TRUE;
     $mskC = TRUE;
     $today = date('Y-m-d');
     include 'geoip.inc';
     $gi = geoip_open('resources/GeoIP.dat', GEOIP_STANDARD);
     $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     //$this->data['country_code'] = $country_code;
     $country_name = geoip_country_name_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     //$this->data['country_name'] = $country_name;
     // close the database
     geoip_close($gi);
     $visit = array('id' => NULL, 'negara' => $country_name, 'visit' => 'gallery');
     $this->model_visit->add($visit);
     $data['title'] = "gallery";
     $bhs = $this->session->userdata('EN');
     $data['pengunjung'] = $this->model_conter->counAll();
     $data['galeri'] = $this->model_galery->getBahasa($bhs);
     $data['gambar'] = $this->model_gambar->getGmb();
     $this->load->view('user/vheader', $data);
     $this->load->view('user/vmenu');
     $this->load->view('user/frontend/page/vgallery');
     $this->load->view('user/vfooter');
 }
开发者ID:adzzie,项目名称:hotel,代码行数:27,代码来源:cpagegallery.php


示例10: 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


示例11: 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


示例12: get_country

function get_country()
{
    include "application/helpers/geoip/files/geoip.inc";
    $gi = geoip_open("application/helpers/geoip/files/GeoIP.dat", GEOIP_STANDARD);
    $country_code = geoip_country_code_by_addr($gi, $_SERVER['HTTP_X_REAL_IP']);
    geoip_close($gi);
    return $country_code;
}
开发者ID:skybee,项目名称:france,代码行数:8,代码来源:geoip_helper.php


示例13: geoip_get_details_by_host

function geoip_get_details_by_host($host)
{
    require_once 'geoipcity.php';
    $geoip = geoip_open('./GeoLiteCity.dat', GEOIP_STANDARD);
    $details = GeoIP_record_by_addr($geoip, gethostbyname($host));
    geoip_close($geoip);
    return $details;
}
开发者ID:hemantshekhawat,项目名称:Snippets,代码行数:8,代码来源:geoip_timezone.php


示例14: country_from_ip

function country_from_ip($addr)
{
    // Switch GEOIP_SHARED_MEMORY for better perfs
    // (or a thousand times better, GeoIP C library binding for PHP)
    $gi = geoip_open('data/GeoIP.dat', GEOIP_STANDARD);
    $country = geoip_country_code_by_addr($gi, $addr);
    geoip_close($gi);
    return $country;
}
开发者ID:pcarrier-unmaintained,项目名称:automirror,代码行数:9,代码来源:redirect.php


示例15: __construct

 function __construct()
 {
     parent::Model();
     $country_name = CI::library('session')->userdata('country_name');
     if (strval(trim($country_name)) == '') {
         if (!defined('USER_COUNTRY_NAME')) {
             if (is_file(BASEPATH . 'libraries/maxmind/geoip.inc') == true) {
                 include BASEPATH . 'libraries/maxmind/geoip.inc';
                 $handle = geoip_open(BASEPATH . "libraries/maxmind/GeoIP.dat", GEOIP_STANDARD);
                 //var_Dump($_SERVER ["REMOTE_ADDR"]);
                 if ($_SERVER["REMOTE_ADDR"] == '::1') {
                     $ip = '77.70.8.202';
                 } else {
                     $ip = $_SERVER["REMOTE_ADDR"];
                 }
                 $the_user_coutry = geoip_country_code_by_addr($handle, $ip);
                 $the_user_coutry_name = geoip_country_name_by_addr($handle, $ip);
                 //var_dump( $the_user_coutry);
                 define("USER_COUNTRY", $the_user_coutry);
                 define("USER_COUNTRY_NAME", $the_user_coutry_name);
                 geoip_close($handle);
             } else {
                 //exit('need geo ip');
             }
         }
         //var_dump(USER_COUNTRY);
         CI::library('session')->set_userdata('country_name', USER_COUNTRY_NAME);
     }
     //print(USER_COUNTRY);
     //print(USER_COUNTRY_NAME);
     $shop_currency = CI::library('session')->userdata('shop_currency');
     $country_name = CI::library('session')->userdata('country_name');
     if (strval($country_name) == '') {
         CI::library('session')->set_userdata('country_name', USER_COUNTRY_NAME);
     }
     $shop_currency = CI::library('session')->userdata('shop_currency');
     //print $shop_currency;
     if (strval($shop_currency) == '') {
         switch (strtolower(USER_COUNTRY)) {
             case 'uk':
                 $this->currencyChangeSessionData("GBP");
                 break;
             case 'us':
             case 'usa':
                 $this->currencyChangeSessionData("USD");
                 break;
             default:
                 $this->currencyChangeSessionData("EUR");
                 break;
         }
     }
     $shop_currency = CI::library('session')->userdata('shop_currency');
     //	print $shop_currency;
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:54,代码来源:cart_model.php


示例16: 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


示例17: log_search_criteria

 private function log_search_criteria()
 {
     $gi = geoip_open($GLOBALS['maxmind_geoip_data_file'], GEOIP_STANDARD);
     $country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     geoip_close($gi);
     if (empty($country) || is_null($country)) {
         $country = '??';
     }
     $query = "INSERT INTO search_log SET \n                  from_ip_address = '" . $_SERVER['REMOTE_ADDR'] . "', \n                  from_country = '" . $country . "', \n                  keywords = '" . sanitize($this->keywords) . "', \n                  filter_industry = " . $this->industry . ", \n                  filter_country_code = '" . $this->country_code . "', \n                  searched_on = NOW()";
     $mysqli = Database::connect();
     return $mysqli->execute($query);
 }
开发者ID:pamalite,项目名称:yel,代码行数:12,代码来源:job_search.php


示例18: _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


示例19: convertip_geo

function convertip_geo($ip = '', $ipdatafile = '')
{
    require_once DISCUZ_ROOT . './source/function/geoip.inc';
    $gi = geoip_open($ipdatafile, GEOIP_STANDARD);
    $country = geoip_country_code_by_addr($gi, $ip);
    geoip_close($gi);
    if ($country) {
        return lang('country', $country);
    } else {
        return lang('country', '??');
    }
}
开发者ID:v998,项目名称:discuzx-en,代码行数:12,代码来源:function_misc.php


示例20: getCountry

 function getCountry($ip)
 {
     if (strpos($ip, ":") === false) {
         $gi = geoip_open($this->ipv4DatabasePath, GEOIP_STANDARD);
         $country = geoip_country_name_by_addr($gi, $ip);
     } else {
         $gi = geoip_open($this->ipv6DatabasePath, GEOIP_STANDARD);
         $country = geoip_country_name_by_addr_v6($gi, $ip);
     }
     geoip_close($gi);
     return $country;
 }
开发者ID:JS-Apps-Team-Sazerac,项目名称:Sazerac-Analytics,代码行数:12,代码来源:VisitorInfoGrabber.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP geoip_country_code_by_addr函数代码示例发布时间:2022-05-15
下一篇:
PHP geodir_is_page函数代码示例发布时间: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