Example #1
0
function dispatchImageRequest()
{
    genericAssertion('img', 'string');
    global $pageno, $tabno;
    switch ($_REQUEST['img']) {
        case 'minirack':
            // rack security context
            $pageno = 'rack';
            $tabno = 'default';
            fixContext();
            assertPermission();
            dispatchMiniRackThumbRequest(getBypassValue());
            break;
        case 'midirack':
            // rack security context
            $pageno = 'rack';
            $tabno = 'default';
            fixContext();
            assertPermission();
            genericAssertion('scale', 'uint');
            # Scaling implies no caching, there is no special dispatching.
            header('Content-type: image/png');
            printRackThumbImage(getBypassValue(), $_REQUEST['scale']);
            break;
        case 'preview':
            // file security context
            $pageno = 'file';
            $tabno = 'download';
            fixContext();
            assertPermission();
            renderImagePreview(getBypassValue());
            break;
        case 'cactigraph':
            $pageno = 'object';
            $tabno = 'cacti';
            fixContext();
            assertPermission();
            genericAssertion('server_id', 'uint');
            genericAssertion('graph_id', 'uint');
            if (!array_key_exists($_REQUEST['graph_id'], getCactiGraphsForObject(getBypassValue()))) {
                throw new InvalidRequestArgException('graph_id', $_REQUEST['graph_id']);
            }
            proxyCactiRequest($_REQUEST['server_id'], $_REQUEST['graph_id']);
            break;
        case 'muningraph':
            $pageno = 'object';
            $tabno = 'munin';
            fixContext();
            assertPermission();
            genericAssertion('server_id', 'uint');
            genericAssertion('graph', 'string');
            if (!array_key_exists($_REQUEST['graph'], getMuninGraphsForObject(getBypassValue()))) {
                throw new InvalidRequestArgException('graph', $_REQUEST['graph']);
            }
            proxyMuninRequest($_REQUEST['server_id'], $_REQUEST['graph']);
            break;
        default:
            renderErrorImage();
    }
}
Example #2
0
function dispatchImageRequest()
{
    genericAssertion('img', 'string');
    global $pageno, $tabno;
    switch ($_REQUEST['img']) {
        case 'minirack':
            // rack security context
            $pageno = 'rack';
            $tabno = 'default';
            fixContext();
            assertPermission();
            renderRackThumb(getBypassValue());
            break;
        case 'preview':
            // file security context
            $pageno = 'file';
            $tabno = 'download';
            fixContext();
            assertPermission();
            renderImagePreview(getBypassValue());
            break;
        case 'cactigraph':
            $pageno = 'object';
            $tabno = 'cacti';
            fixContext();
            assertPermission();
            genericAssertion('graph_id', 'uint');
            if (!array_key_exists($_REQUEST['graph_id'], getCactiGraphsForObject(getBypassValue()))) {
                throw new InvalidRequestArgException('graph_id', $_REQUEST['graph_id']);
            }
            proxyCactiRequest($_REQUEST['graph_id']);
            break;
        default:
            renderErrorImage();
    }
}
Example #3
0
function renderObjectCactiGraphs($object_id)
{
    function printNewItemTR($options)
    {
        echo "<table cellspacing=\"0\" align=\"center\" width=\"50%\">";
        echo "<tr><td>&nbsp;</td><th>Server</th><th>Graph ID</th><th>Caption</th><td>&nbsp;</td></tr>\n";
        printOpFormIntro('add');
        echo "<tr><td>";
        printImageHREF('Attach', 'Link new graph', TRUE);
        echo '</td><td>' . getSelect($options, array('name' => 'server_id'));
        echo "</td><td><input type=text name=graph_id tabindex=100></td><td><input type=text name=caption tabindex=101></td><td>";
        printImageHREF('Attach', 'Link new graph', TRUE, 101);
        echo "</td></tr></form>";
        echo "</table>";
        echo "<br/><br/>";
    }
    if (!extension_loaded('curl')) {
        throw new RackTablesError("The PHP cURL extension is not loaded.", RackTablesError::MISCONFIGURED);
    }
    $servers = getCactiServers();
    $options = array();
    foreach ($servers as $server) {
        $options[$server['id']] = "{$server['id']}: {$server['base_url']}";
    }
    startPortlet('Cacti Graphs');
    if (getConfigVar('ADDNEW_AT_TOP') == 'yes' && permitted('object', 'cacti', 'add')) {
        printNewItemTR($options);
    }
    echo "<table cellspacing=\"0\" cellpadding=\"10\" align=\"center\" width=\"50%\">";
    foreach (getCactiGraphsForObject($object_id) as $graph_id => $graph) {
        $cacti_url = $servers[$graph['server_id']]['base_url'];
        $text = "(graph {$graph_id} on server {$graph['server_id']})";
        echo "<tr><td>";
        echo "<a href='{$cacti_url}/graph.php?action=view&local_graph_id={$graph_id}&rra_id=all' target='_blank'>";
        echo "<img src='index.php?module=image&img=cactigraph&object_id={$object_id}&server_id={$graph['server_id']}&graph_id={$graph_id}' alt='{$text}' title='{$text}'></a></td><td>";
        if (permitted('object', 'cacti', 'del')) {
            echo getOpLink(array('op' => 'del', 'server_id' => $graph['server_id'], 'graph_id' => $graph_id), '', 'Cut', 'Unlink graph', 'need-confirmation');
        }
        echo "&nbsp; &nbsp;{$graph['caption']}";
        echo "</td></tr>";
    }
    echo '</table>';
    if (getConfigVar('ADDNEW_AT_TOP') != 'yes' && permitted('object', 'cacti', 'add')) {
        printNewItemTR($options);
    }
    finishPortlet();
}
Example #4
0
function renderObjectCactiGraphs($object_id)
{
    function printNewItemTR()
    {
        echo "<table cellspacing=\"0\" align=\"center\" width=\"50%\">";
        echo "<tr><td>&nbsp;</td><th>Cacti Graph ID</th><th>Caption</th><td>&nbsp;</td></tr>\n";
        printOpFormIntro('add');
        echo "<tr><td>";
        printImageHREF('Attach', 'Link new graph', TRUE);
        echo "</td><td><input type=text name=graph_id tabindex=100></td><td><input type=text name=caption tabindex=101></td><td>";
        printImageHREF('Attach', 'Link new graph', TRUE, 101);
        echo "</td></tr></form>";
        echo "</table>";
        echo "<br/><br/>";
    }
    if (!extension_loaded('curl')) {
        throw new RackTablesError("The PHP cURL extension is not loaded.", RackTablesError::MISCONFIGURED);
    }
    if (!($cacti_url = getConfigVar('CACTI_URL'))) {
        throw new RackTablesError("Cacti URL not configured.", RackTablesError::MISCONFIGURED);
    }
    startPortlet('Cacti Graphs');
    if (getConfigVar('ADDNEW_AT_TOP') == 'yes') {
        printNewItemTR();
    }
    echo "<table cellspacing=\"0\" cellpadding=\"10\" align=\"center\" width=\"50%\">";
    foreach (getCactiGraphsForObject($object_id) as $graph_id => $graph) {
        echo "<tr><td>";
        echo "<a href='{$cacti_url}/graph.php?action=view&local_graph_id={$graph_id}&rra_id=all' target='_blank'>";
        echo "<img src='index.php?module=image&img=cactigraph&object_id={$object_id}&graph_id={$graph_id}' alt='Cacti Graph ID: {$graph_id}'>";
        echo "</a><br/>";
        echo "<a href='" . makeHrefProcess(array('op' => 'del', 'object_id' => $object_id, 'graph_id' => $graph_id)) . "' onclick=\"javascript:return confirm('Are you sure you want to delete the graph?')\">" . getImageHREF('Cut', 'Unlink graph') . "</a>";
        echo "&nbsp; &nbsp;{$graph['caption']}";
        echo "</td></tr>";
    }
    echo '</table>';
    if (getConfigVar('ADDNEW_AT_TOP') != 'yes') {
        printNewItemTR();
    }
    finishPortlet();
}
Example #5
0
function triggerCactiGraphs()
{
    if ('' == getConfigVar('CACTI_URL')) {
        return '';
    }
    if (count(getCactiGraphsForObject(getBypassValue())) or considerConfiguredConstraint(spotEntity('object', getBypassValue()), 'CACTI_LISTSRC')) {
        return 'std';
    } else {
        return '';
    }
}