Ejemplo n.º 1
0
function generate_device_link($device, $text = NULL, $vars = array(), $start = 0, $end = 0)
{
    global $config;
    $class = devclass($device);
    if (!$text) {
        $text = $device['hostname'];
    }
    $contents = generate_device_link_contents($device, $vars, $start, $end);
    $text = htmlentities($text);
    $url = generate_device_url($device, $vars);
    $link = overlib_link($url, $text, $contents, $class);
    if (!device_permitted($device['device_id'])) {
        return $device['hostname'];
    }
    return $link;
}
if (!$_SESSION['authenticated']) {
    echo '<li class="nav-header">Session expired, please log in again!</li>';
    exit;
}
$vars = get_vars('POST');
switch ($vars['entity_type']) {
    case "port":
        if (is_numeric($vars['entity_id']) && port_permitted($vars['entity_id'])) {
            $port = get_port_by_id($vars['entity_id']);
            device_by_id_cache($port['device_id']);
            echo generate_port_popup($port);
        } else {
            print_warning("You are not permitted to view this port.");
        }
        exit;
        break;
    case "device":
        if (is_numeric($vars['entity_id']) && device_permitted($vars['entity_id'])) {
            $device = device_by_id_cache($vars['entity_id']);
            echo generate_device_link_contents($device, $vars, $start, $end);
        } else {
            print_warning("You are not permitted to view this device.");
        }
        exit;
        break;
    default:
        print_error("Unknown entity type.");
        exit;
        break;
}
// EOF