Page 1 of 1

how do I get the Geocode into MYSQL database with PHP

PostPosted: Sun Mar 06, 2005 2:08 am
by koert
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?

PostPosted: Mon Mar 07, 2005 3:21 pm
by whitecurve
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.

getting Hostip information ready to be put into a database

PostPosted: Thu Mar 17, 2005 4:18 pm
by koert
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);
}

getting Hostip information ready to be put into a database

PostPosted: Fri Mar 18, 2005 2:02 pm
by bfolkens
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

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

PostPosted: Sun Mar 27, 2005 5:33 am
by Guest
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.

PostPosted: Fri May 20, 2005 4:24 pm
by Stephen Oachs
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]

mmonice.com aoc gold

PostPosted: Sun Jan 04, 2009 11:19 pm
by sherriesyo
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!