1
|
<?php
|
2
|
/*
|
3
|
diag_dns.php
|
4
|
|
5
|
Copyright (C) 2009 Jim Pingle (jpingle@gmail.com)
|
6
|
All rights reserved.
|
7
|
|
8
|
Redistribution and use in source and binary forms, with or without
|
9
|
modification, are permitted provided that the following conditions are met:
|
10
|
|
11
|
1. Redistributions of source code must retain the above copyright notice,
|
12
|
this list of conditions and the following disclaimer.
|
13
|
|
14
|
2. Redistributions in binary form must reproduce the above copyright
|
15
|
notice, this list of conditions and the following disclaimer in the
|
16
|
documentation and/or other materials provided with the distribution.
|
17
|
|
18
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
POSSIBILITY OF SUCH DAMAGE.
|
28
|
*/
|
29
|
|
30
|
$pgtitle = "Diagnostics: DNS";
|
31
|
require("guiconfig.inc");
|
32
|
|
33
|
/* Cheap hack to support both $_GET and $_POST */
|
34
|
if ($_GET['host'])
|
35
|
$_POST = $_GET;
|
36
|
|
37
|
if ($_POST) {
|
38
|
unset($input_errors);
|
39
|
|
40
|
$reqdfields = explode(" ", "host");
|
41
|
$reqdfieldsn = explode(",", "Host");
|
42
|
|
43
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
44
|
$host = trim($_POST['host']);
|
45
|
|
46
|
if (!(is_hostname($host) || is_ipaddr($host))) {
|
47
|
$input_errors[] = "Host must be a valid hostname or IP address.";
|
48
|
}
|
49
|
|
50
|
$type = "unknown";
|
51
|
$resolved = "";
|
52
|
$ipaddr = "";
|
53
|
$hostname = "";
|
54
|
if (!$input_errors) {
|
55
|
if (is_ipaddr($host)) {
|
56
|
$type = "ip";
|
57
|
$resolved = gethostbyaddr($host);
|
58
|
$ipaddr = $host;
|
59
|
if ($host != $resolved)
|
60
|
$hostname = $resolved;
|
61
|
} elseif (is_hostname($host)) {
|
62
|
$type = "hostname";
|
63
|
$resolved = gethostbyname($host);
|
64
|
$hostname = $host;
|
65
|
if ($host != $resolved)
|
66
|
$ipaddr = $resolved;
|
67
|
}
|
68
|
|
69
|
if ($host == $resolved) {
|
70
|
$resolved = "No record found";
|
71
|
}
|
72
|
}
|
73
|
}
|
74
|
|
75
|
include("head.inc"); ?>
|
76
|
<body link="#000000" vlink="#000000" alink="#000000">
|
77
|
<? include("fbegin.inc"); ?>
|
78
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
79
|
<tr>
|
80
|
<td>
|
81
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
82
|
<form action="diag_dns.php" method="post" name="iform" id="iform">
|
83
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
84
|
<tr>
|
85
|
<td width="22%" valign="top" class="vncellreq">Hostname or IP</td>
|
86
|
<td width="78%" class="vtable">
|
87
|
<?=$mandfldhtml;?><input name="host" type="text" class="formfld" id="host" size="20" value="<?=htmlspecialchars($host);?>">
|
88
|
<? if ($resolved && $type) { ?>
|
89
|
= <?php echo $resolved; ?>
|
90
|
<? } ?>
|
91
|
</td>
|
92
|
</tr>
|
93
|
<?php if (!$input_errors && $ipaddr) { ?>
|
94
|
<tr>
|
95
|
<td width="22%" valign="top">More Information:</td>
|
96
|
<td width="78%" class="vtable">
|
97
|
NOTE: These links are to external services, so their reliability cannot be guaranteed.<br/><br/>
|
98
|
<a href="http://private.dnsstuff.com/tools/whois.ch?ip=<?php echo $ipaddr; ?>">IP WHOIS @ DNS Stuff</a><br />
|
99
|
<a href="http://private.dnsstuff.com/tools/ipall.ch?ip=<?php echo $ipaddr; ?>">IP Info @ DNS Stuff</a>
|
100
|
</td>
|
101
|
</tr>
|
102
|
<?php } ?>
|
103
|
<tr>
|
104
|
<td width="22%" valign="top"> </td>
|
105
|
<td width="78%">
|
106
|
<input name="Submit" type="submit" class="formbtn" value="DNS Lookup">
|
107
|
</td>
|
108
|
</tr>
|
109
|
</table>
|
110
|
</form>
|
111
|
</td></tr></table>
|
112
|
<?php include("fend.inc"); ?>
|