diff options
Diffstat (limited to 'src/usr/local/www/diag_dns.php')
-rwxr-xr-x[-rw-r--r--] | src/usr/local/www/diag_dns.php | 307 |
1 files changed, 144 insertions, 163 deletions
diff --git a/src/usr/local/www/diag_dns.php b/src/usr/local/www/diag_dns.php index 4c57223..140bf4b 100644..100755 --- a/src/usr/local/www/diag_dns.php +++ b/src/usr/local/www/diag_dns.php @@ -1,35 +1,60 @@ <?php /* diag_dns.php - - Copyright (C) 2009 Jim Pingle (jpingle@gmail.com) - Copyright (C) 2013-2015 Electric Sheep Fencing, LP - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. */ - + /* ==================================================================== + * Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved. + * Copyright (c) 2009 Jim Pingle (jpingle@gmail.com) + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgment: + * "This product includes software developed by the pfSense Project + * for use in the pfSense software distribution. (http://www.pfsense.org/). + * + * 4. The names "pfSense" and "pfSense Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * coreteam@pfsense.org. + * + * 5. Products derived from this software may not be called "pfSense" + * nor may "pfSense" appear in their names without prior written + * permission of the Electric Sheep Fencing, LLC. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * + * "This product includes software developed by the pfSense Project + * for use in the pfSense software distribution (http://www.pfsense.org/). + * + * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ==================================================================== + * + */ /* - pfSense_MODULE: dns + pfSense_MODULE: dns */ $pgtitle = array(gettext("Diagnostics"), gettext("DNS Lookup")); @@ -67,10 +92,9 @@ if (isset($_POST['create_alias']) && (is_hostname($host) || is_ipaddr($host))) { exec("/usr/bin/drill {$host_esc} A | /usr/bin/grep {$host_esc} | /usr/bin/grep -v ';' | /usr/bin/awk '{ print $5 }'", $resolved); $isfirst = true; foreach ($resolved as $re) { - if ($re <> "") { - if (!$isfirst) { + if ($re != "") { + if (!$isfirst) $addresses .= " "; - } $addresses .= rtrim($re) . "/32"; $isfirst = false; } @@ -178,143 +202,100 @@ function display_host_results ($address, $hostname, $dns_speeds) { } } -include("head.inc"); ?> -<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> -<?php include("fbegin.inc"); ?> -<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="diag dns"> - <tr> - <td> -<?php if ($input_errors) print_input_errors($input_errors); ?> - <form action="diag_dns.php" method="post" name="iform" id="iform"> - <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="tabcont"> - <tr> - <td colspan="2" valign="top" class="listtopic"> <?=gettext("Resolve DNS hostname or IP");?></td> - </tr> - <tr> - <td width="22%" valign="top" class="vncellreq"><?=gettext("Hostname or IP");?></td> - <td width="78%" class="vtable"> - <?=$mandfldhtml;?> - <table summary="results"> - <tr> - <td valign="top"> - <input name="host" type="text" class="formfld unknown" id="host" size="20" value="<?=htmlspecialchars($host);?>" /> - </td> -<?php - if ($resolved && $type) { -?> - <td valign="middle"> = </td> - <td> - <font size="+1"> -<?php - $found = 0; - if (is_array($resolved)) { - foreach ($resolved as $hostitem) { - if ($hostitem <> "") { - echo $hostitem . "<br />"; - $found++; - } - } - } else { - echo $resolved; - } - if ($found > 0) { -?> - <br/> - </font> - <font size='-2'> -<?php - if ($alias_exists) { -?> - An alias already exists for the hostname <?= htmlspecialchars($host) ?>. <br /> - <input type="hidden" name="override" value="true"/> - <input type="submit" name="create_alias" value="Overwrite Alias"/> -<?php - } else { - if (!$createdalias) { +include("head.inc"); + +/* Display any error messages resulting from user input */ +if ($input_errors) + print_input_errors($input_errors); +else if (!$resolved && $type) + print('<div class="alert alert-warning" role="alert">' . gettext("Host") .' "'. $host .'" '. gettext("could not be resolved") . '</div>'); + +if ($createdalias) + print('<div class="alert alert-success" role="alert">'.gettext("Alias was created/updated successfully").'</div>'); + +require_once('classes/Form.class.php'); + +$form = new Form('Lookup'); +$section = new Form_Section('DNS Lookup'); + +$section->addInput(new Form_Input( + 'host', + 'Hostname', + 'text', + $host, + ['placeholder' => 'Hostname to look up.'] +)); + +if (!empty($resolved)) { + $form->addGlobal(new Form_Button( + 'create_alias', + 'Add alias' + ))->removeClass('btn-primary')->addClass('btn-success'); +} + +$form->add($section); +print $form; + +if (!$input_errors && $type) { + if ($resolved): ?> - <input type="submit" name="create_alias" value="Create Alias from These Entries"/> -<?php - } else { +<div class="panel panel-default"> + <div class="panel-heading"><h2 class="panel-title">Results</h2></div> + <div class="panel-body"> + <ul class="list-group"> +<? + foreach ((array)$resolved as $hostitem) { ?> - Alias created with name <?= htmlspecialchars($newalias['name']) ?> -<?php - } + <li class="list-group-item"><?=$hostitem?></li> +<? + if ($hostitem != "") { + $found++; } } - } -?> - </font> - </td> - </tr> - </table> - </td> - </tr> -<?php - if ($_POST): -?> - <tr> - <td width="22%" valign="top" class="vncell"><?=gettext("Resolution time per server");?></td> - <td width="78%" class="vtable"> - <table width="170" border="0" cellpadding="6" cellspacing="0" summary="resolution time"> - <tr> - <td class="listhdrr"> - <?=gettext("Server");?> - </td> - <td class="listhdrr"> - <?=gettext("Query time");?> - </td> - </tr> -<?php - if (is_array($dns_speeds)) { - foreach ($dns_speeds as $qt): ?> - <tr> - <td class="listlr"> - <?=$qt['dns_server']?> - </td> - <td class="listr"> - <?=$qt['query_time']?> - </td> - </tr> -<?php - endforeach; - } -?> - </table> - </td> - </tr> -<?php - endif; + </ul> + </div> +</div> +<? endif?> - if (!$input_errors && $ipaddr) { -?> - <tr> - <td width="22%" valign="top" class="vncell"><?=gettext("More Information:");?></td> - <td width="78%" class="vtable"> - <a href ="/diag_ping.php?host=<?=htmlspecialchars($host)?>&interface=wan&count=3"><?=gettext("Ping");?></a> <br /> - <a href ="/diag_traceroute.php?host=<?=htmlspecialchars($host)?>&ttl=18"><?=gettext("Traceroute");?></a> - <p> - <?=gettext("NOTE: The following links are to external services, so their reliability cannot be guaranteed.");?><br /><br /> - <a target="_blank" href="http://private.dnsstuff.com/tools/whois.ch?ip=<?php echo $ipaddr; ?>"><?=gettext("IP WHOIS @ DNS Stuff");?></a><br /> - <a target="_blank" href="http://private.dnsstuff.com/tools/ipall.ch?ip=<?php echo $ipaddr; ?>"><?=gettext("IP Info @ DNS Stuff");?></a> - </p> - </td> - </tr> +<!-- Second table displays the server resolution times --> +<div class="panel panel-default"> + <div class="panel-heading"><h2 class="panel-title">Timings</h2></div> + <div class="panel-body"> + <table class="table"> + <thead> + <tr> + <th>Name server</th> + <th>Query time</th> + </tr> + </thead> + + <tbody> +<? foreach ((array)$dns_speeds as $qt):?> + <tr> + <td><?=$qt['dns_server']?></td><td><?=$qt['query_time']?></td> + </tr> +<? endforeach?> + </tbody> + </table> + </div> +</div> + +<!-- Third table displays "More information" --> +<div class="panel panel-default"> + <div class="panel-heading"><h2 class="panel-title">More information</h2></div> + <div class="panel-body"> + <ul class="list-group"> + <li class="list-group-item"><a href="/diag_ping.php?host=<?=htmlspecialchars($host)?>&interface=wan&count=3"><?=gettext("Ping")?></a></li> + <li class="list-group-item"><a href="/diag_traceroute.php?host=<?=htmlspecialchars($host)?>&ttl=18"><?=gettext("Traceroute")?></a></li> + </ul> + <p><?=gettext("NOTE: The following links are to external services, so their reliability cannot be guaranteed.");?></p> + <ul class="list-group"> + <li class="list-group-item"><a target="_blank" href="http://private.dnsstuff.com/tools/whois.ch?ip=<?php echo $ipaddr; ?>"><?=gettext("IP WHOIS @ DNS Stuff");?></a></li> + <li class="list-group-item"><a target="_blank" href="http://private.dnsstuff.com/tools/ipall.ch?ip=<?php echo $ipaddr; ?>"><?=gettext("IP Info @ DNS Stuff");?></a></li> + </ul> + </div> +</div> <?php - } -?> - <tr> - <td width="22%" valign="top"> </td> - <td width="78%"> - <br /> - <input name="Submit" type="submit" class="formbtn" value="<?=gettext("DNS Lookup");?>" /> - </td> - </tr> - </table> - </form> - </td> - </tr> -</table> -<?php include("fend.inc"); ?> -</body> -</html> +} +include("foot.inc");
\ No newline at end of file |