* Copyright (c) 2016 Jens Langhammer * 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. */ if (defined('show_settings')) { $current_mode = isset($widget_settings['mode']) ? $widget_settings['mode'] : 0; $current_width = isset($widget_settings['tile_width']) ? $widget_settings['tile_width'] : 10; $common_output[] = '
'; } else { require_once 'includes/object-cache.inc.php'; $mode = isset($widget_settings['mode']) ? $widget_settings['mode'] : 0; $tile_width = isset($widget_settings['tile_width']) ? $widget_settings['tile_width'] : 10; $up_count = 0; $warn_count = 0; $down_count = 0; if ($mode == 0 || $mode == 2) { // Only show devices if mode is 0 or 2 (Only Devices or both) $sql = 'SELECT `D`.`hostname`,`D`.`device_id`,`D`.`status`,`D`.`uptime` FROM `devices` AS `D`'; if (is_normal_user() === true) { $sql .= ' , `devices_perms` AS P WHERE D.`device_id` = P.`device_id` AND P.`user_id` = ? AND'; $param = array( $_SESSION['user_id'] ); } else { $sql .= ' WHERE'; } $sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `hostname`"; $temp_output = array(); foreach (dbFetchRows($sql, $param) as $device) { if ($device['status'] == '1') { if (($device['uptime'] < $config['uptime_warning']) && ($device['uptime'] != '0')) { $btn_type = 'btn-warning'; $warn_count++; } else { $btn_type = 'btn-success'; $up_count ++; } } else { $btn_type = 'btn-danger'; $down_count++; } $temp_output[] = ''; } } if ($mode == 1 || $mode == 2) { $service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `D`.`hostname`, `D`.`device_id` from services S, devices D where `S`.`device_id` = `D`.`device_id`;'; foreach (dbFetchRows($service_query) as $service) { if ($service['service_status'] == '0') { $btn_type = 'btn-success'; $up_count ++; } else { $btn_type = 'btn-danger'; $down_count += 1; } $temp_output[] = ''; } } $temp_output[] = ''; $temp_header = array( '
'.$up_count.' '.$warn_count.' '.$down_count.'

' ); $common_output = array_merge($temp_header, $temp_output); }