diff options
| author | Karol Nowacki | 2011-04-21 20:24:38 +0200 |
|---|---|---|
| committer | Pim van den Berg | 2011-04-21 20:30:07 +0200 |
| commit | 1bce11aec73bcd6f90fe8e72877b4061ae8d45af (patch) | |
| tree | 082af880c39ee01a241c0467fec29c239ef0155b | |
| parent | plugin/varnish: deduplicate rrd_format values (diff) | |
| download | apt-panopticon_cgp-1bce11aec73bcd6f90fe8e72877b4061ae8d45af.zip apt-panopticon_cgp-1bce11aec73bcd6f90fe8e72877b4061ae8d45af.tar.gz apt-panopticon_cgp-1bce11aec73bcd6f90fe8e72877b4061ae8d45af.tar.bz2 apt-panopticon_cgp-1bce11aec73bcd6f90fe8e72877b4061ae8d45af.tar.xz | |
resolve php notices
Including a lot of undefined $_GET values.
Diffstat (limited to '')
| -rw-r--r-- | detail.php | 16 | ||||
| -rw-r--r-- | graph.php | 4 | ||||
| -rw-r--r-- | host.php | 4 | ||||
| -rw-r--r-- | inc/functions.inc.php | 6 | ||||
| -rw-r--r-- | inc/html.inc.php | 21 | ||||
| -rw-r--r-- | plugin.php | 6 | ||||
| -rw-r--r-- | plugin/memcached.php | 2 | ||||
| -rw-r--r-- | plugin/swap.php | 2 | ||||
| -rw-r--r-- | type/Default.class.php | 26 |
9 files changed, 47 insertions, 40 deletions
| @@ -11,14 +11,14 @@ if (empty($_GET['x'])) | |||
| 11 | if (empty($_GET['y'])) | 11 | if (empty($_GET['y'])) |
| 12 | $_GET['y'] = $CONFIG['detail-heigth']; | 12 | $_GET['y'] = $CONFIG['detail-heigth']; |
| 13 | 13 | ||
| 14 | $host = validate_get($_GET['h'], 'host'); | 14 | $host = validate_get(GET('h'), 'host'); |
| 15 | $plugin = validate_get($_GET['p'], 'plugin'); | 15 | $plugin = validate_get(GET('p'), 'plugin'); |
| 16 | $pinstance = validate_get($_GET['pi'], 'pinstance'); | 16 | $pinstance = validate_get(GET('pi'), 'pinstance'); |
| 17 | $type = validate_get($_GET['t'], 'type'); | 17 | $type = validate_get(GET('t'), 'type'); |
| 18 | $tinstance = validate_get($_GET['ti'], 'tinstance'); | 18 | $tinstance = validate_get(GET('ti'), 'tinstance'); |
| 19 | $width = $_GET['x']; | 19 | $width = GET('x'); |
| 20 | $heigth = $_GET['y']; | 20 | $heigth = GET('y'); |
| 21 | $seconds = $_GET['s']; | 21 | $seconds = GET('s'); |
| 22 | 22 | ||
| 23 | html_start(); | 23 | html_start(); |
| 24 | 24 | ||
| @@ -3,11 +3,11 @@ | |||
| 3 | require_once 'conf/common.inc.php'; | 3 | require_once 'conf/common.inc.php'; |
| 4 | require_once 'inc/functions.inc.php'; | 4 | require_once 'inc/functions.inc.php'; |
| 5 | 5 | ||
| 6 | $plugin = validate_get($_GET['p'], 'plugin'); | 6 | $plugin = validate_get(GET('p'), 'plugin'); |
| 7 | $width = empty($_GET['x']) ? $CONFIG['width'] : $_GET['x']; | 7 | $width = empty($_GET['x']) ? $CONFIG['width'] : $_GET['x']; |
| 8 | $heigth = empty($_GET['y']) ? $CONFIG['heigth'] : $_GET['y']; | 8 | $heigth = empty($_GET['y']) ? $CONFIG['heigth'] : $_GET['y']; |
| 9 | 9 | ||
| 10 | if (validate_get($_GET['h'], 'host') === NULL) { | 10 | if (validate_get(GET('h'), 'host') === NULL) { |
| 11 | error_log('CGP Error: plugin contains unknown characters'); | 11 | error_log('CGP Error: plugin contains unknown characters'); |
| 12 | error_image(); | 12 | error_image(); |
| 13 | } | 13 | } |
| @@ -4,8 +4,8 @@ require_once 'conf/common.inc.php'; | |||
| 4 | require_once 'inc/html.inc.php'; | 4 | require_once 'inc/html.inc.php'; |
| 5 | require_once 'inc/collectd.inc.php'; | 5 | require_once 'inc/collectd.inc.php'; |
| 6 | 6 | ||
| 7 | $host = validate_get($_GET['h'], 'host'); | 7 | $host = validate_get(GET('h'), 'host'); |
| 8 | $splugin = validate_get($_GET['p'], 'plugin'); | 8 | $splugin = validate_get(GET('p'), 'plugin'); |
| 9 | 9 | ||
| 10 | html_start(); | 10 | html_start(); |
| 11 | 11 | ||
diff --git a/inc/functions.inc.php b/inc/functions.inc.php index 04e58e3..39f1cd0 100644 --- a/inc/functions.inc.php +++ b/inc/functions.inc.php | |||
| @@ -2,6 +2,12 @@ | |||
| 2 | 2 | ||
| 3 | # global functions | 3 | # global functions |
| 4 | 4 | ||
| 5 | function GET($index) { | ||
| 6 | if (isset($_GET[$index])) | ||
| 7 | return $_GET[$index]; | ||
| 8 | return null; | ||
| 9 | } | ||
| 10 | |||
| 5 | function validate_get($value, $type) { | 11 | function validate_get($value, $type) { |
| 6 | switch($type) { | 12 | switch($type) { |
| 7 | case 'host': | 13 | case 'host': |
diff --git a/inc/html.inc.php b/inc/html.inc.php index 1dc3d2c..d4a31f2 100644 --- a/inc/html.inc.php +++ b/inc/html.inc.php | |||
| @@ -118,16 +118,17 @@ function host_summary($hosts) { | |||
| 118 | 118 | ||
| 119 | 119 | ||
| 120 | function breadcrumbs() { | 120 | function breadcrumbs() { |
| 121 | if (validate_get($_GET['h'], 'host')) | 121 | $path = ''; |
| 122 | $path = ' - '.ucfirst($_GET['h']); | 122 | if (validate_get(GET('h'), 'host')) |
| 123 | if (validate_get($_GET['p'], 'plugin')) | 123 | $path .= ' - '.ucfirst(GET('h')); |
| 124 | $path .= ' - '.ucfirst($_GET['p']); | 124 | if (validate_get(GET('p'), 'plugin')) |
| 125 | if (validate_get($_GET['pi'], 'pinstance')) | 125 | $path .= ' - '.ucfirst(GET('p')); |
| 126 | $path .= ' - '.$_GET['pi']; | 126 | if (validate_get(GET('pi'), 'pinstance')) |
| 127 | if (validate_get($_GET['t'], 'type') && validate_get($_GET['p'], 'plugin') && $_GET['t'] != $_GET['p']) | 127 | $path .= ' - '.GET('pi'); |
| 128 | $path .= ' - '.$_GET['t']; | 128 | if (validate_get(GET('t'), 'type') && validate_get(GET('p'), 'plugin') && GET('t') != GET('p')) |
| 129 | if (validate_get($_GET['ti'], 'tinstance')) | 129 | $path .= ' - '.GET('t'); |
| 130 | $path .= ' - '.$_GET['ti']; | 130 | if (validate_get(GET('ti'), 'tinstance')) |
| 131 | $path .= ' - '.GET('ti'); | ||
| 131 | 132 | ||
| 132 | return $path; | 133 | return $path; |
| 133 | } | 134 | } |
| @@ -4,10 +4,10 @@ require_once 'conf/common.inc.php'; | |||
| 4 | require_once 'inc/functions.inc.php'; | 4 | require_once 'inc/functions.inc.php'; |
| 5 | require_once 'inc/html.inc.php'; | 5 | require_once 'inc/html.inc.php'; |
| 6 | 6 | ||
| 7 | $host = validate_get($_GET['h'], 'host'); | 7 | $host = validate_get(GET('h'), 'host'); |
| 8 | $plugin = validate_get($_GET['p'], 'plugin'); | 8 | $plugin = validate_get(GET('p'), 'plugin'); |
| 9 | 9 | ||
| 10 | if ($_GET['a'] == 'del') { | 10 | if (GET('a') == 'del') { |
| 11 | plugin_header($host, $plugin, 1); | 11 | plugin_header($host, $plugin, 1); |
| 12 | } else { | 12 | } else { |
| 13 | plugin_header($host, $plugin, 0); | 13 | plugin_header($host, $plugin, 0); |
diff --git a/plugin/memcached.php b/plugin/memcached.php index b30c27c..e011c9e 100644 --- a/plugin/memcached.php +++ b/plugin/memcached.php | |||
| @@ -21,7 +21,7 @@ require_once 'inc/collectd.inc.php'; | |||
| 21 | # ps_cputime.rrd | 21 | # ps_cputime.rrd |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | switch($_GET['t']) { | 24 | switch(GET('t')) { |
| 25 | # df-cache.rrd | 25 | # df-cache.rrd |
| 26 | case 'df': | 26 | case 'df': |
| 27 | require_once 'type/Default.class.php'; | 27 | require_once 'type/Default.class.php'; |
diff --git a/plugin/swap.php b/plugin/swap.php index 9449b55..c24d90b 100644 --- a/plugin/swap.php +++ b/plugin/swap.php | |||
| @@ -11,7 +11,7 @@ require_once 'inc/collectd.inc.php'; | |||
| 11 | # swap/swap-free.rrd | 11 | # swap/swap-free.rrd |
| 12 | # swap/swap-used.rrd | 12 | # swap/swap-used.rrd |
| 13 | 13 | ||
| 14 | switch($_GET['t']) { | 14 | switch(GET('t')) { |
| 15 | case 'swap': | 15 | case 'swap': |
| 16 | require_once 'type/GenericStacked.class.php'; | 16 | require_once 'type/GenericStacked.class.php'; |
| 17 | $obj = new Type_GenericStacked($CONFIG); | 17 | $obj = new Type_GenericStacked($CONFIG); |
diff --git a/type/Default.class.php b/type/Default.class.php index 45c4458..6429e5e 100644 --- a/type/Default.class.php +++ b/type/Default.class.php | |||
| @@ -59,13 +59,13 @@ class Type_Default { | |||
| 59 | # parse $_GET values | 59 | # parse $_GET values |
| 60 | function parse_get() { | 60 | function parse_get() { |
| 61 | $this->args = array( | 61 | $this->args = array( |
| 62 | 'host' => $_GET['h'], | 62 | 'host' => GET('h'), |
| 63 | 'plugin' => $_GET['p'], | 63 | 'plugin' => GET('p'), |
| 64 | 'pinstance' => $_GET['pi'], | 64 | 'pinstance' => GET('pi'), |
| 65 | 'type' => $_GET['t'], | 65 | 'type' => GET('t'), |
| 66 | 'tinstance' => $_GET['ti'], | 66 | 'tinstance' => GET('ti'), |
| 67 | ); | 67 | ); |
| 68 | $this->seconds = $_GET['s']; | 68 | $this->seconds = GET('s'); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | function validate_color($color) { | 71 | function validate_color($color) { |
| @@ -82,12 +82,12 @@ class Type_Default { | |||
| 82 | 82 | ||
| 83 | $rgb = array('r', 'g', 'b'); | 83 | $rgb = array('r', 'g', 'b'); |
| 84 | 84 | ||
| 85 | $fg[r] = hexdec(substr($fgc,0,2)); | 85 | $fg['r'] = hexdec(substr($fgc,0,2)); |
| 86 | $fg[g] = hexdec(substr($fgc,2,2)); | 86 | $fg['g'] = hexdec(substr($fgc,2,2)); |
| 87 | $fg[b] = hexdec(substr($fgc,4,2)); | 87 | $fg['b'] = hexdec(substr($fgc,4,2)); |
| 88 | $bg[r] = hexdec(substr($bgc,0,2)); | 88 | $bg['r'] = hexdec(substr($bgc,0,2)); |
| 89 | $bg[g] = hexdec(substr($bgc,2,2)); | 89 | $bg['g'] = hexdec(substr($bgc,2,2)); |
| 90 | $bg[b] = hexdec(substr($bgc,4,2)); | 90 | $bg['b'] = hexdec(substr($bgc,4,2)); |
| 91 | 91 | ||
| 92 | foreach ($rgb as $pri) { | 92 | foreach ($rgb as $pri) { |
| 93 | $c[$pri] = dechex(round($percent * $fg[$pri]) + ((1.0 - $percent) * $bg[$pri])); | 93 | $c[$pri] = dechex(round($percent * $fg[$pri]) + ((1.0 - $percent) * $bg[$pri])); |
| @@ -95,7 +95,7 @@ class Type_Default { | |||
| 95 | $c[$pri] = '00'; | 95 | $c[$pri] = '00'; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | return $c[r].$c[g].$c[b]; | 98 | return $c['r'].$c['g'].$c['b']; |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | function rrd_files() { | 101 | function rrd_files() { |
