Annotation of loncom/cgi/plot.gif, revision 1.8

1.5       matthew     1: #!/usr/bin/perl
1.1       matthew     2: #
1.8     ! matthew     3: # $Id: plot.gif,v 1.7 2001/12/21 16:10:58 matthew Exp $
1.1       matthew     4: #
                      5: # Copyright Michigan State University Board of Trustees
                      6: #
                      7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      8: #
                      9: # LON-CAPA is free software; you can redistribute it and/or modify
                     10: # it under the terms of the GNU General Public License as published by
                     11: # the Free Software Foundation; either version 2 of the License, or
                     12: # (at your option) any later version.
                     13: #
                     14: # LON-CAPA is distributed in the hope that it will be useful,
                     15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     17: # GNU General Public License for more details.
                     18: #
                     19: # You should have received a copy of the GNU General Public License
                     20: # along with LON-CAPA; if not, write to the Free Software
                     21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     22: #
                     23: # /home/httpd/cgi-bin/plot.gif
                     24: #
                     25: # http://www.lon-capa.org/
                     26: #
1.6       matthew    27: use strict;
                     28: 
                     29: $|=1;
1.4       matthew    30: 
1.5       matthew    31: my $tmpdir = '/home/httpd/perl/tmp/';
1.8     ! matthew    32: my %data;
        !            33: foreach (split/&/,$ENV{'QUERY_STRING'}) {
        !            34:     my ($name,$value)=split/=/;
        !            35:     $data{$name}=$value;
1.7       matthew    36: }
1.8     ! matthew    37: my $filename = $data{'file'};
        !            38: die if ($filename =~ /\// || $filename !~ /_plot.data$/);
1.7       matthew    39: $filename = $tmpdir . $filename;
1.8     ! matthew    40: die "$data{'file'} does not exist\n" if (! -e $filename);
        !            41: 
        !            42: my $output = $data{'output'};
        !            43: if ($output eq 'gif') {
1.6       matthew    44:     open PLOT, "gnuplot $filename |";
                     45:     print <<"END";
1.5       matthew    46: Content-type: image/gif
1.1       matthew    47: 
1.5       matthew    48: END
1.6       matthew    49:     while ($_=<PLOT>) {
                     50: 	print;
                     51:     }
1.8     ! matthew    52: } elsif ($output eq 'eps') {
        !            53:     system ("gnuplot $filename");
        !            54: } else {
        !            55:     die "output $output is not a recognized value or has no value\n";
1.4       matthew    56: }
1.8     ! matthew    57: 
        !            58: 
1.1       matthew    59: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>