how do I get the Geocode into MYSQL database with PHP

Questions about hostip.info remote GET support.

Moderator: Moderators

how do I get the Geocode into MYSQL database with PHP

Postby koert on Sun Mar 06, 2005 2:08 am

whoaw what a nice web site! well done.
I would like to record the geocodes of people that come on to my site.
I think I know how to make my PHP to get hostip.info to send me the geocode, but how do I get this into my MYSQL database?

also
If you're going to be doing a lot of Geocoding or IP Address Lookups, please take a feed instead which will preserve both our bandwidth and your bandwidth.

what is a feed and how do I do that?
koert
n00b
 
Posts: 2
Joined: Sun Mar 06, 2005 2:00 am

Postby whitecurve on Mon Mar 07, 2005 3:21 pm

a more detailed HOWTO on setting up a local MYSQL hostip database will be forth coming.

Please Stay tuned.

Until then please have a look at the INSTALL text file for the current install instructions.
User avatar
whitecurve
n00b
 
Posts: 6
Joined: Tue Mar 01, 2005 9:07 am
Location: London, England

getting Hostip information ready to be put into a database

Postby koert on Thu Mar 17, 2005 4:18 pm

Okay I sat down and looked and fished on the internet and this is the result.
It gets the user’s IP, and then it asks Hostip for the information. Finally it gets this information ready to be put into a database.

Code: Select all
<?php
$raw_ip = stripslashes($HTTP_SERVER_VARS['REMOTE_ADDR']);
if (isset($HTTP_SERVER_VARS['HTTP_CLIENT_IP'])) {
    $hdr_ip = stripslashes($HTTP_SERVER_VARS['HTTP_CLIENT_IP']);
} else {
    if (isset($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) {
        $hdr_ip = stripslashes($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']);
    } else {
        $hdr_ip = $raw_ip;
    }
}     
$HTTP_SESSION_VARS['ip'] = 'ip';

// send the ip to hostip
  $hostip= "http://www.hostip.info/api/get.html?ip=".$raw_ip;
  $result = file($hostip);
 
// process the array   remove Country: and City:
  $result= str_replace("Country:", "", $result);
  $lines= str_replace("City:", "", $result);
 
foreach ($lines as $line) {
  echo  $ready_for_DB = htmlspecialchars($line);
}
koert
n00b
 
Posts: 2
Joined: Sun Mar 06, 2005 2:00 am

getting Hostip information ready to be put into a database

Postby bfolkens on Fri Mar 18, 2005 2:02 pm

You may want to check out the "contrib" section - there's a script in there that caches the hostip results locally for you.

I think there's a lot in that script you could leverage for you're trying to do (espcially in storing them locally).

Hope that helps
bfolkens
Site Admin
 
Posts: 154
Joined: Tue Feb 22, 2005 8:09 am

Re: getting Hostip information ready to be put into a databa

Postby Guest on Sun Mar 27, 2005 5:33 am

bfolkens wrote:You may want to check out the "contrib" section - there's a script in there that caches the hostip results locally for you.

I think there's a lot in that script you could leverage for you're trying to do (espcially in storing them locally).

Hope that helps


Script from contrib section does not work for me.It just give a blank output.Wonder why?
cache/geo directory has been made with permission to server 777 but outpus is blank.
The script from koert posted above work.
Guest
Expert
 

Postby Stephen Oachs on Fri May 20, 2005 4:24 pm

I did it by doing the following:

- FTP'd the zip to my database server
- unzipped (blush)

mysql -u root -p mydbname < hostip.sql

Takes about 5 minutes...far more effective than doing something this large via PHP.

Hope it helps.

Stephen
[email protected]
Stephen Oachs
Expert
 

mmonice.com aoc gold

Postby sherriesyo on Sun Jan 04, 2009 11:19 pm

I want to say,that is WOO! move me
we are a good site for age of conan game.If you need AOC Gold,Age of Conan Gold,Age of Conan Power Leveling ,Age of Conan PowerLeveling,age of conan service,come here!
sherriesyo
n00b
 
Posts: 4
Joined: Fri Jan 02, 2009 7:38 pm


Return to Hostip.info remote GET/PHP support

Who is online

Users browsing this forum: No registered users and 2 guests

cron