diff --git a/lib/user.pm b/lib/user.pm index 7916d94..3940ee8 100644 --- a/lib/user.pm +++ b/lib/user.pm @@ -170,6 +170,15 @@ sub user_cgi { my $graph = $cgi->{graph}; my $silent = $cgi->{silent}; my $zoom = "--zoom=" . $config->{global_zoom}; + my %rrd = ( + 'new' => \&RRDs::graphv, + 'old' => \&RRDs::graph, + ); + my $version = "new"; + my $pic; + my $picz; + my $picz_width; + my $picz_height; my $u = ""; my $width; @@ -181,6 +190,7 @@ sub user_cgi { my $n; my $err; + $version = "old" if $RRDs::VERSION < 1.3; my $rrd = $config->{base_lib} . $package . ".rrd"; my $title = $config->{graph_title}->{$package}; my $PNG_DIR = $config->{base_dir} . "/" . $config->{imgs_dir}; @@ -279,7 +289,7 @@ sub user_cgi { ($width, $height) = split('x', $config->{graph_size}->{main}) if $silent eq "imagetagbig"; @tmp = @tmpz; } - RRDs::graph("$PNG_DIR" . "$PNG1", + $pic = $rrd{$version}->("$PNG_DIR" . "$PNG1", "--title=$config->{graphs}->{_user1} ($tf->{nwhen}$tf->{twhen})", "--start=-$tf->{nwhen}$tf->{twhen}", "--imgformat=PNG", @@ -302,7 +312,7 @@ sub user_cgi { print("ERROR: while graphing $PNG_DIR" . "$PNG1: $err\n") if $err; if(lc($config->{enable_zoom}) eq "y") { ($width, $height) = split('x', $config->{graph_size}->{zoom}); - RRDs::graph("$PNG_DIR" . "$PNG1z", + $picz = $rrd{$version}->("$PNG_DIR" . "$PNG1z", "--title=$config->{graphs}->{_user1} ($tf->{nwhen}$tf->{twhen})", "--start=-$tf->{nwhen}$tf->{twhen}", "--imgformat=PNG", @@ -310,6 +320,7 @@ sub user_cgi { "--width=$width", "--height=$height", @riglim, + $zoom, @{$cgi->{version12}}, @{$colors->{graph_colors}}, "DEF:sys=$rrd:user_sys:AVERAGE", @@ -325,7 +336,14 @@ sub user_cgi { print(" {url} . "/" . $config->{imgs_dir} . $PNG1z . "\">\n"); } else { - print(" {url} . "/" . $config->{imgs_dir} . $PNG1z . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\">\n"); + if($version eq "new") { + $picz_width = $picz->{image_width} * $config->{global_zoom}; + $picz_height = $picz->{image_height} * $config->{global_zoom}; + } else { + $picz_width = $width + 115; + $picz_height = $height + 100; + } + print(" {url} . "/" . $config->{imgs_dir} . $PNG1z . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\">\n"); } } else { print(" \n"); @@ -359,7 +377,7 @@ sub user_cgi { push(@tmp, "COMMENT: \\n"); push(@tmp, "COMMENT: \\n"); } - RRDs::graph("$PNG_DIR" . "$PNG2", + $pic = $rrd{$version}->("$PNG_DIR" . "$PNG2", "--title=$config->{graphs}->{_user2} ($tf->{nwhen}$tf->{twhen})", "--start=-$tf->{nwhen}$tf->{twhen}", "--imgformat=PNG", @@ -379,7 +397,7 @@ sub user_cgi { print("ERROR: while graphing $PNG_DIR" . "$PNG2: $err\n") if $err; if(lc($config->{enable_zoom}) eq "y") { ($width, $height) = split('x', $config->{graph_size}->{zoom}); - RRDs::graph("$PNG_DIR" . "$PNG2z", + $picz = $rrd{$version}->("$PNG_DIR" . "$PNG2z", "--title=$config->{graphs}->{_user2} ($tf->{nwhen}$tf->{twhen})", "--start=-$tf->{nwhen}$tf->{twhen}", "--imgformat=PNG", @@ -387,6 +405,7 @@ sub user_cgi { "--width=$width", "--height=$height", @riglim, + $zoom, @{$cgi->{version12}}, @{$cgi->{version12_small}}, @{$colors->{graph_colors}}, @@ -403,7 +422,14 @@ sub user_cgi { print(" {url} . "/" . $config->{imgs_dir} . $PNG2z . "\">\n"); } else { - print(" {url} . "/" . $config->{imgs_dir} . $PNG2z . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\">\n"); + if($version eq "new") { + $picz_width = $picz->{image_width} * $config->{global_zoom}; + $picz_height = $picz->{image_height} * $config->{global_zoom}; + } else { + $picz_width = $width + 115; + $picz_height = $height + 100; + } + print(" {url} . "/" . $config->{imgs_dir} . $PNG2z . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\">\n"); } } else { print(" \n"); @@ -433,7 +459,7 @@ sub user_cgi { push(@tmp, "COMMENT: \\n"); push(@tmp, "COMMENT: \\n"); } - RRDs::graph("$PNG_DIR" . "$PNG3", + $pic = $rrd{$version}->("$PNG_DIR" . "$PNG3", "--title=$config->{graphs}->{_user3} ($tf->{nwhen}$tf->{twhen})", "--start=-$tf->{nwhen}$tf->{twhen}", "--imgformat=PNG", @@ -453,7 +479,7 @@ sub user_cgi { print("ERROR: while graphing $PNG_DIR" . "$PNG3: $err\n") if $err; if(lc($config->{enable_zoom}) eq "y") { ($width, $height) = split('x', $config->{graph_size}->{zoom}); - RRDs::graph("$PNG_DIR" . "$PNG3z", + $picz = $rrd{$version}->("$PNG_DIR" . "$PNG3z", "--title=$config->{graphs}->{_user3} ($tf->{nwhen}$tf->{twhen})", "--start=-$tf->{nwhen}$tf->{twhen}", "--imgformat=PNG", @@ -461,6 +487,7 @@ sub user_cgi { "--width=$width", "--height=$height", @riglim, + $zoom, @{$cgi->{version12}}, @{$cgi->{version12_small}}, @{$colors->{graph_colors}}, @@ -477,7 +504,14 @@ sub user_cgi { print(" {url} . "/" . $config->{imgs_dir} . $PNG3z . "\">\n"); } else { - print(" {url} . "/" . $config->{imgs_dir} . $PNG3z . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\">\n"); + if($version eq "new") { + $picz_width = $picz->{image_width} * $config->{global_zoom}; + $picz_height = $picz->{image_height} * $config->{global_zoom}; + } else { + $picz_width = $width + 115; + $picz_height = $height + 100; + } + print(" {url} . "/" . $config->{imgs_dir} . $PNG3z . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\">\n"); } } else { print(" \n");