From dbd182af2eeadd00897d6406e8a451e9e01d700e Mon Sep 17 00:00:00 2001 From: jim-p Date: Tue, 2 Apr 2013 11:28:10 -0400 Subject: Fix/simplify some logic --- usr/local/www/diag_ping.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'usr/local/www/diag_ping.php') diff --git a/usr/local/www/diag_ping.php b/usr/local/www/diag_ping.php index 0c73f21..98a3bdd 100755 --- a/usr/local/www/diag_ping.php +++ b/usr/local/www/diag_ping.php @@ -150,14 +150,14 @@ include("head.inc"); ?> $command = "/sbin/ping"; if ($ipproto == "ipv6") { $command .= "6"; - $ifaddr = get_interface_ipv6($sourceip); + $ifaddr = is_ipaddr($sourceip) ? $sourceip : get_interface_ipv6($sourceip); } else { $ifaddr = is_ipaddr($sourceip) ? $sourceip : get_interface_ip($sourceip); } if ($ifaddr && (is_ipaddr($host) || is_hostname($host))) - $cmd = "{$command} -S" . escapeshellarg($ifaddr) . " -c" . escapeshellarg($count) . " " . escapeshellarg($host); - else - $cmd = "{$command} -c" . escapeshellarg($count) . " " . escapeshellarg($host); + $srcip = "-S" . escapeshellarg($ifaddr); + + $cmd = "{$command} {$srcip} -c" . escapeshellarg($count) . " " . escapeshellarg($host); //echo "Ping command: {$cmd}\n"; system($cmd); echo(''); -- cgit v1.1