#!/usr/bin/perl
#------------------------------------------------------------------------------
# Copyright (C) 2001 Thomax Kaulmann
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


use DBI;
use CGI;
use OMA;
use ORA;
use XSQL;

local (%in, @row, $st, , $trans);
undef(%in);
undef(@row);
undef($trans);


                   ###            ##
                    ##            ##
 ##  ## ## ###   #####   ####    #####    ####
 ##  ##  ##  ## ##  ##      ##    ##     ##  ##
 ##  ##  ##  ## ##  ##   #####    ##     ######
 ##  ##  #####  ##  ##  ##  ##    ## ##  ##
  #####  ##      ### ##  ### ##    ###    ####
        ####
sub update {
	local @deps;
	local (%hashrow, %hashrow2);
	local ($st, $nst);
	local @row;

	foreach $k (keys %in) {
		$in{$k} =~ s/'/\'/g;
		$in{$k} =~ s/"/&quot;/g;
	}

	XSQL::transact("
		UPDATE	ora_page
		SET		dc__title = '$in{'dc__title'}',
				dc__title__program_title = '$in{'dc__title__program_title'}',
				dc__publisher = '$in{'dc__publisher'}',
				dc__type = '$in{'dc__type'}',
				dc__subject = '$in{'dc__subject'}',
				dc__language = '$in{'dc__language'}',
				dc__coverage__spatial = '$in{'dc__coverage__spatial'}',
				dc__coverage__temporal = '$in{'dc__coverage__temporal'}',
				dc__date__issued = '$in{'dc__date__issued'}',
				dc__date__created = '$in{'dc__date__created'}',
				dc__date__digitized = '$in{'dc__date__digitized'}',
				dc__format__extent = '$in{'dc__format__extent'}',
				dc__format__medium = '$in{'dc__format__medium'}',
				dc__format__encoding = '$in{'dc__format__encoding'}',
				dc__source = '$in{'dc__source'}',
				dc__rights = '$in{'dc__rights'}',
				dc__rights__license = '$in{'dc__rights__license'}',
				dc__description__toc = '$in{'dc__description__toc'}',
				dc__description__abstract = '$in{'dc__description__abstract'}',
				dc__description__long = '$in{'dc__description__long'}',
				expire = $in{'expire'}
		WHERE	id=$in{'ID'}
		AND location='$in{'base'}'");

	if($in{'dc__creator'} && $in{'dc__creator__role'}) {
		XSQL::transact("
			INSERT INTO ora_creator
			VALUES (	$in{'ID'},
						'$ORA::HOST',
						'$in{'dc__creator'}',
						'$in{'dc__creator__role'}'
			)
		");
	}
	if($in{'dc__contributor'} && $in{'dc__contributor__role'}) {
		XSQL::transact("
			INSERT INTO ora_contributor
			VALUES (	$in{'ID'},
						'$ORA::HOST',
						'$in{'dc__contributor'}',
						'$in{'dc__contributor__role'}'
			)
		");
	}
	if($in{'dc__relation__type'} && $in{'dc__relation__value'}) {
		XSQL::transact("
			INSERT INTO ora_relation
			VALUES (	$in{'ID'},
						'$ORA::HOST',
						'$in{'dc__relation__type'}',
						'$in{'dc__relation__value'}'
			)
		");
	}


	foreach $k (keys %in) {
		if($k =~ /^del_creator/) {
			local ($del,$creator,$role) = split(/:/,$in{$k});
			XSQL::transact("
				DELETE FROM ora_creator
				WHERE	ID=$in{'ID'}
				AND		location='$in{'base'}'
				AND		dc__creator='$creator'
				AND		dc__creator__role='$role'
			");
		}
		if($k =~ /^del_contributor/) {
			local ($del,$contributor,$role) = split(/:/,$in{$k});
			XSQL::transact("
				DELETE FROM ora_contributor
				WHERE	ID=$in{'ID'}
				AND		location='$in{'base'}'
				AND		dc__contributor='$contributor'
				AND		dc__contributor__role='$role'
			");
		}
		if($k =~ /^del_relation/) {
			local ($del,$type,$value) = split(/:/,$in{$k});
			XSQL::transact("
				DELETE FROM ora_relation
				WHERE	ID=$in{'ID'}
				AND		location='$in{'base'}'
				AND		dc__relation__type='$type'
				AND		dc__relation__value='$value'
			");
		}
	}

		
	$st = $db->prepare("
		SELECT	*
		FROM	ora_conn
		WHERE	ora_conn.ora_page=$in{'ID'}
		AND		ora_conn.location='$in{'base'}'
	");
	$st->execute();
	$st->bind_columns(\(@hashrow{@{$st->{NAME_lc}}}));


	@deps = split(/\000/,$in{'department'});

	while(@row = $st->fetchrow()) {
		XSQL::transact("
			UPDATE	item
			SET		description = '$in{'dc__title'}'
			WHERE	type != 'meta'
			AND		(sid=$hashrow{item_sid}
			OR		link_item=$hashrow{item_sid})
		");
		XSQL::transact("
			UPDATE	item
			SET		node_sid = $deps[0]
			WHERE	type != 'meta'
			AND		(sid=$hashrow{item_sid}
			AND		link_item=0)
		");
	}
	$st->finish();

	print "DONE.\n";
}





  ####   ####    ##  ##   ####
 ##         ##   ##  ##  ##  ##
  ####   #####   ##  ##  ######
     ## ##  ##    ####   ##
 #####   ### ##    ##     ####

sub save {
	local @deps, $ID, $i;
	undef(@deps);

	$ID = time;

	mkdir("$ORA::ORA_PATH/$ID",0775) or die "Can't create desired directory";
	system("mv \"$ORA::DOWNLOAD/$ENV{'REMOTE_USER'}/$in{'dc__identifier'}\" $ORA::ORA_PATH/$ID") if($in{'dc__identifier'});

	foreach $k (keys %in) {
		$in{$k} =~ s/'/\'/g;
		$in{$k} =~ s/"/&quot;/g;
	}

	XSQL::transact("
		INSERT INTO ora_page
		VALUES (	$ID,
					'$ORA::HOST',
					'$ENV{'REMOTE_USER'}',
					$in{'expire'},
					'$ORA::ORADATA',
					'$in{'dc__title'}',
					'$in{'dc__title__program_title'}',
					'$in{'dc__publisher'}',
					'$in{'dc__date__issued'}',
					'$in{'dc__date__created'}',
					'$in{'dc__date__digitized'}',
					$in{'dc__format__extent'},
					'$in{'dc__format__medium'}',
					'$in{'dc__format__encoding'}',
					'$in{'dc__identifier'}',
					'$in{'dc__source'}',
					'$in{'dc__rights'}',
					'$in{'dc__rights__license'}',
					'$in{'dc__description__toc'}',
					'$in{'dc__description__abstract'}',
					'$in{'dc__description__long'}',
					'$in{'dc__type'}',
					'$in{'dc__subject'}',
					'$in{'dc__language'}',
					'$in{'dc__coverage__spatial'}',
					'$in{'dc__coverage__temporal'}'
		)
	");

	XSQL::transact("
		INSERT INTO ora_creator
		VALUES (	$ID,
					'$ORA::HOST',
					'$in{'dc__creator'}',
					'$in{'dc__creator__role'}'
		)
	");
	XSQL::transact("
		INSERT INTO ora_contributor
		VALUES (	$ID,
					'$ORA::HOST',
					'$in{'dc__contributor'}',
					'$in{'dc__contributor__role'}'
		)
	");
	XSQL::transact("
		INSERT INTO ora_relation
		VALUES (	$ID,
					'$ORA::HOST',
					'$in{'dc__relation__type'}',
					'$in{'dc__relation__value'}'
		)
	");

	@deps = split(/\000/,$in{'department'});
	for($i=0;$i<=$#deps;$i++) {
		my $newsid = OMA::nextsid("item_sid");
		XSQL::transact("
			INSERT INTO item
			VALUES (	$newsid,
						$deps[$i],
						'$in{'dc__title'}',
						'ora',
						0,
						0
			)
		");
		XSQL::transact("
			INSERT INTO ora_conn
			VALUES (	$newsid,
						$ID,
						'$ORA::HOST',
						0,
						$newsid
			)
		");
	}
	print "DONE.\n";
}



   ###            ###
    ##             ##
 #####    ####     ##
##  ##   ##  ##    ##
##  ##   ######    ##
##  ##   ##        ##
 ### ##   ####    ####

sub del {
	print "delete all related with $in{'ID'}\n";
	if(-d "$ORA::ORA_PATH/$in{'ID'}") {
		system("rm -rf $ORA::ORA_PATH/$in{'ID'}");	
	}

	$st = $db->prepare("
		SELECT	*
		FROM	ora_conn
		WHERE	ora_conn.ora_page=$in{'ID'}
		AND		ora_conn.location='$in{'base'}'");
	$st->execute();

	while(@row=$st->fetchrow()) {
		XSQL::transact("DELETE FROM item WHERE item.sid = $row[0] AND item.type='ora'");
	}
	$st->finish();

	XSQL::transact("
		DELETE FROM ora_conn
		WHERE	ora_conn.ora_page=$in{'ID'}
		AND		ora_conn.location='$in{'base'}'
	");

	XSQL::transact("
		DELETE FROM ora_page
		WHERE	id=$in{'ID'}
		AND		location='$in{'base'}'
	");

	XSQL::transact("
		DELETE FROM ora_relation
		WHERE	id=$in{'ID'}
		AND		location='$in{'base'}'
	");

	XSQL::transact("
		DELETE FROM ora_contributor
		WHERE	id=$in{'ID'}
		AND		location='$in{'base'}'
	");

	XSQL::transact("
		DELETE FROM ora_creator
		WHERE	id=$in{'ID'}
		AND		location='$in{'base'}'
	");
}



                        ###                     ###
                         ##                      ##
  #####   ####           #####   ####     ####   ##  ##
 ##  ##  ##  ##          ##  ##     ##   ##  ##  ## ##
 ##  ##  ##  ##          ##  ##  #####   ##      ####
  #####  ##  ##          ##  ## ##  ##   ##  ##  ## ##
     ##   ####          ## ###   ### ##   ####  ###  ##
 #####          ########
sub go_back {
	print "You did not enter something in the field <b>$_[0]</b>.
Please <a href=javascript:this.back()>switch back</a> to correct this.

";
}



                                   ###
                                  ## ##
## ###  ## ###    ####    ####    ##
 ##  ##  ### ##  ##  ##  ##  ##  ####
 ##  ##  ##      ##  ##  ##  ##   ##
 #####   ##      ##  ##  ##  ##   ##
 ##     ####      ####    ####   ####
####
sub proof {
	local (@deps, $d="", $i, $op);
	undef(@deps);

	$in{'expire'} = 0 if(!$in{'expire'});
	$in{'dc__format__extent'} = 0 if(!$in{'dc__format__extent'});
	
	print "$ORA::ORA_BODY";
	print "<b>[ora]</b>";

	if((!$in{'dc__identifier'}
	||	!$in{'dc__title'}
	||	!$in{'department'})
	&&	($in{'op2'} ne "delete")) {
		print "SORRY! YOU FORGET TO SELECT MEDIA FILE OR ENTER A TITLE OR SELECT A NODE\n";
		exit;
	}
	print "<table><tr><td><form method=post>";
	@deps = split(/\000/,$in{'department'});
	for($i=0;$i<=$#deps;$i++) {
		$d .= OMA::getpath($deps[$i]). ", ";
#		print "<input type=hidden name=department value=\"$deps[$i]\">";
	}

	print "<input type=hidden name=department value=\"$in{'department'}\">";
	$op = "<input type=hidden name=op value=save>";
	$op = "<input type=hidden name=op value=update> <input type=hidden name=ID value=$in{'ID'}>" if($in{'op2'} eq "update");
	$op = "<input type=hidden name=op value=delete> <input type=hidden name=ID value=$in{'ID'}>" if($in{'op2'} eq "delete");

$in{'abstract'} =~ s/"/&quot;/g;

	print "
Your entry is:
<i>title</i> <b>$in{'dc__title'}</b> | 
<i>program title: $in{'dc__title__program_title'}</b> | 
<i>days to live</i> <b>$in{'expire'}</b> | 
<i>locations</i> <b>$d</b> | 
<i>file</i> <b>$in{'dc__identifier'}</b> | 
<i>publisher</i> <b>$in{'dc__publisher'}</b> | 
<i>type</i> <b>$in{'dc__type'}</b> | 
<i>subject</i> <b>$in{'dc__subject'}</b> | 
<i>language</i> <b>$in{'dc__language'}</b> | 
<i>spacial</i> <b>$in{'dc__coverage__spatial'}</b> | 
<i>temporal</i> <b>$in{'dc__coverage__temporal'}</b> | 
<i>issued</i> <b>$in{'dc__date__issued'}</b> | 
<i>created</i> <b>$in{'dc__date__created'}</b> | 
<i>digitized</i> <b>$in{'dc__date__digitized'}</b> | 
<i>extent</i> <b>$in{'dc__format__extent'}</b> | 
<i>medium</i> <b>$in{'dc__format__medium'}</b> | 
<i>encoding</i> <b>$in{'dc__format__encoding'}</b> | 
<i>source</i> <b>$in{'dc__source'}</b> | 
<i>rights</i> <b>$in{'dc__rights'}</b> | 
<i>license</i> <b>$in{'dc__rights__license'}</b> | 
<i>creator</i> <b>$in{'dc__creator__role'} - $in{'dc__creator'}</b> | 
<i>contributor</i> <b>$in{'dc__contributor__role'} - $in{'dc__contributor'}</b> | 
<i>relation</i> <b>$in{'dc__relation__type'} - $in{'dc__relation__value'}</b>
<br>
description-
<br>
<i>TOC :</i><br>
$in{'dc__description__toc'}
<p>
<i>abstract :</i><br>
$in{'dc__description__abstract'}
<p>
<i>long :</i><br>
$in{'dc__description__long'}
<p>
";

	foreach $k (keys %in) {
		$in{$k} =~ s/'/\\'/g;
		$in{$k} =~ s/"/&quot;/g;
		if($k =~ /del_/) {
			print "<input type=hidden name=\"$k\" value=\"$k\">";
		}
	}

	print <<"EOT";
<input type=hidden name=dc__title value="$in{'dc__title'}">
<input type=hidden name=dc__title__program_title value="$in{'dc__title__program_title'}">
<input type=hidden name=expire value="$in{'expire'}">
<input type=hidden name=dc__identifier value="$in{'dc__identifier'}">
<input type=hidden name=dc__publisher value="$in{'dc__publisher'}">
<input type=hidden name=dc__type value="$in{'dc__type'}">
<input type=hidden name=dc__subject value="$in{'dc__subject'}">
<input type=hidden name=dc__language value="$in{'dc__language'}">
<input type=hidden name=dc__coverage__spatial value="$in{'dc__coverage__spatial'}">
<input type=hidden name=dc__coverage__temporal value="$in{'dc__coverage__temporal'}">
<input type=hidden name=dc__date__issued value="$in{'dc__date__issued'}">
<input type=hidden name=dc__date__created value="$in{'dc__date__created'}">
<input type=hidden name=dc__date__digitized value="$in{'dc__date__digitized'}">
<input type=hidden name=dc__format__extent value="$in{'dc__format__extent'}">
<input type=hidden name=dc__format__medium value="$in{'dc__format__medium'}">
<input type=hidden name=dc__format__encoding value="$in{'dc__format__encoding'}">
<input type=hidden name=dc__source value="$in{'dc__source'}">
<input type=hidden name=dc__rights value="$in{'dc__rights'}">
<input type=hidden name=dc__rights__license value="$in{'dc__rights__license'}">
<input type=hidden name=dc__description__toc value="$in{'dc__description__toc'}">
<input type=hidden name=dc__description__abstract value="$in{'dc__description__abstract'}">
<input type=hidden name=dc__description__long value="$in{'dc__description__long'}">
<input type=hidden name=dc__creator value="$in{'dc__creator'}">
<input type=hidden name=dc__creator__role value="$in{'dc__creator__role'}">
<input type=hidden name=dc__contributor value="$in{'dc__contributor'}">
<input type=hidden name=dc__contributor__role value="$in{'dc__contributor__role'}">
<input type=hidden name=dc__relation__type value="$in{'dc__relation__type'}">
<input type=hidden name=dc__relation__value value="$in{'dc__relation__value'}">

$op
EOT

	go_back("dc__identifier") if(!$in{'dc__identifier'});
	go_back("dc__title") if(!$in{'dc__title'});

	print <<"EOT";
<input type=submit value=\"I am responsible.\">
</form>
EOT
}



                                ###
                                 ##
  ####   ## ##   ####     ####   ##  ##
 ##  ## #######     ##   ##      ## ##
 ###### ## # ##  #####    ####   ####
 ##     ## # ## ##  ##       ##  ## ##
  ####  ##   ##  ### ##  #####  ###  ##

sub emask {
	local $deps;
	local @row;
	local $abstract;
	local %deps_s;
	local %hashrow;
	local $op2;
	local $relation;
	local $creator;
	local $contributor;

	undef(@row);
	undef(%deps_s);
	undef(%hashrow);
	undef(@abstract);
	$deps = "";

	#UPDATE
	if($in{'ID'}) {
		$st = $db->prepare("
				SELECT	*
				FROM	ora_page
				WHERE	id=$in{'ID'}
				AND		location='$in{'base'}'
		");
		$st->execute();
		$st->bind_columns(\(@hashrow{@{$st->{NAME_lc}}}));
		@row = $st->fetchrow();
		$st->finish();

		$deps="";
		$st = $db->prepare("
			SELECT	ora_conn.ora_page,item.node_sid
			FROM	ora_conn, item
 			WHERE	ora_conn.item_sid = item.sid
		 	AND		ora_conn.ora_page=$in{'ID'}
			AND		ora_conn.location='$in{'base'}'
			AND		item.link_item=0
			AND		item.type <> 'meta'
		");
		$st->execute();
		while(@row=$st->fetchrow()) {
		 	$deps_s{$row[1]} = $row[0];
 		}
 		$st->finish();
		$op2 = "<input type=hidden name=op2 value=update>";



		$st = $db->prepare("
			SELECT	dc__creator,dc__creator__role
			FROM	ora_creator
 			WHERE	ID=$in{'ID'}
			AND		location='$in{'base'}'
		");
		$st->execute();
		while(@row=$st->fetchrow()) {
			$creator .= "                <input type=checkbox name=\"del_creator:$row[0]:$row[1]\" value=\"del_creator:$row[0]:$row[1]\">role: $row[1], creator: $row[0]<br>";
		}
		$st->finish();



		$st = $db->prepare("
			SELECT	dc__contributor,dc__contributor__role
			FROM	ora_contributor
 			WHERE	ID=$in{'ID'}
			AND		location='$in{'base'}'
		");
		$st->execute();
		while(@row=$st->fetchrow()) {
			$contributor .= "                <input type=checkbox name=\"del_contributor:$row[0]:$row[1]\" value=\"del_contributor:$row[0]:$row[1]\">role: $row[1], contributor: $row[0]<br>";
		}
		$st->finish();



		$st = $db->prepare("
			SELECT	dc__relation__type,dc__relation__value
			FROM	ora_relation
 			WHERE	ID=$in{'ID'}
			AND		location='$in{'base'}'
		");
		$st->execute();
		while(@row=$st->fetchrow()) {
			$relation .= "                <input type=checkbox name=\"del_relation:$row[0]:$row[1]\" value=\"del_relation:$row[0]:$row[1]\">relation: $row[1], is: $row[0]<br>";
		}
		$st->finish();



	} else {

	#NEW ENTRY
		$hashrow{'dc__identifier'} = "<select name=dc__identifier size=6>\n";
		open(P,"/bin/ls $ORA::DOWNLOAD/$ENV{'REMOTE_USER'}/* 2> /dev/null |");
		while(<P>) {
	        $_ =~ s/$ORA::DOWNLOAD\/$ENV{'REMOTE_USER'}\///g;
			$_ = "<OPTION> $_";
			$hashrow{'dc__identifier'} .= $_;
    	}
	    close(P);
		$hashrow{'dc__identifier'} .= "</select>\n";

	}


	$st = $db->prepare("SELECT * FROM treemap ORDER BY node");
	$st->execute();
	while(@row=$st->fetchrow()) {
		if($deps_s{$row[0]}) {
			$deps .= "<option value=$row[0] selected>$row[1]\n";
		}
		else {
			$deps .= "<option value=$row[0]>$row[1]\n";
		}
	}

	print <<"EOT";

<b>[ora]</b>
<form method=post>
<pre>
        title : <input name=dc__title type=text size=30 value="$hashrow{dc__title}">
program title : <input name=dc__title__program_title type=text size=30 value="$hashrow{'dc__title__program_title'}">

ora File   :
                $hashrow{'dc__identifier'}

tree location :
                <select name=department size=6>
				$deps
				</select>

    publisher : <input name=dc__publisher type=text size=30 value="$hashrow{'dc__publisher'}">
         type : <input name=dc__type type=text size=30 value="$hashrow{'dc__type'}">
      subject : <input name=dc__subject type=text size=30 value="$hashrow{'dc__subject'}">
     language : <input name=dc__language type=text size=30 value="$hashrow{'dc__language'}">
      spacial : <input name=dc__coverage__spatial type=text size=30 value="$hashrow{'dc__coverage__spatial'}">
     temporal : <input name=dc__coverage__temporal type=text size=30 value="$hashrow{'dc__coverage__temporal'}">

dates-
       issued : <input name=dc__date__issued type=text size=30 value="$hashrow{'dc__date__issued'}">
      created : <input name=dc__date__created type=text size=30 value="$hashrow{'dc__date__created'}">
    digitized : <input name=dc__date__digitized type=text size=30 value="$hashrow{'dc__date__digitized'}">

format-
       extent : <input name=dc__format__extent type=text size=30 value="$hashrow{'dc__format__extent'}"> (auslesen)
       medium : <input name=dc__format__medium type=text size=30 value="$hashrow{'dc__format__medium'}">
     encoding : <input name=dc__format__encoding type=text size=30 value="$hashrow{'dc__format__encoding'}">

       source : <input name=dc__source type=text size=30 value="$hashrow{'dc__source'}">
       rights : <input name=dc__rights type=text size=30 value="$hashrow{'dc__rights'}">
      license : <input name=dc__rights__license type=text size=30 value="$hashrow{'dc__rights__license'}">

      creator : <select name=dc__creator__role><option>role 1<option>role 2<option>role 3</select> name: <input type=text name=dc__creator><br>
$creator
  contributor : <select name=dc__contributor__role><option>role 1<option>role 2<option>role 3</select> name: <input type=text name=dc__contributor><br>
$contributor
     relation : <select name=dc__relation__type>
<option>IsVersionOf
<option>HasVersion
<option>IsReplacedBy
<option>Replaces
<option>IsRequiredBy
<option>Requires
<option>IsPartOf
<option>HasPart
<option>IsReferencedB
<option>References
<option>IsFormatOf
</select> relation: <input type=text name=dc__relation__value><br>
$relation

days to live: <input type=text size=3 name=expire value="$hashrow{'expire'}">
description-

          TOC :
<textarea name=dc__description__toc cols=70 rows=12>$hashrow{'dc__description__toc'}</textarea>
     abstract :
<textarea name=dc__description__abstract cols=70 rows=12>$hashrow{'dc__description__abstract'}</textarea>
  description :
<textarea name=dc__description__long cols=70 rows=12>$hashrow{'dc__description__long'}</textarea>


<input type=submit value="I have the right to publish this material.">
</pre>
<input type=hidden name=dc__identifier value="$hashrow{'dc__identifier'}">
<input type=hidden name=op value=proof>
$op2
<input type=hidden name=ID value=$in{'ID'}>
</form>

<form method=post>
<input type=hidden name=op value=proof>
<input type=hidden name=op2 value=delete>
<input type=hidden name=ID value=$in{'ID'}>
<input type=submit value="I have the right to delete this material.">
</form>
</td>
</tr>
</table>
EOT
}


##   ##            ##            ######         ##   ##
### ###           ####             ##           ###  ##
#######          ##  ##            ##           #### ##
#######          ##  ##            ##           ## ####
## # ##          ######            ##           ##  ###
##   ##          ##  ##            ##           ##   ##
##   ##          ##  ##          ######         ##   ##

CGI::ReadParse();
$db = ORA::opendb();
if($msg=OMA::opallowed($in{'ID'},$in{'base'},'ora')) {
    print $msg;
    exit;
}

XSQL::transopen();

del() if($in{'op'} eq "delete");
update() if($in{'op'} eq "update");
save() if($in{'op'} eq "save");
proof() if($in{'op'} eq "proof");
emask() if($in{'op'} eq "correct");
emask() if($in{'op'} eq "" || !defined($in{'op'}));

XSQL::transclose();

