Index: eenstone3/trunk/web/WEB-INF/cgi/gsdlCGI4gs3.pm
===================================================================
--- /greenstone3/trunk/web/WEB-INF/cgi/gsdlCGI4gs3.pm	(revision 18322)
+++ 	(revision )
@@ -1,397 +1,0 @@
-
-package gsdlCGI4gs3;
-
-use strict;
-no strict 'subs';
-no strict 'refs'; # allow filehandles to be variables and viceversa
-
-use CGI;
-use Cwd;
-
-@gsdlCGI4gs3::ISA = ('CGI');
-
-sub new {
-    my $class = shift @_;
-
-
-    my $self;
-    if ((defined $ENV{'REQUEST_METHOD'}) && ($ENV{'REQUEST_METHOD'} eq "POST")) {
-
-	# 1st check if we're dealing with the upload-coll-file cmd. Because it will be a 
-	# multipart POST message and must be dealt with by the default CGI() constructor
-	if((defined $ENV{'QUERY_STRING'}) && ($ENV{'QUERY_STRING'} =~ /upload-collection-file/)) {
-	    $self = new CGI(); 
-	}
- 
-	else { # all other POST commands processed using CGI($line)
-	    my $line = <STDIN>;
-	    if ((defined $line) && ($line ne "")) { 
-		$self = new CGI($line);
-	    }
-	}	
-    }    
-
-    # If one of the conditions above did not hold, then self=new CGI() 
-    if(!defined $self) {
-	$self = new CGI();
-    }
-
-    return bless $self, $class;
-}
-
-
-sub parse_cgi_args
-{
-    my $self = shift @_;
-    my $xml = (defined $self->param("xml")) ? 1 : 0;
-
-    $self->{'xml'} = $xml;
-
-    my @var_names = $self->param;
-    my @arg_list = ();
-    foreach my $n ( @var_names ) {
-	my $arg = "$n=";
-	my $val =  $self->param($n);
-	$arg .= $val if (defined $val);
-	push(@arg_list,$arg);
-    }
-	
-    $self->{'args'} = join("&",@arg_list);
-}
-
-
-sub clean_param
-{
-    my $self = shift @_;
-    my ($param) = @_;
-
-    my $val = $self->SUPER::param($param);
-    $val =~ s/[\r\n]+$// if (defined $val);
-    
-    return $val;
-}
-
-sub safe_val
-{
-    my $self = shift @_;
-    my ($val) = @_;
-
-    # ensure only alpha-numeric plus a few other special chars remain
-
-    $val =~ s/[^[:alnum:]@\.\/\- :_]//g if (defined $val); 
-
-    return $val;
-}
-
-
-sub generate_error
-{
-    my $self = shift @_;
-    my ($mess) = @_;
-    
-    my $xml = $self->{'xml'};
-
-    my $full_mess;
-    my $args = $self->{'args'};
-
-    if ($xml) {
-	# Make $args XML safe
-	my $args_xml_safe = $args;
-	$args_xml_safe =~ s/&/&amp;/g;
-
-	$full_mess =  "<Error>\n";
-	$full_mess .= "  $mess\n";
-	$full_mess .= "  CGI args were: $args_xml_safe\n";
-	$full_mess .= "</Error>\n";
-    }
-    else {
-	$full_mess = "ERROR: $mess\n  ($args)\n";
-    }
-
-    print STDOUT "Content-type:text/plain\n\n";
-    print STDOUT $full_mess;
-
-    die $full_mess;
-}
-
-sub generate_warning
-{
-    my $self = shift @_;
-    my ($mess) = @_;
-    
-    my $xml = $self->{'xml'};
-
-    my $full_mess;
-    my $args = $self->{'args'};
-
-    if ($xml) {
-	# Make $args XML safe
-	my $args_xml_safe = $args;
-	$args_xml_safe =~ s/&/&amp;/g;
-
-	$full_mess =  "<Warning>\n";
-	$full_mess .= "  $mess\n";
-	$full_mess .= "  CGI args were: $args_xml_safe\n";
-	$full_mess .= "</Warning>\n";
-    }
-    else {
-	$full_mess = "Warning: $mess ($args)\n";
-    }
-
-    print STDOUT "Content-type:text/plain\n\n";
-    print STDOUT $full_mess;
-
-    print STDERR $full_mess;
-}
-
-
-sub generate_ok_message
-{
-    my $self = shift @_;
-    my ($mess) = @_;
-    
-    my $xml = $self->{'xml'};
-
-    my $full_mess;
-
-    if ($xml) {
-	$full_mess =  "<Accepted>\n";
-	$full_mess .= "  $mess\n";
-	$full_mess .= "</Accepted>\n";
-    }
-    else {
-	$full_mess = "$mess\n";
-    }
-    
-    print "<pre>";
-    print STDOUT $full_mess;
-    print "</pre>";
-}
-
-
-
-sub get_config_info {
-    my $self = shift @_;
-    my ($infotype) = @_;
-
-    my $site_filename = "gsdl3site.cfg";
-    open (FILEIN, "<$site_filename") 
-	|| $self->generate_error("Could not open gsdl3site.cfg");
-
-    my $config_content = "";
-    while(defined (my $line = <FILEIN>)) {
-	$config_content .= $line;
-    }
-    close(FILEIN);
-
-    my ($loc) = ($config_content =~ m/^$infotype\s+((\".+\")|(\S+))\s*\n/m);
-    $loc =~ s/\"//g if defined $loc;
-
-    if ((!defined $loc) || ($loc =~ m/^\s*$/)) {
-	$self->generate_error("$infotype is not set in gsdl3site.cfg");
-    }
-
-    return $loc;
-}
-
-sub get_gsdl3_src_home{
-    my $self = shift @_;
-    if (defined $self->{'gsdl3srchome'}) {
-	return $self->{'gsdl3srchome'};
-    }
-
-    my $gsdl3srchome = $self->get_config_info("gsdl3srchome");
-
-    $gsdl3srchome =~ s/(\/|\\)$//; # remove trailing slash
-
-    $self->{'gsdl3srchome'} = $gsdl3srchome;
-
-    return $gsdl3srchome;
-}
-
-
-sub get_gsdl_home {
-    my $self = shift @_;
-    
-    if (defined $self->{'gsdlhome'}) {
-	return $self->{'gsdlhome'};
-    }
-
-    my $gsdlhome = $self->get_config_info("gsdlhome");
-
-    #require "$gsdlhome/perllib/util.pm";
-
-    $gsdlhome =~ s/(\/|\\)$//; # remove trailing slash
-
-    $self->{'gsdlhome'} = $gsdlhome;
-
-    return $gsdlhome;
-}
-
-sub get_java_home {
-    my $self = shift @_;
-    
-    if (defined $self->{'javahome'}) {
-	return $self->{'javahome'};
-    }
-
-    my $javahome = $self->get_config_info("javahome");
-
-    $javahome =~ s/(\/|\\)$//; # remove trailing slash
-
-    $self->{'javahome'} = $javahome;
-
-    return $javahome;
-}
-
-sub get_perl_path {
-    my $self = shift @_;
-    
-    if (defined $self->{'perlpath'}) {
-	return $self->{'perlpath'};
-    }
-
-    my $perlpath = $self->get_config_info("perlpath");
-
-    $perlpath =~ s/(\/|\\)$//; # remove trailing slash
-
-    return $perlpath;
-}
-
-sub get_gsdl_os {
-    my $self = shift @_;
-    
-    my $os = $^O;
-
-    if ($os =~ m/linux/i) {
-	return "linux";
-    }
-    elsif ($os =~ /mswin/i) {
-	return "windows";
-    }
-    elsif ($os =~ /macos/i) {
-	return "darwin";
-    }
-    else {
-	# return as is.
-	return $os;
-    }
-}
-
-sub setup_gsdl {
-    my $self = shift @_;
-
-    my $gsdl3srchome = $self->get_gsdl3_src_home();
-    my $gsdlhome = $self->get_gsdl_home();
-    my $gsdlos = $self->get_gsdl_os();
-    #my $javahome = $self->get_java_home();
-
-    $ENV{'GSDL3SRCHOME'} = $gsdl3srchome;
-    $ENV{'GSDLHOME'} = $gsdlhome;
-    $ENV{'GSDLOS'} = $gsdlos;
-    #$ENV{'JAVA_HOME'} = $javahome;
-
-    require "$gsdlhome/perllib/util.pm";
-
-    my $gsdl_bin_script = &util::filename_cat($gsdlhome,"bin","script");
-    &util::envvar_append("PATH",$gsdl_bin_script);
-
-    my $gsdl_bin_os = &util::filename_cat($gsdlhome,"bin",$gsdlos);
-    &util::envvar_append("PATH",$gsdl_bin_os);
-
-    if ($gsdlos eq "windows") {
-	my $gsdl_perl_bin_directory = &util::filename_cat($gsdlhome, "bin", "windows", "perl", "bin");
-	&util::envvar_append("PATH", $gsdl_perl_bin_directory);
-    }
-    #else { # it's on linux now
-	#my $perlpath = $self->get_perl_path();
-	#&util::envvar_append("PATH", $perlpath);
-    #}
-}
-
-
-sub local_rm_r
-{
-    my $self = shift @_;
-    my ($local_dir) = @_;
-
-    my $prefix_dir = getcwd(); 
-    my $full_dir = &util::filename_cat($prefix_dir,$local_dir);
-    if ($prefix_dir !~ m/collect/) {
-	$self->generate_error("Trying to delete outside of Greenstone collect: $full_dir");
-    }
-
-    # Delete recursively
-    if (!-e $full_dir) {
-	$self->generate_error("File/Directory does not exist: $full_dir");
-    }
-
-    &util::rm_r($full_dir);
-}
-
-
-sub get_java_path()
-{
-    # Check the JAVA_HOME environment variable first
-    if (defined $ENV{'JAVA_HOME'}) {
-	my $java_home = $ENV{'JAVA_HOME'};
-	$java_home =~ s/\/$//;  # Remove trailing slash if present (Unix specific)
-	return &util::filename_cat($java_home, "bin", "java");
-    }
-
-    # Hope that Java is on the PATH
-    return "java";
-}
-
-
-sub check_java_home()
-{
-    # Return a warning unless the JAVA_HOME enrivonmen variable is set
-    if (!defined $ENV{'JAVA_HOME'}) {
-	return "JAVA_HOME environment variable not set. Might not be able to find Java unless in PATH (" . $ENV{'PATH'} . ")";
-    }
-
-    return "";
-}
-
-
-sub checked_chdir
-{
-    my $self = shift @_;
-    my ($dir) = @_;
-
-    if (!-e $dir) {
-	$self->generate_error("Directory '$dir' does not exist");
-    }
-
-    chdir $dir
-	|| $self->generate_error("Unable to change to directory: $dir");
-}
-
-sub rot13()
-{
-    my $self = shift @_;
-    my ($password)=@_;
-    my @password_arr=split(//,$password);
-    
-    my @encrypt_password;
-    foreach my $str (@password_arr){
-	my $char=unpack("c",$str);
-	if ($char>=97 && $char<=109){
-	    $char+=13;
-	}elsif ($char>=110 && $char<=122){
-	    $char-=13;
-	}elsif ($char>=65 && $char<=77){
-	    $char+=13;
-	}elsif ($char>=78 && $char<=90){
-	    $char-=13;
-	}
-	$char=pack("c",$char);
-	push(@encrypt_password,$char);
-    }
-    return join("",@encrypt_password);
-}
-
-
-1;
-
