当前位置: 首页>>代码示例>>PHP>>正文


PHP geoip_country_name_by_addr函数代码示例

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


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

示例1: add_info

 public function add_info($uuid, $release)
 {
     // get ip from remote address
     $ip = $_SERVER['REMOTE_ADDR'];
     // get geodata
     $gi = geoip_open("/usr/share/GeoIP/GeoIP.dat", GEOIP_STANDARD);
     // get country code from ip
     $country_code = geoip_country_code_by_addr($gi, $ip);
     // get country name from ip
     $country_name = geoip_country_name_by_addr($gi, $ip);
     try {
         // get connession
         $conn = new PDO("mysql:host=" . $GLOBALS['$dbhost'] . ";dbname=" . $GLOBALS['$dbname'] . "", $GLOBALS['$dbuser'], $GLOBALS['$dbpass']);
         // set the PDO error mode to exception
         $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         // insert query
         $sql = "REPLACE INTO phone_home_tb (uuid,\n                                            release_tag,\n                                            ip,\n                                            country_code,\n                                            country_name,\n                                            reg_date)\n                VALUES (:uuid,\n                        :release,\n                        :ip,\n                        :country_code,\n                        :country_name,\n                        NOW())";
         // prepare statement
         $stmt = $conn->prepare($sql);
         // execute query
         $stmt->execute(array(':uuid' => $uuid, ':release' => $release, ':ip' => $ip, ':country_code' => $country_code, ':country_name' => $country_name));
         // close connession
         $conn = null;
     } catch (PDOException $e) {
         echo $e->getMessage();
     }
 }
开发者ID:dz00te,项目名称:nethserver-phonehome,代码行数:27,代码来源:index.php

示例2: get_country_name_by_ip

/**
 * Получение названия страны по айпишнику
 *
 * @param string $ip_address
 */
function get_country_name_by_ip($ip_address)
{
    $obj =& get_instance();
    require_once APPPATH . 'libraries/geoip.php';
    $gi = geoip_open($obj->config->item('path_to_files') . 'GeoIP.dat', GEOIP_STANDARD);
    return geoip_country_name_by_addr($gi, $ip_address);
}
开发者ID:sabril-2t,项目名称:Open-Ad-Server,代码行数:12,代码来源:location_helper.php

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

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

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

示例7: country_name

 /**
  * @param null $address
  * @return bool|string
  */
 public function country_name($address = null)
 {
     $countryName = geoip_country_name_by_addr($this->gi, $address);
     if ($countryName == null) {
         $countryName = 'Unknown';
     }
     return $countryName;
 }
开发者ID:sh1omi,项目名称:xlrstats-web-v3,代码行数:12,代码来源:GeoIPComponent.php

示例8: __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

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

示例10: 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' => 'home');
     $this->model_visit->add($visit);
     foreach ($this->model_conter->getAll() as $r) {
         if ($ip == $r->ip && $today == $r->tanggal) {
             $masuk = FALSE;
         }
     }
     foreach ($this->model_conter->getAll2() as $r) {
         if ($today == $r->tanggal) {
             $msk = FALSE;
         }
     }
     foreach ($this->model_conter->getAllC() as $r) {
         if ($country_name == $r->negara) {
             $mskC = FALSE;
         }
     }
     $konter = array('total' => $this->model_conter->counN($country_name));
     $this->model_conter->edit($konter, $country_name);
     if ($msk) {
         $konter2 = array('id' => NULL, 'tanggal' => $today);
         $this->model_conter->addR($konter2);
     }
     if ($mskC) {
         $ni = array('id' => NULL, 'negara' => $country_name, 'total' => 1);
         $this->model_conter->addC($ni);
     }
     if ($masuk) {
         $konter = array('idcounter' => NULL, 'tanggal' => $today, 'ip' => $ip, 'negara' => $country_name);
         $this->model_conter->add($konter);
     }
     $data['title'] = "home page";
     $bhs = $this->session->userdata('EN');
     $data['pengunjung'] = $this->model_conter->counAll();
     $data['news'] = $this->model_berita->getSlideNews($bhs);
     $this->load->view('user/vcontent_rev', $data);
 }
开发者ID:adzzie,项目名称:hotel,代码行数:52,代码来源:cpagehome.php

示例11: index

 function index()
 {
     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' => 'welcome');
     $this->model_visit->add($visit);
     $data['gambar'] = $this->model_gambar->getAll();
     $this->load->view('user/frontend/page/vwelcome', $data);
 }
开发者ID:adzzie,项目名称:hotel,代码行数:15,代码来源:cpagewelcome.php

示例12: arprice_Shortcode

 function arprice_Shortcode($atts)
 {
     global $wpdb, $arprice_analytics;
     if (!extension_loaded('geoip')) {
         include PRICINGTABLE_INC_DIR . '/geoip.inc';
     }
     extract(shortcode_atts(array('id' => '1'), $atts));
     $table_id = $atts['id'];
     if ($table_id == "") {
         $table_id = 1;
     }
     $result = $wpdb->get_row($wpdb->prepare("select * from " . $wpdb->prefix . "arp_arprice where ID=%d", $table_id));
     $pricetable_name = $result->table_name;
     if ($pricetable_name == "") {
         return "Please Select Valid Pricing Table";
     } else {
         if ($result->status != 'published') {
             return "Please Select Valid Pricing Table";
         }
     }
     $file_url = PRICINGTABLE_INC_DIR . "/GeoIP.dat";
     if (!extension_loaded('geoip')) {
         $gi = geoip_open($file_url, GEOIP_STANDARD);
         $country_name = geoip_country_name_by_addr($gi, $_SERVER['REMOTE_ADDR']);
     } else {
         $country_name = "";
     }
     $d = date("Y/m/d H:i:s");
     $brow = $_SERVER['HTTP_USER_AGENT'];
     $pageurl = $_SERVER['REQUEST_URI'];
     $ref = $_SERVER['HTTP_REFERER'];
     $ip = $_SERVER['REMOTE_ADDR'];
     $ses_id = session_id();
     $browser = $arprice_analytics->getBrowser($brow);
     $sel = $wpdb->get_row($wpdb->prepare("SELECT tracking_id, session_id FROM " . $wpdb->prefix . "arp_arprice_analytics WHERE pricing_table_id = " . $table_id . " AND session_id = %s", $ses_id));
     if ($sel) {
         require_once PRICINGTABLE_DIR . '/core/views/arprice_front.php';
         $contents = arp_get_pricing_table_string($table_id);
         $contents = apply_filters('arp_predisplay_pricingtable', $contents, $table_id);
         return $contents;
     }
     $res = $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "arp_arprice_analytics (pricing_table_id,browser_info,browser_name,browser_version,page_url,referer,ip_address,country_name,session_id,added_date ) VALUES (%d,%s,%s,%s,%s,%s,%s,%s,%s,%s)", $table_id, $brow, $browser['browser_name'], $browser['version'], $pageurl, $ref, $ip, $country_name, $ses_id, $d));
     require_once PRICINGTABLE_DIR . '/core/views/arprice_front.php';
     $contents = arp_get_pricing_table_string($table_id);
     $contents = apply_filters('arp_predisplay_pricingtable', $contents, $table_id);
     return $contents;
 }
开发者ID:prosenjit-itobuz,项目名称:upages,代码行数:47,代码来源:class.arprice_analytics.php

示例13: country_flag

function country_flag($ip)
{
    global $geoip_path;
    if (file_exists($geoip_path . "GeoIP.dat")) {
        $geocountry = $geoip_path . "GeoIP.dat";
        $gi = geoip_open($geocountry, GEOIP_STANDARD);
        $countryid = strtolower(geoip_country_code_by_addr($gi, $ip));
        $country = geoip_country_name_by_addr($gi, $ip);
        if (!is_null($countryid) and $countryid != "") {
            $flag = "<img src=\"images/flags/" . $countryid . ".gif\" title=\"" . $country . "\" alt=\"" . $country . "\">";
        } else {
            $flag = "<img width=\"16\" height=\"11\" src=\"images/spacer.gif\" title=\"" . $country . "\" alt=\"" . $country . "\">";
        }
        geoip_close($gi);
        return $flag;
    }
}
开发者ID:redrock,项目名称:xlrstats-web-v2,代码行数:17,代码来源:func-awardlogic.php

示例14: location_update

 /**
  * Update Visitor info to include country and city
  */
 public static function location_update()
 {
     $db = JFactory::getDbo();
     if (!defined('DS')) {
         define('DS', DIRECTORY_SEPARATOR);
     }
     if (file_exists(JPATH_COMPONENT . DS . 'assets' . DS . 'geoip' . DS . 'geolitecity.dat')) {
         if (filesize(JPATH_COMPONENT . DS . 'assets' . DS . 'geoip' . DS . 'geolitecity.dat') != 0) {
             if (!function_exists('GeoIP_record_by_addr')) {
                 include JPATH_COMPONENT . DS . 'assets' . DS . 'geoip' . DS . 'geoipcity.inc';
             }
             $geoip = geoip_open(JPATH_COMPONENT . DS . 'assets' . DS . 'geoip' . DS . 'geolitecity.dat', GEOIP_STANDARD);
             $query = $db->getQuery(true);
             $query->select('id, ip');
             $query->from($db->quoteName('#__cwtraffic'));
             $query->where('country_code = "" OR country_code is null');
             $db->setQuery($query);
             foreach ($db->loadObjectList() as $row) {
                 $country_code = strtolower(geoip_country_code_by_addr($geoip, $row->ip));
                 $country_name = geoip_country_name_by_addr($geoip, $row->ip);
                 $addr = GeoIP_record_by_addr($geoip, $row->ip);
                 if (!empty($addr)) {
                     $city = $addr->city;
                 }
                 if ($country_code != '' && $country_name != '') {
                     $query = $db->getQuery(true);
                     $query->update('#__cwtraffic');
                     $query->set('country_code = ' . $db->quote($country_code));
                     $query->set('country_name = ' . $db->quote($country_name));
                     $query->set('city = ' . $db->quote($city));
                     $query->where('id = ' . $row->id);
                     $db->setQuery($query);
                     $db->query();
                 }
             }
             geoip_close($geoip);
             $query = $db->getQuery(true);
             $query->update('#__cwtraffic');
             $query->set('city = NULL');
             $query->where('city = ""');
             $db->setQuery($query);
             $db->query();
         }
     }
     return;
 }
开发者ID:Rikisha,项目名称:proj,代码行数:49,代码来源:celtawebtraffic.php

示例15: getCountryData

 /**
  * Find users country.
  *
  * Attempt to get the country the user is from.  returns unknown if its not
  * able to match something.
  *
  * @param string $ipAddress the ip address to check against
  * @param bool $code get the country code or not
  *
  * @return array the data requested
  */
 public function getCountryData($ipAddress = null, $code = false)
 {
     if (!$ipAddress) {
         $ipAddress = $this->__getIpAddress();
     }
     $data = $this->__loadFile();
     if (!$data) {
         return $this->__emptyCountry;
     }
     $return = array('country' => geoip_country_name_by_addr($data, $ipAddress), 'country_code' => geoip_country_code_by_addr($data, $ipAddress), 'country_id' => geoip_country_id_by_addr($data, $ipAddress), 'city' => null, 'ip_address' => $ipAddress);
     if (empty($return['country']) && $ipAddress == '127.0.0.1') {
         $return['country'] = 'localhost';
         $return['city'] = 'localhost';
     }
     geoip_close($data);
     unset($data);
     return $return;
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:29,代码来源:IpLocation.php


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