| 
									
										
										
										
											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-07-13 20:10:26 +02:00
										 |  |  | $sql = 'SELECT D.device_id AS device_id, `hostname` FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D'; | 
					
						
							| 
									
										
										
										
											2015-07-07 23:18:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | if (is_admin() === false && is_read() === false) { | 
					
						
							|  |  |  |     $sql    .= ' LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`'; | 
					
						
							|  |  |  |     $where  .= ' AND `DP`.`user_id`=?'; | 
					
						
							| 
									
										
										
										
											2015-07-07 23:18:57 +01:00
										 |  |  |     $param[] = $_SESSION['user_id']; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $sql .= " WHERE M.port_id = P.port_id AND P.device_id = D.device_id $where GROUP BY `device_id` ORDER BY `hostname`"; | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | foreach (dbFetchRows($sql, $param) as $data) { | 
					
						
							|  |  |  |     echo '"<option value=\"'.$data['device_id'].'\""+'; | 
					
						
							| 
									
										
										
										
											2015-04-04 11:42:30 +01:00
										 |  |  |     if ($data['device_id'] == $_POST['device_id']) { | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |         echo '" selected "+'; | 
					
						
							| 
									
										
										
										
											2015-04-04 11:42:30 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     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-07-13 20:10:26 +02: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 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02: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\">"+ | 
					
						
							| 
									
										
										
										
											2015-12-24 12:09:01 -06:00
										 |  |  |                 "<input type=\"text\" name=\"searchPhrase\" id=\"address\" value=\""+ | 
					
						
							| 
									
										
										
										
											2015-04-04 11:42:30 +01:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2016-02-17 13:59:58 +00:00
										 |  |  | echo '"'.$_POST['searchPhrase'].'"+'; | 
					
						
							| 
									
										
										
										
											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", | 
					
						
							| 
									
										
										
										
											2016-02-17 13:59:58 +00:00
										 |  |  |             device_id: '<?php echo htmlspecialchars($_POST['device_id']); ?>', | 
					
						
							|  |  |  |             searchby: '<?php echo mres($_POST['searchby']); ?>', | 
					
						
							|  |  |  |             searchPhrase: '<?php echo mres($_POST['searchPhrase']); ?>' | 
					
						
							| 
									
										
										
										
											2015-04-04 11:42:30 +01:00
										 |  |  |         }; | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2015-08-11 14:54:05 -07:00
										 |  |  |     url: "ajax_table.php" | 
					
						
							| 
									
										
										
										
											2015-04-04 11:42:30 +01:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2012-04-21 19:50:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-29 18:34:26 +00:00
										 |  |  | </script> |