--- loncom/cgi/graph.png 2003/10/09 15:56:41 1.23 +++ loncom/cgi/graph.png 2003/10/29 14:47:43 1.30 @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# $Id: graph.png,v 1.23 2003/10/09 15:56:41 matthew Exp $ +# $Id: graph.png,v 1.30 2003/10/29 14:47:43 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -55,9 +55,12 @@ escape( value ) means the values must be =cut use strict; +use lib '/home/httpd/lib/perl'; use GD::Graph::bars; +use GD::Graph::lines; use GD::Graph::colour; use GD::Graph::Data; +use LONCAPA::loncgi(); sub unescape { my $str=shift; @@ -65,99 +68,164 @@ sub unescape { return $str; } +sub error { + my ($error) = @_; + my $Str = <<"END"; +Content-type: text/html + + +
+There was an error producing the graph you requested. +
+$error +
+ + +END + return $Str; +} + +my $id = $ENV{'QUERY_STRING'}; + +# +# &get_env($name,$default) +sub get_env { + my $key = 'cgi.'.$id.'.'.(shift()); + return shift if (! exists($ENV{$key})); + return $ENV{$key}; +} + +if (! &LONCAPA::loncgi::check_cookie_and_load_env()) { + print <