aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--graph.php22
-rw-r--r--inc/functions.inc.php2
2 files changed, 16 insertions, 8 deletions
diff --git a/graph.php b/graph.php
index 3e33b92..2d62d92 100644
--- a/graph.php
+++ b/graph.php
@@ -6,16 +6,24 @@ require_once 'inc/collectd.inc.php';
6 6
7$plugin = validate_get(GET('p'), 'plugin'); 7$plugin = validate_get(GET('p'), 'plugin');
8$type = validate_get(GET('t'), 'type'); 8$type = validate_get(GET('t'), 'type');
9$width = empty($_GET['x']) ? $CONFIG['width'] : $_GET['x']; 9$width = GET('x') ? filter_input(INPUT_GET, 'x', FILTER_VALIDATE_INT, array(
10$height = empty($_GET['y']) ? $CONFIG['height'] : $_GET['y']; 10 'min_range' => 10,
11 11 'max_range' => $CONFIG['max-width']
12if (validate_get(GET('h'), 'host') === NULL) { 12)) : $CONFIG['width'];
13 error_log('CGP Error: plugin contains unknown characters'); 13$height = GET('y') ? filter_input(INPUT_GET, 'y', FILTER_VALIDATE_INT, array(
14 'min_range' => 10,
15 'max_range' => $CONFIG['max-height']
16)) : $CONFIG['height'];
17
18if ($width === NULL || $height === NULL) {
19 error_log(sprintf('Invalid image dimension, x="%s", y="%s"',
20 urlencode(GET('x')),
21 urlencode(GET('y'))));
14 error_image(); 22 error_image();
15} 23}
16 24
17if ($width > $CONFIG['max-width'] || $height > $CONFIG['max-height']) { 25if (validate_get(GET('h'), 'host') === NULL) {
18 error_log('Resquested image is too large. Please configure max-width and max-height.'); 26 error_log('Invalid host: "' . urlencode(GET('h')) . '"');
19 error_image(); 27 error_image();
20} 28}
21 29
diff --git a/inc/functions.inc.php b/inc/functions.inc.php
index c32b3ef..3664d78 100644
--- a/inc/functions.inc.php
+++ b/inc/functions.inc.php
@@ -55,7 +55,7 @@ function crc32hex($str) {
55} 55}
56 56
57function error_image() { 57function error_image() {
58 header("Content-Type: image/png"); 58 header("Content-Type: image/png", true, 400);
59 readfile('layout/error.png'); 59 readfile('layout/error.png');
60 exit; 60 exit;
61} 61}