Skip to content

Batacek/IP-Info

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IP Info

License Lang

Get information about your IP and connection.

Requirements

  • Apache (for web server) or webhosting
  • PHP (I'm using v8.1)

Step 1)

Make PHP file. Just create *.php file. Index.php is typical name in this case.

Step 2)

Paste this code

<?php 

    $protocol = $_SERVER['SERVER_PROTOCOL'];
    $ip = $_SERVER['REMOTE_ADDR'];
    $port = $_SERVER['REMOTE_PORT'];
    $agent = $_SERVER['HTTP_USER_AGENT'];
    $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

    echo('IP Address: '."".$ip ."\n");
        echo("<br>");
    echo('Hostname: '."".$hostname ."\n");
        echo("<br>");
    echo('Port Number: '."".$port ."\n");
        echo("<br>");
    echo('User Agent: '."".$agent ."\n");
        echo("<br>");
    echo('Protocol type: '."".$protocol ."\n");
        echo("<br>");
    $details = json_decode(file_get_contents("http://ipinfo.io/{$ip}"));
    echo ('Country: '."".$details->country ."\n");
?>

Step 3)

Run it with apache or on hosting, visit it with your browser and enjoy!


About

Get information about your IP and connection.

Topics

Resources

License

Stars

Watchers

Forks

Languages