trim_tobias option. sorry Tobias, we love you really, but there's just too much of you! :D

git-svn-id: http://www.observium.org/svn/observer/trunk@3028 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2012-04-12 15:48:33 +00:00
parent 6ff76f0be3
commit b952a94006
3 changed files with 28 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
if ($_GET['from']) { $from = mres($_GET['from']); } if ($_GET['from']) { $from = mres($_GET['from']); }
if ($_GET['to']) { $to = mres($_GET['to']); } if ($_GET['to']) { $to = mres($_GET['to']); }
if ($_GET['width']) { $width = mres($_GET['width']); } if ($_GET['width']) { $width = mres($_GET['width']); }
if($config['trim_tobias']) { $width+=12; }
if ($_GET['height']) { $height = mres($_GET['height']); } if ($_GET['height']) { $height = mres($_GET['height']); }
if ($_GET['inverse']) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; } if ($_GET['inverse']) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; }
if ($_GET['legend'] == "no") { $rrd_options = " -g"; } if ($_GET['legend'] == "no") { $rrd_options = " -g"; }

View File

@@ -88,8 +88,13 @@ function graph_error($string)
} }
if ($error_msg) { if ($error_msg) {
/// We have an error :(
graph_error($graph_error); graph_error($graph_error);
} elseif (!$auth) { } elseif (!$auth) {
/// We are unauthenticated :(
if ($width < 200) if ($width < 200)
{ {
graph_error("No Auth"); graph_error("No Auth");
@@ -126,7 +131,26 @@ if ($error_msg) {
if (!$debug) if (!$debug)
{ {
header('Content-type: image/png'); header('Content-type: image/png');
$fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd); if($config['trim_tobias'])
{
list($w, $h, $type, $attr) = getimagesize($graphfile);
$src_im = imagecreatefrompng($graphfile);
$src_x = '0'; // begin x
$src_y = '0'; // begin y
$src_w = $w-12; // width
$src_h = $h; // height
$dst_x = '0'; // destination x
$dst_y = '0'; // destination y
$dst_im = imagecreatetruecolor($src_w, $src_h);
$white = imagecolorallocate($dst_im, 255, 255, 255);
imagefill($dst_im, 0, 0, $white);
imagecopy($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h);
imagepng($dst_im);
imagedestroy($dst_im);
} else {
$fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd);
}
} else { } else {
echo(`ls -l $graphfile`); echo(`ls -l $graphfile`);
echo('<img src="'.data_uri($graphfile,'image/png').'" alt="graph" />'); echo('<img src="'.data_uri($graphfile,'image/png').'" alt="graph" />');

View File

@@ -15,6 +15,7 @@ if($_SESSION['widescreen'])
$graph_array['to'] = $config['time']['now']; $graph_array['to'] = $config['time']['now'];
#echo('<p class="badtobias"');
foreach ($periods as $period) foreach ($periods as $period)
{ {
$graph_array['from'] = $config['time'][$period]; $graph_array['from'] = $config['time'][$period];
@@ -29,5 +30,6 @@ foreach ($periods as $period)
echo(overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL)); echo(overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL));
} }
#echo('</p>');
?> ?>