+ $pconf = $pconf + (array)$this->config_page;
+
+ return $this->page_simple($pconf, $graph_extras);
+ }
+
+ function page_index($pconf) {
+ // create a bare, very simple index list HTML page and return it in a string
+ $td = $this->mod_textdomain;
+ $ptitle = isset($pconf['title_page'])?$pconf['title_page']:dgettext($td, 'RRD statistics index');
+
+ $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">'.dgettext($td, 'The following RRD stats are available:').'</p>';
+ }
+
+ $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 = 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) {
+ $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>';
+ }
+ $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
+ $td = $this->mod_textdomain;
+ $ptitle = isset($pconf['title_page'])?$pconf['title_page']:dgettext($td, '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);
+
+ 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'; }
+
+ $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 = isset($s_psub)?sprintf(dgettext($td, '%s (%s) statistics'), $sname, $s_psub):sprintf(dgettext($td, '%s statistics'), $sname);
+ }
+ 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'];
+ $gURL = str_replace('%f', basename($gmeta['filename']), $gURL);
+ $gURL = str_replace('%p', $gmeta['filename'], $gURL);
+ if (substr($gURL, -1) == '/') { $gURL .= $gmeta['filename']; }
+ }
+ else {
+ $gURL = $gmeta['filename'];
+ }
+ $sURL = str_replace('%i', $sname, $sURL_base);
+ $sURL = str_replace('%a', isset($s_psub)?$sURL_add:'', $sURL);
+ $sURL = str_replace('%s', isset($s_psub)?$s_pub:'', $sURL);
+ $out .= '<a href="'.$sURL.'">';
+ $out .= '<img src="'.$gURL.'"';
+ $out .= ' alt="'.$s_rrd->basename.(!is_null($g_sub)?' - '.$g_sub:'').' - '.$tframe.'" class="rrdgraph"';
+ if (isset($gmeta['width']) && isset($gmeta['height'])) { $out .= ' style="width:'.$gmeta['width'].'px;height:'.$gmeta['height'].'px;"'; }
+ $out .= '></a>';
+ }
+ else {
+ $out .= sprintf(dgettext($td, 'RRD error: status is "%s"'), $s_rrd->status);
+ }
+ }
+ else {
+ $out .= ' ';
+ }
+ $out .= '</td>';
+ }
+ $out .= '</tr>';