Пример #1
0
function makeIPAllocLink($ip_bin, $alloc, $display_ifname = FALSE)
{
    $object_name = !isset($object_name) || !strlen($object_name) ? formatEntityName(spotEntity('object', $alloc['object_id'])) : $alloc['object_name'];
    $title = $display_ifname ? '' : "{$alloc['name']} @ {$object_name}";
    return '<a href="' . makeHref(array('page' => 'object', 'tab' => 'default', 'object_id' => $alloc['object_id'], 'hl_ip' => ip_format($ip_bin))) . '"' . ' title="' . htmlspecialchars($title, ENT_QUOTES) . '"' . ">" . ($display_ifname ? $alloc['name'] . '@' : '') . $object_name . "</a>";
}
Пример #2
0
function getFileLinks($file_id)
{
    $query = usePreparedSelectBlade('SELECT id, file_id, entity_type, entity_id FROM FileLink ' . 'WHERE file_id = ? ORDER BY entity_type, entity_id', array($file_id));
    $rows = $query->fetchAll(PDO::FETCH_ASSOC);
    $ret = array();
    foreach ($rows as $row) {
        // get info of the parent
        switch ($row['entity_type']) {
            case 'ipv4net':
            case 'ipv6net':
                $page = $row['entity_type'];
                $id_name = 'id';
                $parent = spotEntity($row['entity_type'], $row['entity_id']);
                $name = sprintf("%s (%s/%s)", $parent['name'], $parent['ip'], $parent['mask']);
                break;
            case 'ipv4rspool':
                $page = 'ipv4rspool';
                $id_name = 'pool_id';
                $parent = spotEntity($row['entity_type'], $row['entity_id']);
                $name = $parent['name'];
                break;
            case 'ipv4vs':
                $page = 'ipv4vs';
                $id_name = 'vs_id';
                $parent = spotEntity($row['entity_type'], $row['entity_id']);
                $name = $parent['name'];
                break;
            case 'object':
                $page = 'object';
                $id_name = 'object_id';
                $parent = spotEntity($row['entity_type'], $row['entity_id']);
                $name = $parent['dname'];
                break;
            case 'location':
                $page = 'location';
                $id_name = 'location_id';
                $parent = spotEntity($row['entity_type'], $row['entity_id']);
                $name = $parent['name'];
                break;
            case 'rack':
                $page = 'rack';
                $id_name = 'rack_id';
                $parent = spotEntity($row['entity_type'], $row['entity_id']);
                $name = $parent['name'];
                break;
            case 'user':
                $page = 'user';
                $id_name = 'user_id';
                $parent = spotEntity($row['entity_type'], $row['entity_id']);
                $name = $parent['user_name'];
                break;
        }
        // name needs to have some value for hrefs to work
        if (!strlen($name)) {
            $name = sprintf("[Unnamed %s]", formatEntityName($row['entity_type']));
        }
        $ret[$row['id']] = array('page' => $page, 'id_name' => $id_name, 'entity_type' => $row['entity_type'], 'entity_id' => $row['entity_id'], 'name' => $name);
    }
    return $ret;
}
Пример #3
0
function deleteVS()
{
    $vsinfo = spotEntity('ipvs', assertUIntArg('vs_id'));
    if (count(getTriplets($vsinfo)) != 0) {
        showError("Could not delete linked virtual service group");
        return;
    }
    commitDeleteVSG($vsinfo['id']);
    showSuccess(formatEntityName($vsinfo) . ' deleted');
    return buildRedirectURL('ipv4slb', 'vs');
}
Пример #4
0
function renderFileLinks($links)
{
    startPortlet('Links (' . count($links) . ')');
    echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n";
    foreach ($links as $link) {
        echo '<tr><td class=tdleft>';
        switch ($link['entity_type']) {
            case 'user':
            case 'ipv4net':
            case 'rack':
            case 'ipv4vs':
            case 'ipv4rspool':
            case 'object':
                renderCell(spotEntity($link['entity_type'], $link['entity_id']));
                break;
            default:
                echo formatEntityName($link['entity_type']) . ': ';
                echo "<a href='" . makeHref(array('page' => $link['page'], $link['id_name'] => $link['entity_id']));
                echo "'>{$link['name']}</a>";
                break;
        }
        echo '</td></tr>';
    }
    echo "</table><br>\n";
    finishPortlet();
}