Skip to content

Instantly share code, notes, and snippets.

Created Aug 31, 2017

What would you like to do?
DNS Lookup - Modified
$result = array();
$result_html = '';
if (isset($_GET['domain']) && !empty($_GET['domain'])) {
$domain_regex = '/[a-z\d][a-z\-\d\.]+[a-z\d]/i';
if (preg_match($domain_regex, $_GET['domain'])) {
if ($url = parse_url($_GET['domain'])) { //compatible when user post an url instead of a domain
if (isset($url['host'])) {
$result = dns_get_record($url['host'], DNS_A + DNS_AAAA + DNS_CNAME);
} else if (isset($url['path'])) {
$result = dns_get_record($url['path'], DNS_A + DNS_AAAA + DNS_CNAME);
if (empty($result)) {
$result_html = 'Nothing found or Domain Invalid';
} else {
foreach($result as $r) {
$host = current($r);
$type = next($r);
$value = next($r);
$result_html .= sprintf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n", $host, $type, $value);
$result_html = "<hr>\n<table>\n$result_html</table>\n";
<html xmlns="">
<meta charset="UTF-8"/>
<title>Raw Dns Lookup</title>
<style>/* somethin from bootstrap */
button,input {margin: 0;font-size: 100%;vertical-align: middle;}
hr {margin: 20px 0;border: 0;border-top: 1px solid #eeeeee;border-bottom: 1px solid #ffffff;}
label {margin-bottom: 3px;}
.form-inline {vertical-align: middle;}
table {width: 100%;text-align: center;margin: auto;}
<div style="text-align: center;width: 800px;margin: 1em auto">
<h1>Raw Dns Lookup</h1>
<p>Server Location:
$geo = json_decode(file_get_contents(''));
echo $geo->countryName;
<span>Powered by <a href="" title="Developer:horsley" target="_blank">Horsley</a></span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.