0) { foreach($states as $line) { $line_split = preg_split("/\s+/", $line); $type = array_shift($line_split); $proto = array_shift($line_split); $state = array_pop($line_split); $info = implode(" ", $line_split); /* break up info and extract $srcip and $dstip */ $ends = preg_split("/\-\>?/", $info); if (strpos($info, '->') === FALSE) { $srcinfo = $ends[count($ends) - 1]; $dstinfo = $ends[0]; } else { $srcinfo = $ends[0]; $dstinfo = $ends[count($ends) - 1]; } $parts = split(":", $srcinfo); $srcip = trim($parts[0]); $srcport = trim($parts[1]); $parts = split(":", $dstinfo); $dstip = trim($parts[0]); $dstport = trim($parts[1]); addipinfo($srcipinfo, $srcip, $proto, $srcport, $dstport); addipinfo($dstipinfo, $dstip, $proto, $srcport, $dstport); addipinfo($pairipinfo, "{$srcip} -> {$dstip}", $proto, $srcport, $dstport); addipinfo($allipinfo, $srcip, $proto, $srcport, $dstport); addipinfo($allipinfo, $dstip, $proto, $srcport, $dstport); } } function sort_by_ip($a, $b) { return ip2ulong($a) < ip2ulong($b) ? -1 : 1; } function build_port_info($portarr, $proto) { $ports = array(); asort($portarr); foreach (array_reverse($portarr, TRUE) as $port => $count) { $str = ""; $service = getservbyport($port, strtolower($proto)); $port = "{$proto}/{$port}"; if ($service) $port = "{$port} ({$service})"; $ports[] = "{$port}: {$count}"; } return implode($ports, ', '); } function print_summary_table($label, $iparr, $sort = TRUE) { ?>
=gettext("IP");?> | # =gettext("States");?> | =gettext("Proto");?> | # =gettext("States");?> | =gettext("Src Ports");?> | =gettext("Dst Ports");?> |