aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPim van den Berg2015-05-25 11:26:47 +0200
committerPim van den Berg2015-05-25 12:11:25 +0200
commit2a337e593359fb03472d1a6c4155971942b307be (patch)
tree2a2285fec7083ccfa87a9df6c5c325648ec85ebc
parentinc/html: s/licence/license/ (diff)
downloadapt-panopticon_cgp-2a337e593359fb03472d1a6c4155971942b307be.zip
apt-panopticon_cgp-2a337e593359fb03472d1a6c4155971942b307be.tar.gz
apt-panopticon_cgp-2a337e593359fb03472d1a6c4155971942b307be.tar.bz2
apt-panopticon_cgp-2a337e593359fb03472d1a6c4155971942b307be.tar.xz
inc/functions: make type argument of validate_get function exactly the same as $_GET value
-rw-r--r--detail.php12
-rw-r--r--graph.php8
-rw-r--r--host.php4
-rw-r--r--inc/functions.inc.php12
-rw-r--r--inc/html.inc.php10
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']))
15if ($CONFIG['graph_type'] == 'hybrid') 15if ($CONFIG['graph_type'] == 'hybrid')
16 $CONFIG['graph_type'] = 'canvas'; 16 $CONFIG['graph_type'] = 'canvas';
17 17
18$host = validate_get(GET('h'), 'host'); 18$host = validate_get(GET('h'), 'h');
19$plugin = validate_get(GET('p'), 'plugin'); 19$plugin = validate_get(GET('p'), 'p');
20$pinstance = validate_get(GET('pi'), 'pinstance'); 20$pinstance = validate_get(GET('pi'), 'pi');
21$category = validate_get(GET('c'), 'category'); 21$category = validate_get(GET('c'), 'c');
22$type = validate_get(GET('t'), 'type'); 22$type = validate_get(GET('t'), 't');
23$tinstance = validate_get(GET('ti'), 'tinstance'); 23$tinstance = validate_get(GET('ti'), 'ti');
24$seconds = GET('s'); 24$seconds = GET('s');
25 25
26$selected_plugins = !$plugin ? $CONFIG['overview'] : array($plugin); 26$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';
4require_once 'inc/functions.inc.php'; 4require_once 'inc/functions.inc.php';
5require_once 'inc/collectd.inc.php'; 5require_once 'inc/collectd.inc.php';
6 6
7$plugin = validate_get(GET('p'), 'plugin'); 7$plugin = validate_get(GET('p'), 'p');
8$type = validate_get(GET('t'), 'type'); 8$type = validate_get(GET('t'), 't');
9$width = GET('x') ? filter_var(GET('x'), FILTER_VALIDATE_INT, array( 9$width = GET('x') ? filter_var(GET('x'), FILTER_VALIDATE_INT, array(
10 'min_range' => 10, 10 'min_range' => 10,
11 'max_range' => $CONFIG['max-width'] 11 'max_range' => $CONFIG['max-width']
@@ -22,7 +22,7 @@ if ($width === NULL || $height === NULL) {
22 error_image(); 22 error_image();
23} 23}
24 24
25if (validate_get(GET('h'), 'host') === NULL) { 25if (validate_get(GET('h'), 'h') === NULL) {
26 error_log('Invalid host: "' . urlencode(GET('h')) . '"'); 26 error_log('Invalid host: "' . urlencode(GET('h')) . '"');
27 error_image(); 27 error_image();
28} 28}
@@ -31,7 +31,7 @@ $typesdb = parse_typesdb_file($CONFIG['typesdb']);
31 31
32if ($plugin == 'aggregation') { 32if ($plugin == 'aggregation') {
33 $pi = explode("-", GET('pi')); 33 $pi = explode("-", GET('pi'));
34 $plugin = $_GET['p'] = validate_get($pi[0], 'plugin'); 34 $plugin = $_GET['p'] = validate_get($pi[0], 'p');
35} 35}
36 36
37# plugin json 37# 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';
4require_once 'inc/html.inc.php'; 4require_once 'inc/html.inc.php';
5require_once 'inc/collectd.inc.php'; 5require_once 'inc/collectd.inc.php';
6 6
7$host = validate_get(GET('h'), 'host'); 7$host = validate_get(GET('h'), 'h');
8$plugin = validate_get(GET('p'), 'plugin'); 8$plugin = validate_get(GET('p'), 'p');
9 9
10$selected_plugins = !$plugin ? $CONFIG['overview'] : array($plugin); 10$selected_plugins = !$plugin ? $CONFIG['overview'] : array($plugin);
11 11
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) {
10 10
11function validate_get($value, $type) { 11function validate_get($value, $type) {
12 switch($type) { 12 switch($type) {
13 case 'host': 13 case 'h': # host
14 if (!preg_match('/^[\w-.]+$/u', $value)) 14 if (!preg_match('/^[\w-.]+$/u', $value))
15 return NULL; 15 return NULL;
16 break; 16 break;
17 case 'plugin': 17 case 'p': # plugin
18 case 'category': 18 case 'c': # category
19 case 'type': 19 case 't': # type
20 if (!preg_match('/^\w+$/u', $value)) 20 if (!preg_match('/^\w+$/u', $value))
21 return NULL; 21 return NULL;
22 break; 22 break;
23 case 'pinstance': 23 case 'pi': # plugin instance
24 case 'tinstance': 24 case 'ti': # type instance
25 if (!preg_match('/^[\w-]+$/u', $value)) 25 if (!preg_match('/^[\w-]+$/u', $value))
26 return NULL; 26 return NULL;
27 break; 27 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) {
313 313
314function breadcrumbs() { 314function breadcrumbs() {
315 $path = ''; 315 $path = '';
316 if (validate_get(GET('h'), 'host')) 316 if (validate_get(GET('h'), 'h'))
317 $path .= ' - '.ucfirst(GET('h')); 317 $path .= ' - '.ucfirst(GET('h'));
318 if (validate_get(GET('p'), 'plugin')) 318 if (validate_get(GET('p'), 'p'))
319 $path .= ' - '.ucfirst(GET('p')); 319 $path .= ' - '.ucfirst(GET('p'));
320 if (validate_get(GET('pi'), 'pinstance')) 320 if (validate_get(GET('pi'), 'pi'))
321 $path .= ' - '.GET('pi'); 321 $path .= ' - '.GET('pi');
322 if (validate_get(GET('t'), 'type') && validate_get(GET('p'), 'plugin') && GET('t') != GET('p')) 322 if (validate_get(GET('t'), 't') && validate_get(GET('p'), 'p') && GET('t') != GET('p'))
323 $path .= ' - '.GET('t'); 323 $path .= ' - '.GET('t');
324 if (validate_get(GET('ti'), 'tinstance')) 324 if (validate_get(GET('ti'), 'ti'))
325 $path .= ' - '.GET('ti'); 325 $path .= ' - '.GET('ti');
326 326
327 return $path; 327 return $path;