Rectangle 27 1

It appears you need to install a C library in order to use GeoIP.

Here is a snippet from the file that is throwing that error.

# The shared library for the GeoIP C API.  May be downloaded
#  from http://www.maxmind.com/download/geoip/api/c/
if lib_path:
    lib_name = None
else:
    # TODO: Is this really the library name for Windows?
    lib_name = 'GeoIP'

Once you have it installed somewhere you need to reference it in your settings.py

GEOIP_LIBRARY_PATH = '/whatever'

The library was trying to tell you this, but it seems that there is a bug that prevents it from raising the correct error. https://github.com/django/django/pull/103

Python/django : Cannot import GeoIP - Stack Overflow

python django geodjango geoip
Rectangle 27 3

First download the ASN database from GeoIP then install pygeoip by

pip install pygeoip
>>> gi = pygeoip.GeoIP('/path/to/GeoIPASNum.dat')
>>> gi.org_by_name('cnn.com')
'AS5662 Turner Broadcasting'
>>> gi.org_by_addr("90.223.167.43")
u'AS5607 BSKYB-BROADBAND-AS'

If you do not want to download any database you can use pyip2asn

In [1]:import pyip2asn

In [2]:# Generate ASN Description Dictionary in order to speed up the IPv4 to ASN lookup.

In [3]: asn_dict = pyip2asn.get_asn_dictionary()
In [4]: pyip2asn.ip2asn("8.8.8.8",asn_dict)
Out[4]: (15169, u'GOOGLE - Google Inc.')

python - How to query ASN for a known IP address with GeoIP on Django?...

python django gis geodjango geoip
Rectangle 27 0

The reason you're stuck in a loop is that your script is probably executed on every page an on every page-load.

You are most likely working with sessions, so the most convenient way would be to just set a flag there that you have already checked this user:

<?php

//...

// Do this only if the flag is not set
if( ! isset($_SESSION['checkedGeoIp']) )
{
  // Set the flag here so you don't need to set it after each case.
  // Now this will be set for all requests during the session and 
  // the above if-statement will prevent from checking and redirecting again
  $_SESSION['checkedGeoIp'] = true;

  // Execute the GeoIP logic...
  require_once('geoplugin.class.php');
  $geoplugin = new geoPlugin();
  $geoplugin->locate();
  $country_code = $geoplugin->countryCode;

  switch ($country_code)
  {
      // ...
  }

}

thank you man, the problem is that script not working so I switched to Javascript one, if you can help i'll appreciate it stackoverflow.com/questions/22897314/

html - PHP GeoIP loop error - Stack Overflow

php html loops geolocation geoip
Rectangle 27 0

The specific database for location lookups is probably not installed. Try geoip_country_code_by_name and it should work.

php - GeoIP installed / loaded, but not returning records - Stack Over...

php geolocation geoip php-extension
Rectangle 27 0

You probably already have GEOIP installed as a PECL extension. If you don't, then you can just install it yourself.

If you need anything more specific than country, you'll have to pay to get the DB, but the functions are still there.

php - GEOIP and getting a computers IP address Location? - Stack Overf...

php ip
Rectangle 27 0

If you have direct access to the server/command line, you can use the binary format. This offers better performance, but you will need to alter your PHP configuration to install the GeoIP extension or Pecl package. This then gives you access to some handy PHP functions: http://www.php.net/manual/en/ref.geoip.php

If you don't have access to the server config, you can download the CSV versions and import this into a MySQL DB. You will then have direct access to the data and you can write the relevant queries to produce the results required by your app. If you're using PHP MyAdmin MySQL panel, you can just download the CSV gz or zip and upload/import directly. You will need to create the tables first. Remember to create indexes on the relevant columns.

GeoLite City contains two tables, IP block/City and City Locations (lat/lng). GeoLite Country contains only IP blocks and country names.

If you don't need IP data, the World Cities Database may be more suitable: http://www.maxmind.com/en/worldcities

If you're only concerned with the second file of the geoIP city data, the following SQL will create a table with the necessary columns:

DROP TABLE IF EXISTS location;
CREATE TABLE location(
    locId int(10) unsigned NOT NULL,
    country char(2) NOT NULL,
    region char(2) NOT NULL,
    city varchar(50),
    postalCode char(5) NOT NULL,
    latitude float,
    longitude float,
    dmaCode integer,
    areaCode integer,
    PRIMARY KEY (locId)
);

Presuming you mean under the PHPMyAdmin, I have found a query window I can open and can from there upload files, if this is not what you meant, could you please explain further how I would find out if I have direct access to the server/command line? Best Regards, Tim

Unless you have a dedicated or virtual server from 1&1 you probably don't have command line access. Stick with the CSVs. Yes use PHPMyAdmin. The following guide (taken from the Maxmind resources page) details what you need to do: bartomedia.blogspot.co.uk/2007/11/

The first part of this tutorial returns "MySQL said: #1044 - Access denied for user 'dbo458117895'@'%' to database 'geoip'"

If you're with 1&1, you've probably already created the database in your control panel. So just skip the first part. If you connect to the DB using PHPMyAdmin, you're already "using" the DB, whatever it may be called (not necessarily "geoip").

Skipping this step seems to get myself back on track with the tutorial. I'll continue but not set this as the answer just yet in case I need further assistance.

php - How to set up and using GeoIP Lite - Stack Overflow

php database phpmyadmin
Rectangle 27 0

You'll need to find a repo that has this module already added. If you find it, you can simply use that.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

ubuntu 12.04 - Installing nginx + geoip with puppet - Stack Overflow

nginx ubuntu-12.04 puppet geoip
Rectangle 27 0

The 'GeoIP.h could not be located' error indicates that you need to install libgeoip-dev first. Though I have no idea how to install it on windows easiy.

I suggest you to use the pygeoip package, based on the following reasons:

For the legacy GeoIP format, pygeoip is the better API unless you absolutely need the extra speed. It isn't quite compatible with the MaxMind API, but the differences are fairly minor.

For the new MaxMind format, geoip2 provides both a C extension and pure Python version.

Thank you! This worked very well. I was trying to use Django's GeoIP implementation, but this was far easier to work with and apply to what I needed.

python - Install GeoIP on Windows? - Stack Overflow

python django geoip
Rectangle 27 0

# emerge dev-php/pecl-geoip 
 * Last emerge --sync was 43d 4h 12m 46s ago.
>>> Verifying ebuild manifests
>>> Starting parallel fetch
>>> Emerging (1 of 2) dev-libs/geoip-1.4.8
>>> Installing (1 of 2) dev-libs/geoip-1.4.8
>>> Emerging (2 of 2) dev-php/pecl-geoip-1.0.7-r1
>>> Installing (2 of 2) dev-php/pecl-geoip-1.0.7-r1
>>> Recording dev-php/pecl-geoip in "world" favorites file...
# /etc/init.d/apache2  restart 
 * apache2 not running (no pid file)
 * Starting apache2 ...       [ ok ]

# cd /usr/share/GeoIP
# wget http://www.pc-freak.net/bshscr/geoip_update.sh 
--2012-02-23 15:09:01--  http://www.pc-freak.net/bshscr/geoip_update.sh
Resolving www.pc-freak.net... 83.228.93.76
Connecting to www.pc-freak.net|83.228.93.76|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 270 [application/x-sh]
Saving to: `geoip_update.sh'

100%[=============================>] 270         --.-K/s   in 0s      

2012-02-23 15:09:01 (54.4 MB/s) - `geoip_update.sh' saved [270/270]

# bash geoip_update.sh 
--2012-02-23 15:10:07--  http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
Resolving geolite.maxmind.com... 174.36.207.186
Connecting to geolite.maxmind.com|174.36.207.186|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17572430 (17M) [text/plain]
Saving to: `GeoLiteCity.dat.gz'

100%[=============================================>] 17,572,430  2.63M/s   in 9.0s    

2012-02-23 15:10:16 (1.86 MB/s) - `GeoLiteCity.dat.gz' saved [17572430/17572430]

# ln -s  GeoLiteCity.dat  GeoIPCity.dat 

# cd /var/www/raptor.lan/htdocs/ # <-- MY WEB ROOT
# mkdir -p tmp/geoip
# cd tmp/geoip/
# cat hmz.php 
<?php

echo "<pre>";
print_r(geoip_record_by_name('php.net'));

?>
# curl http://localhost/tmp/geoip/hmz.php
<pre>Array
(
    [continent_code] => NA
    [country_code] => US
    [country_code3] => USA
    [country_name] => United States
    [region] => CA
    [city] => Sunnyvale
    [postal_code] => 94089
    [latitude] => 37.424900054932
    [longitude] => -122.0074005127
    [dma_code] => 807
    [area_code] => 408
)

btw. your config might be wrong.

# equery f dev-php/pecl-geoip  | grep ini 
/etc/php/apache2-php5.3/ext-active/geoip.ini
/etc/php/apache2-php5.3/ext/geoip.ini
/etc/php/cli-php5.3/ext-active/geoip.ini
/etc/php/cli-php5.3/ext/geoip.ini
raptor: ~
# cat /etc/php/apache2-php5.3/ext-active/geoip.ini 
extension=geoip.so

linux - gentoo geoip installation - Stack Overflow

linux gentoo geoip
Rectangle 27 0

Here is the example :

GeoIPEnable On
GeoIPDBFile /path/to/GeoIP.dat
RewriteEngine On
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} !(US|GB|CA)$
RewriteRule ^(.*)$ /error_page.html [NC,L]

The above example checks the IP and redirects the request to error_page.html in case the IP does not belong to US,GB and CA. Can you let me know the rule that you are using, if it is other than the mentioned above ?

i am using this example in my vhost config: dev.maxmind.com/geoip/ (Allowing clients based on country) I do not use .htaccess for blocking

Check this : dev.maxmind.com/geoip/mod_geoip2 and go to section "Redirecting a client based on country". You redirect request to any page based on the country

yes but this only works in htaccess i think. and if i do it with htaccess i have to place htaccess in every folder of my app. if i have it in my vhost config, it "secures" my whole vhost. is it not possible to include it in vhost? or can i just use this code in my vhost too?

apache - Apache2 GeoIP / mod_geoip2 custom error page - Stack Overflow

apache geoip
Rectangle 27 0

The Database might be outdated. Why don't use use a remote solution that is properly updated such as http://www.geoplugin.net/

$xml = simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=76.109.14.196");
echo $xml->geoplugin_countryName ;
United States

Should be mentioned that remote solution is slower and may be down.

You can combine it with cache solution like memcache how many request are you look at per min ?

This is an acceptable alternative, but I'm interested in solving the original problem (for the sake of understanding, and also for the reasons @hookman listed).

php - GeoIP installed / loaded, but not returning records - Stack Over...

php geolocation geoip php-extension
Rectangle 27 0

There seems to be a mis-configuration or you are giving the function name wrong. To check that it's successfully installed/active;

if (function_exists("Function_Name_Here")) {
  echo "Function Does Exist";
} else {
  echo "Function Does Not Exist";
}

If this function "does not exist" then re-trace through your installation steps of consult the official manual of this extension for exact installation instructions.

I installed GeoIP-1.5.0.tar.gz then yum install php-pear and yum install pecl

how can I check the configuration of geoip ?

why it's working with php5.3 and not php5.4

php - Call to undefined function geoip - Stack Overflow

php linux geoip
Rectangle 27 0

Have tried that, to no effect. Is there a way to effectively and completely uninstall both of them and then try again from a blank slate?

Installing GeoIP - maxminddb_module and libmaxminddb Errors - Stack Ov...

geoip
Rectangle 27 0

  • Extract in your computer
  • Add extension=php_geoip.dll in php.ini

Installing PERCL GeoIP for PHP on windows XAMPP - Stack Overflow

php xampp geoip
Rectangle 27 0

Your previous web host likely had the GeoIP PECL extension installed. If you install that and the GeoIP City database at your new web host, the above code should work.

If you are unable to install extensions, you could try the pure PHP API. You will have to make some changes to your code though, as the API differs slightly from the extension.

redirect - How to fix this MaxMind GeoIP redirection issue? - Stack Ov...

redirect geoip maxmind
Rectangle 27 0

include ("include/geoip.inc");

I got it to work by adding that include and $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD); But does that mean it's going to load this 700kb file every time the script is processed? I am writing a tracking script that may fire several times per second, so loading a file that size with each run is really not ideal.

Yeah, I think it will have to load each time. Maybe you can move the functions you need into a new file and include that instead...sounds tedious.

Internal Error 500 with nginx and PHP GeoIP Module - Stack Overflow

php nginx geolocation geoip
Rectangle 27 0

It appears you need to install a C library in order to use GeoIP.

Here is a snippet from the file that is throwing that error.

# The shared library for the GeoIP C API.  May be downloaded
#  from http://www.maxmind.com/download/geoip/api/c/
if lib_path:
    lib_name = None
else:
    # TODO: Is this really the library name for Windows?
    lib_name = 'GeoIP'

Once you have it installed somewhere you need to reference it in your settings.py

GEOIP_LIBRARY_PATH = '/whatever'

The library was trying to tell you this, but it seems that there is a bug that prevents it from raising the correct error. https://github.com/django/django/pull/103

Python/django : Cannot import GeoIP - Stack Overflow

python django geodjango geoip
Rectangle 27 0

It turns out that I made a mistake, and was looking for the file in the wrong location on the server. That said the error messages given by geoip don't make it clear where the error in the code lies and it would be helpful to be told that no .dat file was located and throw the error at the 'LookupService' line rather than the error coming on the 'Country' line. Thanks for those who tried to help!

c# - Maxmind/geoip error "Database has been closed" - Stack Overflow

c# maxmind
Rectangle 27 0

These DLLs cover PHP versions 5.3, 5.4 and 5.5, including threadsafe (TS) and non-threadsafe (NTS). PHP 5.3 and 5.4 are compiled against VC9 on x86 while PHP 5.5 uses VC11 for both x86 and x64. You can figure out which to use in your PHP's phpinfo output.

The dll should go in PHP's extension directory - this varies depending on the installation. Look for "extension" in phpinfo's output to tell you what directory extensions are loaded from. Finally, in the php.ini, enable it via extension=php_geoip.dll

pear - install php extension geoip on windows - Stack Overflow

php pear pecl geoip
Rectangle 27 0

If you really have a comma in there, then you are setting GEOIP_PATH to a tuple and not a string, which would explain the error. If this is the case, simply remove the comma:

# settings.py

import os

BASE_DIR = os.path.abspath(os.path.dirname(__file__))
GEOIP_PATH = os.path.join(BASE_DIR, 'geoip')

Oh, your __file__ probably turned into file in your above comment

That's exactly right. I haven't figured out how to post formatted code in comments. But the underscore was there. Still can't figure out what the issue is.

Well, I tried that and got the same error. Sorry for the frustration. Have been trying to get GeoIP to work for nine hours.

Okay, i closed out the old shell, restarted and it seems to be working. Thanks!

python - Django GeoIP Error; invalid path type - Stack Overflow

python django geolocation