From ef927882e087309e81e37ce8be27978bd7c382eb Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 24 Dec 2013 16:41:11 +0100 Subject: [PATCH] remove rrdtool theme; STI told me that it never really worked --- templates/themes/rrdtool/cron.php | 9 -- templates/themes/rrdtool/info.php | 122 ------------------- templates/themes/rrdtool/theme.php | 184 ----------------------------- templates/themes/rrdtool/thumb.png | Bin 2967 -> 0 bytes 4 files changed, 315 deletions(-) delete mode 100644 templates/themes/rrdtool/cron.php delete mode 100644 templates/themes/rrdtool/info.php delete mode 100644 templates/themes/rrdtool/theme.php delete mode 100644 templates/themes/rrdtool/thumb.png diff --git a/templates/themes/rrdtool/cron.php b/templates/themes/rrdtool/cron.php deleted file mode 100644 index b4d8b47e..00000000 --- a/templates/themes/rrdtool/cron.php +++ /dev/null @@ -1,9 +0,0 @@ - '', 'HTTP_HOST' => '', 'SCRIPT_FILENAME' => ''); - chdir(str_replace('\\', '/', dirname(__FILE__)) . '/../../../'); - - require 'inc/functions.php'; - - require dirname(__FILE__) . '/theme.php'; - rebuildTheme('rrdtool', 'cron'); - diff --git a/templates/themes/rrdtool/info.php b/templates/themes/rrdtool/info.php deleted file mode 100644 index 46a20587..00000000 --- a/templates/themes/rrdtool/info.php +++ /dev/null @@ -1,122 +0,0 @@ - 'Path', - 'name' => 'path', - 'type' => 'text', - 'default' => str_replace('\\', '/', dirname(__FILE__)) . '/data', - '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) - $__default_boards[] = $__board['uri']; - - $theme['config'][] = Array( - 'title' => 'Boards', - 'name' => 'boards', - 'type' => 'text', - 'comment' => '(boards to graph; space seperated)', - 'size' => 24, - 'default' => implode(' ', $__default_boards) - ); - - $theme['config'][] = Array( - 'title' => 'Excluded Boards', - 'name' => 'boards_exclude', - 'type' => 'text', - 'comment' => '(above boards to exclude from the "combined" graph)', - 'size' => 24 - ); - - $theme['config'][] = Array( - 'title' => 'Interval', - 'name' => 'interval', - 'type' => 'text', - 'comment' => '(minutes between updates; max: 86400)', - 'size' => 3, - 'default' => '2' - ); - - $theme['config'][] = Array( - 'title' => 'Graph Width', - 'name' => 'width', - 'type' => 'text', - 'size' => 3, - 'default' => '700' - ); - - $theme['config'][] = Array( - 'title' => 'Graph Height', - 'name' => 'height', - 'type' => 'text', - 'size' => 3, - 'default' => '150' - ); - - $theme['config'][] = Array( - 'title' => 'Graph Rate', - 'name' => 'rate', - 'type' => 'text', - 'comment' => 'Graph posts per X? ("minute", "day", "year", etc.)', - 'size' => 3, - 'default' => 'hour' - ); - - $theme['install_callback'] = 'rrdtool_install'; - if (!function_exists('rrdtool_install')) { - function rrdtool_install($settings) { - global $config; - - if (!is_numeric($settings['interval']) || $settings['interval'] < 1 || $settings['interval'] > 86400) - return Array(false, 'Invalid interval: ' . $settings['interval'] . '. Must be an integer greater than 1 and less than 86400.'); - - if (!is_numeric($settings['width']) || $settings['width'] < 1) - return Array(false, 'Invalid width: ' . $settings['width'] . '!'); - - if (!is_numeric($settings['height']) || $settings['height'] < 1) - return Array(false, 'Invalid height: ' . $settings['height'] . '!'); - - if (!in_array($settings['rate'], Array('second', 'minute', 'day', 'hour', 'week', 'month', 'year'))) - return Array(false, 'Invalid rate: ' . $settings['rate'] . '!'); - - $job = '*/' . $settings['interval'] . ' * * * * php -q ' . str_replace('\\', '/', dirname(__FILE__)) . '/cron.php' . PHP_EOL; - - if (function_exists('system')) { - $crontab = tempnam($config['tmp'], 'tinyboard-rrdtool'); - file_write($crontab, $job); - @system('crontab ' . escapeshellarg($crontab), $ret); - unlink($crontab); - - if ($ret === 0) - return ''; // it seems to install okay? - } - - return Array(true, '

I couldn\'t install the crontab!

' . - 'In order to use this plugin, you must add the following crontab entry (`crontab -e`):' . - '
' . $job . '
'); - } - } - - // Unique function name for building everything - $theme['build_function'] = 'rrdtool_build'; -?> diff --git a/templates/themes/rrdtool/theme.php b/templates/themes/rrdtool/theme.php deleted file mode 100644 index a14169a3..00000000 --- a/templates/themes/rrdtool/theme.php +++ /dev/null @@ -1,184 +0,0 @@ -build($action, $settings); - } - - // Wrap functions in a class so they don't interfere with normal Tinyboard operations - class TB_RRDTool { - public function build($action, $settings) { - global $config, $_theme, $argv; - - if (!$settings) { - error('This theme is not currently installed.'); - } - - $this->boards = explode(' ', $settings['boards']); - $this->spans = Array('hour', 'day', 'week', 'month', 'year'); - // exclude boards from the "combined" graph - $this->combined_exclude = Array(); - - 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'; - - if (!file_exists($file)) { - // Create graph - if (!rrd_create($file, Array( - '-s 60', - 'DS:posts:COUNTER:86400:0:10000', - - 'RRA:AVERAGE:0:1:60', - 'RRA:AVERAGE:0:1:1440', - 'RRA:AVERAGE:0:30:10080', - 'RRA:AVERAGE:0:120:43829', - 'RRA:AVERAGE:0:1440:525948', - 'RRA:AVERAGE:0:2880:1051897', - - 'RRA:MAX:0:1:60', - 'RRA:MAX:0:1:1440', - 'RRA:MAX:0:30:10080', - 'RRA:MAX:0:120:43829', - 'RRA:MAX:0:1440:525948', - 'RRA:MAX:0:2880:1051897' - ))) - error('RRDtool failed: ' . htmlentities(rrd_error())); - } - - // debug just the graphing (not updating) with the --debug switch - if (!isset($argv[1]) || $argv[1] != '--debug') { - // Update graph - $query = query(sprintf("SELECT MAX(`id`) FROM ``posts_%s``", $board)); - $count = $query->fetchColumn(); - - if (!rrd_update($file, Array( - '-t', - 'posts', - 'N:' . $count))) - 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) .' this ' . $span, - '--lazy', - '-l 0', - '-h', $settings['height'], '-w', $settings['width'], - '-a', 'PNG', - '-R', 'mono', - '-W', 'Powered by Tinyboard', - '-E', - '-X', '0', - '-Y', - '-v posts/' . $settings['rate'], - 'DEF:posts-second=' . $file . ':posts:AVERAGE', - 'CDEF:posts-minute=posts-second,60,*', - 'CDEF:posts-hour=posts-minute,60,*', - 'CDEF:posts-day=posts-hour,24,*', - 'CDEF:posts-week=posts-day,7,*', - 'CDEF:posts-month=posts-day,28,*', - 'CDEF:posts-year=posts-day,365,*', - 'DEF:posts=' . $file . ':posts:AVERAGE', - 'LINE2:posts-' . $settings['rate'] . '#663300:Posts', - 'GPRINT:posts-' . $settings['rate'] . ':MAX:Max\\: %5.2lf', - 'GPRINT:posts-' . $settings['rate'] . ':AVERAGE:Average\\: %5.2lf', - 'GPRINT:posts-' . $settings['rate'] . ':LAST:Current\\: %5.2lf posts/' . $settings['rate'], - 'HRULE:0#000000'))) - error('RRDtool failed: ' . htmlentities(rrd_error())); - } - } - - // combined graph - foreach ($this->spans as &$span) { - $options = Array( - '-s -1' . $span, - '-t Posts this ' . $span, - '--lazy', - '-l 0', - '-h', $settings['height'], '-w', $settings['width'], - '-a', 'PNG', - '-R', 'mono', - '-W', 'Powered by Tinyboard', - '-E', - '-X', '0', - '-Y', - '-v posts/' . $settings['rate']); - - $red = 0; - $green = 0; - $blue = 0; - $c = 0; - $cc = 0; - - $c = 1; - $cc = 0; - $red = 2; - foreach ($this->boards as &$board) { - if (in_array($board, $this->combined_exclude)) - continue; - $color = str_pad(dechex($red*85), 2, '0', STR_PAD_LEFT) . - str_pad(dechex($green*85), 2, '0', STR_PAD_LEFT) . - str_pad(dechex($blue*85), 2, '0', STR_PAD_LEFT); - - $options[] = 'DEF:posts' . $board . '-second=' . $settings['path'] . '/' . $board . '.rrd' . ':posts:AVERAGE'; - $options[] = 'CDEF:posts' . $board . '-minute=posts' . $board . '-second,60,*'; - $options[] = 'CDEF:posts' . $board . '-hour=posts' . $board . '-minute,60,*'; - $options[] = 'CDEF:posts' . $board . '-day=posts' . $board . '-hour,24,*'; - $options[] = 'CDEF:posts' . $board . '-week=posts' . $board . '-day,7,*'; - $options[] = 'CDEF:posts' . $board . '-month=posts' . $board . '-day,28,*'; - $options[] = 'CDEF:posts' . $board . '-year=posts' . $board . '-day,365,*'; - $options[] = 'LINE2:posts' . $board . '-' . $settings['rate'] . '#' . $color . ':' . - sprintf($config['board_abbreviation'], $board); - - // Randomize colors using this horrible undocumented algorithm I threw together while debugging - if ($c == 0) - $red++; - elseif ($c == 1) - $green++; - elseif ($c == 2) - $blue++; - elseif ($c == 3) - $green--; - elseif ($c == 4) - $red--; - - $cc++; - if ($cc > 2) { - $c++; - $cc = 0; - } - if ($c > 4) - $c = 0; - - if ($red > 3) - $red = 0; - if ($green > 3) - $green = 0; - if ($blue > 3) - $blue = 0; - } - $options[] = 'HRULE:0#000000'; - - if (!rrd_graph($settings['images'] . '/combined-' . $span . '.png', $options)) - error('RRDtool failed: ' . htmlentities(rrd_error())); - } - } - } - }; - -?> diff --git a/templates/themes/rrdtool/thumb.png b/templates/themes/rrdtool/thumb.png deleted file mode 100644 index d4e48a0d5a85839db4edb425cddbe54c8e63e0e5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2967 zcmc(hdpHvcAIIk&HJ5}AavLeP$#I#>XofanlB4F<5s}DcuG8?kO{66!bRu#amP?{^ zWG0e2HFL>58&TWTa$7F5w&T3-`|tbT`#k6K{4Rg~zTe;T{GR8R=jm|@D5EL^004kU zgp=1^C-0^AKC!(z@AwJ<0EhuR-MpO*3=GmMg?mt`R5LR(ZEbB86_sbto*|J)G#b6V zz0Kip=yZB%X(*e&9;Tf-? zPH1y0M^r%WRs5)kh=?;P$}=#}!rH|r>~3)KAA1q-zX=M*k_H$5b}rl*`8PawbOYzbmWV4(U_aULAhk6*t%Iq!FllVvKbid_!(rrVw5+z^GDoA;TLPk|_n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