basic beta

This commit is contained in:
Savetheinternet 2011-06-07 17:18:08 +10:00
parent 41dcdcdade
commit dfbb77af83
2 changed files with 31 additions and 17 deletions

View File

@ -18,6 +18,14 @@
'size' => '50' 'size' => '50'
); );
$theme['config'][] = Array(
'title' => 'Images path',
'name' => 'images',
'type' => 'text',
'default' => str_replace('\\', '/', dirname(__FILE__)) . '/images',
'size' => '50'
);
$__boards = listBoards(); $__boards = listBoards();
$__default_boards = Array(); $__default_boards = Array();
foreach($__boards as $__board) foreach($__boards as $__board)

View File

@ -18,6 +18,7 @@
global $config, $_theme; global $config, $_theme;
$this->boards = explode(' ', $settings['boards']); $this->boards = explode(' ', $settings['boards']);
$this->spans = Array('hour', 'day', 'week', 'month');
$this->interval = 60; $this->interval = 60;
$this->height = 150; $this->height = 150;
$this->width = 700; $this->width = 700;
@ -25,6 +26,8 @@
if($action == 'cron') { if($action == 'cron') {
if(!file_exists($settings['path'])) if(!file_exists($settings['path']))
mkdir($settings['path']); mkdir($settings['path']);
if(!file_exists($settings['images']))
mkdir($settings['images']);
foreach($this->boards as &$board) { foreach($this->boards as &$board) {
$file = $settings['path'] . '/' . $board . '.rrd'; $file = $settings['path'] . '/' . $board . '.rrd';
@ -54,23 +57,26 @@
'N:' . $count))) 'N:' . $count)))
error('RRDtool failed: ' . htmlentities(rrd_error())); error('RRDtool failed: ' . htmlentities(rrd_error()));
foreach($this->spans as &$span) {
// Graph graph // Graph graph
if(!rrd_graph('/var/vhosts/s.avetheinter.net/intel/test-' . $board . '.png', Array( if(!rrd_graph($settings['images'] . $board . '-' . $span . '.png', Array(
'-s -1hour', '-s -1' . $span,
'-t Posts on ' . sprintf($config['board_abbreviation'], $board), '-t Posts on ' . sprintf($config['board_abbreviation'], $board),
'--lazy', //'--lazy',
'-l 0',
'-h', $this->height, '-w', $this->width, '-h', $this->height, '-w', $this->width,
'-l 0', '-l 0',
'-a', 'PNG', '-a', 'PNG',
'-v posts/sec', '-W', 'Powered by Tinyboard',
'-v posts/minute',
'DEF:posts=' . $file . ':posts:AVERAGE', 'DEF:posts=' . $file . ':posts:AVERAGE',
'LINE2:posts#336600:Posts', 'LINE2:posts#336600:Posts',
'GPRINT:posts:MAX: Max\\: %5.1lf %S', 'GPRINT:posts:MAX: Max\\: %5.1lf %s',
'GPRINT:posts:AVERAGE: Avg\\: %5.1lf %S', 'GPRINT:posts:AVERAGE: Avg\\: %5.1lf %s',
'GPRINT:posts:LAST: Current\\: %5.1lf %Sreq/sec', 'GPRINT:posts:LAST: Current\\: %5.1lf %sposts/min',
'HRULE:0#000000'))) 'HRULE:0#000000')))
error('RRDtool failed: ' . htmlentities(rrd_error())); error('RRDtool failed: ' . htmlentities(rrd_error()));
}
} }
} }
} }