Exemple #1
0
require_once 'conf/common.inc.php';
require_once 'inc/functions.inc.php';
require_once 'inc/html.inc.php';
require_once 'inc/collectd.inc.php';
# use width/height from config if nothing is given
if (empty($_GET['x'])) {
    $_GET['x'] = $CONFIG['detail-width'];
}
if (empty($_GET['y'])) {
    $_GET['y'] = $CONFIG['detail-heigth'];
}
$host = validate_get(GET('h'), 'host');
$plugin = validate_get(GET('p'), 'plugin');
$pinstance = validate_get(GET('pi'), 'pinstance');
$type = validate_get(GET('t'), 'type');
$tinstance = validate_get(GET('ti'), 'tinstance');
$width = GET('x');
$heigth = GET('y');
$seconds = GET('s');
$requesthash = sha1(serialize($_GET));
$rediskey = "cache:grapher:detail:{$host}:{$plugin}:{$type}:{$tinstance}:{$seconds}";
$content = $redis->get($rediskey);
if ($content) {
    http_cache_etag();
    http_send_data($content);
    exit;
}
ob_start();
html_start();
if (isset($_GET["tz"])) {
    $tz = $_GET["tz"];
            $link = "?page={$l1}&section={$l2}";
        } elseif (!is_null($l1)) {
            $link = "?page={$l1}";
        } else {
            $link = "";
        }
    }
    # result
    return $link;
}
/**
 *	verify GET parameters
 *
 *		we need to make sure that GET parameters are valid for phpipam scheme
 */
validate_get($_GET);
function validate_get($get)
{
    # l1 check
    if (isset($get['page'])) {
        $valid = array("administration", "dashboard", "install", "ipaddr", "login", "tools", "upgrade", "error", "subnets", "folder", "vlan", "vrf", "request_ip", "widgets");
        if (!in_array($get['page'], $valid)) {
            header("Location:" . create_link("error", "406"));
        }
    }
    # validate all post vars
    if (sizeof($get) > 0) {
        foreach ($get as $g) {
            if (preg_match('/[^A-Za-z0-9_.#\\-$]/', $g)) {
                # permit for search
                if ($get['section'] != "search") {
Exemple #3
0
<?php

require_once 'conf/common.inc.php';
require_once 'inc/functions.inc.php';
require_once 'inc/html.inc.php';
$host = validate_get(GET('h'), 'host');
$plugin = validate_get(GET('p'), 'plugin');
if (GET('a') == 'del') {
    plugin_header($host, $plugin, 1);
} else {
    plugin_header($host, $plugin, 0);
    graphs_from_plugin($host, $plugin);
}
Exemple #4
0
    if (isset($_GET[$v])) {
        $get_cleaned[$v] = $_GET[$v];
    }
}
$plugin = validate_get(GET('p'), 'plugin');
$width = empty($_GET['x']) ? $CONFIG['width'] : $_GET['x'];
$heigth = empty($_GET['y']) ? $CONFIG['heigth'] : $_GET['y'];
$requesthash = sha1(serialize($get_cleaned));
$rediskey = "cache:grapher:graph:{$plugin}:{$width}x{$heigth}:{$requesthash}:{$tz}";
$cached = $redis->get($rediskey);
if ($cached) {
    Header("Content-Type: image/png");
    http_cache_etag();
    http_send_data($cached);
    exit;
}
if (validate_get(GET('h'), 'host') === NULL) {
    error_log('CGP Error: plugin contains unknown characters');
    error_image();
}
if (!file_exists($CONFIG['webdir'] . '/plugin/' . $plugin . '.php')) {
    error_log(sprintf('CGP Error: plugin "%s" is not available', $plugin));
    error_image();
}
ob_start();
# load plugin
include $CONFIG['webdir'] . '/plugin/' . $plugin . '.php';
$content = ob_get_clean();
$redis->setex($rediskey, 60, $content);
http_cache_etag();
http_send_data($content);
Exemple #5
0
function breadcrumbs()
{
    $path = '';
    if (validate_get(GET('h'), 'host')) {
        $path .= ' - ' . ucfirst(GET('h'));
    }
    if (validate_get(GET('p'), 'plugin')) {
        $path .= ' - ' . ucfirst(GET('p'));
    }
    if (validate_get(GET('pi'), 'pinstance')) {
        $path .= ' - ' . GET('pi');
    }
    if (validate_get(GET('t'), 'type') && validate_get(GET('p'), 'plugin') && GET('t') != GET('p')) {
        $path .= ' - ' . GET('t');
    }
    if (validate_get(GET('ti'), 'tinstance')) {
        $path .= ' - ' . GET('ti');
    }
    return $path;
}