2007-04-03 14:10:23 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								< ? php 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/* 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  This  program  is  free  software :  you  can  redistribute  it  and / or  modify  it 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  under  the  terms  of  the  GNU  General  Public  License  as  published  by  the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  Free  Software  Foundation ,  either  version  3  of  the  License ,  or  ( at  your 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  option )  any  later  version .   Please  see  LICENSE . txt  at  the  top  level  of 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  the  source  code  distribution  for  details . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @ package     LibreNMS 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @ subpackage  webui 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @ link        http :// librenms . org 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @ copyright   2017  LibreNMS 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @ author      LibreNMS  Contributors 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*/ 
							 
						 
					
						
							
								
									
										
										
										
											2007-04-03 14:10:23 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-10-18 14:41:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								$pagetitle []  =  " Ports " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-05-25 12:24:34 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// Set Defaults here
 
							 
						 
					
						
							
								
									
										
										
										
											2007-04-03 14:10:23 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  ( ! isset ( $vars [ 'format' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $vars [ 'format' ]  =  " list_basic " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2007-04-03 14:10:23 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								$displayLists  =  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$displayLists  .=  '<span style="font-weight: bold;">Ports lists</span> » ' ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								$menu_options  =  array ( 'basic'  =>  'Basic' ,  'detail'  =>  'Detail' ); 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$sep  =  " " ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								foreach  ( $menu_options  as  $option  =>  $text )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $displayLists  .=  $sep ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( $vars [ 'format' ]  ==  " list_ "  .  $option )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $displayLists  .=  '<span class="pagemenu-selected">' ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $displayLists  .=  '<a href="'  .  generate_url ( $vars ,  array ( 'format'  =>  " list_ "  .  $option ))  .  '">'  .  $text  .  '</a>' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( $vars [ 'format' ]  ==  " list_ "  .  $option )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $displayLists  .=  '</span>' ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $sep  =  "  |  " ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-08 21:54:21 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								$displayLists  .=  '  <span style="font-weight: bold;">Graphs</span> » ' ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$menu_options  =  array ( 'bits'  =>  'Bits' , 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    'upkts'  =>  'Unicast Packets' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    'nupkts'  =>  'Non-Unicast Packets' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    'errors'  =>  'Errors' ); 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$sep  =  " " ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								foreach  ( $menu_options  as  $option  =>  $text )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $displayLists  .=  $sep ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( $vars [ 'format' ]  ==  'graph_'  .  $option )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $displayLists  .=  '<span class="pagemenu-selected">' ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $displayLists  .=  '<a href="'  .  generate_url ( $vars ,  array ( 'format'  =>  'graph_'  .  $option ))  .  '">'  .  $text  .  '</a>' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( $vars [ 'format' ]  ==  'graph_'  .  $option )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $displayLists  .=  '</span>' ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $sep  =  "  |  " ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								$displayLists  .=  '<div style="float: right;">' ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-25 16:34:24 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								$displayLists  .=  '<a href="csv.php/report='  .  generate_url ( $vars ,  array ( 'format'  =>  '' ))  .  '" title="Export as CSV" target="_blank" rel="noopener">Export CSV</a> | <a href="'  .  generate_url ( $vars )  .  '" title="Update the browser URL to reflect the search criteria.">Update URL</a> | ' ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  ( isset ( $vars [ 'searchbar' ])  &&  $vars [ 'searchbar' ]  ==  " hide " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $displayLists  .=  '<a href="'  .  generate_url ( $vars ,  array ( 'searchbar'  =>  '' ))  .  '">Search</a>' ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $displayLists  .=  '<a href="'  .  generate_url ( $vars ,  array ( 'searchbar'  =>  'hide' ))  .  '">Search</a>' ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								$displayLists  .=  ' | ' ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  ( isset ( $vars [ 'bare' ])  &&  $vars [ 'bare' ]  ==  " yes " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $displayLists  .=  '<a href="'  .  generate_url ( $vars ,  array ( 'bare'  =>  '' ))  .  '">Header</a>' ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $displayLists  .=  '<a href="'  .  generate_url ( $vars ,  array ( 'bare'  =>  'yes' ))  .  '">Header</a>' ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								$displayLists  .=  ' | ' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$displayLists  .=  '<span style="font-weight: bold;">Bulk actions</span> »' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$displayLists  .=  '<a href="ports/deleted=yes/purge=all" title="Delete ports"> Purge all deleted</a>' ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								$displayLists  .=  '</div>' ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  (( isset ( $vars [ 'searchbar' ])  &&  $vars [ 'searchbar' ]  !=  " hide " )  ||  ! isset ( $vars [ 'searchbar' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $output  =  " <div class='pull-left'> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <form method='post' action='' class='form-inline' role='form'> " ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-18 08:29:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $output  .=  addslashes ( csrf_field ()); 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $output  .=  " <div style='margin-bottom:4px;text-align:left;'> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <div class='form-group'> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <select name='device_id' id='device_id' class='form-control input-sm'> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <option value=''>All Devices</option> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-05 14:16:05 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( Auth :: user () -> hasGlobalRead ())  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $results  =  dbFetchRows ( " SELECT `device_id`,`hostname`, `sysName` FROM `devices` ORDER BY `hostname` " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-05 14:16:05 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $results  =  dbFetchRows ( " SELECT `D`.`device_id`,`D`.`hostname`, `D`.`sysname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` ORDER BY `hostname` " ,  array ( Auth :: id ())); 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    foreach  ( $results  as  $data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( $data [ 'device_id' ]  ==  $vars [ 'device_id' ])  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $deviceselected  =  " selected " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $deviceselected  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $ui_device  =  strlen ( format_hostname ( $data ))  >  15  ?  substr ( format_hostname ( $data ),  0 ,  15 )  .  " ... "  :  format_hostname ( $data ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $output  .=  " <option value=' "  .  $data [ 'device_id' ]  .  " '  "  .  $deviceselected  .  " > "  .  $ui_device  .  " </option> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-14 13:38:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-05 14:16:05 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( ! Auth :: user () -> hasGlobalRead ())  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $results  =  dbFetchRows ( " SELECT `D`.`device_id`,`D`.`hostname`, `D`.`sysName` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` ORDER BY `hostname` " ,  array ( Auth :: id ())); 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $results  =  array (); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2014-06-25 14:51:50 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    foreach  ( $results  as  $data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( $data [ 'device_id' ]  ==  $vars [ 'device_id' ])  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $deviceselected  =  " selected " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $deviceselected  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $output  .=  " <option value=' "  .  $data [ 'device_id' ]  .  " '  "  .  $deviceselected  .  " > "  .  format_hostname ( $data )  .  " </option> " ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2014-06-25 14:51:50 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $output  .=  " </select>  " ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-14 14:28:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( strlen ( $vars [ 'hostname' ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $hasvalue  =  " value=' "  .  $vars [ 'hostname' ]  .  " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $hasvalue  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 21:35:16 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $output  .=  " <input type='text' name='hostname' id='hostname' title='Hostname' class='form-control input-sm'  "  .  $hasvalue  .  "  placeholder='Hostname'> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " </div>  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    switch  ( $vars [ 'state' ])  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        case  " up " : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $isup  =  " selected " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $isdown  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $admindown  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        case  " down " : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $isup  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $isdown  =  " selected " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $admindown  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        case  " admindown " : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $isup  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $isdown  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $admindown  =  " selected " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 21:35:16 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $output  .=  " <div class='form-group'> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <select name='state' id='state' class='form-control input-sm'> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <option value=''>All States</option> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <option value='up'  "  .  $isup  .  " >Up</option> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <option value='down'  "  .  $isdown  .  " >Down</option> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <option value='admindown'  "  .  $admindown  .  " >Shutdown</option> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " </select>  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-24 01:13:13 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $output  .=  " <select name='ifSpeed' id='ifSpeed' class='form-control input-sm'> " ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $output  .=  " <option value=''>All Speeds</option> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-05 14:16:05 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( Auth :: user () -> hasGlobalRead ())  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $sql  =  " SELECT `ifSpeed` FROM `ports` GROUP BY `ifSpeed` ORDER BY `ifSpeed` " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $sql  =  " SELECT `ifSpeed` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` GROUP BY `ifSpeed` ORDER BY `ifSpeed` " ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-05 14:16:05 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $param []  =  array ( Auth :: id (),  Auth :: id ()); 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    foreach  ( dbFetchRows ( $sql ,  $param )  as  $data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( $data [ 'ifSpeed' ])  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            if  ( $data [ 'ifSpeed' ]  ==  $vars [ 'ifSpeed' ])  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                $speedselected  =  " selected " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                $speedselected  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $output  .=  " <option value=' "  .  $data [ 'ifSpeed' ]  .  " ' "  .  $speedselected  .  " > "  .  humanspeed ( $data [ 'ifSpeed' ])  .  " </option> " ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-22 21:35:16 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $output  .=  " </select>  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " </div> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <div class='form-group'> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <select name='ifType' id='ifType' class='form-control input-sm'> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <option value=''>All Media</option> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-05 14:16:05 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( Auth :: user () -> hasGlobalRead ())  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $sql  =  " SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `ifType` " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $sql  =  " SELECT `ifType` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` GROUP BY `ifType` ORDER BY `ifType` " ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-05 14:16:05 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $param []  =  array ( Auth :: id (),  Auth :: id ()); 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-05 12:25:58 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    foreach  ( dbFetchRows ( $sql ,  $param )  as  $data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( $data [ 'ifType' ])  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            if  ( $data [ 'ifType' ]  ==  $vars [ 'ifType' ])  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                $dataselected  =  " selected " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                $dataselected  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-21 04:26:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            $output  .=  " <option value=' "  .  clean_bootgrid ( $data [ 'ifType' ])  .  " '  "  .  $dataselected  .  " > "  .  clean_bootgrid ( $data [ 'ifType' ])  .  " </option> " ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $output  .=  " </select>  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <select name='port_descr_type' id='port_descr_type' class='form-control input-sm'> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <option value=''>All Port Types</option> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-05 14:16:05 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( Auth :: user () -> hasGlobalRead ())  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $sql  =  " SELECT `port_descr_type` FROM `ports` GROUP BY `port_descr_type` ORDER BY `port_descr_type` " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $sql  =  " SELECT `port_descr_type` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` GROUP BY `port_descr_type` ORDER BY `port_descr_type` " ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-05 14:16:05 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $param []  =  array ( Auth :: id (),  Auth :: id ()); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $ports  =  dbFetchRows ( $sql ,  $param ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    foreach  ( $ports  as  $data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( $data [ 'port_descr_type' ])  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            if  ( $data [ 'port_descr_type' ]  ==  $vars [ 'port_descr_type' ])  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                $portdescrib  =  " selected " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                $portdescrib  =  " " ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-29 02:23:19 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-21 04:26:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            $output  .=  " <option value=' "  .  clean_bootgrid ( $data [ 'port_descr_type' ])  .  " '  "  .  $portdescrib  .  " > "  .  ucfirst ( clean_bootgrid ( $data [ 'port_descr_type' ]))  .  " </option> " ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " </select>  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " </div> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <div class='form-group'> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( strlen ( $vars [ 'ifAlias' ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $ifaliasvalue  =  " value=' "  .  $vars [ 'ifAlias' ]  .  " ' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " </div> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " </div> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <div style='text-align:left;'> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <input title='Port Description' type='text' name='ifAlias' id='ifAlias' class='form-control input-sm'  "  .  $ifaliasvalue  .  "  placeholder='Port Description'>  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <select title='Location' name='location' id='location' class='form-control input-sm'>  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <option value=''>All Locations</option> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										 
										
											
												Refactored and update Location Geocoding (#9359)
- Fix location so it is a regular database relation (this allows multiple devices to be accurately linked to one location and saves api calls)
- Parse coordinates from the location more consistently
- Add settings to webui
- ~~Used [PHP Geocoder](http://geocoder-php.org/), which has lots of backends and is well tested. (also includes reverse and geoip)~~
- Google Maps, Bing, Mapquest, and OpenStreetMap supported initially.
- Default to OpenStreetMap, which doesn't require a key.  They will liberally hand out bans if you exceed 1 query per second though.
- All other Geocoding APIs require an API key. (Google requires a credit card on file, but seems to be the most accurate)
- Update all (I think) sql queries to handle the new structure
- Remove final vestiges of override_sysLocation as a device attribute
- Update existing device groups and rules in DB
- Tested all APIs with good/bad location, no/bad/good key, and no connection.
- Cannot fix advanced queries that use location
This blocks #8868
DO NOT DELETE THIS TEXT
#### Please note
> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.
- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)
#### Testers
If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
After you are done testing, you can remove the changes with `./scripts/github-remove`.  If there are schema changes, you can ask on discord how to revert.
											 
										 
										
											2018-11-28 16:49:18 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    foreach  ( getlocations ()  as  $location_row )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $location  =  $location_row [ 'location' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $location_id  =  $location_row [ 'id' ]; 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( $location )  { 
							 
						 
					
						
							
								
									
										
											 
										 
										
											
												Refactored and update Location Geocoding (#9359)
- Fix location so it is a regular database relation (this allows multiple devices to be accurately linked to one location and saves api calls)
- Parse coordinates from the location more consistently
- Add settings to webui
- ~~Used [PHP Geocoder](http://geocoder-php.org/), which has lots of backends and is well tested. (also includes reverse and geoip)~~
- Google Maps, Bing, Mapquest, and OpenStreetMap supported initially.
- Default to OpenStreetMap, which doesn't require a key.  They will liberally hand out bans if you exceed 1 query per second though.
- All other Geocoding APIs require an API key. (Google requires a credit card on file, but seems to be the most accurate)
- Update all (I think) sql queries to handle the new structure
- Remove final vestiges of override_sysLocation as a device attribute
- Update existing device groups and rules in DB
- Tested all APIs with good/bad location, no/bad/good key, and no connection.
- Cannot fix advanced queries that use location
This blocks #8868
DO NOT DELETE THIS TEXT
#### Please note
> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.
- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)
#### Testers
If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
After you are done testing, you can remove the changes with `./scripts/github-remove`.  If there are schema changes, you can ask on discord how to revert.
											 
										 
										
											2018-11-28 16:49:18 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            if  ( $location_id  ==  $vars [ 'location' ])  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                $locationselected  =  " selected " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                $locationselected  =  " " ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-29 02:23:19 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            $ui_location  =  strlen ( $location )  >  15  ?  substr ( $location ,  0 ,  15 )  .  " ... "  :  $location ; 
							 
						 
					
						
							
								
									
										
											 
										 
										
											
												Refactored and update Location Geocoding (#9359)
- Fix location so it is a regular database relation (this allows multiple devices to be accurately linked to one location and saves api calls)
- Parse coordinates from the location more consistently
- Add settings to webui
- ~~Used [PHP Geocoder](http://geocoder-php.org/), which has lots of backends and is well tested. (also includes reverse and geoip)~~
- Google Maps, Bing, Mapquest, and OpenStreetMap supported initially.
- Default to OpenStreetMap, which doesn't require a key.  They will liberally hand out bans if you exceed 1 query per second though.
- All other Geocoding APIs require an API key. (Google requires a credit card on file, but seems to be the most accurate)
- Update all (I think) sql queries to handle the new structure
- Remove final vestiges of override_sysLocation as a device attribute
- Update existing device groups and rules in DB
- Tested all APIs with good/bad location, no/bad/good key, and no connection.
- Cannot fix advanced queries that use location
This blocks #8868
DO NOT DELETE THIS TEXT
#### Please note
> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.
- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)
#### Testers
If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
After you are done testing, you can remove the changes with `./scripts/github-remove`.  If there are schema changes, you can ask on discord how to revert.
											 
										 
										
											2018-11-28 16:49:18 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            $output  .=  " <option value=' $location_id '  $locationselected > "  .  clean_bootgrid ( $ui_location )  .  " </option> " ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-14 13:38:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $output  .=  " </select>  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( $vars [ 'ignore' ])  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $ignorecheck  =  " checked " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $ignorecheck  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( $vars [ 'disabled' ])  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $disabledcheck  =  " checked " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $disabledcheck  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-14 13:38:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( $vars [ 'deleted' ])  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $deletedcheck  =  " checked " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $deletedcheck  =  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <label for='ignore'>Ignored</label>  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <input type='checkbox' id='ignore' name='ignore' value='1'  "  .  $ignorecheck  .  " >  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <label for='disabled'>Disabled</label>  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <input type='checkbox' id='disabled' name='disabled' value='1'  "  .  $disabledcheck  .  " >  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <label for='deleted'>Deleted</label>  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <input type='checkbox' id='deleted' name='deleted' value='1'  "  .  $deletedcheck  .  " >  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <button type='submit' class='btn btn-default btn-sm'>Search</button>  " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " <a class='btn btn-default btn-sm' href=' "  .  generate_url ( array ( 'page'  =>  'ports' ,  'section'  =>  $vars [ 'section' ],  'bare'  =>  $vars [ 'bare' ]))  .  " ' title='Reset critera to default.'>Reset</a> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " </div> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " </form> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $output  .=  " </div> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-14 13:38:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$param  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  ( ! isset ( $vars [ 'ignore' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $vars [ 'ignore' ]  =  " 0 " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  ( ! isset ( $vars [ 'disabled' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $vars [ 'disabled' ]  =  " 0 " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  ( ! isset ( $vars [ 'deleted' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $vars [ 'deleted' ]  =  " 0 " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-14 14:28:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-26 00:21:22 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								$where  =  '' ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-18 23:16:53 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								$ignore_filter  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$disabled_filter  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-06-26 00:21:22 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								foreach  ( $vars  as  $var  =>  $value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( $value  !=  " " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        switch  ( $var )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            case  'hostname' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                $where  .=  "  AND D.hostname LIKE ? " ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                $param []  =  " % "  .  $value  .  " % " ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            case  'location' : 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-29 13:04:11 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                if  ( is_int ( $value ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $where  .=  "  AND L.id = ? " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $param []  =  $value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $where  .=  "  AND L.location LIKE ? " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $param []  =  " % "  .  $value  .  " % " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            case  'device_id' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                $where  .=  "  AND D.device_id = ? " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                $param []  =  $value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            case  'deleted' : 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-21 14:23:48 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                if  ( $value  ==  1  ||  $value  ==  'yes' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                    $where  .=  "  AND `I`.`deleted` = 1 " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $ignore_filter  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            case  'ignore' : 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-21 14:23:48 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                if  ( $value  ==  1  ||  $value  ==  'yes' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                    $where  .=  "  AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0 " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $ignore_filter  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            case  'disabled' : 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-21 14:23:48 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                if  ( $value  ==  1  ||  $value  ==  'yes' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                    $where  .=  "  AND `I`.`disabled` = 1 AND `I`.`deleted` = 0 " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $disabled_filter  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            case  'ifSpeed' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                if  ( is_numeric ( $value ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $where  .=  "  AND I. $var  = ? " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $param []  =  $value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            case  'ifType' : 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                $where  .=  "  AND I. $var  = ? " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                $param []  =  $value ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            case  'ifAlias' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            case  'port_descr_type' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                $where  .=  "  AND I. $var  LIKE ? " ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                $param []  =  " % "  .  $value  .  " % " ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            case  'errors' : 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-21 14:23:48 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                if  ( $value  ==  1  ||  $value  ==  'yes' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                    $where  .=  "  AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0') " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            case  'state' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                if  ( $value  ==  " down " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $where  .=  "  AND I.ifAdminStatus = ? AND I.ifOperStatus = ? " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $param []  =  " up " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $param []  =  " down " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                }  elseif  ( $value  ==  " up " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $where  .=  "  AND I.ifAdminStatus = ? AND I.ifOperStatus = ? " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $param []  =  " up " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $param []  =  " up " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                }  elseif  ( $value  ==  " admindown " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $where  .=  "  AND I.ifAdminStatus = ? AND D.ignore = 0 " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $param []  =  " down " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                break ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-24 21:58:59 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            case  'purge' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                if  ( $vars [ 'purge' ]  ===  'all' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $interfaces  =  dbFetchRows ( 'SELECT * from `ports` AS P, `devices` AS D WHERE `deleted` = 1 AND D.device_id = P.device_id' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    foreach  ( $interfaces  as  $interface )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        $interface  =  cleanPort ( $interface ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        if  ( port_permitted ( $interface [ 'port_id' ],  $interface [ 'device_id' ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                            delete_port ( $interface [ 'port_id' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $interface  =  dbFetchRow ( 'SELECT * from `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id' ,  array ( $vars [ 'purge' ])); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    $interface  =  cleanPort ( $interface ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    if  ( port_permitted ( $interface [ 'port_id' ],  $interface [ 'device_id' ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                        delete_port ( $interface [ 'port_id' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                break ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-18 23:16:53 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-20 16:03:54 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-14 13:38:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-06-18 23:16:53 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  ( $ignore_filter  ==  0  &&  $disabled_filter  ==  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $where  .=  "  AND `I`.`ignore` = 0 AND `I`.`disabled` = 0 AND `I`.`deleted` = 0 " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-11-29 13:04:11 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								$query  =  " SELECT * FROM `ports` AS I, `devices` AS D LEFT JOIN `locations` AS L ON D.location_id = L.id WHERE I.device_id = D.device_id "  .  $where  .  "   "  .  $query_sort ; 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-25 10:34:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								$row  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-11 23:26:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								list ( $format ,  $subformat )  =  explode ( '_' ,  basename ( $vars [ 'format' ])); 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-25 10:34:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-11-29 13:04:11 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// only grab list of ports for graph pages, table uses ajax
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ports  =  $format  ==  'graph'  ?  dbFetchRows ( $query ,  $param )  :  []; 
							 
						 
					
						
							
								
									
										
										
										
											2012-05-25 10:34:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								switch  ( $vars [ 'sort' ])  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    case  'traffic' : 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-01 15:27:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $ports  =  array_sort_by_column ( $ports ,  'ifOctets_rate' ,  SORT_DESC ); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    case  'traffic_in' : 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-01 15:27:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $ports  =  array_sort_by_column ( $ports ,  'ifInOctets_rate' ,  SORT_DESC ); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    case  'traffic_out' : 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-01 15:27:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $ports  =  array_sort_by_column ( $ports ,  'ifOutOctets_rate' ,  SORT_DESC ); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    case  'packets' : 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-01 15:27:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $ports  =  array_sort_by_column ( $ports ,  'ifUcastPkts_rate' ,  SORT_DESC ); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    case  'packets_in' : 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-01 15:27:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $ports  =  array_sort_by_column ( $ports ,  'ifInUcastOctets_rate' ,  SORT_DESC ); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    case  'packets_out' : 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-01 15:27:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $ports  =  array_sort_by_column ( $ports ,  'ifOutUcastOctets_rate' ,  SORT_DESC ); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    case  'errors' : 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-01 15:27:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $ports  =  array_sort_by_column ( $ports ,  'ifErrors_rate' ,  SORT_DESC ); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    case  'speed' : 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-01 15:27:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $ports  =  array_sort_by_column ( $ports ,  'ifSpeed' ,  SORT_DESC ); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    case  'port' : 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-01 15:27:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $ports  =  array_sort_by_column ( $ports ,  'ifDescr' ,  SORT_ASC ); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    case  'media' : 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-01 15:27:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $ports  =  array_sort_by_column ( $ports ,  'ifType' ,  SORT_ASC ); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    case  'descr' : 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-01 15:27:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $ports  =  array_sort_by_column ( $ports ,  'ifAlias' ,  SORT_ASC ); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    case  'device' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    default : 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-01 15:27:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        $ports  =  array_sort_by_column ( $ports ,  'hostname' ,  SORT_ASC ); 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-26 16:31:13 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-11 23:26:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  ( file_exists ( 'includes/html/pages/ports/'  .  $format  .  '.inc.php' ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    require  'includes/html/pages/ports/'  .  $format  .  '.inc.php' ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-14 13:38:01 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}