Skip to content

Instantly share code, notes, and snippets.

@caius
Created January 8, 2017 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caius/11bd5156406be3efd509403779650899 to your computer and use it in GitHub Desktop.
Save caius/11bd5156406be3efd509403779650899 to your computer and use it in GitHub Desktop.
<?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