本文整理汇总了PHP中geoip_country_code_by_addr函数的典型用法代码示例。如果您正苦于以下问题:PHP geoip_country_code_by_addr函数的具体用法?PHP geoip_country_code_by_addr怎么用?PHP geoip_country_code_by_addr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了geoip_country_code_by_addr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: setlang
function setlang()
{
$CFG =& load_class('Config');
//$OUT = &load_class('Output');
$CFG->load('site');
$a = explode('/', $_SERVER["REQUEST_URI"]);
if (sizeof($a) > 0) {
$lang = $a[1];
if ($CFG->item('folder') == true) {
$lang = $a[2];
}
switch ($lang) {
case 'ru':
$CFG->set_item('language', "ru");
break;
case 'en':
$CFG->set_item('language', "en");
break;
default:
include BASEPATH . 'libraries/third_party/Geoip.php';
$country = geoip_country_code_by_addr(open_geo(), $_SERVER['REMOTE_ADDR']);
switch ($country) {
case 'RU':
$CFG->set_item('language', "ru");
break;
case 'UA':
$CFG->set_item('language', "ru");
break;
default:
$CFG->set_item('language', "en");
break;
}
}
}
}
开发者ID:pussbb,项目名称:CI_DEV_CMS,代码行数:35,代码来源:system.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: 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
示例5: 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
示例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: wpgeoip_redirect
function wpgeoip_redirect()
{
if (get_option('wpgeoip_no_redirect', 0) == 1 and isset($_GET['noredirect'])) {
return false;
}
require_once 'geoip.inc';
//open geoip binary database
$gi = geoip_open(plugin_dir_path(__FILE__) . 'GeoIP.dat', GEOIP_STANDARD);
global $wpdb;
global $wp_query;
global $post;
$prefix = $wpdb->prefix;
$postID = $post->ID;
$catID = intval($wp_query->query_vars['cat']);
$isHome = is_home();
$the_page_name = '';
//get user country
$countryCode = geoip_country_code_by_addr($gi, WPGeoIP_getIP());
//sitewide rule
$rs_redirect = $wpdb->get_row("SELECT `targetURL` FROM `" . $prefix . "grules` WHERE `countryID` = '{$countryCode}' \n\t\t\t\t\t\t\tAND `postID` = 999999");
if (isset($rs_redirect) and count($rs_redirect)) {
$the_page_name = get_the_title($postID);
$wpdb->query("INSERT INTO wpgeoip_log VALUES (null, 'SITEWIDE Redirect', 'Redirecting Country <strong>" . $countryCode . "</strong> to " . $rs_redirect->targetURL . "')");
print '<meta http-equiv="refresh" content="0;url=' . $rs_redirect->targetURL . '"/>';
exit;
}
//redirect if any rule for this country
if ($postID != 0) {
$rs_redirect = $wpdb->get_row("SELECT `targetURL` FROM `" . $prefix . "grules` WHERE `countryID` = '{$countryCode}' \n\t\t\t\t\t\t\tAND `postID` = {$postID}");
$the_page_name = get_the_title($postID);
}
if ($catID != 0) {
$rs_redirect = $wpdb->get_row("SELECT `targetURL` FROM `" . $prefix . "grules` WHERE `countryID` = '{$countryCode}' \n\t\t\t\t\t\t\tAND `catID` = {$catID}");
$the_page_name = 'Category : ' . get_the_category_by_ID($catID);
}
if ($isHome) {
$rs_redirect = $wpdb->get_row("SELECT `targetURL` FROM `" . $prefix . "grules` WHERE `countryID` = '{$countryCode}' \n\t\t\t\t\t\t\tAND `home_rule` = 1");
$the_page_name = 'Homepage';
}
if (!$rs_redirect) {
//NOTHING TO DO
#$wpdb->query("INSERT INTO wpgeoip_log VALUES (null, 'Redirect', 'Nothing to do. No rules for Country <strong>".$countryCode."</strong>')");
}
if (isset($rs_redirect) and count($rs_redirect)) {
$wpdb->query("INSERT INTO wpgeoip_log VALUES (null, 'Redirect <em>" . $the_page_name . "</em>', 'Redirecting Country <strong>" . $countryCode . "</strong> to " . $rs_redirect->targetURL . "')");
print '<meta http-equiv="refresh" content="0;url=' . $rs_redirect->targetURL . '"/>';
exit;
} else {
//CHECK COUNTRIES WITHOUT REDIRECT RULES
$mass_redirect_enabled = get_option('wpgeoip_mass_redirect');
if ($mass_redirect_enabled != "0") {
$mass_url = get_option('wpgeoip_mass_url');
$wpdb->query("INSERT INTO wpgeoip_log VALUES (null, 'Mass Redirect', 'Redirecting Country <strong>" . $countryCode . "</strong> to " . $rs_redirect->targetURL . "')");
print '<meta http-equiv="refresh" content="0;url=' . $mass_url . '"/>';
exit;
} else {
//NOTHING TO DO AGAINM
}
}
}
开发者ID:virendrayadav,项目名称:bigperlus,代码行数:60,代码来源:wpgeoip_redirect.php
示例8: 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
示例9: GetCurrencyByIP
/**
* Fetch the currency code to use based on the current visitors IP address. This function will perform a
* GeoIP based lookup of the current visitors IP address and if possible, find a matching currency.
*
* @return mixed False if a currency cannot be found, else the currency ID if a matching currency was found.
*/
function GetCurrencyByIP()
{
require_once ISC_BASE_PATH."/lib/geoip/geoip.php";
$geoIp = @geoip_open(ISC_BASE_PATH."/lib/geoip/GeoIP.dat", GEOIP_STANDARD);
if(!$geoIp) {
return false;
}
$code = geoip_country_code_by_addr($geoIp, GetIP());
if(!$code) {
return false;
}
$query = "
SELECT currencyid
FROM [|PREFIX|]currencies cu
LEFT JOIN [|PREFIX|]countries co ON cu.currencycountryid = co.countryid
LEFT JOIN (
SELECT r.couregid, c.countryiso2
FROM [|PREFIX|]countries c
JOIN [|PREFIX|]country_regions r ON c.countrycouregid = r.couregid
) cr ON cu.currencycouregid = cr.couregid
WHERE
(
co.countryiso2 = '" . $GLOBALS['ISC_CLASS_DB']->Quote($code) . "' OR
cr.countryiso2 = '" . $GLOBALS['ISC_CLASS_DB']->Quote($code) . "'
) AND
cu.currencystatus = 1
LIMIT 1
";
return $GLOBALS['ISC_CLASS_DB']->FetchOne($query, 'currencyid');
}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:37,代码来源:currency.php
示例10: 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
示例11: 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
示例12: getCountryCodeFromIP
/**
* Return in lower case the country code from an ip
*
* @param $ip IP to scan
* @return string Country code (two letters)
*/
function getCountryCodeFromIP($ip)
{
if (empty($this->gi))
{
return '';
}
return strtolower(geoip_country_code_by_addr($this->gi, $ip));
}
开发者ID:remyyounes,项目名称:dolibarr,代码行数:14,代码来源:dolgeoip.class.php
示例13: ip2cc
function ip2cc($ip)
{
static $gi = null;
if ($gi === null) {
$gi = geoip_open(__DIR__ . '/geoip/GeoIP.dat', GEOIP_STANDARD);
}
return geoip_country_code_by_addr($gi, $ip);
}
开发者ID:jiangyu7408,项目名称:notification,代码行数:8,代码来源:ip2cc.php
示例14: 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
示例15: country_code
/**
* @param null $address
* @return bool|string
*/
public function country_code($address = null)
{
$countryCode = geoip_country_code_by_addr($this->gi, $address);
if ($countryCode == null) {
$countryCode = '-';
}
return $countryCode;
}
开发者ID:sh1omi,项目名称:xlrstats-web-v3,代码行数:12,代码来源:GeoIPComponent.php
示例16: 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
示例17: get_country_by_ip
/**
* Получение страны по айпишнику
*
* @param string $ip_address
*/
function get_country_by_ip($ip_address)
{
$obj =& get_instance();
static $gi = null;
if (null === $gi) {
require_once APPPATH . 'libraries/geoip.php';
$gi = geoip_open($obj->config->item('path_to_files') . 'GeoIP.dat', GEOIP_STANDARD);
}
return geoip_country_code_by_addr($gi, $ip_address);
}
开发者ID:sabril-2t,项目名称:Open-Ad-Server,代码行数:15,代码来源:location_helper.php
示例18: get_country
/**
* Функция определения страны бота
*/
function get_country($ip)
{
$gi = geoip_open("includes/geoip.dat", GEOIP_STANDARD);
$id = geoip_country_code_by_addr($gi, $ip);
if (empty($id)) {
$id = "xx";
}
geoip_close($gi);
return $id;
}
开发者ID:sucof,项目名称:footlocker,代码行数:13,代码来源:functions.php
示例19: __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
示例20: get_geo_code_country
public function get_geo_code_country($ip_address)
{
require_once ROOT . "geoip.inc";
$gi = geoip_open(ROOT . "GeoLiteIPCountry.dat", GEOIP_STANDARD);
$record = geoip_country_code_by_addr($gi, $ip_address);
geoip_close($gi);
if (!empty($record)) {
return $record;
} else {
return null;
}
}
开发者ID:adtech-musings,项目名称:digitaladexchange,代码行数:12,代码来源:maxmind.php
注:本文中的geoip_country_code_by_addr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论