From 7a95ff23f3cc8b3bcf9e92a2fd22aa0159cb56cb Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 20 Jun 2021 12:13:10 +0800 Subject: [PATCH] Make admin tool graphs work on windows --- web/public_php/admin/config.php | 9 ++++++++- web/public_php/admin/tool_graphs.php | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/web/public_php/admin/config.php b/web/public_php/admin/config.php index bfc0fe70d..041097df7 100644 --- a/web/public_php/admin/config.php +++ b/web/public_php/admin/config.php @@ -17,7 +17,14 @@ define('NELTOOL_LOGBASE', NELTOOL_SYSTEMBASE .'/logs/'); define('NELTOOL_IMGBASE', NELTOOL_SYSTEMBASE .'/imgs/'); - define('NELTOOL_RRDTOOL', '/usr/bin/rrdtool'); + if ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')) + { + define('NELTOOL_RRDTOOL', NELTOOL_SYSTEMBASE . '../../../../external/rrdtool/rrdtool.exe'); + } + else + { + define('NELTOOL_RRDTOOL', '/usr/bin/rrdtool'); + } define('NELTOOL_RRDSYSBASE', NELTOOL_SYSTEMBASE . 'graphs_output/'); define('NELTOOL_RRDWEBBASE', NELTOOL_SITEBASE . 'graphs_output/'); diff --git a/web/public_php/admin/tool_graphs.php b/web/public_php/admin/tool_graphs.php index 32d0dff0c..74bf90b53 100644 --- a/web/public_php/admin/tool_graphs.php +++ b/web/public_php/admin/tool_graphs.php @@ -159,7 +159,7 @@ foreach($graph_list as $graph_item) { $rrd_path = $AS_RRDPath . $graph_item['rd_file']; - $rrd_def = "DEF:val=". $rrd_path .":var:AVERAGE"; + $rrd_def = "DEF:val=". str_replace(":", "\\:", $rrd_path) .":var:AVERAGE"; $rrd_draw = "LINE2:val#0000FF --no-legend"; $rrd_output = NELTOOL_RRDSYSBASE . $graph_item['rd_file'] ."-". $view_time_lowframe .".gif"; $rrd_web = NELTOOL_RRDWEBBASE . $graph_item['rd_file'] ."-". $view_time_lowframe .".gif"; @@ -216,7 +216,7 @@ foreach($graph_list as $graph_item) { $rrd_path = $AS_RRDPath . $graph_item['rd_file']; - $rrd_def = "DEF:val=". $rrd_path .":var:AVERAGE"; + $rrd_def = "DEF:val=". str_replace(":", "\\:", $rrd_path) .":var:AVERAGE"; $rrd_draw = "LINE2:val#0000FF --no-legend"; $rrd_output = NELTOOL_RRDSYSBASE . $graph_item['rd_file'] ."-". $view_time_lowframe .".gif"; $rrd_web = NELTOOL_RRDWEBBASE . $graph_item['rd_file'] ."-". $view_time_lowframe .".gif"; @@ -373,7 +373,7 @@ { $rrd_values = array(1200, 10800, 86400, 604800, 2592000, 7776000); // 20mins, 3h, 24h, 7days, 30 days, 90 days (unit is 1 second) $rrd_path = $AS_RRDPath . $tool_selected_variable_data['low_file']; - $rrd_def = "DEF:val=". $rrd_path .":var:AVERAGE"; + $rrd_def = "DEF:val=". str_replace(":", "\\:", $rrd_path) .":var:AVERAGE"; $rrd_draw = "LINE2:val#0000FF"; $rrd_webs = array();