From 2a337e593359fb03472d1a6c4155971942b307be Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Mon, 25 May 2015 11:26:47 +0200 Subject: inc/functions: make type argument of validate_get function exactly the same as $_GET value --- detail.php | 12 ++++++------ graph.php | 8 ++++---- host.php | 4 ++-- inc/functions.inc.php | 12 ++++++------ inc/html.inc.php | 10 +++++----- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/detail.php b/detail.php index 777294b..b4ece36 100644 --- a/detail.php +++ b/detail.php @@ -15,12 +15,12 @@ if (empty($_GET['y'])) if ($CONFIG['graph_type'] == 'hybrid') $CONFIG['graph_type'] = 'canvas'; -$host = validate_get(GET('h'), 'host'); -$plugin = validate_get(GET('p'), 'plugin'); -$pinstance = validate_get(GET('pi'), 'pinstance'); -$category = validate_get(GET('c'), 'category'); -$type = validate_get(GET('t'), 'type'); -$tinstance = validate_get(GET('ti'), 'tinstance'); +$host = validate_get(GET('h'), 'h'); +$plugin = validate_get(GET('p'), 'p'); +$pinstance = validate_get(GET('pi'), 'pi'); +$category = validate_get(GET('c'), 'c'); +$type = validate_get(GET('t'), 't'); +$tinstance = validate_get(GET('ti'), 'ti'); $seconds = GET('s'); $selected_plugins = !$plugin ? $CONFIG['overview'] : array($plugin); diff --git a/graph.php b/graph.php index 8eec2ec..b546d02 100644 --- a/graph.php +++ b/graph.php @@ -4,8 +4,8 @@ require_once 'conf/common.inc.php'; require_once 'inc/functions.inc.php'; require_once 'inc/collectd.inc.php'; -$plugin = validate_get(GET('p'), 'plugin'); -$type = validate_get(GET('t'), 'type'); +$plugin = validate_get(GET('p'), 'p'); +$type = validate_get(GET('t'), 't'); $width = GET('x') ? filter_var(GET('x'), FILTER_VALIDATE_INT, array( 'min_range' => 10, 'max_range' => $CONFIG['max-width'] @@ -22,7 +22,7 @@ if ($width === NULL || $height === NULL) { error_image(); } -if (validate_get(GET('h'), 'host') === NULL) { +if (validate_get(GET('h'), 'h') === NULL) { error_log('Invalid host: "' . urlencode(GET('h')) . '"'); error_image(); } @@ -31,7 +31,7 @@ $typesdb = parse_typesdb_file($CONFIG['typesdb']); if ($plugin == 'aggregation') { $pi = explode("-", GET('pi')); - $plugin = $_GET['p'] = validate_get($pi[0], 'plugin'); + $plugin = $_GET['p'] = validate_get($pi[0], 'p'); } # plugin json diff --git a/host.php b/host.php index 03d515c..2ba662d 100644 --- a/host.php +++ b/host.php @@ -4,8 +4,8 @@ require_once 'conf/common.inc.php'; require_once 'inc/html.inc.php'; require_once 'inc/collectd.inc.php'; -$host = validate_get(GET('h'), 'host'); -$plugin = validate_get(GET('p'), 'plugin'); +$host = validate_get(GET('h'), 'h'); +$plugin = validate_get(GET('p'), 'p'); $selected_plugins = !$plugin ? $CONFIG['overview'] : array($plugin); diff --git a/inc/functions.inc.php b/inc/functions.inc.php index abe0763..f667772 100644 --- a/inc/functions.inc.php +++ b/inc/functions.inc.php @@ -10,18 +10,18 @@ function GET($index) { function validate_get($value, $type) { switch($type) { - case 'host': + case 'h': # host if (!preg_match('/^[\w-.]+$/u', $value)) return NULL; break; - case 'plugin': - case 'category': - case 'type': + case 'p': # plugin + case 'c': # category + case 't': # type if (!preg_match('/^\w+$/u', $value)) return NULL; break; - case 'pinstance': - case 'tinstance': + case 'pi': # plugin instance + case 'ti': # type instance if (!preg_match('/^[\w-]+$/u', $value)) return NULL; break; diff --git a/inc/html.inc.php b/inc/html.inc.php index cf3d15d..3998f54 100644 --- a/inc/html.inc.php +++ b/inc/html.inc.php @@ -313,15 +313,15 @@ function host_summary($cat, $hosts) { function breadcrumbs() { $path = ''; - if (validate_get(GET('h'), 'host')) + if (validate_get(GET('h'), 'h')) $path .= ' - '.ucfirst(GET('h')); - if (validate_get(GET('p'), 'plugin')) + if (validate_get(GET('p'), 'p')) $path .= ' - '.ucfirst(GET('p')); - if (validate_get(GET('pi'), 'pinstance')) + if (validate_get(GET('pi'), 'pi')) $path .= ' - '.GET('pi'); - if (validate_get(GET('t'), 'type') && validate_get(GET('p'), 'plugin') && GET('t') != GET('p')) + if (validate_get(GET('t'), 't') && validate_get(GET('p'), 'p') && GET('t') != GET('p')) $path .= ' - '.GET('t'); - if (validate_get(GET('ti'), 'tinstance')) + if (validate_get(GET('ti'), 'ti')) $path .= ' - '.GET('ti'); return $path; -- cgit v1.1