X-Git-Url: https://git-public.kairo.at/?p=php-utility-classes.git;a=blobdiff_plain;f=include%2Fclasses%2Frrdstat.php-class;h=5e8cc6659c92b68f849e72bd2800c0a39b554ebf;hp=0cc03ef556fc62aada4882a69cef84bc2c8d6fdf;hb=2e28e4bd8d68f7bd199c387efb63b22d99bf04d6;hpb=633b21afce66bd8ea1f0a3345173f2a6c33b9389 diff --git a/include/classes/rrdstat.php-class b/include/classes/rrdstat.php-class index 0cc03ef..5e8cc66 100644 --- a/include/classes/rrdstat.php-class +++ b/include/classes/rrdstat.php-class @@ -35,6 +35,10 @@ class rrdstat { // var $basename // base name for this RRD (usually file name without .rrd) // + // var $basedir + // base directory for this RRD (with a trailing slash) + // note that $rrd_file usually includes that path as well, but graph directory gets based on this value + // // var $config_all // complete, raw configuration array set // @@ -128,6 +132,7 @@ class rrdstat { var $rrd_file = null; var $basename = null; + var $basedir = null; var $config_all = null; var $config_raw = null; @@ -184,16 +189,21 @@ class rrdstat { $iinfo = $complete_conf; } + if (isset($iinfo['path']) && strlen($iinfo['path'])) { + $this->basedir = $iinfo['path']; + if (substr($this->basedir, -1) != '/') { $this->basedir .= '/'; } + } + if (isset($iinfo['graph-only']) && $iinfo['graph-only'] && !is_null($conf_id)) { $this->basename = $conf_id; $this->status = 'graphonly'; } elseif (isset($iinfo['file'])) { - $this->rrd_file = $iinfo['file']; + $this->rrd_file = (($iinfo['file']{0} != '/')?$this->basedir:'').$iinfo['file']; $this->basename = (substr($this->rrd_file, -4) == '.rrd')?substr($this->rrd_file, 0, -4):$this->rrd_file; } elseif (!is_null($conf_id) && file_exists($conf_id.'.rrd')) { - $this->rrd_file = $conf_id.'.rrd'; + $this->rrd_file = (($iinfo['file']{0} != '/')?$this->basedir:'').$conf_id.'.rrd'; $this->basename = $conf_id; } else { @@ -457,7 +467,8 @@ class rrdstat { $fname = str_replace('%t', $timeframe, $fname); $fname = str_replace('%f', $fmt_ext, $fname); if (substr($fname, -strlen($fmt_ext)) != $fmt_ext) { $fname .= $fmt_ext; } - if (isset($gconf['path'])) { $fname = $gconf['path'].'/'.$fname; } + if (isset($gconf['path']) && ($fname{0} != '/')) { $fname = $gconf['path'].'/'.$fname; } + if ($fname{0} != '/') { $fname = $this->basedir.$fname; } $fname = str_replace('//', '/', $fname); $graphrows = array(); $specialrows = array(); $gC = 0;