array('regexp' => '/^([0-9]+|all)$/')));
get_filter_request_var('local_graph_id');
get_filter_request_var('graph_end');
get_filter_request_var('graph_start');
get_filter_request_var('view_type', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^([a-zA-Z0-9]+)$/')));
/* ==================================================== */
api_plugin_hook_function('graph');
include_once('./lib/html_tree.php');
top_graph_header();
if (!isset_request_var('rra_id')) {
set_request_var('rra_id', 'all');
}
if (get_request_var('rra_id') == 'all') {
$sql_where = ' WHERE id IS NOT NULL';
}else{
$sql_where = ' WHERE id=' . get_request_var('rra_id');
}
/* make sure the graph requested exists (sanity) */
if (!(db_fetch_cell_prepared('SELECT local_graph_id FROM graph_templates_graph WHERE local_graph_id = ?', array(get_request_var('local_graph_id'))))) {
print "GRAPH DOES NOT EXIST";
exit;
}
/* take graph permissions into account here */
if (!is_graph_allowed(get_request_var('local_graph_id'))) {
header('Location: permission_denied.php');
exit;
}
$graph_title = get_graph_title(get_request_var('local_graph_id'));
if (get_request_var('action') != 'properties') {
print "
";
}
$rras = get_associated_rras(get_request_var('local_graph_id'));
switch (get_request_var('action')) {
case 'view':
api_plugin_hook_function('page_buttons',
array(
'lgid' => get_request_var('local_graph_id'),
'leafid' => '',//$leaf_id,
'mode' => 'mrtg',
'rraid' => get_request_var('rra_id')
)
);
?>
0) {
$graph_end = time();
foreach ($rras as $rra) {
$graph_start = $graph_end - db_fetch_cell_prepared('SELECT timespan FROM rra WHERE id = ?', array($rra['id']));
$aggregate_url = aggregate_build_children_url(get_request_var('local_graph_id'), $graph_start, $graph_end, $rra['id']);
?>
|
|
0) {
foreach ($rras as $rra) {
if ($rra['steps'] * $rra['rows'] * $rra['rrd_step'] > $max_timespan) {
$max_timespan = $rra['steps'] * $rra['rows'] * $rra['rrd_step'];
}
}
}
/* fetch information for the current RRA */
if (isset_request_var('rra_id') && get_request_var('rra_id') > 0) {
$rra = db_fetch_row_prepared('SELECT id, timespan, steps, name FROM rra WHERE id = ?', array(get_request_var('rra_id')));
}else{
$rra = db_fetch_row_prepared('SELECT id, timespan, steps, name FROM rra WHERE id = ?', array($rras[0]['id']));
}
/* define the time span, which decides which rra to use */
$timespan = -($rra['timespan']);
/* find the step and how often this graph is updated with new data */
$ds_step = db_fetch_cell_prepared('SELECT
data_template_data.rrd_step
FROM (data_template_data, data_template_rrd, graph_templates_item)
WHERE graph_templates_item.task_item_id = data_template_rrd.id
AND data_template_rrd.local_data_id = data_template_data.local_data_id
AND graph_templates_item.local_graph_id = ?
LIMIT 0,1', array(get_request_var('local_graph_id')));
$ds_step = empty($ds_step) ? 300 : $ds_step;
$seconds_between_graph_updates = ($ds_step * $rra['steps']);
$now = time();
if (isset_request_var('graph_end') && (get_request_var('graph_end') <= $now - $seconds_between_graph_updates)) {
$graph_end = get_request_var('graph_end');
}else{
$graph_end = $now - $seconds_between_graph_updates;
}
if (isset_request_var('graph_start')) {
if (($graph_end - get_request_var('graph_start'))>$max_timespan) {
$graph_start = $now - $max_timespan;
}else {
$graph_start = get_request_var('graph_start');
}
}else{
$graph_start = $now + $timespan;
}
/* required for zoom out function */
if ($graph_start == $graph_end) {
$graph_start--;
}
$graph = db_fetch_row_prepared('SELECT * FROM graph_templates_graph WHERE local_graph_id = ?', array(get_request_var('local_graph_id')));
$graph_height = $graph['height'];
$graph_width = $graph['width'];
if (read_user_setting('custom_fonts') == 'on' & read_user_setting('title_size') != '') {
$title_font_size = read_user_setting('title_size');
}elseif (read_config_option('title_size') != '') {
$title_font_size = read_config_option('title_size');
}else {
$title_font_size = 10;
}
?>
|
' graph_width='' graph_height='' title_font_size='' style="min-height: ;">
" . htmlspecialchars($graph["title_cache"]) . "" : "");?>
|
_properties' class='hyperLink properties'>
' alt='' title='Graph Source/Properties'>
_csv' class='hyperLink properties'>
' alt='' title='Graph Data'>
'zoom', 'local_graph_id' => get_request_var('local_graph_id'), 'rra' => get_request_var('rra_id'), 'view_type' => get_request_var('view_type'))); ?>
|
|
|
|
|
\n";
print "\n";
print "\n";
print "\n";
print trim(@rrdtool_function_graph(get_request_var('local_graph_id'), get_request_var('rra_id'), $graph_data_array));
print " | \n";
print " |
\n";
exit;
break;
}
print '';
bottom_footer();