![]() |
|
|||||||
| Register | FAQ | Members List | Downloads | Calendar | Today's Posts | Search | Webmaster Resources | Webmaster Blogs |
![]() UK Web Hosting |
![]() Website Hosting |
![]() UK One Way |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I've just spent a little time setting up a trial for Geo IPLite to resolve users IP addresses to Country, seeing as you've all been nice and posted things like this here I thought I would too.
I've ran my demo from a Linux apache server running MySQL, I am currently using Perl but have also tested using PHP. 1st off download the CSV data from here and import the data into your database, I found the instructions here to be full and complete for my purposes (I would rewrite it here but it's that good). Not wanting to install their APIs I set about utilizing the data from Perl, the biggest problem is that the GeoIP lists ip addresses as "ip strings" (which is a term I hadn't come across before). The IP string is a concatination of the 4 (8bit) binary IP blocks converted to decimal. So as a quick example 192.168.1.0 becomes 3215458560. I believe the PHP for getting the user IP address/string is PHP Code:
Code:
$ipstring=ipstring($ENV{'REMOTE_ADDR'});
sub ipstring
{
my ($numip) = @_;
my($w,$null,$x,$null,$y,$null,$z,$null)=split /([.])/,$numip;
$numw = substr(unpack("B*", pack("N", $w)),24,8);
$numx = substr(unpack("B*", pack("N", $x)),24,8);
$numy = substr(unpack("B*", pack("N", $y)),24,8);
$numz = substr(unpack("B*", pack("N", $z)),24,8);
$comb="$numw$numx$numy$numz";
$decval = unpack("N", pack("B32", substr($comb, -32)));
return $decval;
}
Code:
select cc.ci,cc.cn from ip,cc where ip.start < "$ipstring" AND ip.end > "$ipstring" AND ip.ci=cc.ci Humous |
|
||||
|
Great post - rep added
![]()
__________________
|
|
||||
|
Nice post mate
![]()
__________________
* Build a shopping cart for your business with eCommerce software UK * BossCart.com can build you a Bespoke shopping cart :: Add Eco sites to The Green Directory free of charge. |
|
|||
|
I looked into this when I 1st started using Perl (way before I started PHP) and couldn't figure it out. Tried again yesterday and found it a lot easier.
Now - to figure out how to combine htaccess with Active Directory... To the VM lab Thanks for the rep GKD Humous. |
![]() |
| Bookmarks |
| Webmaster Resources |
| • UK Web Hosting • UK WW SEO Tools • Free site submission • Web Directory |
| Advertisement |
|
| Site Of the Month |
![]() Nominate site of the month |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can you change my user name? | Christoper | Help using this forum | 2 | 11-29-2007 10:07 PM |
| Is there a user manual? | buzz_r@hotmail.com | FAQs | 0 | 11-22-2007 05:54 AM |
| Bulk Domain Lookup & Research Script | midlandi | Webmaster Toolbox | 0 | 08-09-2007 10:48 PM |
| For country sepecific search hosting location plays role? | UK WW ex member | 4 | 05-18-2007 12:36 PM | |
| User Accounts | mikes | Boss Cart General Support | 1 | 03-30-2007 11:27 PM |
| UK Webmaster World Forums - Internet marketing, web development, domain names, SEO contest and discussuons. |
| Subscribe to our feeds |