diff options
Diffstat (limited to 'packages/arpwatch_reports.php')
-rwxr-xr-x | packages/arpwatch_reports.php | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/packages/arpwatch_reports.php b/packages/arpwatch_reports.php new file mode 100755 index 00000000..8311507a --- /dev/null +++ b/packages/arpwatch_reports.php @@ -0,0 +1,119 @@ +#!/usr/local/bin/php +<?php +/* + $Id$ + + diag_logs.php + Copyright (C) 2005 Colin Smith + 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. +*/ + +require("guiconfig.inc"); + +$logfile = "/usr/local/arpwatch/arp.dat"; + +if ($_POST['clear']) { + stop_service("arpwatch"); + unlink_if_exists($logfile); + start_service("arpwatch"); +} + +$rawrep = file($logfile); +foreach($rawrep as $line) { + $todo = preg_split('/\s/', $line); + $report[$todo[1]][] = array( + "mac" => trim($todo[0]), + "timestamp" => trim($todo[2]), + "hostname" => trim($todo[3]) ? trim($todo[3]) : "Unknown" + ); +} +$pgtitle = "arpwatch: Reports"; +include("head.inc"); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> +<p class="pgtitle"><?=$pgtitle?></p> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td> +<?php + $tab_array = array(); + $tab_array[] = array("Settings", false, "pkg_edit.php?xml=arpwatch.xml&id=0"); + $tab_array[] = array("Reports", true, "arpwatch_reports.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0"> + <tr> + <td colspan="4" class="listtopic">arp.dat entries</td> + </tr> + <tr> + <td width="15%" class="listhdrr">IP</td> + <td width="25%" class="listhdrr">Timestamp</td> + <td width="25%" class="listhdrr">MAC</td> + <td width="35%" class="listhdrr">Hostname</td> + </tr> + <?php + foreach($report as $ip => $rawentries) { + $printip = true; + $entries = $rawentries; + sort($entries); + foreach($entries as $entry) { + echo '<tr>'; + if($printip) { + echo '<td class="listlr">' . $ip . '</td>'; + $stampclass = "listr"; + $printip = false; + } else { + $stampclass = "listlr"; + echo '<td></td>'; + } + echo '<td class="' . $stampclass . '">' . + date("D M j G:i:s", $entry['timestamp']) . + '</td>'; + echo '<td class="listr">' . $entry['mac'] . '</td>'; + echo '<td class="listr">' . $entry['hostname'] . '</td>'; + echo '</tr>'; + } + } + ?> + <tr> + <td> + <br> + <form action="diag_logs.php" method="post"> + <input name="clear" type="submit" class="formbtn" value="Clear log"> + </form> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> |