lainchan/templates/themes/rrdtool/info.php

68 lines
1.8 KiB
PHP
Raw Normal View History

<?php
$theme = Array();
// Theme name
$theme['name'] = 'RRDtool';
// Description (you can use Tinyboard markup here)
$theme['description'] = 'Graph basic statistics using the PHP RRDtool extension.';
$theme['version'] = 'v0.1';
// Theme configuration
$theme['config'] = Array();
$theme['config'][] = Array(
'title' => 'Path',
'name' => 'path',
'type' => 'text',
'default' => str_replace('\\', '/', dirname(__FILE__)) . '/data',
'size' => '50'
);
2011-06-07 03:18:08 -04:00
$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)
);
2011-06-07 04:52:54 -04:00
$theme['install_callback'] = 'rrdtool_install';
if(!function_exists('rrdtool_install')) {
function rrdtool_install($settings) {
global $config;
2011-06-07 07:03:22 -04:00
$job = '*/2 * * * * php -q ' . str_replace('\\', '/', dirname(__FILE__)) . '/cron.php' . PHP_EOL;
2011-06-07 04:52:54 -04:00
if(function_exists('system')) {
$crontab = tempnam($config['tmp'], 'tinyboard-rrdtool');
file_write($crontab, $job);
2011-06-07 06:43:15 -04:00
@system('crontab ' . escapeshellarg($crontab), $ret);
2011-06-07 04:52:54 -04:00
unlink($crontab);
if($ret === 0)
2011-06-07 06:43:15 -04:00
return ''; // it seems to install okay?
2011-06-07 04:52:54 -04:00
}
return '<h2>I couldn\'t install the crontab!</h2>' .
'In order to use this plugin, you must add the following crontab entry:' .
'<pre>' . $job . '</pre>';
}
}
// Unique function name for building everything
$theme['build_function'] = 'rrdtool_build';
?>