#!/usr/bin/perl -w #process_mvco_request.pl #Process the MVCO user request(s) for plots, downloads, etc. # (Based on the process_ship_questionnaire.pl script) $version = "V1.00/July 10, 2001"; #print STDERR ("**debug, $0 $version\n"); # July 10, 2001 V1.00 Bob Groman $debug = 'yes'; $error="
&x "; $warning="
#"; $| = 1; print <Processing Martha's Vineyard Coastal Observatory Data Request

Processing Martha's Vineyard Coastal Observatory Data Request

BEGIN ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); if ($year > 97 and $year < 100 ) {$year = $year + 1900; } $mon++; if ($mon < 10) { $mon = "0" . $mon; } if ($mday < 10) {$mday = "0" . $mday; } if ($hour < 10) { $hour = "0" . $hour; } if ($min < 10) { $min = "0" . $min; } if ($sec < 10) { $sec = "0" . $sec; } undef $isdst; undef $wday; &get_web_form_data ; &process_request; print STDOUT ("


Script process_mvco_request.pl Version: $version\n"); undef $error; undef $warning; exit; #--------------------------------------------------------------------------- sub sendmessage { #Send a message to the user. #The message sent will be in the strings $_[1] and $_[2] #The prefix string is in $_[0] my ( @args, $mailfile, $message0, $message1, $prefix, $who); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst); $prefix=$_[0]; $message0=$_[1]; $message1=$_[2]; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); if ($year > 97 and $year < 100 ) {$year = $year + 1900; } $mon++; if ($mon < 10) { $mon = "0" . $mon; } if ($mday < 10) {$mday = "0" . $mday; } if ($hour < 10) { $hour = "0" . $hour; } if ($min < 10) { $min = "0" . $min; } if ($sec < 10) { $sec = "0" . $sec; } $mailfile=">/tmp/sendmess" . $year . $yday . $hour . $min . $sec . ".tmp"; if ( open TEMPFILE, $mailfile) { if ( exists $ENV{'REMOTE_HOST'} ) {$who=$ENV{'REMOTE_HOST'} ; } elsif (exists $ENV{'REMOTE_ADDR'} ) {$who=$ENV{'REMOTE_ADDR'} ; } else {$who="not available"; } print TEMPFILE ("Message from $0\n"); print TEMPFILE (" Date of message: $year/$mon/$mday $hour:$min\n"); print TEMPFILE (" From: $who\n"); print TEMPFILE (" $message0\n"); print TEMPFILE (" $message1\n"); close TEMPFILE; `/bin/mail -w dmo\@globec.whoi.edu <$mailfile`; unlink $mailfile; } print STDOUT ($prefix,"Message from $0\n"); print STDOUT ($prefix," Date of message: $year/$mon/$mday $hour:$min\n"); print STDOUT ($prefix," $message0\n"); print STDOUT ($prefix," $message1\n"); undef $wday; undef $isdst; return; } #-------------------------------------------------------------------------- sub get_web_form_data { # Get web form data by reading from STDIN and splitting out the # names and their values. Result is placed in th %param hash variable. my $string = ; my $last_flag="no"; while ($string) { $string =~ s/^(.*)&(.*)/$1/; # print STDOUT ("string=$string
\n"); $substring = $2; unless (defined $substring) { if (defined $string) { $substring = $string; undef $string; } else { last; } } LOOP: # print STDOUT ("substring=$substring
\n"); ($key, $value) = split /=/, $substring; $key =~ s/\+/ /g; $key =~ s/\%40/@/g; $value = " " unless defined $value ; $value =~ s/\+/ /g; $value =~ s/\%0D\%0A/\n/g; $value =~ s/\%09/\t/g; $value =~ s/\%20/\ /g; $value =~ s/\%21/\!/g; $value =~ s/\%22/\"/g; $value =~ s/\%23/\#/g; $value =~ s/\%24/\$/g; $value =~ s/\%25/\%/g; $value =~ s/\%26/\&/g; $value =~ s/\%27/\'/g; $value =~ s/\%28/\(/g; $value =~ s/\%29/\)/g; $value =~ s/\%2A/\*/g; $value =~ s/\%2B/\+/g; $value =~ s/\%2C/\,/g; $value =~ s/\%2D/\-/g; $value =~ s/\%2E/\./g; $value =~ s/\%2F/\//g; $value =~ s/\%3A/\:/g; $value =~ s/\%3B/\;/g; $value =~ s/\%3C/\/g; $value =~ s/\%3F/\?/g; $value =~ s/\%40/\@/g; $value =~ s/\%5B/\[/g; $value =~ s/\%5C/\\/g; $value =~ s/\%5D/\]/g; $value =~ s/\%5E/\^/g; $value =~ s/\%5F/\_/g; $value =~ s/\%60/\`/g; $value =~ s/\%7B/\{/g; $value =~ s/\%7C/\|/g; $value =~ s/\%7D/\}/g; $value =~ s/\%7E/\~/g; $param{$key} = $value; # print STDOUT ("key=$key, value=$value
\n"); # Check for last entry. Doesn't seem to work as before 5/19/00 last if $last_flag eq "yes"; unless ($string =~ m/&/ ) { $substring = $string; undef $string; $last_flag="yes"; goto LOOP; } last unless defined $string; } } #-------------------------------------------------------------------- sub process_request { # Process the user's request based on the values of the form entries # Restrictions: # 1. Set up to do only one plot for now my (@downloads_to_make, $key, $numb_downloads, $numb_plots, @plots_to_make, $type); # Determine what to do foreach $key (sort keys %param) { if ($key =~ m/ plot$/ and $param{$key} ne 'Choose one' ) { $type = $key; $type =~ s/(.*) plot/$1/; push @plots_to_make, $type; next; } elsif ($key =~ m/ download$/ and $param{$key} ne 'Choose one' ) { $type = $key; $type =~ s/(.*) download/$1/; push @downloads_to_make, $type; next; } } $numb_plots = $#plots_to_make + 1; $numb_downloads = $#downloads_to_make + 1; print STDOUT < You have requested $numb_plots plot(s) and $numb_downloads downloads. However, you will only see one plot for now and downloads are not currently supported. Please wait while we prepare the plot for display.

SUMMARY #print STDOUT ("***debug,"); #print STDOUT ("***debug, plots_to_make=@plots_to_make

\n") if $debug eq 'yes'; #print STDOUT ("***debug, downloads_to_make=@downloads_to_make

\n") if $debug eq 'yes'; }