Created
January 8, 2017 08:38
-
-
Save caius/11bd5156406be3efd509403779650899 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
// Looks up the IP address accessing us and prints rDNS record | |
$remote_ip = $_SERVER["REMOTE_ADDR"]; | |
if (strstr($remote_ip, ', ')) { | |
$ips = explode(', ', $remote_ip); | |
$remote_ip = $ips[0]; | |
} | |
$rdns_record = gethostbyaddr($remote_ip); | |
if (strpos($_SERVER["HTTP_USER_AGENT"], "curl") !== false) { | |
header("Content-Type: text/plain"); | |
?> | |
Remote IP: <?php echo $remote_ip ?> | |
rDNS record: <?php echo $rdns_record ?> | |
<?php | |
} else { | |
?><!DOCTYPE html> | |
<html> | |
<head> | |
<title>rDNS Finder</title> | |
</head> | |
<body> | |
<dl> | |
<dt>Remote IP</dt> | |
<dd><tt><?php echo $remote_ip ?>i</tt></dd> | |
<dt>rDNS record</dt> | |
<dd><tt><?php echo $rdns_record ?></tt></dd> | |
</dl> | |
</body> | |
</html> | |
<?php | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment