diff --git a/templates/themes/rrdtool/info.php b/templates/themes/rrdtool/info.php index fa1844e9..824609a4 100644 --- a/templates/themes/rrdtool/info.php +++ b/templates/themes/rrdtool/info.php @@ -18,6 +18,14 @@ 'size' => '50' ); + $theme['config'][] = Array( + 'title' => 'Images path', + 'name' => 'images', + 'type' => 'text', + 'default' => str_replace('\\', '/', dirname(__FILE__)) . '/images', + 'size' => '50' + ); + $__boards = listBoards(); $__default_boards = Array(); foreach($__boards as $__board) diff --git a/templates/themes/rrdtool/theme.php b/templates/themes/rrdtool/theme.php index e6cdc726..e6f20b81 100644 --- a/templates/themes/rrdtool/theme.php +++ b/templates/themes/rrdtool/theme.php @@ -18,6 +18,7 @@ global $config, $_theme; $this->boards = explode(' ', $settings['boards']); + $this->spans = Array('hour', 'day', 'week', 'month'); $this->interval = 60; $this->height = 150; $this->width = 700; @@ -25,6 +26,8 @@ if($action == 'cron') { if(!file_exists($settings['path'])) mkdir($settings['path']); + if(!file_exists($settings['images'])) + mkdir($settings['images']); foreach($this->boards as &$board) { $file = $settings['path'] . '/' . $board . '.rrd'; @@ -54,23 +57,26 @@ 'N:' . $count))) error('RRDtool failed: ' . htmlentities(rrd_error())); - // Graph graph - if(!rrd_graph('/var/vhosts/s.avetheinter.net/intel/test-' . $board . '.png', Array( - '-s -1hour', - '-t Posts on ' . sprintf($config['board_abbreviation'], $board), - '--lazy', - '-h', $this->height, '-w', $this->width, - '-l 0', - '-a', 'PNG', - '-v posts/sec', - 'DEF:posts=' . $file . ':posts:AVERAGE', - 'LINE2:posts#336600:Posts', - 'GPRINT:posts:MAX: Max\\: %5.1lf %S', - 'GPRINT:posts:AVERAGE: Avg\\: %5.1lf %S', - 'GPRINT:posts:LAST: Current\\: %5.1lf %Sreq/sec', - 'HRULE:0#000000'))) - error('RRDtool failed: ' . htmlentities(rrd_error())); - + foreach($this->spans as &$span) { + // Graph graph + if(!rrd_graph($settings['images'] . $board . '-' . $span . '.png', Array( + '-s -1' . $span, + '-t Posts on ' . sprintf($config['board_abbreviation'], $board), + //'--lazy', + '-l 0', + '-h', $this->height, '-w', $this->width, + '-l 0', + '-a', 'PNG', + '-W', 'Powered by Tinyboard', + '-v posts/minute', + 'DEF:posts=' . $file . ':posts:AVERAGE', + 'LINE2:posts#336600:Posts', + 'GPRINT:posts:MAX: Max\\: %5.1lf %s', + 'GPRINT:posts:AVERAGE: Avg\\: %5.1lf %s', + 'GPRINT:posts:LAST: Current\\: %5.1lf %sposts/min', + 'HRULE:0#000000'))) + error('RRDtool failed: ' . htmlentities(rrd_error())); + } } } }