--- loncom/cgi/graph.png 2003/10/09 15:56:41 1.23 +++ loncom/cgi/graph.png 2003/10/27 21:21:08 1.29 @@ -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.29 2003/10/27 21:21:08 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,155 @@ 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 <