Webmaster Forum
Go Back   Webmaster Forums UK SEO SEM Webmaster Community Forum - UKWW > General > General Webmaster Talk
Register FAQ Members List Downloads Calendar Today's Posts Webmaster Resources Webmaster Blogs

UK Web Hosting
UK Web Hosting
Website Hosting
Website Hosting
UK One Way
UK One Way
Get Top 10 Exposure
 
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-29-2007, 03:17 PM
Member
 
Join Date: May 2007
Posts: 42
iTrader: 0 / 0%
Humous is on a distinguished road
Default Geo IP - User location lookup

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:
$ipstring=ip2long($_SERVER);['REMOTE_ADDR']
I couldn't find a perl function so wrote one
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;
}
Then use that number in the following SQL query

Code:
select cc.ci,cc.cn from ip,cc where ip.start < "$ipstring" AND ip.end > "$ipstring" AND ip.ci=cc.ci
Hopefully that will get you going.

Humous
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 06-29-2007, 03:26 PM
gkd_uk's Avatar
Super Moderator
 
Join Date: Mar 2007
Location: zeshaan.info
Posts: 3,653
iTrader: 3 / 100%
gkd_uk has much to be proud ofgkd_uk has much to be proud ofgkd_uk has much to be proud ofgkd_uk has much to be proud ofgkd_uk has much to be proud ofgkd_uk has much to be proud ofgkd_uk has much to be proud ofgkd_uk has much to be proud ofgkd_uk has much to be proud of
Default

Great post - rep added
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 06-29-2007, 03:32 PM
temi's Avatar
Facilitator
 
Join Date: Jun 2003
Location: London, England.
Posts: 11,339
iTrader: 15 / 100%
temi is just really nicetemi is just really nicetemi is just really nicetemi is just really nicetemi is just really nice
Send a message via ICQ to temi
Default

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.
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 06-29-2007, 03:55 PM
Member
 
Join Date: May 2007
Posts: 42
iTrader: 0 / 0%
Humous is on a distinguished road
Default

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.
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 06-30-2007, 12:28 AM
Banned
 
Join Date: May 2007
Posts: 10
iTrader: 0 / 0%
mac_jsn is on a distinguished road
Thumbs up Is your online business paralyze by this? (personal experience)

Hi Humous

If you get any further queries specially related to technical then go for

www(dot)techhelpformarketers(dot)com
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
Reply

Bookmarks

Webmaster Resources
UK Web Hosting
UK WW SEO Tools
Free site submission
Web Directory
 
Advertisement
firewall script
 
Site Of the Month
BizzFace
Nominate site of the month
 
Tag Cloud
3.7 adsense ads space bollywood downloads bollywood latest buy banners cctv changing host changing server channel solutions cheap off page packages cheap seo packages cheap seo services closing coupon code boss cart jv directory announcement domain name extension domain names e brochures ecommerce flash website promotion flash websites forum free directory free directory software google google adwords host quack hostquack inline price changes introduction ipn paypal payment boss job site joomla job junglejar junglejar.com lbs. link bid script link bid script hungarian link exchange linux host moving server nokia off page seo packages picture of the day referral sale sell baners seo seo packages shared hosting sososher submit url switching host symbian templates tld today in history traffic transfering host uk shipping postcodes upgrade vbulletin web design webinare webmaster tools website wordpress

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


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 Google 4 05-18-2007 12:36 PM
User Accounts mikes Boss Cart General Support 1 03-30-2007 11:27 PM


All times are GMT. The time now is 06:06 AM.

UK Webmaster World Forums - Internet marketing, web development, domain names, SEO contest and discussuons.
Subscribe to our feeds   Subscribe to our feeds

Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149