From 5793a8cd003643974206e44ea752ab0966cfa8c0 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Sat, 18 May 2013 16:05:43 +0200 Subject: integrate jsrrdgraph in CGP --- inc/collectd.inc.php | 21 +++++++++++++++------ inc/functions.inc.php | 15 +++++++++++++++ inc/html.inc.php | 31 +++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 6 deletions(-) (limited to 'inc') diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php index ad15774..1df8bb0 100644 --- a/inc/collectd.inc.php +++ b/inc/collectd.inc.php @@ -169,12 +169,21 @@ function graphs_from_plugin($host, $plugin, $overview=false) { ? $CONFIG['time_range'][$plugin] : $CONFIG['time_range']['default']; - printf(''."\n", - $CONFIG['weburl'], - build_url('detail.php', $items, $time), - $CONFIG['weburl'], - build_url('graph.php', $items, $time) - ); + if ($CONFIG['graph_type'] == 'canvas') { + chdir($CONFIG['webdir']); + isset($items['p']) ? $_GET['p'] = $items['p'] : $_GET['p'] = ''; + isset($items['pi']) ? $_GET['pi'] = $items['pi'] : $_GET['pi'] = ''; + isset($items['t']) ? $_GET['t'] = $items['t'] : $_GET['t'] = ''; + isset($items['ti']) ? $_GET['ti'] = $items['ti'] : $_GET['ti'] = ''; + include $CONFIG['webdir'].'/plugin/'.$plugin.'.php'; + } else { + printf(''."\n", + $CONFIG['weburl'], + build_url('detail.php', $items, $time), + $CONFIG['weburl'], + build_url('graph.php', $items, $time) + ); + } } } diff --git a/inc/functions.inc.php b/inc/functions.inc.php index a72a589..6642e51 100644 --- a/inc/functions.inc.php +++ b/inc/functions.inc.php @@ -30,6 +30,21 @@ function validate_get($value, $type) { return $value; } +function validateRRDPath($base, $path) { + $realpath = realpath(sprintf('%s/%s', $base, $path)); + + if (strpos($realpath, $base) === false) + return false; + + if (strpos($realpath, $base) !== 0) + return false; + + if (!preg_match('/\.rrd$/', $realpath)) + return false; + + return $realpath; +} + function crc32hex($str) { return sprintf("%x",crc32($str)); } diff --git a/inc/html.inc.php b/inc/html.inc.php index a9e6a94..a0e2c8d 100644 --- a/inc/html.inc.php +++ b/inc/html.inc.php @@ -19,6 +19,26 @@ function html_start() { CGP{$path} + +EOT; + + if ($CONFIG['graph_type'] == 'canvas') { + echo << + + + + + + + + + + +EOT; + } + +echo << @@ -52,6 +72,17 @@ function html_end() { + +EOT; + + if ($CONFIG['graph_type'] == 'canvas') { + echo << + +EOT; + } + +echo << EOT; -- cgit v1.1