// 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
//
var $rrd_file = null;
var $basename = null;
+ var $basedir = null;
var $config_all = null;
var $config_raw = null;
$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->basename = (substr($this->rrd_file, -4) == '.rrd')?substr($this->rrd_file, 0, -4):$this->rrd_file;
+ $this->rrd_file = (($iinfo['file']{0} != '/')?$this->basedir:'').$iinfo['file'];
+ $this->basename = 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 {
}
}
$key_names = (!is_numeric(array_shift(array_keys($upvals))));
- if (in_array('L', $upvals)) {
+ if (in_array('L', $upvals, true)) {
// for at least one value, we need to set the same as the last recorded value
$fvals = $this->fetch();
$rowids = array_shift($fvals);
$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;
$grow['legend'] = $ds['legend'];
if (!isset($gconf['show_legend'])) { $gconf['show_legend'] = true; }
}
+ if (isset($ds['desc'])) { $grow['desc'] = $ds['desc']; }
$graphrows[] = $grow;
}
}
$pconf = $pconf + (array)$this->config_page;
$return = null;
- switch ($pconf['type']) {
+ switch (@$pconf['type']) {
case 'index':
$return = $this->page_index($pconf);
break;
$stats = $this->h_page_statsArray($pconf);
+ if (isset($pconf['stats_url'])) { $sURL_base = $pconf['stats_url']; }
+ else { $sURL_base = '?stat=%i%a'; }
+
+ if (isset($pconf['stats_url_add'])) { $sURL_add = $pconf['stats_url_add']; }
+ else { $sURL_add = '&sub=%s'; }
+
$out .= '<ul class="indexlist">';
foreach ($stats as $stat) {
$out .= '<li'.(isset($stat['class'])?' class="'.$stat['class'].'"':'').'>';
- $surl = '?stat='.$stat['name'];
- $out .= '<a href="'.$surl.'">'.$stat['name'].'</a>';
+ $sURL = str_replace('%i', $stat['name'], $sURL_base);
+ $sURL = str_replace('%a', '', $sURL);
+ $sURL = str_replace('%s', '', $sURL);
+ $out .= '<a href="'.$sURL.'">'.$stat['name'].'</a>';
if (isset($stat['sub']) && count($stat['sub'])) {
$sprt = array();
- foreach ($stat['sub'] as $ssub) { $sprt[] = '<a href="'.$surl.'&sub='.$ssub.'">'.$ssub.'</a>'; }
+ foreach ($stat['sub'] as $ssub) {
+ $sURL = str_replace('%i', $stat['name'], $sURL_base);
+ $sURL = str_replace('%a', $sURL_add, $sURL);
+ $sURL = str_replace('%s', $ssub, $sURL);
+ $sprt[] = '<a href="'.$sURL.'">'.$ssub.'</a>';
+ }
$out .= ' <span="subs">('.implode(', ', $sprt).')</span>';
}
$out .= '</li>';
$gmeta = $this->graph_plus($tframe, $g_sub, $graph_extras);
if (isset($pconf['graph_url'])) {
$gURL = $pconf['graph_url'];
- $fname = str_replace('%f', basename($gmeta['filename']), $gURL);
- $fname = str_replace('%p', $gmeta['filename'], $gURL);
+ $gURL = str_replace('%f', basename($gmeta['filename']), $gURL);
+ $gURL = str_replace('%p', $gmeta['filename'], $gURL);
if (substr($gURL, -1) == '/') { $gURL .= $gmeta['filename']; }
}
else {
$out .= '<h2>'.$gtitle[$tframe].'</h2>';
$out .= '<img src="'.$gURL.'"';
$out .= ' alt="'.$this->basename.(!is_null($g_sub)?' - '.$g_sub:'').' - '.$tframe.'" class="rrdgraph"';
- $out .= ' style="width:'.$gmeta['width'].'px;height:'.$gmeta['height'].'px;">';
+ if (isset($gmeta['width']) && isset($gmeta['height'])) { $out .= ' style="width:'.$gmeta['width'].'px;height:'.$gmeta['height'].'px;"'; }
+ $out .= '>';
if (isset($gmeta['data']) && count($gmeta['data'])) {
$out .= '<table class="gdata">';
foreach ($gmeta['data'] as $field=>$gdata) {