--- loncom/cgi/plot.gif 2001/12/20 22:36:15 1.5 +++ loncom/cgi/plot.gif 2001/12/21 16:10:58 1.7 @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# $Id: plot.gif,v 1.5 2001/12/20 22:36:15 matthew Exp $ +# $Id: plot.gif,v 1.7 2001/12/21 16:10:58 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -24,27 +24,26 @@ # # http://www.lon-capa.org/ # - use strict; -my $output; -my $tmpdir = '/home/httpd/perl/tmp/'; -my $filename = $tmpdir . $ENV{'QUERY_STRING'}; - -$output =<<"END"; -Content-type: text/html +$|=1; -END +my $tmpdir = '/home/httpd/perl/tmp/'; +my $filename = $ENV{'QUERY_STRING'}; -if (0) { -$output =<<"END"; +if ($filename =~ /\// | + $filename !~ /_plot.data$/) { + die; +} +$filename = $tmpdir . $filename; +if (-e $filename) { + open PLOT, "gnuplot $filename |"; + print <<"END"; Content-type: image/gif - END -$output .= `gnuplot $filename`; + while ($_=) { + print; + } } -print $output; - -