Maybe a group project?
Moderator: General Moderators
Maybe a group project?
Hey guys - I have an idea for a project that maybe a few people could contribute to =>
Given a database of ip addresses, this script creates an image of a map showing (through colors) the density of the ip address locations.
Here are my inital questions...
Whats the easiest way to find the country of an ip address?
Any ideas on how to do this map idea?
Given a database of ip addresses, this script creates an image of a map showing (through colors) the density of the ip address locations.
Here are my inital questions...
Whats the easiest way to find the country of an ip address?
Any ideas on how to do this map idea?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
$ipLong = ip2long($ip);
$sql = "SELECT `COUNTRY_NAME` FROM `IP_Countries` WHERE `IP_FROM` <= '$ipLong' and `IP_TO` >= '$ipLong'";Code: Select all
$ipLong = ip2long($ip);
$sql = "SELECT `COUNTRY_NAME` FROM `IP_Countries` WHERE '$ipLong' BETWEEN `IP_FROM` AND `IP_TO`";- smpdawg
- Forum Contributor
- Posts: 292
- Joined: Thu Jan 27, 2005 3:10 pm
- Location: Houston, TX
- Contact:
BTW - I like the idea but resolution to country is pretty vague. I would like to know to a finer detail like state or even city. It would make an interesting display especially if it were dynamic so you could see where the people you are talking to are located.
It is good for trying to default to a language or hint at a language but I want more.
It is good for trying to default to a language or hint at a language but I want more.
How do i "structure dump" through phpmyadmin?
Field Type Null Default
IP_FROM double No 0
IP_TO double No 0
COUNTRY_CODE2 char(2) No
COUNTRY_CODE3 char(3) No
COUNTRY_NAME varchar(50) No
Indexes :
Keyname Type Cardinality Field
IP_FROM INDEX 54775 IP_FROM
IP_TO INDEX 54775 IP_TO
Copied from the print view from phpmyadmin...
Field Type Null Default
IP_FROM double No 0
IP_TO double No 0
COUNTRY_CODE2 char(2) No
COUNTRY_CODE3 char(3) No
COUNTRY_NAME varchar(50) No
Indexes :
Keyname Type Cardinality Field
IP_FROM INDEX 54775 IP_FROM
IP_TO INDEX 54775 IP_TO
Copied from the print view from phpmyadmin...
CREATE TABLE `IP_Countries` (
`IP_FROM` double NOT NULL default '0',
`IP_TO` double NOT NULL default '0',
`COUNTRY_CODE2` char(2) NOT NULL default '',
`COUNTRY_CODE3` char(3) NOT NULL default '',
`COUNTRY_NAME` varchar(50) NOT NULL default '',
KEY `IP_FROM` (`IP_FROM`),
KEY `IP_TO` (`IP_TO`)
) TYPE=MyISAM;
[sorry folks... still a semi-n00b i guess]
`IP_FROM` double NOT NULL default '0',
`IP_TO` double NOT NULL default '0',
`COUNTRY_CODE2` char(2) NOT NULL default '',
`COUNTRY_CODE3` char(3) NOT NULL default '',
`COUNTRY_NAME` varchar(50) NOT NULL default '',
KEY `IP_FROM` (`IP_FROM`),
KEY `IP_TO` (`IP_TO`)
) TYPE=MyISAM;
[sorry folks... still a semi-n00b i guess]