Geo-IP Tracking

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Slap Dot
    Confirmed User
    • Aug 2004
    • 3168

    #1

    Geo-IP Tracking

    How do you trace the country, state, and city from one IP using PHP? Or can I get an sample code from PHP or any other language?

    » AIM: slapdotted
    » Skype: slapdot
    » ICQ: 190444
  • spentrent
    Confirmed User
    • Feb 2004
    • 876

    #2
    Originally posted by Slap Dot
    How do you trace the country, state, and city from one IP using PHP? Or can I get an sample code from PHP or any other language?
    The only way to match IP addresses to geo-location is to refer to a database that links the two. There's nothing encoded in an IP address that implies anything about geo-location.

    There are companies that supply such databases. But to answer your question, you cannot use PHP alone to find this information. A variable like $_PHP_CITY would be awesome, but it just doesn't exist.

    Comment

    • Slap Dot
      Confirmed User
      • Aug 2004
      • 3168

      #3
      Yea, I know. I was hoping someone can hook me up with a DB export of the info and sample code of any language.

      » AIM: slapdotted
      » Skype: slapdot
      » ICQ: 190444

      Comment

      • borked
        Totally Borked
        • Feb 2005
        • 6284

        #4
        plug in maxmind's PHP API:
        http://www.maxmind.com/app/php

        If you don't own your own server or your admin won't install the mod_geoip Apache module, then use the pure php module

        For coding work - hit me up on andy // borkedcoder // com
        (consider figuring out the email as test #1)



        All models are wrong, but some are useful. George E.P. Box. p202

        Comment

        • INever
          Confirmed User
          • Jan 2005
          • 4031

          #5
          Go to Jadebucks

          They have a simple javascript for redirecting Netscape Chinese Browsers. You may be able to play with it so it does what you want.
          I love Camdough

          airvpn

          Comment

          • mortenb
            Confirmed User
            • Jul 2004
            • 2203

            #6
            You could take a look at the IP-to-Country http://www.ip-to-country.com/ database. You can download it for free. Don't know if it's free for commercial use, but at least you can test how it works.

            Comment

            • PRIVATE
              Registered User
              • Oct 2004
              • 40

              #7
              Yes, very fast is http://www.ip-to-country.com/ base + own script 9string
              sample :

              $ip_addr=getenv("REMOTE_ADDR");
              $ip_int = ip2long($ip_addr);
              $query_country = "select * from ip_country
              where '$ip_int'>=ip_low_long
              and '$ip_int'<=ip_high_long";
              $result_country = mysql_query($query_country);
              $num_country = mysql_num_rows($result_country);
              $row = mysql_fetch_array ($result_country);
              $ip = htmlspecialchars(stripslashes($row["ip"]));

              MAKE MONEY $$$ => Persign 35$ -> 550 sites -> 10000 FHG !!!:::::

              8 years of leadership !!! - adult dating

              Comment

              • xxxoutsourcing
                Confirmed User
                • Oct 2003
                • 3888

                #8
                You can use a free service from redirectgeo.com

                xxxoutsourcing.com
                ICQ:119936 | Aim:xxxoutsourcing | MSN:msn@ xxxoutsourcing.com | Yahoo:xxxoutsourcing
                Submitters, Designers, Programmers, Cartoonist, Creative Writers, Video & Photo Editors
                Convert your Paysite into a cartoon site convert2toons.com

                Comment

                Working...