コード例 #1
0
ファイル: functions.inc.php プロジェクト: Rosiak/librenms
function generate_device_link($device, $text = null, $vars = array(), $start = 0, $end = 0, $escape_text = 1, $overlib = 1)
{
    global $config;
    if (!$start) {
        $start = $config['time']['day'];
    }
    if (!$end) {
        $end = $config['time']['now'];
    }
    $class = devclass($device);
    if (!$text) {
        $text = $device['hostname'];
    }
    $text = ip_to_sysname($device, $text);
    if (isset($config['os'][$device['os']]['over'])) {
        $graphs = $config['os'][$device['os']]['over'];
    } elseif (isset($device['os_group']) && isset($config['os'][$device['os_group']]['over'])) {
        $graphs = $config['os'][$device['os_group']]['over'];
    } else {
        $graphs = $config['os']['default']['over'];
    }
    $url = generate_device_url($device, $vars);
    // beginning of overlib box contains large hostname followed by hardware & OS details
    $contents = '<div><span class="list-large">' . $device['hostname'] . '</span>';
    if ($device['hardware']) {
        $contents .= ' - ' . $device['hardware'];
    }
    if ($device['os']) {
        $contents .= ' - ' . mres($config['os'][$device['os']]['text']);
    }
    if ($device['version']) {
        $contents .= ' ' . mres($device['version']);
    }
    if ($device['features']) {
        $contents .= ' (' . mres($device['features']) . ')';
    }
    if (isset($device['location'])) {
        $contents .= ' - ' . htmlentities($device['location']);
    }
    $contents .= '</div>';
    foreach ($graphs as $entry) {
        $graph = $entry['graph'];
        $graphhead = $entry['text'];
        $contents .= '<div class="overlib-box">';
        $contents .= '<span class="overlib-title">' . $graphhead . '</span><br />';
        $contents .= generate_minigraph_image($device, $start, $end, $graph);
        $contents .= generate_minigraph_image($device, $config['time']['week'], $end, $graph);
        $contents .= '</div>';
    }
    if ($escape_text) {
        $text = htmlentities($text);
    }
    if ($overlib == 0) {
        $link = $contents;
    } else {
        $link = overlib_link($url, $text, escape_quotes($contents), $class);
    }
    if (device_permitted($device['device_id'])) {
        return $link;
    } else {
        return $device['hostname'];
    }
}
コード例 #2
0
                     $serviceLabelOld = 'availability-map-oldview-box-down';
                     $serviceState = "down";
                     $service_down_count++;
                 }
             }
         }
         if ($config['webui']['availability_map_compact'] == 0) {
             if ($directpage == "yes") {
                 $deviceIcon = getImage($service);
                 $temp_output[] = '
                 <a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '">
                     <div class="service-availability ' . $serviceState . '" style="width:' . $config['webui']['availability_map_direct_tile_size'] . 'px;">
                         <span class="service-name-label label ' . $serviceLabel . ' label-font-border">' . $service["service_type"] . '</span>
                         <span class="availability-label label ' . $serviceLabel . ' label-font-border">' . $serviceState . '</span>
                         <span class="device-icon">' . $deviceIcon . '</span><br>
                         <span class="small">' . shorthost(ip_to_sysname($service, $service['hostname'])) . '</span>
                     </div>
                 </a>';
             } else {
                 $temp_output[] = '
                 <a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '">
                     <span class="label ' . $serviceLabel . ' widget-availability label-font-border">' . $service['service_type'] . ' - ' . $serviceState . '</span>
                 </a>';
             }
         } else {
             $temp_output[] = '<a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '"><div class="' . $serviceLabelOld . '" style="width:' . $compact_tile . 'px;"></div></a>';
         }
     }
 } else {
     $temp_output[] = '';
 }
コード例 #3
0
                     <a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '">
                         <div class="service-availability ' . $serviceState . '" style="width:' . $config['webui']['availability_map_box_size'] . 'px;">
                             <span class="service-name-label label ' . $serviceLabel . ' label-font-border">' . $service["service_type"] . '</span>
                             <span class="availability-label label ' . $serviceLabel . ' label-font-border">' . $serviceState . '</span>
                             <span class="device-icon">' . $deviceIcon . '</span><br>
                             <span class="small">' . shorthost(ip_to_sysname($service, $service['hostname'])) . '</span>
                         </div>
                     </a>';
                 } else {
                     $serviceText = $service['service_type'] . ' - ' . $serviceState;
                     if ($widget_settings['color_only_select'] == 1) {
                         $serviceText = ' ';
                         $serviceLabel .= ' widget-availability-fixed';
                     }
                     $temp_output[] = '
                     <a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . shorthost(ip_to_sysname($device, $device['hostname'])) . " - " . $service['service_type'] . " - " . $service['service_desc'] . '">
                         <span class="label ' . $serviceLabel . ' widget-availability label-font-border">' . $serviceText . '</span>
                     </a>';
                 }
             } else {
                 $temp_output[] = "<a href='" . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . "' title='{$service['hostname']} - {$service['service_type']} - {$service['service_desc']}'><div class='" . $serviceLabelOld . "' style='width:{$compact_tile}px;height:{$compact_tile}px;'></div></a>";
             }
         }
     } else {
         $temp_output[] = '';
     }
 }
 if ($directpage == "yes") {
     $temp_header[] = '
     <div class="page-availability-title-left">
         <span class="page-availability-title">Availability map for</span>