diff options
Diffstat (limited to '')
-rw-r--r-- | inc/collectd.inc.php | 21 | ||||
-rw-r--r-- | inc/functions.inc.php | 15 | ||||
-rw-r--r-- | inc/html.inc.php | 31 |
3 files changed, 61 insertions, 6 deletions
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) { | |||
169 | ? $CONFIG['time_range'][$plugin] | 169 | ? $CONFIG['time_range'][$plugin] |
170 | : $CONFIG['time_range']['default']; | 170 | : $CONFIG['time_range']['default']; |
171 | 171 | ||
172 | printf('<a href="%s%s"><img src="%s%s"></a>'."\n", | 172 | if ($CONFIG['graph_type'] == 'canvas') { |
173 | $CONFIG['weburl'], | 173 | chdir($CONFIG['webdir']); |
174 | build_url('detail.php', $items, $time), | 174 | isset($items['p']) ? $_GET['p'] = $items['p'] : $_GET['p'] = ''; |
175 | $CONFIG['weburl'], | 175 | isset($items['pi']) ? $_GET['pi'] = $items['pi'] : $_GET['pi'] = ''; |
176 | build_url('graph.php', $items, $time) | 176 | isset($items['t']) ? $_GET['t'] = $items['t'] : $_GET['t'] = ''; |
177 | ); | 177 | isset($items['ti']) ? $_GET['ti'] = $items['ti'] : $_GET['ti'] = ''; |
178 | include $CONFIG['webdir'].'/plugin/'.$plugin.'.php'; | ||
179 | } else { | ||
180 | printf('<a href="%s%s"><img src="%s%s"></a>'."\n", | ||
181 | $CONFIG['weburl'], | ||
182 | build_url('detail.php', $items, $time), | ||
183 | $CONFIG['weburl'], | ||
184 | build_url('graph.php', $items, $time) | ||
185 | ); | ||
186 | } | ||
178 | } | 187 | } |
179 | } | 188 | } |
180 | 189 | ||
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) { | |||
30 | return $value; | 30 | return $value; |
31 | } | 31 | } |
32 | 32 | ||
33 | function validateRRDPath($base, $path) { | ||
34 | $realpath = realpath(sprintf('%s/%s', $base, $path)); | ||
35 | |||
36 | if (strpos($realpath, $base) === false) | ||
37 | return false; | ||
38 | |||
39 | if (strpos($realpath, $base) !== 0) | ||
40 | return false; | ||
41 | |||
42 | if (!preg_match('/\.rrd$/', $realpath)) | ||
43 | return false; | ||
44 | |||
45 | return $realpath; | ||
46 | } | ||
47 | |||
33 | function crc32hex($str) { | 48 | function crc32hex($str) { |
34 | return sprintf("%x",crc32($str)); | 49 | return sprintf("%x",crc32($str)); |
35 | } | 50 | } |
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() { | |||
19 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | 19 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
20 | <title>CGP{$path}</title> | 20 | <title>CGP{$path}</title> |
21 | <link rel="stylesheet" href="{$CONFIG['weburl']}layout/style.css" type="text/css"> | 21 | <link rel="stylesheet" href="{$CONFIG['weburl']}layout/style.css" type="text/css"> |
22 | |||
23 | EOT; | ||
24 | |||
25 | if ($CONFIG['graph_type'] == 'canvas') { | ||
26 | echo <<<EOT | ||
27 | <script type="text/javascript" src="{$CONFIG['weburl']}js/sprintf.js"></script> | ||
28 | <script type="text/javascript" src="{$CONFIG['weburl']}js/strftime.js"></script> | ||
29 | <script type="text/javascript" src="{$CONFIG['weburl']}js/RrdRpn.js"></script> | ||
30 | <script type="text/javascript" src="{$CONFIG['weburl']}js/RrdTime.js"></script> | ||
31 | <script type="text/javascript" src="{$CONFIG['weburl']}js/RrdGraph.js"></script> | ||
32 | <script type="text/javascript" src="{$CONFIG['weburl']}js/RrdGfxCanvas.js"></script> | ||
33 | <script type="text/javascript" src="{$CONFIG['weburl']}js/binaryXHR.js"></script> | ||
34 | <script type="text/javascript" src="{$CONFIG['weburl']}js/rrdFile.js"></script> | ||
35 | <script type="text/javascript" src="{$CONFIG['weburl']}js/RrdDataFile.js"></script> | ||
36 | <script type="text/javascript" src="{$CONFIG['weburl']}js/RrdCmdLine.js"></script> | ||
37 | |||
38 | EOT; | ||
39 | } | ||
40 | |||
41 | echo <<<EOT | ||
22 | </head> | 42 | </head> |
23 | <body> | 43 | <body> |
24 | 44 | ||
@@ -52,6 +72,17 @@ function html_end() { | |||
52 | <div id="footer"> | 72 | <div id="footer"> |
53 | <hr><span class="small"><a href="http://pommi.nethuis.nl/category/cgp/" rel="external">Collectd Graph Panel</a> ({$version}) is distributed under the <a href="{$CONFIG['weburl']}doc/LICENSE" rel="licence">GNU General Public License (GPLv3)</a></span> | 73 | <hr><span class="small"><a href="http://pommi.nethuis.nl/category/cgp/" rel="external">Collectd Graph Panel</a> ({$version}) is distributed under the <a href="{$CONFIG['weburl']}doc/LICENSE" rel="licence">GNU General Public License (GPLv3)</a></span> |
54 | </div> | 74 | </div> |
75 | |||
76 | EOT; | ||
77 | |||
78 | if ($CONFIG['graph_type'] == 'canvas') { | ||
79 | echo <<<EOT | ||
80 | <script type="text/javascript" src="{$CONFIG['weburl']}js/CGP.js"></script> | ||
81 | |||
82 | EOT; | ||
83 | } | ||
84 | |||
85 | echo <<<EOT | ||
55 | </body> | 86 | </body> |
56 | </html> | 87 | </html> |
57 | EOT; | 88 | EOT; |