本文整理汇总了PHP中geoip_record_by_addr函数的典型用法代码示例。如果您正苦于以下问题:PHP geoip_record_by_addr函数的具体用法?PHP geoip_record_by_addr怎么用?PHP geoip_record_by_addr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了geoip_record_by_addr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}