#! /usr/oracle/bin/oraperl

##### read clipid #####

$clipid = $ENV{'QUERY_STRING'};
$clipid =~ s/clipid=(\d+).*/$1/;

##### create the html header #####
print ("Content-type: TEXT/HTML\n\n");
print ("<HTML><TITLE>ADMP response</TITLE><BODY>\n");
print ("<h2>You asked for clip No. $clipid </h2>\n");

##### set oracle's env variables #####

$ENV{'ORACLE_HOME'}='/usr/oracle';
$ENV{'ORACLE_SID'}='nodb';

##### SQL stuff #####
##### first logon oracle #####
$lda = &ora_login('','michal', 'michal');

##### query the database #####
$csr = &ora_open($lda, "select 
title, server, filename, encoding, length, foff, 
start_fr, end_fr, start_off, end_off from clip 
where clipid = $clipid ");

##### get the results back #####
($title, $server, $filename, $encoding, $length, $foff, 
$st_fr, $en_fr, $st_off, $en_off) = (&ora_fetch($csr, 1));

######## for updating or deleting #########
print ("<FORM ACTION=\"http://kayak.npac.syr.edu:1963/cgi-bin/vser/updel\" method=\"POST\">\n");

##### print out the details about the clip #####
print ("<INPUT TYPE=\"HIDDEN\" NAME=\"clipid\" VALUE=\"$clipid\">\n");
print ("<TABLE BORDER=1 WIDTH=\"100\%\">\n");


print ("<TR><TD><B>Title:</B></TD>\n");
print ("<TD><input name=\"title\" type=\"text\" size=40 maxlength=100
value=\"$title\"></TD></TR><BR>\n");

print ("<TR><TD><b>Server:</b></TD>\n");
print ("<TD><input name=\"server\" type=\"text\" size=15 maxlength=15 
value=\"$server\"></TD></TR><BR>\n");

print ("<TR><TD><b>Filename: </b></TD>\n");
print ("<TD><input name=\"filename\" type=\"text\" size=50 maxlength=100
value=\"$filename\"></TD></TR><BR>\n");

print ("<TR><TD><b>Encoding: </b></TD>\n");
print ("<TD><input name=\"encoding\" type=\"text\" size=10 maxlength=100
value=\"$encoding\"></TD></TR><BR>\n");

print ("<TR><TD><b>URL: </b></TD>\n");
print ("<TD><input name=\"url\" type=\"text\" size=50 maxlength=100
value=\"$foff\"</TD></TR><BR><HR>\n");

print ("<TR><TD><b>Length: </b></TD>\n");
print ("<TD><input name=\"length\" type=\"text\" size=15 maxlength=100
value=\"$length\"></TD></TR><BR>\n");

print ("<TR><TD><B>Start frame:</B></TD><TD>
<INPUT NAME=\"st_frame\" SIZE=\"10\" VALUE=\"$st_fr\"></TD></TR>\n");
print ("<TR><TD><B>End frame :</B></TD><TD>
<INPUT NAME=\"en_frame\" SIZE=\"10\" VALUE=\"$en_fr\"></TD></TR>\n");
print ("<TR><TD><B>Start offset:</B></TD><TD>
<INPUT NAME=\"st_offset\" SIZE=\"10\" VALUE=\"$st_off\" ></TD></TR>\n");
print ("<TR><TD><B>End offset :</B> </TD><TD>
<INPUT NAME=\"en_offset\" SIZE=\"10\" VALUE=\"$en_off\"></TD></TR>\n");

print ("</TABLE>\n");

print ("<BR>\n");
print ("Specify the action you want to perform: <br>\n");
print ("<INPUT TYPE=\"SUBMIT\" NAME=\"action\" VALUE=\"Update\">\n");
print ("<INPUT TYPE=\"SUBMIT\" NAME=\"action\" VALUE=\"Delete\">\n");
print ("<INPUT TYPE=\"RESET\" VALUE=\"Reset form\">\n");

print("</FORM>\n");


##### logoff oracle #####

&ora_logoff($lda);


print ("</BODY></HTML>");


