Пример #1
16
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
0
 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');
 }
Пример #3
0
 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');
 }
Пример #4
0
 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;
 }
Пример #5
0
/**
 * 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');
}
Пример #6
0
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
        }
    }
}
Пример #7
0
 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;
 }
Пример #8
0
 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);
 }
 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;
 }
Пример #10
0
 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();
     }
 }
Пример #11
0
/**
 * Получение названия страны по айпишнику
 *
 * @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);
}
Пример #12
0
 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']));
         }
     }
 }
 /**
  * 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);
 }
 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);
 }
Пример #15
0
	/**
	 * 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);
	}
Пример #16
0
 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']);
 }
Пример #17
0
 /**
  * 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;
 }
Пример #18
0
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);
}
Пример #19
0
 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;
     }
 }
Пример #20
0
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;
}
Пример #21
0
 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);
 }
Пример #22
0
 private function open()
 {
     $file = $this->getGeoliteFileName();
     if (!file_exists($file)) {
         return false;
     }
     $this->handle = geoip_open($file, GEOIP_STANDARD);
 }
Пример #23
0
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;
}
Пример #24
0
 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);
 }
Пример #25
0
 private function open()
 {
     $file = __DIR__ . "/geoip/GeoLiteCity.dat";
     if (!file_exists($file)) {
         return false;
     }
     $this->handle = geoip_open($file, GEOIP_STANDARD);
 }
Пример #26
0
function geoip_get_details_by_host($host)
{
    require_once 'geoipcity.php';
    $geoip = geoip_open('./GeoLiteCity.dat', GEOIP_STANDARD);
    $details = GeoIP_record_by_addr($geoip, gethostbyname($host));
    geoip_close($geoip);
    return $details;
}
Пример #27
0
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;
}
Пример #28
0
 public function testRegion()
 {
     $gi = geoip_open("tests/data/GeoIPRegion.dat", GEOIP_STANDARD);
     list($countryCode, $region) = geoip_region_by_addr($gi, '64.17.254.223');
     $this->assertEquals('CA', $region);
     $this->assertEquals('US', $countryCode);
     global $GEOIP_REGION_NAME;
     $this->assertEquals('California', $GEOIP_REGION_NAME[$countryCode][$region]);
 }
Пример #29
0
/**
* Функция определения страны бота
*/
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;
}
Пример #30
0
 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);
 }