+ $out = '<html><head>';
+ $out .= '<title>'.$ptitle.'</title>';
+ $out .= '<style>';
+ if (isset($pconf['style_base'])) { $out .= $pconf['style_base']; }
+ else {
+ $out .= 'h1 { font-weight: bold; font-size: 1.5em; }';
+ $out .= '.footer { font-size: 0.75em; margin: 0.5em 0; }';
+ $out .= 'li.scanfile { font-style: italic; }';
+ }
+ if (isset($pconf['style'])) { $out .= $pconf['style']; }
+ $out .= '</style>';
+ $out .= '</head>';
+ $out .= '<body>';
+
+ $out .= '<h1>'.$ptitle.'</h1>';
+ if (isset($pconf['text_intro']) && strlen($pconf['text_intro'])) {
+ $out .= '<p class="intro">'.$pconf['text_intro'].'</p>';
+ }
+ elseif (!isset($pconf['text_intro'])) {
+ $out .= '<p class="intro">The following RRD stats are available:</p>';
+ }
+
+ $stats = $this->h_page_statsArray($pconf);
+
+ $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>';
+ if (isset($stat['sub']) && count($stat['sub'])) {
+ $sprt = array();
+ foreach ($stat['sub'] as $ssub) { $sprt[] = '<a href="'.$surl.'&sub='.$ssub.'">'.$ssub.'</a>'; }
+ $out .= ' <span="subs">('.implode(', ', $sprt).')</span>';
+ }
+ $out .= '</li>';
+ }
+ $out .= '</ul>';
+
+ $out .= $this->h_page_footer();
+ $out .= '</body></html>';
+ return $out;
+ }
+
+ function page_overview($pconf, $graph_extras = null) {
+ // create an overview HTML page (including graphs) and return it in a string
+
+ $ptitle = isset($pconf['title_page'])?$pconf['title_page']:'RRD statistics overview';
+
+ $out = '<html><head>';
+ $out .= '<title>'.$ptitle.'</title>';
+ $out .= '<style>';
+ if (isset($pconf['style_base'])) { $out .= $pconf['style_base']; }
+ else {
+ $out .= 'h1 { font-weight: bold; font-size: 1.5em; }';
+ $out .= 'h2 { font-weight: bold; font-size: 1em; margin: 0.5em 0; }';
+ $out .= '.footer { font-size: 0.75em; margin: 0.5em 0; }';
+ $out .= 'img.rrdgraph { border: none; }';
+ }
+ if (isset($pconf['style'])) { $out .= $pconf['style']; }
+ $out .= '</style>';
+ $out .= '</head>';
+ $out .= '<body>';
+
+ $out .= '<h1>'.$ptitle.'</h1>';
+ if (isset($pconf['text_intro'])) { $out .= '<p class="intro">'.$pconf['text_intro'].'</p>'; }
+
+ $stats = $this->h_page_statsArray($pconf);
+
+ $num_rows = is_numeric($pconf['num_rows'])?$pconf['num_rows']:2;
+ $num_cols = ceil(count($stats)/$num_rows);
+
+ $out .= '<table class="overview">';
+ for ($col = 0; $col < $num_cols; $col++) {
+ $out .= '<tr>';
+ for ($row = 0; $row < $num_rows; $row++) {
+ $idx = $col * $num_rows + $row;
+ $out .= '<td>';
+ if ($idx < count($stats)) {
+ list($sname, $s_psub) = explode('|', $stats[$idx]['name'], 2);
+ $s_psname = 'page'.(isset($s_psub)?'.'.$s_psub:'');
+ $g_sub = $this->config_all[$sname][$s_psname]['graph_sub'];
+
+ if (isset($this->config_all[$sname][$s_psname]['title_page'])) {
+ $s_ptitle = $this->config_all[$sname][$s_psname]['title_page'];
+ }
+ elseif (isset($this->config_all[$sname]['page']['title_page'])) {
+ $s_ptitle = $this->config_all[$sname]['page']['title_page'];
+ }
+ else {
+ $s_ptitle = $sname.(isset($s_psub)?' ('.$s_psub.')':'').' statistics';
+ }
+ if (!isset($pconf['hide_titles']) || !$pconf['hide_titles']) {
+ $out .= '<h2>'.$s_ptitle.'</h2>';
+ }
+
+ $s_rrd = new rrdstat($this->config_all, $sname);
+ if (in_array($s_rrd->status, array('ok','readonly','graphonly'))) {
+ $tframe = isset($pconf['graph_timeframe'])?$pconf['graph_timeframe']:'day';
+ $gmeta = $s_rrd->graph_plus($tframe, $g_sub);
+ if (isset($pconf['graph_url'])) {
+ $gURL = $pconf['graph_url'];
+ $fname = str_replace('%f', basename($gmeta['filename']), $gURL);
+ $fname = str_replace('%p', $gmeta['filename'], $gURL);
+ if (substr($gURL, -1) == '/') { $gURL .= $gmeta['filename']; }
+ }
+ else {
+ $gURL = $gmeta['filename'];
+ }
+ $out .= '<a href="?stat='.$sname.(isset($s_psub)?'&sub='.$s_psub:'').'"';
+ $out .= '<img src="'.$gURL.'"';
+ $out .= ' alt="'.$s_rrd->basename.(!is_null($g_sub)?' - '.$g_sub:'').' - '.$tframe.'" class="rrdgraph"';
+ $out .= ' style="width:'.$gmeta['width'].'px;height:'.$gmeta['height'].'px;">';
+ $out .= '</a>';
+ }
+ else {
+ $out .= 'RRD error: status is "'.$s_rrd->status.'"';
+ }
+ }
+ else {
+ $out .= ' ';
+ }
+ $out .= '</td>';
+ }
+ $out .= '</tr>';
+ }
+ $out .= '</table>';
+
+ $out .= $this->h_page_footer();
+ $out .= '</body></html>';
+ return $out;
+ }
+
+ function page_simple($pconf, $graph_extras = null) {
+ // create a simple (MRTG-like) HTML page and return it in a string
+
+ $ptitle = isset($pconf['title_page'])?$pconf['title_page']:$this->basename.' - RRD statistics';