ip and geo location tracing script

Discussion in 'PHP' started by Djshazz, Oct 24, 2009.

  1. #1
    I ned a script that can trace ip inserted by user and its geo location i have a script that detects but ip of the user but there is no input method you casn check it out at http://www.skforums.com/ip-checker.htm
     
    Djshazz, Oct 24, 2009 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    a script for checking IP?? whoo!! it's just 1 line code :)

    anyways, for checking geo location, either you can try this or this.
     
    mastermunj, Oct 24, 2009 IP
  3. xenon2010

    xenon2010 Peon

    Messages:
    237
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    there are many free ip database providers on the net..
    you just query users IPs and put these ips in database provider. here is an example:
    $ip = "111.111.111.111";
    $country = file_get_contents('http://api.hostip.info/get_html.php?ip='.$ip);
    echo "$ip: $country: <IMG SRC=http://api.hostip.info/flag.php?ip=$ip height=15 border=0>";
    PHP:
    cheers
     
    xenon2010, Oct 24, 2009 IP
  4. Djshazz

    Djshazz Peon

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    This is my code;
    
    <style type="text/css">
    <!--
    body,td,th {
    	color: #FFFFFF;
    }
    body {
    	background-color: #000000;
    }
    -->
    </style><div align="center"></div>
    <?php
    $reqhost = $_SERVER['HTTP_HOST'];
    $proxy = $_SERVER['HTTP_X_FORWARDED_FOR'];
    $ipaddr = $_SERVER['REMOTE_ADDR'];
    $revdns = $_SERVER['REMOTE_HOST'];
    $final = "";
    if ($revdns) {$final = $revdns;}
    else {$final = $ipaddr;}
    if ($proxy) {
            $final = $proxy;
            $prxyhost = gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']);
            if ($prxyhost) {$final = $prxyhost;}
            }
    echo"<br><br><br><div style=\"font-weight:bold; text-align:center; font-family:Verdana\">Your Current IP is <br><span style=\"font-size:50\">$final</div></div>";
    echo"<br><br><div style=\"font-weight:bold; text-align:center; font-family:Verdana\">This script is Officially made by Skforums.com</div>";
    echo"<br><br><div style=\"font-weight:bold; text-align:center; font-family:Verdana\">(Powered by SKFORUMS.com)</div>";
    ?>
    
    Code (markup):
    Now tell me how i can modify it to get coutry name and its flag under the ip.
     
    Djshazz, Oct 24, 2009 IP
  5. eamong

    eamong Well-Known Member

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    108
    #5
    you should use api.hostip.info
    keep the load off your server to check for location and ip
    e.g.
    just this
    http://api.hostip.info/flag.php
    will display each visitor own flag
     
    eamong, Oct 28, 2009 IP