#!/usr/bin/perl -w

require "ctime.pl";

$adminmail = "sjg\@cires.colorado.edu";

# make files readable
umask(011);

# disable buffering
$| = 1;

# Try to Get rid of noise from gnuplot
open(STDERR,">/dev/null");

# read in STDIN from the browser
$size_of_form_information = $ENV{'CONTENT_LENGTH'};
read (STDIN, $form_info, $size_of_form_information );


@key_value_pairs = split (/&/, $form_info);
foreach $key_value (@key_value_pairs)
{
	($key, $value) = split (/=/, $key_value);
	$value =~ tr/+/ /;
	$value =~ s/%([\dA-Fa-f]{2})/pack ("C",hex ($1))/eg;
	$value =~ s/\r\n\r\n/<p>/g;     # convert paragraph marks to html pgraps
	$value =~ s/\r\n/<br>/g;                # same but for dos
	$value =~ s/\n/<br>/g;          # same but for dos
	#print "<tr><td><b>$key</b><td>$value";
	$$key = $value;
}

# Print HTML Response
print "Content-type: text/html","\n\n";
print "
<HTML>
<HEAD>
<TITLE>Make a Plot of Hayward Fault Creep Data</TITLE></HEAD>
<body test=#000000 bgcolor=#CCFFFF link=#0000EE vlink=#551A8B alink=#FF0000>
<CENTER>
<h2> Make a plot of Hayward Fault Creep Data </h2>
<form action=showplot2.pl method=POST>
<br>
<center>
Start Time (mo/da/Yr hr:min):<input type=text name=xmin value=\"$xmin\">
End Time: (mo/da/Yr hr:min) <input type=text name=xmax value=\"$xmax\">
<input type=hidden name=station5 value=''>
<p>
Instruments to Plot:
<select name=station1>
<option value=''> first dataset
<option> coz.dat 3 Oakland Zoo Voltage 1  
<option> coz.dat 4 Oakland Zoo Temperature   
<option> coz.dat 5 Oakland Zoo Voltage 2  
<option> a1wh.dat 3 a1wh Voltage  
<option> a1wh.dat 4 a1wh Temperature   
<option> c1wh.dat 3 c1wh Temperature  
<option> c1wh.dat 4 c1wh Voltage   
<option> b2wh.dat 3 b2wh Temperature  
<option> b2wh.dat 4 b2wh Voltage   
<option> alltimes.dat 3 a1ft Long Valley tilt S end float   
<option> alltimes.dat 4 a1wh Long Valley tilt S end water height 
<option> alltimes.dat 5 a1wt Long Valley tilt S end water temperature 
<option> alltimes.dat 6 a1z1 Long Valley tilt S end vertical strain
<option> alltimes.dat 7 b1bv Long Valley tilt N end  
<option> alltimes.dat 8 b1ft Long Valley tilt N end float
<option> alltimes.dat 9 b1wh Long Valley tilt N end water height
<option> alltimes.dat 10 b1z1 Long Valley tilt N end vertical strain
<option> alltimes.dat 11 b2ft Long Valley tilt E end float 
<option> alltimes.dat 12 b2wh Long Valley tilt E end water height 
<option> alltimes.dat 13 b2wt Long Valley tilt E end water temperature 
<option> alltimes.dat 14 c1ft Long Valley tilt W end float 
<option> alltimes.dat 15 c1wh Long Valley tilt W end water height
<option> alltimes.dat 16 c1wt Long Valley tilt W end water temperature
<option> alltimes.dat 17 c1z1 Long Valley tilt W end vertical strain
<option> alltimes.dat 18 cfw1 Osbourne Rd Fremont creep (1)
<option> alltimes.dat 19 cfw2 Osbourne Rd Fremont creep (2)
<option> alltimes.dat 20 cfwb Osbourne Rd Fremont voltage (raw)
<option> alltimes.dat 21 cfwd Osbourne Rd Fremont temp
<option> alltimes.dat 22 cfwr Osbourne Rd Fremont rainfall
<option> alltimes.dat 23 cfwt Osbourne Rd Fremont creep (3)
<option> alltimes.dat 24 cfwx Osbourne Rd Fremont tilt (x)
<option> alltimes.dat 25 cfwy Osbourne Rd Fremont tilt (y)
<option> alltimes.dat 26 chp1 Palisades Rd Hayward creep (1)
<option> alltimes.dat 27 chp2 Palisades Rd Hayward creep (2)
<option> alltimes.dat 28 chpt Palisades Rd Hayward temp
<option> alltimes.dat 29 chpv Palisades Rd Hayward voltage (DCP 1)
<option> alltimes.dat 30 coz1 Oakland Zoo  creep (1)
<option> alltimes.dat 31 coz2 Oakland Zoo  creep (2)
<option> alltimes.dat 32 cozb Oakland Zoo  voltage (DCP 1)
<option> alltimes.dat 33 cozt Oakland Zoo  temp
<option> alltimes.dat 34 cpp1 Point Pinole creep (1)
<option> alltimes.dat 35 cpp2 Point Pinole creep (2)
<option> alltimes.dat 36 cppb Point Pinole voltage (raw)
<option> alltimes.dat 37 cppr Point Pinole rainfall
<option> alltimes.dat 38 cppt Point Pinole temp
<option> alltimes.dat 39 ctme Temescal Park creep (thermal)
<option> alltimes.dat 39 CTME Temescal Park creep (east)
<option> alltimes.dat 40 ctmt Temescal Park creep (low gain)
<option> alltimes.dat 40 CTMT Temescal Park creep (thermal)
<option> alltimes.dat 41 ctmv Temescal Park voltage (DCP 1)
<option> alltimes.dat 42 ctmw Temescal Park creep (high gain)
<option> alltimes.dat 42 CTMW Temescal Park creep (west)
</select>
<select name=station2>
<option value=''> second dataset
<option> coz.dat 3 Oakland Zoo Voltage 1  
<option> coz.dat 4 Oakland Zoo Temperature   
<option> coz.dat 5 Oakland Zoo Voltage 2  
<option> a1wh.dat 3 a1wh Voltage  
<option> a1wh.dat 4 a1wh Temperature   
<option> c1wh.dat 3 c1wh Temperature  
<option> c1wh.dat 4 c1wh Voltage   
<option> b2wh.dat 3 b2wh Temperature  
<option> b2wh.dat 4 b2wh Voltage   
<option> alltimes.dat 3 a1ft Long Valley tilt S end float   
<option> alltimes.dat 4 a1wh Long Valley tilt S end water height 
<option> alltimes.dat 5 a1wt Long Valley tilt S end water temperature 
<option> alltimes.dat 6 a1z1 Long Valley tilt S end vertical strain
<option> alltimes.dat 7 b1bv Long Valley tilt N end  
<option> alltimes.dat 8 b1ft Long Valley tilt N end float
<option> alltimes.dat 9 b1wh Long Valley tilt N end water height
<option> alltimes.dat 10 b1z1 Long Valley tilt N end vertical strain
<option> alltimes.dat 11 b2ft Long Valley tilt E end float 
<option> alltimes.dat 12 b2wh Long Valley tilt E end water height 
<option> alltimes.dat 13 b2wt Long Valley tilt E end water temperature 
<option> alltimes.dat 14 c1ft Long Valley tilt W end float 
<option> alltimes.dat 15 c1wh Long Valley tilt W end water height
<option> alltimes.dat 16 c1wt Long Valley tilt W end water temperature
<option> alltimes.dat 17 c1z1 Long Valley tilt W end vertical strain
<option> alltimes.dat 18 cfw1 Osbourne Rd Fremont creep (1)
<option> alltimes.dat 19 cfw2 Osbourne Rd Fremont creep (2)
<option> alltimes.dat 20 cfwb Osbourne Rd Fremont voltage (raw)
<option> alltimes.dat 21 cfwd Osbourne Rd Fremont temp
<option> alltimes.dat 22 cfwr Osbourne Rd Fremont rainfall
<option> alltimes.dat 23 cfwt Osbourne Rd Fremont creep (3)
<option> alltimes.dat 24 cfwx Osbourne Rd Fremont tilt (x)
<option> alltimes.dat 25 cfwy Osbourne Rd Fremont tilt (y)
<option> alltimes.dat 26 chp1 Palisades Rd Hayward creep (1)
<option> alltimes.dat 27 chp2 Palisades Rd Hayward creep (2)
<option> alltimes.dat 28 chpt Palisades Rd Hayward temp
<option> alltimes.dat 29 chpv Palisades Rd Hayward voltage (DCP 1)
<option> alltimes.dat 30 coz1 Oakland Zoo  creep (1)
<option> alltimes.dat 31 coz2 Oakland Zoo  creep (2)
<option> alltimes.dat 32 cozb Oakland Zoo  voltage (DCP 1)
<option> alltimes.dat 33 cozt Oakland Zoo  temp
<option> alltimes.dat 34 cpp1 Point Pinole creep (1)
<option> alltimes.dat 35 cpp2 Point Pinole creep (2)
<option> alltimes.dat 36 cppb Point Pinole voltage (raw)
<option> alltimes.dat 37 cppr Point Pinole rainfall
<option> alltimes.dat 38 cppt Point Pinole temp
<option> alltimes.dat 39 ctme Temescal Park creep (thermal)
<option> alltimes.dat 39 CTME Temescal Park creep (east)
<option> alltimes.dat 40 ctmt Temescal Park creep (low gain)
<option> alltimes.dat 40 CTMT Temescal Park creep (thermal)
<option> alltimes.dat 41 ctmv Temescal Park voltage (DCP 1)
<option> alltimes.dat 42 ctmw Temescal Park creep (high gain)
<option> alltimes.dat 42 CTMW Temescal Park creep (west)
</select>
<select name=station3>
<option value=''> third dataset
<option> coz.dat 3 Oakland Zoo Voltage 1  
<option> coz.dat 4 Oakland Zoo Temperature   
<option> coz.dat 5 Oakland Zoo Voltage 2  
<option> a1wh.dat 3 a1wh Voltage  
<option> a1wh.dat 4 a1wh Temperature   
<option> c1wh.dat 3 c1wh Temperature  
<option> c1wh.dat 4 c1wh Voltage   
<option> b2wh.dat 3 b2wh Temperature  
<option> b2wh.dat 4 b2wh Voltage   
<option> alltimes.dat 3 a1ft Long Valley tilt S end float   
<option> alltimes.dat 4 a1wh Long Valley tilt S end water height 
<option> alltimes.dat 5 a1wt Long Valley tilt S end water temperature 
<option> alltimes.dat 6 a1z1 Long Valley tilt S end vertical strain
<option> alltimes.dat 7 b1bv Long Valley tilt N end  
<option> alltimes.dat 8 b1ft Long Valley tilt N end float
<option> alltimes.dat 9 b1wh Long Valley tilt N end water height
<option> alltimes.dat 10 b1z1 Long Valley tilt N end vertical strain
<option> alltimes.dat 11 b2ft Long Valley tilt E end float 
<option> alltimes.dat 12 b2wh Long Valley tilt E end water height 
<option> alltimes.dat 13 b2wt Long Valley tilt E end water temperature 
<option> alltimes.dat 14 c1ft Long Valley tilt W end float 
<option> alltimes.dat 15 c1wh Long Valley tilt W end water height
<option> alltimes.dat 16 c1wt Long Valley tilt W end water temperature
<option> alltimes.dat 17 c1z1 Long Valley tilt W end vertical strain
<option> alltimes.dat 18 cfw1 Osbourne Rd Fremont creep (1)
<option> alltimes.dat 19 cfw2 Osbourne Rd Fremont creep (2)
<option> alltimes.dat 20 cfwb Osbourne Rd Fremont voltage (raw)
<option> alltimes.dat 21 cfwd Osbourne Rd Fremont temp
<option> alltimes.dat 22 cfwr Osbourne Rd Fremont rainfall
<option> alltimes.dat 23 cfwt Osbourne Rd Fremont creep (3)
<option> alltimes.dat 24 cfwx Osbourne Rd Fremont tilt (x)
<option> alltimes.dat 25 cfwy Osbourne Rd Fremont tilt (y)
<option> alltimes.dat 26 chp1 Palisades Rd Hayward creep (1)
<option> alltimes.dat 27 chp2 Palisades Rd Hayward creep (2)
<option> alltimes.dat 28 chpt Palisades Rd Hayward temp
<option> alltimes.dat 29 chpv Palisades Rd Hayward voltage (DCP 1)
<option> alltimes.dat 30 coz1 Oakland Zoo  creep (1)
<option> alltimes.dat 31 coz2 Oakland Zoo  creep (2)
<option> alltimes.dat 32 cozb Oakland Zoo  voltage (DCP 1)
<option> alltimes.dat 33 cozt Oakland Zoo  temp
<option> alltimes.dat 34 cpp1 Point Pinole creep (1)
<option> alltimes.dat 35 cpp2 Point Pinole creep (2)
<option> alltimes.dat 36 cppb Point Pinole voltage (raw)
<option> alltimes.dat 37 cppr Point Pinole rainfall
<option> alltimes.dat 38 cppt Point Pinole temp
<option> alltimes.dat 39 ctme Temescal Park creep (thermal)
<option> alltimes.dat 39 CTME Temescal Park creep (east)
<option> alltimes.dat 40 ctmt Temescal Park creep (low gain)
<option> alltimes.dat 40 CTMT Temescal Park creep (thermal)
<option> alltimes.dat 41 ctmv Temescal Park voltage (DCP 1)
<option> alltimes.dat 42 ctmw Temescal Park creep (high gain)
<option> alltimes.dat 42 CTMW Temescal Park creep (west)
</select>
<select name=station4>
<option value=''> fourth dataset
<option> coz.dat 3 Oakland Zoo Voltage 1  
<option> coz.dat 4 Oakland Zoo Temperature   
<option> coz.dat 5 Oakland Zoo Voltage 2  
<option> a1wh.dat 3 a1wh Voltage  
<option> a1wh.dat 4 a1wh Temperature   
<option> c1wh.dat 3 c1wh Temperature  
<option> c1wh.dat 4 c1wh Voltage   
<option> b2wh.dat 3 b2wh Temperature  
<option> b2wh.dat 4 b2wh Voltage   
<option> alltimes.dat 3 a1ft Long Valley tilt S end float   
<option> alltimes.dat 4 a1wh Long Valley tilt S end water height 
<option> alltimes.dat 5 a1wt Long Valley tilt S end water temperature 
<option> alltimes.dat 6 a1z1 Long Valley tilt S end vertical strain
<option> alltimes.dat 7 b1bv Long Valley tilt N end  
<option> alltimes.dat 8 b1ft Long Valley tilt N end float
<option> alltimes.dat 9 b1wh Long Valley tilt N end water height
<option> alltimes.dat 10 b1z1 Long Valley tilt N end vertical strain
<option> alltimes.dat 11 b2ft Long Valley tilt E end float 
<option> alltimes.dat 12 b2wh Long Valley tilt E end water height 
<option> alltimes.dat 13 b2wt Long Valley tilt E end water temperature 
<option> alltimes.dat 14 c1ft Long Valley tilt W end float 
<option> alltimes.dat 15 c1wh Long Valley tilt W end water height
<option> alltimes.dat 16 c1wt Long Valley tilt W end water temperature
<option> alltimes.dat 17 c1z1 Long Valley tilt W end vertical strain
<option> alltimes.dat 18 cfw1 Osbourne Rd Fremont creep (1)
<option> alltimes.dat 19 cfw2 Osbourne Rd Fremont creep (2)
<option> alltimes.dat 20 cfwb Osbourne Rd Fremont voltage (raw)
<option> alltimes.dat 21 cfwd Osbourne Rd Fremont temp
<option> alltimes.dat 22 cfwr Osbourne Rd Fremont rainfall
<option> alltimes.dat 23 cfwt Osbourne Rd Fremont creep (3)
<option> alltimes.dat 24 cfwx Osbourne Rd Fremont tilt (x)
<option> alltimes.dat 25 cfwy Osbourne Rd Fremont tilt (y)
<option> alltimes.dat 26 chp1 Palisades Rd Hayward creep (1)
<option> alltimes.dat 27 chp2 Palisades Rd Hayward creep (2)
<option> alltimes.dat 28 chpt Palisades Rd Hayward temp
<option> alltimes.dat 29 chpv Palisades Rd Hayward voltage (DCP 1)
<option> alltimes.dat 30 coz1 Oakland Zoo  creep (1)
<option> alltimes.dat 31 coz2 Oakland Zoo  creep (2)
<option> alltimes.dat 32 cozb Oakland Zoo  voltage (DCP 1)
<option> alltimes.dat 33 cozt Oakland Zoo  temp
<option> alltimes.dat 34 cpp1 Point Pinole creep (1)
<option> alltimes.dat 35 cpp2 Point Pinole creep (2)
<option> alltimes.dat 36 cppb Point Pinole voltage (raw)
<option> alltimes.dat 37 cppr Point Pinole rainfall
<option> alltimes.dat 38 cppt Point Pinole temp
<option> alltimes.dat 39 ctme Temescal Park creep (thermal)
<option> alltimes.dat 39 CTME Temescal Park creep (east)
<option> alltimes.dat 40 ctmt Temescal Park creep (low gain)
<option> alltimes.dat 40 CTMT Temescal Park creep (thermal)
<option> alltimes.dat 41 ctmv Temescal Park voltage (DCP 1)
<option> alltimes.dat 42 ctmw Temescal Park creep (high gain)
<option> alltimes.dat 42 CTMW Temescal Park creep (west)
</select>
<p><input TYPE=submit VALUE=View Plot>
<br>
<br>
<p></form>
</body>
</html>
";
