diff options
Diffstat (limited to 'graph.php')
-rw-r--r-- | graph.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/graph.php b/graph.php new file mode 100644 index 0000000..4747552 --- /dev/null +++ b/graph.php | |||
@@ -0,0 +1,39 @@ | |||
1 | <?php | ||
2 | |||
3 | require_once 'conf/common.inc.php'; | ||
4 | |||
5 | $host = $_GET['h']; | ||
6 | $plugin = $_GET['p']; | ||
7 | $pinstance = $_GET['pi']; | ||
8 | $type = $_GET['t']; | ||
9 | $tinstance = $_GET['ti']; | ||
10 | $width = $_GET['x']; | ||
11 | $heigth = $_GET['y']; | ||
12 | $seconds = $_GET['s']; | ||
13 | |||
14 | if (!preg_match('/^[a-z]+$/', $plugin)) { | ||
15 | die_img('Error: plugin contains unknown characters.'); | ||
16 | exit; | ||
17 | } | ||
18 | |||
19 | if (!file_exists($CONFIG['webdir']."/plugin/$plugin.php")) { | ||
20 | die_img(sprintf('Error: plugin not available (%s).', $plugin)); | ||
21 | exit; | ||
22 | } | ||
23 | |||
24 | include $CONFIG['webdir']."/plugin/$plugin.php"; | ||
25 | |||
26 | |||
27 | function die_img($msg) { | ||
28 | header("Content-Type: image/png"); | ||
29 | $image = ImageCreatetruecolor(300, 30); | ||
30 | $black = ImageColorAllocate($image, 0, 0, 0); | ||
31 | $white = ImageColorAllocate($image, 255, 255, 255); | ||
32 | imagefill($image, 0, 0, $white); | ||
33 | imagerectangle($image, 0, 0, 299, 29, $black); | ||
34 | imagestring($image, 2, 10, 9, $msg, $black); | ||
35 | imagepng($image); | ||
36 | imagedestroy($image); | ||
37 | } | ||
38 | |||
39 | ?> | ||