2015-04-04 11:42:30 +01:00
< div class = " panel panel-default panel-condensed " >
< div class = " panel-heading " >
< strong > ARP Entries </ strong >
</ div >
< table id = " arp-search " class = " table table-hover table-condensed table-striped " >
< thead >
< tr >
< th data - column - id = " mac_address " > MAC Address </ th >
< th data - column - id = " ipv4_address " > IP Address </ th >
< th data - column - id = " hostname " data - order = " asc " > Device </ th >
< th data - column - id = " interface " > Interface </ th >
< th data - column - id = " remote_device " data - sortable = " false " > Remote device </ th >
< th data - column - id = " remote_interface " data - sortable = " false " > Remote interface </ th >
</ tr >
</ thead >
</ table >
</ div >
< script >
2012-04-21 19:50:39 +00:00
2015-04-04 11:42:30 +01:00
var grid = $ ( " #arp-search " ) . bootgrid ({
ajax : true ,
templates : {
header : " <div id= \" { { ctx.id}} \" class= \" { { css.header}} \" ><div class= \" row \" > " +
" <div class= \" col-sm-9 actionBar \" ><span class= \" pull-left \" > " +
" <form method= \" post \" action= \" \" class= \" form-inline \" role= \" form \" > " +
" <div class= \" form-group \" > " +
" <select name= \" device_id \" id= \" device_id \" class= \" form-control input-sm \" > " +
" <option value= \" \" >All Devices</option> " +
2012-04-21 19:50:39 +00:00
< ? php
// Select the devices only with ARP tables
2015-04-04 11:42:30 +01:00
foreach ( dbFetchRows ( " SELECT D.device_id AS device_id, `hostname` FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D WHERE M.port_id = P.port_id AND P.device_id = D.device_id GROUP BY `device_id` ORDER BY `hostname` " ) as $data ) {
echo ( '"<option value=\"' . $data [ 'device_id' ] . '\""+' );
if ( $data [ 'device_id' ] == $_POST [ 'device_id' ]) {
echo ( '" selected "+' );
}
echo ( '">' . $data [ 'hostname' ] . '</option>"+' );
2012-04-21 19:50:39 +00:00
}
?>
2015-04-04 11:42:30 +01:00
" </select> " +
" </div> " +
" <div class= \" form-group \" > " +
" <select name= \" searchby \" id= \" searchby \" class= \" form-control input-sm \" > " +
" <option value= \" mac \" " +
2012-04-21 19:50:39 +00:00
< ? php
2015-04-04 11:42:30 +01:00
if ( $_POST [ 'searchby' ] != " ip " ) {
echo ( '" selected "+' );
2014-10-29 18:34:26 +00:00
}
2015-04-04 11:42:30 +01:00
?>
2014-10-29 18:34:26 +00:00
2015-04-04 11:42:30 +01:00
" >MAC Address</option> " +
" <option value= \" ip \" " +
< ? php
2012-04-21 19:50:39 +00:00
2015-04-04 11:42:30 +01:00
if ( $_POST [ 'searchby' ] == " ip " ) {
echo ( '" selected "+' );
2014-10-29 18:34:26 +00:00
}
2015-04-04 11:42:30 +01:00
?>
2012-05-02 22:02:30 +00:00
2015-04-04 11:42:30 +01:00
" >IP Address</option> " +
" </select> " +
" </div> " +
" <div class= \" form-group \" > " +
" <input type= \" text \" name= \" address \" id= \" address \" value= \" " +
< ? php
2012-04-21 19:50:39 +00:00
2015-04-04 11:42:30 +01:00
echo '"' . $_POST [ 'address' ] . '"+' ;
2012-04-21 19:50:39 +00:00
2014-10-29 18:34:26 +00:00
?>
2012-04-21 19:50:39 +00:00
2015-04-04 11:42:30 +01:00
" \" class= \" form-control input-sm \" placeholder= \" Address \" /> " +
" </div> " +
" <button type= \" submit \" class= \" btn btn-default input-sm \" >Search</button> " +
" </form></span></div> " +
" <div class= \" col-sm-3 actionBar \" ><p class= \" { { css.actions}} \" ></p></div></div></div> "
},
post : function ()
{
return {
id : " arp-search " ,
device_id : '<?php echo htmlspecialchars($_POST[' device_id ']); ?>' ,
searchby : '<?php echo mres($_POST[' searchby ']); ?>' ,
address : '<?php echo mres($_POST[' address ']); ?>'
};
},
url : " /ajax_table.php "
});
2012-04-21 19:50:39 +00:00
2014-10-29 18:34:26 +00:00
</ script >