#!/usr/local/bin/perl -T -I. # # IF PERL IS IN A DIFFERENT LOCATION, CHANGE THE ABOVE LINE! # # search.cgi # # Script to generate form for searches and then process the input # and return a list of matching files. # #********* DO NOT CHANGE ANYTHING BELOW THIS LINE ********************# require 5.002; # Imports all the necessary variables use AutomatedArchiveSettings; use Time::Local; unshift(@INC, @LIBDIR); require 'cgi-lib.pl'; require 'txt2htmlLib.pl'; require 'fileProcessingLib.pl'; require 'convertLib.pl'; require 'archiveLib.pl'; require 'attributeLib.pl'; require 'formLib.pl'; # Need to set a default path if using taint checks $ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin'; # The name of the file to log to $LOGFILE = "$FILEDIR/searchLog"; # The name of this script $SCRIPTURL = &MyBaseUrl; ####### MAIN PROCESSING ##################################################### MAIN: { # If this is being run to generate quicksearch links, # prevent content-type headers from being printed out $outputToFile = 0; if ( defined($ENV{'QUICKSEARCH'}) && $ENV{'QUICKSEARCH'} =~ m/1/) { $outputToFile = 1; } my ( %cgi_data, # The form data %cgi_cfn, # The uploaded file(s) client-provided name(s) %cgi_ct, # The uploaded file(s) content-type(s). These are # set by the user's browser and may be unreliable %cgi_sfn, # The uploaded file(s) name(s) on the server (this machine) $ret, # Return value of the ReadParse call. $buf # Buffer for data read from disk. ); # Start off by reading and parsing the data. Save the return value. # Pass references to retreive the data, the filenames, and the content-type $ret = &ReadParse(\%cgi_data,\%cgi_cfn,\%cgi_ct,\%cgi_sfn); ######################################################################### ### PRINTING THE FORM ######################################################################### %cleanData = (); $ERRMSG = ""; if (!defined $ret || !$ret) { # Print out the form &printSearchForm; exit; ###################################################################### ### ERROR CHECKING AND INPUT CLEANUP ###################################################################### } elsif (! &cleanInput(0, \%cgi_data, \%cleanData, \%origData) ) { # The form input couldn't be cleaned. &CgiDie("Invalid or missing data\n", $INVALID_DATA_ERRMSG . "Specific error message: $ERRMSG

"); } ###################################################################### ### FINDING FILES AND PRINTING RESULTS ###################################################################### if ($DEBUG) { foreach $key (sort keys %cleanData) { &logMsg("$key: $cleanData{$key}"); } } # Read in the FILES hash $startTime = time; &readDB; $dbTime = time - $startTime; if ($DEBUG) { &logMsg("Time to read DB: $dbTime s"); } if (defined(%FILES) && ((scalar keys %FILES) >= 1) ) { # Print out the results, passing both the originally submitted # data from the form and the cleaned data &printSearchResults(\%origData, \%cleanData, \%FILES, $outputToFile); } else { &CgiDie("No files in archive", "There are no files in this archive!"); } }