From 20b9b3358e4a5bf622009ba0f9e7f31f8627d9d0 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Fri, 11 Sep 2009 17:49:59 -0400 Subject: Add more comments. Reformat --- usr/local/www/diag_arp.php | 76 +++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/usr/local/www/diag_arp.php b/usr/local/www/diag_arp.php index 9594c90..97db24c 100755 --- a/usr/local/www/diag_arp.php +++ b/usr/local/www/diag_arp.php @@ -1,8 +1,10 @@ + originally part of m0n0wall (http://m0n0.ch/wall) Copyright (C) 2005 Paul Taylor (paultaylor@winndixie.com) and Manuel Kasper . All rights reserved. @@ -50,18 +52,23 @@ function adjust_gmt($dt) { } function remove_duplicate($array, $field) { -foreach ($array as $sub) - $cmp[] = $sub[$field]; + foreach ($array as $sub) + $cmp[] = $sub[$field]; $unique = array_unique($cmp); foreach ($unique as $k => $rien) $new[] = $array[$k]; return $new; } -$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases"; +// Define path to AWK $awk = "/usr/bin/awk"; + +// Read in leases file +$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases"; + /* this pattern sticks comments into a single array item */ $cleanpattern = "'{ gsub(\"#.*\", \"\");} { gsub(\";\", \"\"); print;}'"; + /* We then split the leases file by } */ $splitpattern = "'BEGIN { RS=\"}\";} {for (i=1; i<=NF; i++) printf \"%s \", \$i; printf \"}\\n\";}'"; @@ -190,7 +197,6 @@ if(count($pools) > 0) { asort($pools); } - // Put this in an easy to use form $dhcpmac = array(); $dhcpip = array(); @@ -240,12 +246,12 @@ function getHostName($mac,$ip) $pgtitle = array("Diagnostics","ARP Table"); include("head.inc"); + ?> + - +
Loading, please wait... @@ -258,7 +264,9 @@ include("head.inc"); for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); } ob_implicit_flush(1); -// Resolve hostnames +// Resolve hostnames and replace Z_ with "". The intention +// is to sort the list by hostnames, alpha and then the non +// resolvable addresses will appear last in the list. foreach ($data as &$entry) { $dns = trim(getHostName($entry['mac'], $entry['ip'])); if(trim($dns)) @@ -266,34 +274,38 @@ foreach ($data as &$entry) { else $entry['dnsresolve'] = "Z_ "; } + +// Sort the data alpha first $data = msort($data, "dnsresolve"); ?> - -
- - - - - - - - - - - - - - - - + + +
IP addressMAC addressHostnameInterface
- -
+ + + + + + + + + + + + + + + + +
IP addressMAC addressHostnameInterface
+ +
+
-
-- cgit v1.1