#!/usr/bin/perl ######################################################################### #site Search #Version 2.00b #copyright 1997-1998 Krishnan Jayakrishnan. #All Rights Reserved #------------------------------------------------------------------------ #copyright Notice:- #site Search is a shareware program and may be used , modified or #distributed by anyone free of charge. site Search is provided on an #"as-is" basis and Krishnan Jayakrishnan makes no warranties either #expressed or implied with respect to the software's merchantablity or #fitness for any particular purpose. By using site Search, you agree to #indemnify Krishnan Jayakrishnan from any and all incidental or #consequential damages that may arise from its use. Please obtain a #written permission before selling this program.In all cases this #copyright Notice must remain intact. #------------------------------------------------------------------------ #Contact information #krishnan@bayou.uh.edu # #Krishnan . J #Allied Geophysical Labs #University of Houston #Houston TX77204-4231 #------------------------------------------------------------------------ #Version History #Intial Release on September 17th 1997 Version 1.00 #2nd Release on September 23rd 1997 Version 1.01 #3rd Release on September 25th 1997 Version 1.02 #4th Release on January 21nd 1998 Version 2.00b # #The latest version is available at http://www.agl.uh.edu/~saljxk/site_Search #------------------------------------------------------------------------ #Thanks To, # #B. G. Mahesh (www.mahesh.com), #Darron Hutchison (tm)(www.webmakers.com.au), #Cinnamon Chu, Tina Ma, #Bob Lenaerts, Patrice Serrano, #V.A. #------------------------------------------------------------------------ open(READ,"site_Search.conf ") or &Error_Module("1"); require("./site_Search.conf"); require ("cgi-lib.pl") or &Error_Module("2"); $version = "2.00b"; @months = (January,February,March,April,May,June,July,August,September,October,November,December); &Check_Configurations if($check_script eq "1"); &Clean_Scratch if($clean_scratch eq "1"); &Get_Search_Terms; &Get_Files_to_Search if($skip_search ne "1"); &Search_Files; &Display_Results1 if ((scalar(@file_names_to_display) == 0) || (scalar(@file_names_to_display) <= int($get_hits)) || ($get_hits =~ /all/i) || ($get_hits eq "") || ($multi_display eq "0")); &Display_Results2; # -:PRIMARY MODULES:- # ######################################################### # Module Checks for errors in configuration file # ######################################################### sub Check_Configurations{ print &Header; &Error_Module("3") if(!(-r "site_Search.desc") && ($desc1 eq "1")); &Error_Module("4") if(!(-d "$base_path") || !(-r "$base_path")); &Error_Module("5") if(scalar(@filetypes) == 0); if ($multi_display eq "1"){ &Error_Module("6") if(($scratch eq "") || !(-d "$base_path/$scratch") || !(-w "$base_path/$scratch") || !(-r "$base_path/$scratch")); } if ($record_usage eq "1"){ &Error_Module("7") if ((-e "site_Search.usage") && !(-w "site_Search.usage")); } &Error_Module("8") if ($path_to_searchform eq ""); &Error_Module("9") if ((($output_form eq "1") && ($form_to_use !~ /\binternal\b/)) && !(-r "$form_to_use")); ($name_of_URI = "http:\/\/" . $ENV{'HTTP_HOST'}) if (length($name_of_URI) == 0); print "
No errors were Found. However, the script only runs a simple check through the configuration file.
If you notice the script not working as intended please go through the files,
To run the script set the variable \"\$check_script\" to \"0\" in the configuration file.
" if ($errors ne "1"); print &Bottom; die; } ################################################# # Module Cleans the Scratch directory # ################################################# sub Clean_Scratch{ my @list; @list = <$base_path/$scratch/[1-9]*.html>; $^T = time; foreach (@list){ unlink($_) if (int(100*($age = -M)) > int(100*($empty_scratch))); } } ################################################# # Module Parses the Form Output # ################################################# sub Get_Search_Terms{ &ReadParse(*input); $search_terms = ($input{'Searchterms'}); @get_search_terms = split(/ /,$search_terms); $get_case = ($input{'Case'}); $get_construct = ($input{'Construct'}); if (defined $input{'OUTPUT_FORM'}){ $skip_search = $skip_hits = "1"; $get_hits = "ALL"; open(READ,$input{'List_File'}); @files_to_be_searched =Match(es) " . ($files_displayed+1) . " to " . ($files_displayed+$hits) . "
" if (($counter + $hits) < scalar(@file_names_to_display)); print $output "Match(es) " . ($files_displayed+1) . " to " . scalar(@file_names_to_display) . "
" if (($counter + $hits) > scalar(@file_names_to_display)); print $output " A Configuration file site_Search.conf could not be located in the current
directory, either the file is not present or does not have read permissions. To get help rectifying
the error, read the \"Errors\" section, (Error-1) of the \"readme.html\" file.
" if ($_[0] eq "1");
print "
Could not load the cgi-lib.pl library. To get help rectifying the error, read
read the \"Errors\" section, (Error-2) of the \"readme.html\" file.
" if ($_[0] eq "2");
print "
The description file site_Search.desc could not be opened for reading. There
could be a permission problem. To get help rectifying the error, read the \"Errors\" section, (Error-3) of
of the \"readme.html\" file.
" if ($_[0] eq "3");
print "
There is a problem with the base-path specified to start the search. To get help rectifying the error,
read the \"Errors\" section, (Error-4) of the \"readme.html\" file.
" if ($_[0] eq "4");
print "
No filetypes have been specified to search. To get help rectifying the error, read the \"Errors\" section,
(Error-5) of the \"readme.html\" file.
" if ($_[0] eq "5");
print "
There is a problem with the scratch directory specified. To get help rectifying the error, read the
\"Errors\" section, (Error-6) of the \"readme.html\" file.
" if ($_[0] eq "6");
print "
There is a problem recording the script usage. To get help rectifying the error, read the \"Errors\"
section, (Error-7) of the \"readme.html\" file.
" if ($_[0] eq "7");
print "
A HTTP Path to the search form was not specified. To get help rectifying the error, read the \"Errors\"
section, (Error-8) of the \"readme.html\" file.
" if ($_[0] eq "8");
print "
No Valid form was found at $form_to_use . To get help rectifying the error, read the \"Errors\"
section, (Error-9) of the \"readme.html\" file.
" if ($_[0] eq "9");
print "
No search terms were entered for search. Please use your browser's back button to go back to the form and search again or do a New Search.
No successful matches were found after the search. Please use your browser's back button to go back to the form and search again or do a New Search.