#!/oracle/app/oracle/product/7.3.3/bin/oraperl

##### set Oracle's variables #####
$ENV{'ORACLE_HOME'}='/oracle/app/oracle/product/7.3.3';
$ENV{'ORACLE_SID'}='rabbit';
$orauser="vod";
$orapass="vod";

#### set web server address ####
$WSA = "http://clarissa.npac.syr.edu/vod";
$PROJDIR="/project/K136/VOD";




$input = <>;
#chop $input;

@param = split(/\&/, $input );

foreach (@param)
{
    ##### for URL decoding ######
    ### convert plus to space ###
    $_ =~ s/\+/ /g;
    ### convert %XX from hex numbers to alphanumeric ###
    $_ =~ s/%(..)/pack("c", hex($1))/ge;

    $clipid = $1 if /clipid=(.*)/;
    $filename = $1 if /filename=(.*)/;
    $serverid = $1 if /serverid=(.*)/;
    
}

print ("Content-type: TEXT/HTML\n\n");
print <<"EndOfHTML";
<HTML>
<TITLE>Video News Database - Rename Clip </TITLE>
<BODY bgcolor="gold">
<H1> Results of the Rename Clip operation </H1>
<HR>
<FONT Size="4"> Input data <BR><BR>
<FONT Size="3">
Clip ID : $clipid <BR>
Filename : $filename <BR>
Server ID : $serverid <BR>
<HR>
<FONT Size="4"> Results: <BR><BR>
<FONT Size="3">
EndOfHTML


##### logon oracle #####
$lda = &ora_login('', $orauser, $orapass);

$ret = &ora_do ($lda," update CLIPSERVER set filename='$filename'
where clipid=$clipid and serverid =$serverid ");
if($ret>=1) {
  print "CLIPSERVER: $ret row updated.<BR>";
} else {
  print "CLIPSERVER UPDATE: ORACLE error $ora_errno,  $ora_errstr<BR>";
  print <<"EndOfHTML"; 
<HR>
<A HREF="$WSA/vns2index.html">Asset Management Home Page</A> / 
<A HREF="$WSA/cgi-bin/chanclipform">CLONE ANOTHER</A>
</BODY>
</HTML>
EndOfHTML
  &ora_logoff($lda);
  die;
}

print "Clip filename update has been successful.<BR>";
&ora_commit($lda);
&ora_logoff($lda);

print <<"EndOfHTML"; 
<HR>
<A HREF="$WSA/cgi-bin/chanclipform">CHANGE ANOTHER</A>
</BODY>
</HTML>
EndOfHTML


