Created
September 14, 2014 16:24
-
-
Save binarybucks/3e30b0a487a5f1efbedf to your computer and use it in GitHub Desktop.
little page to return current ip and user agent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($_SERVER["HTTP_X_FORWARDED_FOR"] != "") { | |
$IP = $_SERVER["HTTP_X_FORWARDED_FOR"]; | |
$host = @gethostbyaddr($_SERVER["HTTP_X_FORWARDED_FOR"]); | |
} else { | |
$IP = $_SERVER["REMOTE_ADDR"]; | |
$host = @gethostbyaddr($_SERVER["REMOTE_ADDR"]); | |
} | |
header('Content-Type: application/json'); | |
echo json_encode(array('ip' => $IP, 'host' => $host, 'userAgent' => $_SERVER["HTTP_USER_AGENT"]), JSON_PRETTY_PRINT); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment