本文整理汇总了PHP中geoip_country_name_by_name函数的典型用法代码示例。如果您正苦于以下问题:PHP geoip_country_name_by_name函数的具体用法?PHP geoip_country_name_by_name怎么用?PHP geoip_country_name_by_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了geoip_country_name_by_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCountryByIp
/**
* Get the country by IP
* Return an array with : short name, like 'us', long name, like 'United States and response like 'OK' or <error_message> '
* @access public
* @param string $ip
* @return array
*/
public function getCountryByIp($ip)
{
$country = array(0 => 'unknown', 1 => 'NA', 'response' => 'OK');
if (Dot_Kernel::validIp($ip) != "public") {
return $country;
}
if (extension_loaded('geoip') == false) {
// GeoIp extension is not active
$api = new Dot_Geoip_Country();
$geoipPath = $this->config->resources->geoip->path;
if (file_exists($geoipPath)) {
$country = $api->getCountryByAddr($geoipPath, $ip);
} else {
$country['response'] = 'Warning: ' . $this->option->warningMessage->modGeoIp;
}
}
if (function_exists('geoip_db_avail') && geoip_db_avail(GEOIP_COUNTRY_EDITION) && 'unknown' == $country[0]) {
//if GeoIP.dat file exists
$countryCode = geoip_country_code_by_name($ip);
$countryName = geoip_country_name_by_name($ip);
$country[0] = $countryCode != false ? $countryCode : 'unknown';
$country[1] = $countryName != false ? $countryName : 'NA';
}
if ('unknown' == $country[0]) {
// GeoIp extension is active, but .dat files are missing
$api = new Dot_Geoip_Country();
$geoipPath = $this->config->resources->geoip->path;
if (file_exists($geoipPath)) {
$country = $api->getCountryByAddr($geoipPath, $ip);
} else {
$country['response'] = 'Warning: ' . $this->option->warningMessage->modGeoIp;
}
}
return $country;
}
示例2: dmn_getcountry
function dmn_getcountry($mnip, &$countrycode)
{
$mnipalone = substr($mnip, 0, strpos($mnip, ":"));
$res = geoip_country_name_by_name($mnipalone);
$countrycode = strtolower(geoip_country_code_by_name($mnipalone));
return $res;
}
示例3: track
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function track($id, $uniqid)
{
$email = Email::where('id', $id)->where('uniqid', $uniqid)->first();
// If email is found
if ($email) {
// Get data
$ip = $_SERVER['REMOTE_ADDR'];
$host = gethostbyaddr($ip);
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$country = @geoip_country_name_by_name($ip);
if (!$country) {
$country = null;
}
$validator = EmailTracking::validate(array('ip' => $ip, 'host' => $host, 'user_agent' => $user_agent, 'country' => $country));
if ($validator->passes()) {
$tracking = new EmailTracking();
$tracking->ip = $ip;
$tracking->host = $host;
$tracking->user_agent = $user_agent;
$tracking->country = $country;
$tracking->save();
$email->email_trackings()->save($tracking);
// Attach tracking to email
// Send pushbullet notification
$user = $email->user;
if ($user->pushbullet && $ip != env('IGNORE_IP', 'null')) {
$pushbullet = new PHPushbullet($user->pushbullet_api_key);
$message = 'Your email "' . $email->title . '" has been read by ' . $ip . ' (' . $host . ' - ' . $country . ').';
$pushbullet->device($user->pushbullet_device)->note($email->title, $message);
}
// Return pixel
$response = Response::make(File::get(Config::get('mail_tracker.pixel_file')));
$response->header('Content-Type', 'image/gif');
return $response;
}
// Otherwise, log error
abort(500, 'Something went wrong...');
}
// Otherwise, exit
abort(404, 'Email not found!');
}
示例4: getGeocodedData
/**
* {@inheritDoc}
*/
public function getGeocodedData($address)
{
if (!filter_var($address, FILTER_VALIDATE_IP)) {
throw new UnsupportedException('The GeoipProvider does not support Street addresses.');
}
// This API does not support IPv6
if (filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
throw new UnsupportedException('The GeoipProvider does not support IPv6 addresses.');
}
if ('127.0.0.1' === $address) {
return array($this->getLocalhostDefaults());
}
$results = array('country_name' => @geoip_country_name_by_name($address), 'country_code' => @geoip_country_code_by_name($address));
if ($results['country_code'] === false) {
throw new NoResultException(sprintf('Could not find %s ip address in database.', $address));
}
$timezone = @geoip_time_zone_by_country_and_region($results['country_code']) ?: null;
$results = array_merge($this->getDefaults(), array('country' => $results['country_name'], 'countryCode' => $results['country_code'], 'timezone' => $timezone));
return array(array_map(function ($value) {
return is_string($value) ? utf8_encode($value) : $value;
}, $results));
}
示例5: getCountryName
/**
* Get country name.
*
* @return string|false Country name or FALSE on failure
*/
public function getCountryName()
{
return geoip_country_name_by_name($this->ip);
}
示例6: doDirectPayment
//.........这里部分代码省略.........
syslog(LOG_NOTICE, $log);
print "<p>";
print _("Transaction completed sucessfully. ");
/*
if ($this->CardProcessor->environment!='sandbox' && $this->account->first_transaction) {
print "<p>";
print _("This is your first payment. ");
print "<p>";
print _("Please allow the time to check the validity of your transaction before activating your Credit. ");
print "<p>";
print _("You can speed up the validation process by sending a copy of an utility bill (electriciy, gas or TV) that displays your address. ");
print "<p>";
printf (_("For questions related to your payments or to request a refund please email to <i>%s</i> and mention your transaction id <b>%s</b>. "),
$this->account->billing_email,
$pay_process_results['success']['desc']->TransactionID
);
$this->make_credit_checks=true;
} else {
print "<p>";
print _("You may check your new balance in the Credit tab. ");
}
*/
}
if ($this->account->Preferences['ip'] && $_loc=geoip_record_by_name($this->account->Preferences['ip'])) {
$enrollment_location=$_loc['country_name'].'/'.$_loc['city'];
} else if ($this->account->Preferences['ip'] && $_loc=geoip_country_name_by_name($this->account->Preferences['ip'])) {
$enrollment_location=$_loc;
} else {
$enrollment_location='Unknown';
}
if ($_loc=geoip_record_by_name($_SERVER['REMOTE_ADDR'])) {
$transaction_location=$_loc['country_name'].'/'.$_loc['city'];
} else if ($_loc=geoip_country_name_by_name($_SERVER['REMOTE_ADDR'])) {
$transaction_location=$_loc;
} else {
$transaction_location='Unknown';
}
if ($this->account->Preferences['timezone']) {
$timezone=$this->account->Preferences['timezone'];
} else {
$timezone='Unknown';
}
$extra_information=array(
'Account Page' => $this->account->admin_url_absolute,
'Account First Name' => $this->account->firstName,
'Account Last Name ' => $this->account->lastName,
'Account Timezone' => $this->account->timezone,
'Enrollment IP' => $this->account->Preferences['ip'],
'Enrollment Location' => $enrollment_location,
'Enrollment Email' => $this->account->Preferences['registration_email'],
'Enrollment Timezone' => $timezone,
'Transaction Location' => $transaction_location
);
$result = $this->account->addInvoice($this->CardProcessor);
示例7: genInfo
/**
* @param string $proxy
* @param string $answer
* @param null|array $curlInfo
* @return array|bool
*/
protected function genInfo($proxy, $answer, $curlInfo = null)
{
if (preg_match('%^[01]{5}%', $answer) && preg_match_all('%(?<fun_status>[01])%', $answer, $matches)) {
$infoProxy['proxy'] = $proxy['proxy'];
$infoProxy['source'] = isset($proxy['source']) ? $proxy['source'] : null;
$infoProxy['protocol'] = isset($proxy['protocol']) ? $proxy['protocol'] : null;
$infoProxy['anonym'] = (bool) $matches['fun_status'][0];
$infoProxy['referer'] = (bool) $matches['fun_status'][1];
$infoProxy['post'] = (bool) $matches['fun_status'][2];
$infoProxy['get'] = (bool) $matches['fun_status'][3];
$infoProxy['cookie'] = (bool) $matches['fun_status'][4];
$infoProxy['last_check'] = time();
preg_match('%(?<ip>\\d+\\.\\d+\\.\\d+\\.\\d+)\\:\\d+%ims', $infoProxy['proxy'], $match);
$countryName = isset($match['ip']) && function_exists('geoip_country_name_by_name') ? geoip_country_name_by_name($match['ip']) : NULL;
$infoProxy['country'] = $countryName ? $countryName : 'no country';
$infoProxy['starttransfer'] = isset($curlInfo['starttransfer_time']) ? $curlInfo['starttransfer_time'] : NULL;
$infoProxy['upload_speed'] = isset($curlInfo['speed_upload']) ? $curlInfo['speed_upload'] : NULL;
$infoProxy['download_speed'] = isset($curlInfo['speed_download']) ? $curlInfo['speed_download'] : NULL;
return $infoProxy;
} else {
return [];
}
}
示例8: get_countryname_by_ip
/**
* Returns the country name from the current IP
*
* See <get_ip_address>
* @return string Country name or empty string if unknown
*/
function get_countryname_by_ip()
{
// // maxmind installed as server module?
// if(isset($_SERVER["GEOIP_COUNTRY_CODE"]))
// return $_SERVER["GEOIP_COUNTRY_CODE"];
if (function_exists('geoip_open')) {
$gi = geoip_open($GLOBALS['CONFIG']['geoip']['city_dat_file'], GEOIP_STANDARD);
$country_name = geoip_country_name_by_name($gi, $GLOBALS['current_ip_addr']);
geoip_close($gi);
} else {
$country_name = geoip_country_name_by_name($GLOBALS['current_ip_addr']);
}
return $country_name;
}
示例9: getGeoIpHostInfo
/**
* Get GeoIp host information
*
* @return void
*/
protected function getGeoIpHostInfo()
{
if (function_exists('geoip_db_get_all_info') && null !== $this->host && $this->host != '127.0.0.1' && $this->host != 'localhost') {
// Get base info by city
if ($this->databases['city']) {
$data = geoip_record_by_name($this->host);
$this->hostInfo['areaCode'] = $data['area_code'];
$this->hostInfo['city'] = $data['city'];
$this->hostInfo['continentCode'] = $data['continent_code'];
$this->hostInfo['country'] = $data['country_name'];
$this->hostInfo['countryCode'] = $data['country_code'];
$this->hostInfo['countryCode3'] = $data['country_code3'];
$this->hostInfo['dmaCode'] = $data['dma_code'];
$this->hostInfo['latitude'] = $data['latitude'];
$this->hostInfo['longitude'] = $data['longitude'];
$this->hostInfo['postalCode'] = $data['postal_code'];
$this->hostInfo['region'] = $data['region'];
// Else, get base info by country
} else {
if ($this->databases['country']) {
$this->hostInfo['continentCode'] = geoip_continent_code_by_name($this->host);
$this->hostInfo['country'] = geoip_country_name_by_name($this->host);
$this->hostInfo['countryCode'] = geoip_country_code_by_name($this->host);
$this->hostInfo['countryCode3'] = geoip_country_code3_by_name($this->host);
}
}
// If available, get ISP name
if ($this->databases['isp']) {
$this->hostInfo['isp'] = geoip_isp_by_name($this->host);
}
// If available, get internet connection speed
if ($this->databases['netspeed']) {
$netspeed = geoip_id_by_name($this->host);
switch ($netspeed) {
case GEOIP_DIALUP_SPEED:
$this->hostInfo['netspeed'] = 'Dial-Up';
break;
case GEOIP_CABLEDSL_SPEED:
$this->hostInfo['netspeed'] = 'Cable/DSL';
break;
case GEOIP_CORPORATE_SPEED:
$this->hostInfo['netspeed'] = 'Corporate';
break;
default:
$this->hostInfo['netspeed'] = 'Unknown';
}
}
// If available, get Organization name
if ($this->databases['org']) {
$this->hostInfo['org'] = geoip_org_by_name($this->host);
}
}
}
示例10: getCountryInfo
/**
* Returns the country ID and Name for a given hostname.
*
* @param string $name The hostname.
*
* @return mixed An array with 'code' as the country code and 'name' as
* the country name, or false if not found.
*/
public function getCountryInfo($name)
{
if (Horde_Util::extensionExists('geoip')) {
$id = @geoip_country_code_by_name($name);
$cname = @geoip_country_name_by_name($name);
return !empty($id) && !empty($cname) ? array('code' => Horde_String::lower($id), 'name' => $cname) : false;
}
$id = $this->countryIdByName($name);
if (!empty($id)) {
$code = $this->_countryCodes[$id];
return array('code' => Horde_String::lower($code), 'name' => $this->_getName($code));
}
return false;
}
示例11: ip_details
private function ip_details($ip)
{
$ip_details = [];
$ip_details['country'] = geoip_country_name_by_name($ip);
return $ip_details;
}
示例12: require_once
<?
require_once($_SERVER['DOCUMENT_ROOT'].'/private/config.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/private/init/mysql.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/private/func.php');
$table = $table_market = $data_market = $transaction_table = $tx_rate = $block_table = $mn_count = $mntable = $hash_rate = $price_usd = $mtable = $diff_stat = $ghash_rate = $tpools = '';
$all_reward = $k = $other_reward = $pools_all_blocks = $pools_all_reward = $pools_all_hashrate = $step = $all_sum = $all_price = 0;
$pools_stats = array();
$rur = get_json_param('rur');
$markets = get_json_param('markets');
$query = $db->prepare("SELECT * FROM `mn_data`");
$query->execute();
while($row=$query->fetch()){
$mntable = $mntable."<tr><td>{$row['ip']}</td><td>{$row['port']}</td><td>{$row['status']}</td><td><img src=\"https://dash.org.ru/img/16/".mb_strtolower(geoip_country_code_by_name($row['ip'])).".png\"> ".geoip_country_name_by_name($row['ip'])."</td><td>{$row['version']}</td><td><a href=\"https://chainz.cryptoid.info/dash/address.dws?{$row['address']}.htm\" target=\"_blank\">{$row['address']}</a></td></tr>";
}
//$query = $db->prepare("select sum(tx_sum), sum(txs), time from `data` group by month(from_unixtime(`time`)) order by `time` desc");
$query = $db->prepare("select sum(tx_sum), sum(txs), time from `data` group by concat(month(from_unixtime(`time`)),year(from_unixtime(`time`))) order by `time` desc");
$query->execute();
while($row=$query->fetch()){
$transaction_table = $transaction_table."<tr><td>".date("Y, F" ,$row['time'])."</td><td>".round($row['sum(tx_sum)'])."</td><td>{$row['sum(txs)']}</td></tr>";
}
//$query = $db->prepare("select sum(tx_sum), time from `data` group by day(from_unixtime(`time`)) order by `time` asc");
$query = $db->prepare("select sum(tx_sum), date(from_unixtime(`time`)) as dateNum from `data` group by dateNum");
$query->execute();
while($row=$query->fetch()){
if(empty($row["sum(tx_sum)"])) continue;
//$tx_rate = "$tx_rate [{$row['time']}000, ".round($row["sum(tx_sum)"])."],";
$tx_rate = "$tx_rate [".strtotime($row['dateNum'])."000, ".round($row["sum(tx_sum)"])."],";
示例13: getCountry
/**
* getCountry
*
* Returns the country of the set IP.
*
* @access protected
* @static
* @return string
*/
protected static function getCountry()
{
return geoip_country_name_by_name(self::_getIP());
}
示例14: VALUES
$query_select = $db->prepare("SELECT * FROM `node` WHERE `ip` = :ip");
$query_select->bindParam(':ip', $value, PDO::PARAM_STR);
$query_select->execute();
if ($query_select->rowCount() != 1) {
$query_insert = $db->prepare("INSERT INTO `node` (`ip`, `country`, `users`, `hash`, `fee`, `uptime`) VALUES (:ip, :country, :users, :hash, :fee, :uptime)");
$query_insert->bindParam(':ip', $value, PDO::PARAM_STR);
$query_insert->bindParam(':country', geoip_country_name_by_name($value), PDO::PARAM_STR);
$query_insert->bindParam(':users', $users, PDO::PARAM_STR);
$query_insert->bindParam(':hash', round($sum), PDO::PARAM_STR);
$query_insert->bindParam(':fee', round($json['fee'], 2), PDO::PARAM_STR);
$query_insert->bindParam(':uptime', round($uptime), PDO::PARAM_STR);
$query_insert->execute();
} else {
$query_update = $db->prepare("UPDATE `node` SET `country` = :country, `users` = :users, `hash` = :hash, `fee` =:fee, `uptime` = :uptime WHERE `ip` = :ip");
$query_update->bindParam(':ip', $value, PDO::PARAM_STR);
$query_update->bindParam(':country', geoip_country_name_by_name($value), PDO::PARAM_STR);
$query_update->bindParam(':users', $users, PDO::PARAM_STR);
$query_update->bindParam(':hash', round($sum), PDO::PARAM_STR);
$query_update->bindParam(':fee', round($json['fee'], 2), PDO::PARAM_STR);
$query_update->bindParam(':uptime', round($uptime), PDO::PARAM_STR);
$query_update->execute();
}
}
$query = $db->prepare("SELECT * FROM `node`");
$query->execute();
while ($row = $query->fetch()) {
if (!in_array($row['ip'], $addr) || in_array($row['ip'], $remove_nodes)) {
$query_delete = $db->prepare("DELETE FROM `node` WHERE `ip` = :ip");
$query_delete->bindParam(':ip', $row['ip'], PDO::PARAM_STR);
$query_delete->execute();
}
示例15: error
}
if (mb_strlen($post['password']) > 20) {
error(sprintf($config['error']['toolong'], 'password'));
}
wordfilters($post['body']);
$post['body'] = escape_markup_modifiers($post['body']);
if ($mod && isset($post['raw']) && $post['raw']) {
$post['body'] .= "\n<tinyboard raw html>1</tinyboard>";
}
if ($config['country_flags']) {
if (!geoip_db_avail(GEOIP_COUNTRY_EDITION)) {
error('GeoIP not available: ' . geoip_db_filename(GEOIP_COUNTRY_EDITION));
}
if ($country_code = @geoip_country_code_by_name($_SERVER['REMOTE_ADDR'])) {
if (!in_array(strtolower($country_code), array('eu', 'ap', 'o1', 'a1', 'a2'))) {
$post['body'] .= "\n<tinyboard flag>" . strtolower($country_code) . "</tinyboard>" . "\n<tinyboard flag alt>" . @geoip_country_name_by_name($_SERVER['REMOTE_ADDR']) . "</tinyboard>";
}
}
}
if (mysql_version() >= 50503) {
$post['body_nomarkup'] = $post['body'];
// Assume we're using the utf8mb4 charset
} else {
// MySQL's `utf8` charset only supports up to 3-byte symbols
// Remove anything >= 0x010000
$chars = preg_split('//u', $post['body'], -1, PREG_SPLIT_NO_EMPTY);
$post['body_nomarkup'] = '';
foreach ($chars as $char) {
$o = 0;
$ord = ordutf8($char, $o);
if ($ord >= 0x10000) {