Welcome, Guest. Please login or register.
Did you miss your activation email?
February 13, 2012, 12:49:56 AM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
149699 Posts in 21103 Topics by 7538 Members
Latest Member: ionline
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: New Admin-Tool: GeoIP  (Read 6042 times)
thorn

Offline Offline

Posts: 980


WWW
« on: September 27, 2008, 09:42:02 PM »

Hello,

GeoIP v1.3.2  (updated: 05 Apr 2009)

Developer Documentation: http://nettest.thekk.de/docs/geoip/files/geoip_functions-php.html

This version includes the database-file, so there is no need for an initial download.
ATTN: if you have downloaded the database manually so far, you may have to remove it manually too, before trying to update this module.

GeoIP provides a geoip-database which can be used from within other website baker modules.
(I used "GeoLite Country" from http://maxmind.com/).
There are flag-icons added for each country, too.
Since 1.2, there is the phpwhois-library, too.

Requirements:
PHP 4.1 (4.3 for download-functionality) or higher, or PHP 5.x

See the second image for an example on what you can do (as module developer) with this data.

If you are a module-developer, planning to make use of geoip-data for your own module, please consider to use this admin-tool (please read the developer documentation under Admin-Tools-->GeoIP-->Developer-Docu).

Edit: Database-download requires PHP >=4.3. For PHP <4.3 the download-field will be disabled and one has to download the database manually.

In time of writing there are two module using this tool (searchtools >= v0.60.01, guestbook >= v2.8.2.)

Using-example (if geoip is required):
Code: (example)

// load geoip-functions
if(file_exists(WB_PATH.'/modules/geoip/geoip_functions.php'))
    require_once(WB_PATH.'/modules/geoip/geoip_functions.php');
else
    exit('GeoIP-module not installed!');

$gi = geoip_open_db(); // opens GeoIP database
if($gi===FALSE)
    exit(Failed to open GeoIP-database!);

$ip = geoip_best_ip();

echo $ip.' - '.geoip_country_code_by_addr($gi, $ip).' - '.geoip_country_name_by_addr($gi, $ip).' - '.geoip_flag_html($gi, $ip);

geoip_close($gi);

Quote from: output

86.10.40.1 - GB - United Kingdom -

Using-example II (if geoip is optional):
Code: (example)

// load geoip-functions, if available
if(file_exists(WB_PATH.'/modules/geoip/geoip_functions.php'))
    require_once(WB_PATH.'/modules/geoip/geoip_functions.php');

if(function_exists('geoip_open_db'))
    $gi = geoip_open_db(); // $gi will be FALSE if this fails
else
    $gi = FALSE;

// Now you can check against $gi or defined('GEOIP_DATABASE_LOADED') to see if geoip-database is ready to use
// if($gi) { // ready to use } else { // not available }
// if(defined('GEOIP_DATABASE_LOADED')) { // ready to use } else { // not available }

if($gi)
    $ip = geoip_best_ip();
else
    $ip = '';

if($gi) {
    echo $ip.' - '.geoip_country_code_by_addr($gi, $ip).' - '.geoip_country_name_by_addr($gi, $ip).' - '.geoip_flag_html($gi, $ip);
} else {
    echo '<br />';
}

if($gi)
    geoip_close($gi);



End-users: You need to install this admin-tool ONLY if required by a module.


Download: http://www.websitebakers.com/pages/admin/admin-tools/geoip.php

thorn.

This product includes GeoLite data created by MaxMind, available from http://maxmind.com/
This product includes flag-icons, available from http://www.famfamfam.com/
This product includes phpwhois, available from http://sourceforge.net/projects/phpwhois

« Last Edit: July 24, 2009, 01:57:23 PM by thorn » Logged

thorn

Offline Offline

Posts: 980


WWW
« Reply #1 on: November 12, 2008, 07:22:05 PM »

Hello,

just released GeoIP 1.2

changes:
- added API, see file DEVELOPER.txt
- added phpwhois-library from http://sourceforge.net/projects/phpwhois (GPL), see file DEVELOPER.txt
- used phplib's template-system

thorn.
Logged

mad_nico

Offline Offline

Posts: 8


« Reply #2 on: November 30, 2008, 03:57:54 PM »

Hi,

kann es sein, dass maxmind.com den Namen für die DB Datei geändert hat? Dort gibts nur noch eine GeoLiteCity.dat.gz. Reicht es, wenn man den Namen entsprechend in den Install Dateien ändert, oder muss noch was anderes angepasst werden?

Could it be, that maxmind.com has changed its DB filenames to GeoLiteCity.dat.gz? If so, should I change the name to the right one in installation files, or is more to change?
Logged
thorn

Offline Offline

Posts: 980


WWW
« Reply #3 on: November 30, 2008, 04:59:57 PM »

Hello,

oh, MaxMind changed the path to
Code:
http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
Please update your configuration accordingly.

I didn't test GeoLiteCity.dat.gz for use with GeoIP. The file is much bigger 18MB (18-Megabytes sic!) against 550KB.
Zumal die Genauigkeit dieser IP2City-Dienste sowieso alles andere als Toll ist. Wenn du Glück hast bekommst du wenigstens eine Stadt aus der näheren Umgebung angezeigt -- wenn du Pech hast dagegen nur den Firmensitz des Providers.

thorn.
Logged

ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 7665



WWW
« Reply #4 on: December 27, 2008, 10:12:19 AM »

Hello,

just tested guestbook 2.8.4 together with GeoIP 1.2. Got it working with some manually changes. Maybe there should made a fixed GeoIP 1.3

1.) Couldn't change the Path to GeoIP.dat.gz in the admin tools. It is greyed out. So there are two possible solutions:
     a) in install.php there should be the correct path or
     b) in admin tools the path should be editable.

2.) The tool couldn't download and store the GeoIP.dat.gz. The Path is correct (manually download works) and temp folder has (ftp)chmod 777. So don't know why it does not work from within the admin tool. Manually upload the dat.gz and then actualize works without issues.

Matthias
Logged
maverik

Offline Offline

Posts: 1541



WWW
« Reply #5 on: December 27, 2008, 10:45:22 AM »

hello

at an 1&1 hosting account it is the same as ruebenwurzel wrote

on my own server it works fine, i can change the download path and download and store the GeoIP.dat.gz

greets maverik
Logged

Signatur wird geladen...
ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 7665



WWW
« Reply #6 on: December 27, 2008, 11:42:18 AM »

Hello,

think i found the issue. Since PHP 5.2 there exists a value "allow_url_include". If this is set to "off" you got the above described issue.

Had som other domains where allow_url_include is on and there the geoip tool works like a charm.

Unfortunately it seems not to be possible this value to overwrite with .htaccess and php_value or from within a script with ini_set. So i asked my hoster to change this.

Matthias

Edit:
Setting allow_url_include to on didn't solve the issue.
« Last Edit: December 27, 2008, 02:11:37 PM by ruebenwurzel » Logged
thorn

Offline Offline

Posts: 980


WWW
« Reply #7 on: December 27, 2008, 01:41:15 PM »

Hello,

1.) Couldn't change the Path to GeoIP.dat.gz in the admin tools. It is greyed out. So there are two possible solutions:
     a) in install.php there should be the correct path or
     b) in admin tools the path should be editable.

This is the expected behavior -- if PHP<4.3.0 or ini_get(allow_url_fopen)==OFF, the download is disabled, and one has to download the file manually, and copy it to the directory stated in "Copy GeoIP.dat.gz from".

Hope this worked as exacted!?

thorn.
Logged

ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 7665



WWW
« Reply #8 on: December 27, 2008, 02:09:40 PM »

Hello,

temporary here the phpinfo of my page. allow_url_fopen = On and allow_url_include = on but the download is disabled. Another server mysterium?

Matthias
Logged
thorn

Offline Offline

Posts: 980


WWW
« Reply #9 on: December 27, 2008, 03:02:29 PM »

Hello,

Another server mysterium?

It will fail (and should show a PHP warning - did you try Error-Level E_ALL?) if ini_get() is not allowed on your server (but it's all-inkl, isn't it?).

You can try and empty the field download_from from table geoip_settings. Once empty, the field is enabled, and you can enter a new url. - But it will be disabled again after hitting save, i bet.

thorn.
Logged

ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 7665



WWW
« Reply #10 on: December 27, 2008, 05:13:02 PM »

Hello,

Quote
You can try and empty the field download_from from table geoip_settings. Once empty, the field is enabled, and you can enter a new url. - But it will be disabled again after hitting save, i bet.

Exactly this happens.

Quote
It will fail (and should show a PHP warning - did you try Error-Level E_ALL?) if ini_get() is not allowed on your server (but it's all-inkl, isn't it?).

E_All brings no PHP warning, and yes it is allinkl and the mysterium is on other allinkl pages it works. huh

Matthias
Logged
thorn

Offline Offline

Posts: 980


WWW
« Reply #11 on: December 27, 2008, 06:36:33 PM »

Hello,

just released GeoIP 1.3.0

        - updated download-URL
        - added functions to fetch hostname and to check hostname through reverse lookup
        - on some servers the Download-field was disabled. Supposed to be fixed now.

thorn.
Logged

maverik

Offline Offline

Posts: 1541



WWW
« Reply #12 on: December 27, 2008, 06:53:51 PM »

hello

the new version dont work for me, only a blank page at adminpanel, at my own server and on 1&1 hosting

i uninstalled it and reinstalled version 1.2.0 and it works fine

so long maverik
Logged

Signatur wird geladen...
thorn

Offline Offline

Posts: 980


WWW
« Reply #13 on: December 27, 2008, 07:14:01 PM »

Hello,

need a break - used php_version() instead of phpversion() by an oversight.

GeoIP 1.3.1 is fixed.

thorn.
Logged

ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 7665



WWW
« Reply #14 on: December 27, 2008, 07:54:32 PM »

Hello,

you're great thomas. Version 1.3.1 works as aspected. Thanks for this fantastic Tool.

Matthias
« Last Edit: December 27, 2008, 07:56:13 PM by ruebenwurzel » Logged
thorn

Offline Offline

Posts: 980


WWW
« Reply #15 on: April 05, 2009, 01:12:32 AM »

Hello,

just released GeoIP 1.3.2

- new developer documentation (Admin-Tool --> GeoIP --> Developer-Docu)
- added two functions: geoip_in_bogons_lis t($ip) and geoip_in_drop_list($ip)
  to check $ip against bogons-list (private, unallocated) and spamhaus' drop-list ("Don't Route Or Peer", stolen 'zombie' netblocks and netblocks controlled entirely by professional spammers).
- the GeoIP-Database is now included into the module, no need for an initial download anymore.

See first post for download.

thorn.
« Last Edit: April 11, 2009, 02:37:59 PM by thorn » Logged

quinto

Offline Offline

Posts: 67


WWW
« Reply #16 on: April 05, 2009, 08:13:22 PM »

Hello,

just released GeoIP 1.3.2

- new developer documentation (Admin-Tool --> GeoIP --> Developer-Docu)
- added two functions: geoip_in_bogons_lis t($ip) and geoip_in_drop_list($ip)
  to check $ip against bogons-list (private, unallocated) and spamhaus' drop-list ("Don't Route Or Peer", stolen 'zombie' netblocks and netblocks controlled entirely by professional spammers).
- the GeoIP-Database is now included into the module, no need for an initial download anymore.

thorn.

Hello, here is the FR.php file for GeoIP 1.3.2 Smiley
Logged
thorn

Offline Offline

Posts: 980


WWW
« Reply #17 on: April 05, 2009, 09:48:19 PM »

Hello,

thanks for this contribution. Will add it in next release.

thorn.
Logged

oeh

Offline Offline

Posts: 190



« Reply #18 on: April 11, 2009, 10:26:47 PM »

Hi.

I've don a Norwegian translation.

Regards
Odd Egil
Logged

Good bye ;-{(
oeh ;-}>
thorn

Offline Offline

Posts: 980


WWW
« Reply #19 on: April 12, 2009, 12:17:39 AM »

Hello,

thanks for this contribution, too. Will add it to next release.

thorn.
Logged

Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!