Commit 6cb5788f authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(legacy) move display_host_results into log.widget.php

The widget collection needs a cleanup, but is not at the top of the priority list. Lets make sure the legacy functionality delivers output and make sure the already cleaned components stay that way.

(cherry picked from commit d4d07fbb)
parent 95aa7297
......@@ -3,6 +3,7 @@
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2007 Scott Dale
Copyright (C) 2009 Jim Pingle (jpingle@gmail.com)
Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net>
and Jonathan Watt <jwatt@jwatt.org>.
All rights reserved.
......@@ -49,6 +50,55 @@ function find_action_image($action)
return 'glyphicon glyphicon-remove text-danger';
}
/**
* original from diag_dns.php
* temporary solution.
*/
function display_host_results ($address,$hostname,$dns_speeds) {
$map_lengths = function($element) { return strlen($element[0]); };
echo gettext("IP Address") . ": {$address} \n";
echo gettext("Host Name") . ": {$hostname} \n";
echo "\n";
$text_table = array();
$text_table[] = array(gettext("Server"), gettext("Query Time"));
if (is_array($dns_speeds)) {
foreach ($dns_speeds as $qt) {
$text_table[] = array(trim($qt['dns_server']), trim($qt['query_time']));
}
}
$col0_padlength = max(array_map($map_lengths, $text_table)) + 4;
foreach ($text_table as $text_row) {
echo str_pad($text_row[0], $col0_padlength) . $text_row[1] . "\n";
}
}
if (!empty($_GET['host']) && !empty($_GET['dialog_output'])) {
$host = trim($_GET['host'], " \t\n\r\0\x0B[];\"'");
$host_esc = escapeshellarg($host);
$dns_servers = array();
exec("/usr/bin/grep nameserver /etc/resolv.conf | /usr/bin/cut -f2 -d' '", $dns_servers);
foreach ($dns_servers as $dns_server) {
$query_time = exec("/usr/bin/drill {$host_esc} " . escapeshellarg("@" . trim($dns_server)) . " | /usr/bin/grep Query | /usr/bin/cut -d':' -f2");
if ($query_time == "") {
$query_time = gettext("No response");
}
$dns_speeds[] = array('dns_server' => $dns_server, 'query_time' => $query_time);
}
$ipaddr = "";
if (count($input_errors) == 0) {
if (is_ipaddr($host)) {
$resolved[] = " " . gethostbyaddr($host); // add a space to provide an empty type field
$ipaddr = $host;
} elseif (is_hostname($host)) {
exec("/usr/bin/drill {$host_esc} A | /usr/bin/grep 'IN' | /usr/bin/grep -v ';' | /usr/bin/awk '{ print $4 \" \" $5 }'", $resolved);
$ipaddr = explode(" ", $resolved[count($resolved)-1])[1];
}
}
display_host_results ($host, $resolved[0], $dns_speeds);
exit;
}
if (is_numeric($_POST['filterlogentries'])) {
$config['widgets']['filterlogentries'] = $_POST['filterlogentries'];
......@@ -85,7 +135,6 @@ if (is_numeric($_POST['filterlogentries'])) {
$nentries = isset($config['widgets']['filterlogentries']) ? $config['widgets']['filterlogentries'] : 5;
//set variables for log
$nentriesacts = isset($config['widgets']['filterlogentriesacts']) ? $config['widgets']['filterlogentriesacts'] : 'All';
$nentriesinterfaces = isset($config['widgets']['filterlogentriesinterfaces']) ? $config['widgets']['filterlogentriesinterfaces'] : 'All';
......@@ -254,11 +303,11 @@ endforeach;
<td class="listMRr ellipsis nowrap" title="<?php echo htmlspecialchars($filterent['time']);?>"><?php echo substr(htmlspecialchars($filterent['time']), 0, -3);?></td>
<td class="listMRr ellipsis nowrap" title="<?php echo htmlspecialchars($filterent['interface']);?>"><?php echo htmlspecialchars($filterent['interface']);?></td>
<td class="listMRr ellipsis nowrap" title="<?php echo htmlspecialchars($filterent['src']);?>">
<a href="#" onclick="javascript:getURL('diag_dns.php?host=<?php echo "{$filterent['srcip']}";
<a href="#" onclick="javascript:getURL('widgets/widgets/log.widget.php?host=<?php echo "{$filterent['srcip']}";
?>&amp;dialog_output=true', outputrule);" title="<?=gettext("Reverse Resolve with DNS");?>">
<?php echo htmlspecialchars($filterent['srcip']);?></a></td>
<td class="listMRr ellipsis nowrap" title="<?php echo htmlspecialchars($filterent['dst']);?>">
<a href="#" onclick="javascript:getURL('diag_dns.php?host=<?php echo "{$filterent['dstip']}";
<a href="#" onclick="javascript:getURL('widgets/widgets/log.widget.php?host=<?php echo "{$filterent['dstip']}";
?>&amp;dialog_output=true', outputrule);" title="<?=gettext("Reverse Resolve with DNS");?>">
<?php echo htmlspecialchars($filterent['dstip']);?></a><?php echo ":" . htmlspecialchars($filterent['dstport']);?></td>
<?php
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment