Skip to content

Instantly share code, notes, and snippets.

@javierwilson
Created April 3, 2013 01:00
Show Gist options
  • Save javierwilson/5297625 to your computer and use it in GitHub Desktop.
Save javierwilson/5297625 to your computer and use it in GitHub Desktop.
looks up an ip address in a DNSBL zone
<?php
$zone = 'dnsbl.example.com';
if (isset($_REQUEST['ip'])) {
$ip = preg_replace('/[^0-9.]/', '', $_REQUEST['ip']);
if(filter_var($ip, FILTER_VALIDATE_IP)) {
$fields = explode('.', $ip);
$fields = array_reverse($fields);
$reverse_ip = implode('.', $fields);
$record = $reverse_ip . '.' . $zone;
$result = dns_get_record($record, DNS_A);
} else {
}
}
?>
<html>
<head></head>
<body>
<pre>
<?php if (isset($result) && !empty($result)) {
echo "<font color=red>$ip listed!</font>";
} elseif (isset($ip)) {
echo "$ip not listed.";
} ?>
</pre>
<form>
IP address: <input type="text" name="ip" value="<?=$ip?>"/>
<input type="submit"/>
</form>
<small>
Contact: syadmin at example dot net
</small>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment