本文整理汇总了PHP中geoip_open函数的典型用法代码示例。如果您正苦于以下问题:PHP geoip_open函数的具体用法?PHP geoip_open怎么用?PHP geoip_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了geoip_open函数的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: 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
示例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: 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
示例5: 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
示例6: 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
示例7: 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
示例8: 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
示例9: activate
public function activate()
{
global $lC_Vqmod;
include $lC_Vqmod->modCheck('external/maxmind/geoip/geoip.php');
$this->_handler = geoip_open('external/maxmind/geoip/geoip.dat', GEOIP_MEMORY_CACHE);
$this->_active = true;
}
开发者ID:rajeshb001,项目名称:itpl_loaded7,代码行数:7,代码来源:maxmind_geolite_country.php
示例10: 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
示例11: 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
示例12: 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
示例13: __construct
/**
* Load dependencies, etc
*/
function __construct()
{
/**
* MaxMind Country codes
*
* AP, EU, AD, AE, AF, AG, AI, AL, AM, CW, AO, AQ, AR, AS, AT, AU, AW, AZ, BA, BB, BD, BE, BF, BG,
* BH, BI, BJ, BM, BN, BO, BR, BS, BT, BV, BW, BY, BZ, CA, CC, CD, CF, CG, CH, CI, CK, CL, CM, CN,
* CO, CR, CU, CV, CX, CY, CZ, DE, DJ, DK, DM, DO, DZ, EC, EE, EG, EH, ER, ES, ET, FI, FJ, FK, FM,
* FO, FR, SX, GA, GB, GD, GE, GF, GH, GI, GL, GM, GN, GP, GQ, GR, GS, GT, GU, GW, GY, HK, HM, HN,
* HR, HT, HU, ID, IE, IL, IN, IO, IQ, IR, IS, IT, JM, JO, JP, KE, KG, KH, KI, KM, KN, KP, KR, KW,
* KY, KZ, LA, LB, LC, LI, LK, LR, LS, LT, LU, LV, LY, MA, MC, MD, MG, MH, MK, ML, MM, MN, MO, MP,
* MQ, MR, MS, MT, MU, MV, MW, MX, MY, MZ, NA, NC, NE, NF, NG, NI, NL, NO, NP, NR, NU, NZ, OM, PA,
* PE, PF, PG, PH, PK, PL, PM, PN, PR, PS, PT, PW, PY, QA, RE, RO, RU, RW, SA, SB, SC, SD, SE, SG,
* SH, SI, SJ, SK, SL, SM, SN, SO, SR, ST, SV, SY, SZ, TC, TD, TF, TG, TH, TJ, TK, TM, TN, TO, TL,
* TR, TT, TV, TW, TZ, UA, UG, UM, US, UY, UZ, VA, VC, VE, VG, VI, VN, VU, WF, WS, YE, YT, RS, ZA,
* ZM, ME, ZW, A1, A2, O1, AX, GG, IM, JE, BL, MF, BQ, SS, O1
*/
//Array with structure MaxMind Code => WPML Code
$this->language_mappings = array('SE' => 'sv', 'NO' => 'nb', 'FI' => 'fi', 'DK' => 'da', 'US' => 'en', 'CA' => 'en');
//Set the default WPML language which is used if no matching language is found
$this->default_language = 'sv';
//Make sure to not redeclare the GeoIP API if it is loaded already.
if (!function_exists('geoip_country_code_by_addr')) {
include_once 'lib/geoip-api-php/geoip.inc';
include_once 'lib/geoip-api-php/geoipregionvars.php';
include_once 'lib/geoip-api-php/timezone/timezone.php';
}
//MaxMind gets cranky when we don't use the full path
$this->db = geoip_open(plugin_dir_path(__FILE__) . '/database/GeoIP.dat', GEOIP_STANDARD);
}
开发者ID:shimuraken0730,项目名称:wp-wpml-geoip-browser-language-redirect,代码行数:33,代码来源:WPML_GeoIP_IPResolver.class.php
示例14: 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
示例15: DolGeoIP
/**
* Constructor
*
* @param $type 'country' or 'city'
* @param $datfile Data file
* @return GeoIP
*/
function DolGeoIP($type,$datfile)
{
if ($type == 'country') require_once(DOL_DOCUMENT_ROOT."/includes/geoip/geoip.inc");
else if ($type == 'city') require_once(DOL_DOCUMENT_ROOT."/includes/geoip/geoipcity.inc");
else { print 'ErrorBadParameterInConstructor'; return 0; }
if (empty($type) || empty($datfile))
{
//dol_syslog("DolGeoIP::DolGeoIP parameter datafile not defined", LOG_ERR);
$this->errorlabel='DolGeoIP constructor was called with no datafile parameter';
//dol_print_error('','DolGeoIP constructor was called with no datafile parameter');
print $this->errorlabel;
return 0;
}
if (! file_exists($datfile))
{
//dol_syslog("DolGeoIP::DolGeoIP datafile ".$datfile." can not be read", LOG_ERR);
$this->error='ErrorGeoIPClassNotInitialized';
$this->errorlabel="Datafile ".$datfile." not found";
print $this->errorlabel;
return 0;
}
$this->gi = geoip_open($datfile,GEOIP_STANDARD);
}
开发者ID:remyyounes,项目名称:dolibarr,代码行数:32,代码来源:dolgeoip.class.php
示例16: __construct
function __construct()
{
$CI =& get_instance();
$CI->config->load('geolocation', true);
$this->config = $CI->config->item('geolocation', 'geolocation');
$this->geoip = geoip_open(dirname(__FILE__) . '/geoip/GeoIP.dat', $this->config['geoip_openmode']);
}
开发者ID:hungarosoft,项目名称:CI-Geolocation,代码行数:7,代码来源:Geolocation.php
示例17: 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
示例18: 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
示例19: __loadFile
private function __loadFile($type = 'country')
{
$type = strtolower((string) $type);
new GeoIP();
switch ($type) {
case 'country':
if (!is_file($this->countryDataFile)) {
throw new Exception(sprintf(__('%s data file is missing'), $type));
return false;
}
return geoip_open($this->countryDataFile, GEOIP_STANDARD);
break;
case 'city':
if (!is_file($this->cityDataFile)) {
return false;
}
App::import('Lib', 'GeoLocation.Geoip/city.php');
App::import('Lib', 'GeoLocation.Geoip/region_vars.php');
return geoip_open($this->cityDataFile, GEOIP_STANDARD);
break;
default:
throw new Exception(sprintf(__('%s is not a valid data file'), $type));
break;
}
}
开发者ID:nani8124,项目名称:infinitas,代码行数:25,代码来源:IpLocation.php
示例20: 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
注:本文中的geoip_open函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论