2011-03-17 00:09:20 +00:00
< ? php
2010-07-26 17:28:51 +00:00
2012-05-25 12:24:34 +00:00
// Set Defaults here
2011-09-12 04:57:56 +00:00
2015-07-13 20:10:26 +02:00
if ( ! isset ( $vars [ 'format' ])) {
$vars [ 'format' ] = " list_detail " ;
}
2011-09-12 04:57:56 +00:00
2011-10-18 14:41:19 +00:00
$pagetitle [] = " Devices " ;
2011-09-14 13:38:01 +00:00
print_optionbar_start ();
2014-01-13 10:05:19 +00:00
echo ( '<span style="font-weight: bold;">Lists</span> » ' );
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 ) {
echo ( $sep );
if ( $vars [ 'format' ] == " list_ " . $option ) {
echo ( " <span class='pagemenu-selected'> " );
}
echo ( '<a href="' . generate_url ( $vars , array ( 'format' => " list_ " . $option )) . '">' . $text . '</a>' );
if ( $vars [ 'format' ] == " list_ " . $option ) {
echo ( " </span> " );
}
$sep = " | " ;
2014-01-13 10:05:19 +00:00
}
?>
|
< span style = " font-weight: bold; " > Graphs </ span > & #187;
< ? php
2015-06-10 08:02:22 +02:00
$menu_options = array ( 'bits' => 'Bits' ,
2015-07-13 20:10:26 +02:00
'processor' => 'CPU' ,
'ucd_load' => 'Load' ,
'mempool' => 'Memory' ,
'uptime' => 'Uptime' ,
'storage' => 'Storage' ,
'diskio' => 'Disk I/O' ,
'poller_perf' => 'Poller' ,
'ping_perf' => 'Ping'
);
2014-01-13 10:05:19 +00:00
$sep = " " ;
2015-07-13 20:10:26 +02:00
foreach ( $menu_options as $option => $text ) {
echo ( $sep );
if ( $vars [ 'format' ] == 'graph_' . $option ) {
echo ( " <span class='pagemenu-selected'> " );
}
echo ( '<a href="' . generate_url ( $vars , array ( 'format' => 'graph_' . $option )) . '">' . $text . '</a>' );
if ( $vars [ 'format' ] == 'graph_' . $option ) {
echo ( " </span> " );
}
$sep = " | " ;
2014-01-13 10:05:19 +00:00
}
?>
< div style = " float: right; " >
< ? php
2015-07-13 20:10:26 +02:00
if ( isset ( $vars [ 'searchbar' ]) && $vars [ 'searchbar' ] == " hide " ) {
2014-01-13 10:05:19 +00:00
echo ( '<a href="' . generate_url ( $vars , array ( 'searchbar' => '' )) . '">Restore Search</a>' );
2015-07-13 20:10:26 +02:00
}
else {
2014-01-13 10:05:19 +00:00
echo ( '<a href="' . generate_url ( $vars , array ( 'searchbar' => 'hide' )) . '">Remove Search</a>' );
2015-07-13 20:10:26 +02:00
}
2014-01-13 10:05:19 +00:00
2015-07-13 20:10:26 +02:00
echo ( " | " );
2014-01-13 10:05:19 +00:00
2015-07-13 20:10:26 +02:00
if ( isset ( $vars [ 'bare' ]) && $vars [ 'bare' ] == " yes " ) {
2014-01-13 10:05:19 +00:00
echo ( '<a href="' . generate_url ( $vars , array ( 'bare' => '' )) . '">Restore Header</a>' );
2015-07-13 20:10:26 +02:00
}
else {
2014-01-13 10:05:19 +00:00
echo ( '<a href="' . generate_url ( $vars , array ( 'bare' => 'yes' )) . '">Remove Header</a>' );
2015-07-13 20:10:26 +02:00
}
2014-01-13 10:05:19 +00:00
print_optionbar_end ();
2010-07-26 17:28:51 +00:00
?>
2011-05-10 10:34:51 +00:00
2015-04-08 21:17:48 +01:00
</ div >
2009-03-20 13:25:19 +00:00
2011-09-20 09:55:11 +00:00
< ? php
2011-09-14 13:38:01 +00:00
2015-06-10 00:47:26 +02:00
list ( $format , $subformat ) = explode ( " _ " , $vars [ 'format' ], 2 );
2011-09-14 13:38:01 +00:00
2015-07-13 20:10:26 +02:00
if ( $format == " graph " ) {
$sql_param = array ();
2015-04-13 13:21:30 +00:00
2015-07-13 20:10:26 +02:00
if ( isset ( $vars [ 'state' ])) {
if ( $vars [ 'state' ] == 'up' ) {
$state = '1' ;
}
elseif ( $vars [ 'state' ] == 'down' ) {
$state = '0' ;
}
}
2015-04-13 13:21:30 +00:00
2015-07-13 20:10:26 +02:00
if ( ! empty ( $vars [ 'hostname' ])) {
$where .= " AND hostname LIKE ? " ;
$sql_param [] = " % " . $vars [ 'hostname' ] . " % " ;
}
if ( ! empty ( $vars [ 'os' ])) {
$where .= " AND os = ? " ;
$sql_param [] = $vars [ 'os' ];
}
if ( ! empty ( $vars [ 'version' ])) {
$where .= " AND version = ? " ;
$sql_param [] = $vars [ 'version' ];
}
if ( ! empty ( $vars [ 'hardware' ])) {
$where .= " AND hardware = ? " ;
$sql_param [] = $vars [ 'hardware' ];
}
if ( ! empty ( $vars [ 'features' ])) {
$where .= " AND features = ? " ;
$sql_param [] = $vars [ 'features' ];
}
2015-04-13 13:21:30 +00:00
2015-07-13 20:10:26 +02:00
if ( ! empty ( $vars [ 'type' ])) {
if ( $vars [ 'type' ] == 'generic' ) {
$where .= " AND ( type = ? OR type = '') " ;
$sql_param [] = $vars [ 'type' ];
}
else {
$where .= " AND type = ? " ;
$sql_param [] = $vars [ 'type' ];
}
}
if ( ! empty ( $vars [ 'state' ])) {
$where .= " AND status= ? " ;
$sql_param [] = $state ;
$where .= " AND disabled='0' AND `ignore`='0' " ;
$sql_param [] = '' ;
}
if ( ! empty ( $vars [ 'disabled' ])) {
$where .= " AND disabled= ? " ;
$sql_param [] = $vars [ 'disabled' ];
}
if ( ! empty ( $vars [ 'ignore' ])) {
$where .= " AND `ignore`= ? " ;
$sql_param [] = $vars [ 'ignore' ];
}
if ( ! empty ( $vars [ 'location' ]) && $vars [ 'location' ] == " Unset " ) {
$location_filter = '' ;
}
if ( ! empty ( $vars [ 'location' ])) {
$location_filter = $vars [ 'location' ];
}
if ( ! empty ( $vars [ 'group' ]) ) {
require_once ( '../includes/device-groups.inc.php' );
$where .= " AND ( " ;
foreach ( GetDevicesFromGroup ( $vars [ 'group' ]) as $dev ) {
$where .= " device_id = ? OR " ;
$sql_param [] = $dev [ 'device_id' ];
}
$where = substr ( $where , 0 , strlen ( $where ) - 3 );
$where .= " ) " ;
}
2015-04-13 13:21:30 +00:00
2015-07-13 20:10:26 +02:00
$query = " SELECT * FROM `devices` WHERE 1 " ;
2015-04-13 13:21:30 +00:00
2015-07-13 20:10:26 +02:00
if ( isset ( $where )) {
$query .= $where ;
}
2011-09-14 13:38:01 +00:00
2015-07-13 20:10:26 +02:00
$query .= " ORDER BY hostname " ;
2011-09-14 13:38:01 +00:00
2015-07-13 20:10:26 +02:00
$row = 1 ;
foreach ( dbFetchRows ( $query , $sql_param ) as $device ) {
if ( is_integer ( $row / 2 )) {
$row_colour = $list_colour_a ;
}
else {
$row_colour = $list_colour_b ;
}
if ( device_permitted ( $device [ 'device_id' ])) {
2015-07-20 16:52:33 +01:00
if ( ! $location_filter || $device [ 'location' ] == $location_filter ) {
2015-07-13 20:10:26 +02:00
$graph_type = " device_ " . $subformat ;
2011-09-21 13:22:27 +00:00
2015-07-13 20:10:26 +02:00
if ( $_SESSION [ 'widescreen' ]) {
$width = 270 ;
}
else {
$width = 315 ;
}
2015-08-05 07:13:19 +10:00
$graph_array = array ();
$graph_array [ 'type' ] = $graph_type ;
$graph_array [ 'device' ] = $device [ 'device_id' ];
$graph_array [ 'to' ] = $config [ 'time' ][ 'now' ];
$graph_array [ 'from' ] = $config [ 'time' ][ 'day' ];
$graph_array [ 'height' ] = '110' ;
$graph_array [ 'width' ] = $width ;
$graph_array [ 'legend' ] = 'no' ;
$graph_array [ 'title' ] = 'yes' ;
$graph_array_zoom = $graph_array ;
$graph_array_zoom [ 'height' ] = '150' ;
$graph_array_zoom [ 'width' ] = '400' ;
$graph_array_zoom [ 'legend' ] = 'yes' ;
$overlib_link = " device/device= " . $device [ 'device_id' ] . " / " ;
2015-09-23 15:41:48 +05:30
echo " <div style='display: block; padding: 1px; margin: 2px; min-width: " . ( $width + 90 ) . " px; max-width: " . ( $width + 90 ) . " px; min-height:170px; max-height:170px; text-align: center; float: left; background-color: #f5f5f5;'> " ;
echo '<div class="panel panel-default">' ;
2015-08-05 07:13:19 +10:00
echo overlib_link ( $overlib_link , generate_lazy_graph_tag ( $graph_array ), generate_graph_tag ( $graph_array_zoom ), NULL );
2015-09-23 15:41:48 +05:30
echo " </div></div> \n \n " ;
2015-07-13 20:10:26 +02:00
}
}
2011-09-14 13:38:01 +00:00
}
2015-07-13 20:10:26 +02:00
}
else {
2011-09-14 13:38:01 +00:00
2015-04-08 21:17:48 +01:00
?>
< div class = " panel panel-default panel-condensed " >
< div class = " table-responsive " >
2015-08-23 15:21:12 +05:30
< table id = " devices " class = " table table-condensed table-hover " >
2015-04-08 21:17:48 +01:00
< thead >
< tr >
2015-08-23 00:09:12 +05:30
< th data - column - id = " status " data - sortable = " false " data - searchable = " false " data - formatter = " status " > Status </ th >
2015-08-23 15:20:18 +05:30
< th data - column - id = " icon " data - sortable = " false " data - searchable = " false " > Vendor </ th >
2015-04-08 21:17:48 +01:00
< th data - column - id = " hostname " data - order = " asc " > Device </ th >
< th data - column - id = " ports " data - sortable = " false " data - searchable = " false " ></ th >
< th data - column - id = " hardware " > Platform </ th >
< th data - column - id = " os " > Operating System </ th >
< th data - column - id = " uptime " > Uptime / Location </ th >
< th data - column - id = " actions " data - sortable = " false " data - searchable = " false " > Actions </ th >
</ tr >
</ thead >
</ table >
</ div >
</ div >
< script >
2015-07-08 00:22:36 +01:00
searchbar = " <div id= \" { { ctx.id}} \" class= \" { { css.header}} \" ><div class= \" row \" > " +
2015-04-08 21:17:48 +01:00
" <div class= \" col-sm-9 actionBar \" ><span class= \" pull-left \" ><form method= \" post \" action= \" \" class= \" form-inline \" role= \" form \" > " +
" <span class= \" pull-left \" ><div class= \" form-group \" > " +
" <input type= \" text \" name= \" hostname \" id= \" hostname \" value= \" <?php echo( $vars['hostname'] ); ?> \" class= \" form-control input-sm \" placeholder= \" Hostname \" /> " +
" </div> " +
" <div class= \" form-group \" > " +
" <select name='os' id='os' class= \" form-control input-sm \" > " +
" <option value=''>All OSes</option> " +
< ? php
2015-07-13 20:10:26 +02:00
if ( is_admin () === TRUE || is_read () === TRUE ) {
$sql = " SELECT `os` FROM `devices` AS D WHERE 1 GROUP BY `os` ORDER BY `os` " ;
}
else {
$sql = " SELECT `os` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `os` ORDER BY `os` " ;
$param [] = $_SESSION [ 'user_id' ];
}
foreach ( dbFetch ( $sql , $param ) as $data ) {
if ( $data [ 'os' ]) {
$tmp_os = clean_bootgrid ( $data [ 'os' ]);
echo ( '"<option value=\"' . $tmp_os . '\""+' );
if ( $tmp_os == $vars [ 'os' ]) {
echo ( '" selected "+' );
}
echo ( '">' . $config [ 'os' ][ $tmp_os ][ 'text' ] . '</option>"+' );
2015-04-08 21:17:48 +01:00
}
}
?>
" </select> " +
" </div> " +
" <div class= \" form-group \" > " +
" <select name='version' id='version' class= \" form-control input-sm \" > " +
" <option value=''>All Versions</option> " +
< ? php
2015-07-13 20:10:26 +02:00
if ( is_admin () === TRUE || is_read () === TRUE ) {
$sql = " SELECT `version` FROM `devices` AS D WHERE 1 GROUP BY `version` ORDER BY `version` " ;
}
else {
$sql = " SELECT `version` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `version` ORDER BY `version` " ;
$param [] = $_SESSION [ 'user_id' ];
}
foreach ( dbFetch ( $sql , $param ) as $data ) {
if ( $data [ 'version' ]) {
$tmp_version = clean_bootgrid ( $data [ 'version' ]);
echo ( '"<option value=\"' . $tmp_version . '\""+' );
if ( $tmp_version == $vars [ 'version' ]) {
echo ( '" selected "+' );
}
echo ( '">' . $tmp_version . '</option>"+' );
2015-04-08 21:17:48 +01:00
}
2015-07-13 20:10:26 +02:00
}
2015-04-08 21:17:48 +01:00
?>
" </select> " +
" </div> " +
" <div class= \" form-group \" > " +
" <select name= \" hardware \" id= \" hardware \" class= \" form-control input-sm \" > " +
" <option value= \" \" >All Platforms</option> " +
< ? php
2011-09-14 13:38:01 +00:00
2015-07-13 20:10:26 +02:00
if ( is_admin () === TRUE || is_read () === TRUE ) {
$sql = " SELECT `hardware` FROM `devices` AS D WHERE 1 GROUP BY `hardware` ORDER BY `hardware` " ;
}
else {
$sql = " SELECT `hardware` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hardware` ORDER BY `hardware` " ;
$param [] = $_SESSION [ 'user_id' ];
}
foreach ( dbFetch ( $sql , $param ) as $data ) {
if ( $data [ 'hardware' ]) {
$tmp_hardware = clean_bootgrid ( $data [ 'hardware' ]);
echo ( '"<option value=\"' . $tmp_hardware . '\""+' );
if ( $tmp_hardware == $vars [ 'hardware' ]) {
echo ( '" selected"+' );
}
echo ( '">' . $tmp_hardware . '</option>"+' );
2015-04-08 21:17:48 +01:00
}
}
?>
" </select> " +
" </div> " +
" <div class= \" form-group \" > " +
" <select name= \" features \" id= \" features \" class= \" form-control input-sm \" > " +
" <option value= \" \" >All Featuresets</option> " +
< ? php
2015-07-13 20:10:26 +02:00
if ( is_admin () === TRUE || is_read () === TRUE ) {
$sql = " SELECT `features` FROM `devices` AS D WHERE 1 GROUP BY `features` ORDER BY `features` " ;
2015-04-08 21:17:48 +01:00
}
2015-07-13 20:10:26 +02:00
else {
$sql = " SELECT `features` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `features` ORDER BY `features` " ;
$param [] = $_SESSION [ 'user_id' ];
}
foreach ( dbFetch ( $sql , $param ) as $data ) {
if ( $data [ 'features' ]) {
$tmp_features = clean_bootgrid ( $data [ 'features' ]);
echo ( '"<option value=\"' . $tmp_features . '\""+' );
if ( $tmp_features == $vars [ 'features' ]) {
echo ( '" selected"+' );
}
echo ( '">' . $tmp_features . '</option>"+' );
}
2015-04-08 21:17:48 +01:00
}
?>
" </select> " +
" </div></span><span class= \" pull-left \" > " +
" <div class= \" form-group \" > " +
" <select name= \" location \" id= \" location \" class= \" form-control input-sm \" > " +
" <option value= \" \" >All Locations</option> " +
< ? php
// fix me function?
2015-07-13 20:10:26 +02:00
foreach ( getlocations () as $location ) {
if ( $location ) {
$location = clean_bootgrid ( $location );
echo ( '"<option value=\"' . $location . '\""+' );
if ( $location == $vars [ 'location' ]) {
echo ( '" selected"+' );
}
echo ( '">' . $location . '</option>"+' );
2011-09-14 13:38:01 +00:00
}
2011-03-31 17:19:54 +00:00
}
2015-04-08 21:17:48 +01:00
?>
" </select> " +
" </div> " +
" <div class= \" form-group \" > " +
" <select name= \" type \" id= \" type \" class= \" form-control input-sm \" > " +
" <option value= \" \" >All Device Types</option> " +
< ? php
2015-07-13 20:10:26 +02:00
if ( is_admin () === TRUE || is_read () === TRUE ) {
$sql = " SELECT `type` FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type` " ;
}
else {
$sql = " SELECT `type` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `type` ORDER BY `type` " ;
$param [] = $_SESSION [ 'user_id' ];
}
foreach ( dbFetch ( $sql , $param ) as $data ) {
if ( $data [ 'type' ]) {
echo ( '"<option value=\"' . $data [ 'type' ] . '\""+' );
if ( $data [ 'type' ] == $vars [ 'type' ]) {
echo ( '" selected"+' );
}
echo ( '">' . ucfirst ( $data [ 'type' ]) . '</option>"+' );
2015-04-08 21:17:48 +01:00
}
}
?>
" </select> " +
" </div> " +
" <button type= \" submit \" class= \" btn btn-default input-sm \" >Search</button> " +
" <div class= \" form-group \" > " +
" <a href= \" <?php echo(generate_url( $vars )); ?> \" title= \" Update the browser URL to reflect the search criteria. \" > Update URL</a> | " +
" <a href= \" <?php echo(generate_url(array('page' => 'devices', 'section' => $vars['section'] , 'bare' => $vars['bare'] ))); ?> \" title= \" Reset critera to default. \" > Reset</a> " +
" </div> " +
" </form></span></div> " +
" <div class= \" col-sm-3 actionBar \" ><p class= \" { { css.actions}} \" ></p></div></div></div> "
2015-07-08 00:22:36 +01:00
< ? php
2015-07-13 20:10:26 +02:00
if ( isset ( $vars [ 'searchbar' ]) && $vars [ 'searchbar' ] == " hide " ) {
echo " searchbar = '' " ;
}
2015-07-08 00:22:36 +01:00
?>
var grid = $ ( " #devices " ) . bootgrid ({
ajax : true ,
rowCount : [ 50 , 100 , 250 , - 1 ],
columnSelection : false ,
formatters : {
" status " : function ( column , row ) {
return " <h4><span class='label label- " + row . extra + " threeqtr-width'> " + row . msg + " </span></h4> " ;
}
},
templates : {
header : searchbar
2015-04-08 21:17:48 +01:00
},
post : function ()
{
return {
id : " devices " ,
format : '<?php echo mres($vars[' format ']); ?>' ,
hostname : '<?php echo htmlspecialchars($vars[' hostname ']); ?>' ,
os : '<?php echo mres($vars[' os ']); ?>' ,
version : '<?php echo mres($vars[' version ']); ?>' ,
hardware : '<?php echo mres($vars[' hardware ']); ?>' ,
features : '<?php echo mres($vars[' features ']); ?>' ,
location : '<?php echo mres($vars[' location ']); ?>' ,
type : '<?php echo mres($vars[' type ']); ?>' ,
state : '<?php echo mres($vars[' state ']); ?>' ,
disabled : '<?php echo mres($vars[' disabled ']); ?>' ,
ignore : '<?php echo mres($vars[' ignore ']); ?>' ,
group : '<?php echo mres($vars[' group ']); ?>' ,
};
},
2015-08-11 14:54:05 -07:00
url : " ajax_table.php "
2015-04-08 21:17:48 +01:00
});
</ script >
< ? php
2007-04-03 14:10:23 +00:00
}