From c1a1537272c3832e6fd2c8ca310d15f8b4142088 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 17 Apr 2014 21:15:20 +0200 Subject: Use absolute paths for image storage --- web/nms.gathering.org/showswitch.pl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'web') diff --git a/web/nms.gathering.org/showswitch.pl b/web/nms.gathering.org/showswitch.pl index 5ed0029..0391a57 100755 --- a/web/nms.gathering.org/showswitch.pl +++ b/web/nms.gathering.org/showswitch.pl @@ -7,7 +7,9 @@ use strict; use warnings; use lib '../../include'; use nms; +use File::Basename; my $cgi = CGI->new; +my $cwd = dirname($0); my $switch = $cgi->param('id'); my $width = $cgi->param('width'); my $height = $cgi->param('height'); @@ -17,7 +19,7 @@ my $resthtml = ""; $width = 500 unless (defined($width)); $height = 250 unless (defined($height)); -require './mygraph.pl'; +require "$cwd/mygraph.pl"; my $start = [Time::HiRes::gettimeofday]; my $dbh = nms::db_connect(); @@ -72,8 +74,8 @@ while (my $ref = $q->fetchrow_hashref()) { plotseries($graph, \@x, \@y1, 255, 0, 0, $min_x, $max_y); plotseries($graph, \@x, \@y2, 0, 0, 255, $min_x, $max_y); - open GRAPH, ">img/$filename" - or die "img/$filename: $!"; + open GRAPH, ">$cwd/img/$filename" + or die "$cwd/img/$filename: $!"; print GRAPH $graph->png; close GRAPH; exit; @@ -183,7 +185,7 @@ if ($pid == 0) { plotseries($graph, \@x, \@y1, 255, 0, 0, $min_x, $max_y); plotseries($graph, \@x, \@y2, 0, 0, 255, $min_x, $max_y); - open GRAPH, ">img/$filename" + open GRAPH, ">$cwd/img/$filename" or die "img/$filename: $!"; print GRAPH $graph->png; close GRAPH; @@ -201,11 +203,10 @@ plotseries($graph, \@totx, \@toty1, 255, 0, 0, $min_x, $max_ty); plotseries($graph, \@totx, \@toty2, 0, 0, 255, $min_x, $max_ty); $filename = "$switch-$width-$height.png"; -open GRAPH, ">img/$filename" or die "img/$filename: $!"; +open GRAPH, ">$cwd/img/$filename" or die "img/$filename: $!"; print GRAPH $graph->png; close GRAPH; - # Wait for all the other graphs to be done while (waitpid(-1, 0) != -1) { 1; -- cgit v1.2.3