#!C:\Perl\bin\perl use Cwd; use LWP::Simple qw(mirror getstore is_error status_message); #use warnings; #perl2exe_noopt "Opcode.pm" #perl2exe_exclude "ExtUtils/MM_MacOS.pm" #perl2exe_exclude "VMS/Filespec.pm" #perl2exe_exclude "vmsish.pm" #perl2exe_exclude "Mac/MoreFiles.pm" #perl2exe_exclude "Digest/Perl/MD5.pm" #perl2exe_exclude "Apache2/RequestRec.pm" #perl2exe_exclude "Apache2/RequestIO.pm" #perl2exe_exclude "Apache2/RequestUtil.pm" #perl2exe_exclude "APR/Pool.pm" #perl2exe_exclude "ModPerl/Util.pm" #perl2exe_exclude "Apache2/Response.pm" #perl2exe_exclude "Apache2/Response.pm" #perl2exe_exclude "Apache2/RequestRec.pm" #perl2exe_exclude "Apache2/RequestUtil.pm" #perl2exe_exclude "Apache2/RequestIO.pm" #perl2exe_exclude "APR/Pool.pm" #perl2exe_exclude "Apache2/RequestUtil.pm" #perl2exe_exclude "APR/Table.pm" #perl2exe_include "CGI/Session/Driver/file.pm" #perl2exe_include "CGI/Session/Serialize/default.pm" #perl2exe_include "bytes.pm" #perl2exe_include "CGI/Session/ID/md5.pm" #perl2exe_include "ExtUtils/MM_Win32.pm" #pxerl2exe_exclude "Compress/Bzip2.pm" #perl2exe_include "HTTP/Message.pm" #perl2exe_exclude "Carp/Heavy.pm" use CGI::Carp qw(fatalsToBrowser); use ExtUtils::Installed; ###### /usr/local/bin/perl5 is an unusual name for the perl interpreter. ###### on many systems, perl is located in /usr/bin/perl, and rarely ###### carries a numeric suffix. ###### ###### You can try executing "which perl" or "locate /perl" ###### to try and locate perl, if you don't know it's location ###### ###### NT systems do not use this facility, but instead rely entirely ###### on the extension of the file (hence the need to name the file ###### with a .pl extension on most NT web servers) ############################################ # Library Search 1.1.0 release 1 # # (c) copyright 1998-2000 NCP Technologies, # At Connex Global Communication Systems Inc, # Jaywil Software Dev. Inc. 1-800-815-8370 # # Derived from Library Search 1.0.1 release 1, 7-Feb-2002 # by CCj/Clearline. # ############################################################################# # Main Program Section # *NOTE* no changes are required in this file whatsoever.. view lib.conf ############################################################################# # Programming # Comments ############################################################################# # &PrintHeader1; # Print basic header info > WWW # check to see if CGI::Session is installed for password support my $UseSession = undef; my $installed = ExtUtils::Installed->new(); # print "and ..."; # if (grep(/CGI::Session/,$installed->modules() )) { $UseSession = true; # print "found it."; # } # # Find all the installed packages # print("Finding all installed modules...\n"); # my $installed2 = ExtUtils::Installed->new(); # foreach my $module ($installed2->modules) { # my $version = $installed2->version($module) || "???"; # print("Found module $module Version $version\n"); # } # $libConf = "lib.conf"; # Find the configuration file. # Original file path check for Unix-type servers & some NT servers too ($libConf = $ENV{PATH_TRANSLATED}) =~ s/[^\\]*$/lib.conf/ unless ( -e $libConf); # Jan 20/2004 M.Whiting. Add a separate check to find lib.conf for NT servers, as # they just don't seem to find it with the Unix check. The check has never failed on # Unix, so we've left it alone for them. $FileCheckCount = 0; unless (-e $libConf) { &FindConf; } &GetQueryData; &PrintHeader1; # Print basic header info > WWW ###### $virtual and $logoImage are used to describe web content on the forms ###### generated by this script. They may be overridden by the config ###### variables VIRTUAL and LOGO_IMAGE respectively. Note the trailing ###### slash for virtual. $virtual = "http://www.google.com/search/"; $logoImage = "logo.gif"; ###### These two variables are new -- NT requires that certain types of ###### executables have certain extensions, and it also requires ###### backslashes as directory separators. These variables here are the UNIX ###### defaults. The config file variables CGISCRIPT, and DIRSEP ###### will override these defaults on any platform, and must be defined on NT. $script = "libsearch.cgi"; $dirsep = "/"; ###### $countpath defines the path to your count directory. Reads the value of ###### "pwd" to assign the correct count -- each new library created will have ###### a unique value, and this script will automatically generate a count data ###### file if it doesn't exist. Define COUNTPATH in the config file to ###### override this default. Note that on UNIX this may be a relative ###### pathname. On NT it must be a fully qualified pathname. $countpath = "tmp"; ###### Similarly these are defaults for the mail program, the organisation ###### name, and a URL to associate with the organisation's name. They ###### may be overriden by the MAILPROG, ORG_NAME, and ORG_URL config ###### vars respectively. $mailProg = "/usr/sbin/sendmail -t"; $orgName = "Our Favourite Org, Inc."; $orgUrl = "http://www.google.com/"; ###### Defaults for the search field labels, overridden by the SEARCH_FIELD_LABEL1, ###### SEARCH_FIELD_LABEL2, etc, values in lib.conf. $SearchFieldLabel1 = "Title"; $SearchFieldLabel2 = "Author"; $SearchFieldLabel3 = "Category"; $SearchFieldLabel4 = "Subject"; $SearchFieldLabel5 = "Dewey"; $SearchFieldLabel6 = "ISBN"; $SearchFieldLabel7 = "Publisher"; $SearchFieldLabel8 = "User1"; ###### Seven more search fields added. Nov.20/2006. M.Whiting ###### ($SearchFieldDisplayed and $SearchFieldSearchable defaults not declared here, ###### code is written to effectively default to Y for both) $SearchFieldLabel9 = "User2"; $SearchFieldLabel10 = "User3"; $SearchFieldLabel11 = "User4"; $SearchFieldLabel12 = "User5"; $SearchFieldLabel13 = "User6"; $SearchFieldLabel14 = "User7"; ###### Default for whether or not to show the 'request a book' area on the search results page. $AllowRequests = "Y"; ###### New variables, may be overridden by conf.var. April 2007. M.Whiting $ConfigIn{'SCREEN_BGCOLOR'} = 'White'; $ConfigIn{'GENERAL_FONT_TYPE'} = 'Verdana'; $ConfigIn{'GENERAL_FONT_SIZE'} = '10pt'; $ConfigIn{'GENERAL_FONT_COLOR'} = 'Black'; $ConfigIn{'GENERAL_FONT_COLOR'} = 'Black'; $ConfigIn{'SHOW_ABOUT_LINK'} = 'N'; $ConfigIn{'SHOW_LIST_LIBRARIES_LINK'} = 'N'; $ConfigIn{'SHOW_CONTACT_ADMIN_LINK'} = 'N'; $ConfigIn{'SHOW_SEARCH_LINK'} = 'Y'; $ConfigIn{'SHOW_VISITOR_NUMBER'} = 'N'; $ConfigIn{'SHOW_TOTAL_LIBRARY_DATABASES'} = 'N'; $ConfigIn{'TEXT_ABOUT_LINK'} = 'About'; $ConfigIn{'TEXT_LIST_LIBRARIES_LINK'} = 'List Libraries'; $ConfigIn{'TEXT_CONTACT_ADMIN_LINK'} = 'Contact Admin'; $ConfigIn{'TEXT_SEARCH_LINK'} = 'Search'; $ConfigIn{'TEXT_VISITOR_NUMBER'} = 'Visitor Number:'; $ConfigIn{'TEXT_TOTAL_LIBRARY_DATABASES'} = 'Total Library Databases:'; $ConfigIn{'SHOW_PASSWORD_REQUIRED'} = 'Y'; $ConfigIn{'TEXT_PASSWORD_REQUIRED'} = 'Password Required'; $ConfigIn{'TEXT_NO_PASSWORD_REQUIRED'} = 'No Password'; $ConfigIn{'PASSWORD_TIMEOUT'} = '10m'; $ConfigIn{'SHOW_NUM_DATABASE_ITEMS'} = 'Y'; $ConfigIn{'RESULTSPAGE_TEXT_PREV_BUTTON'} = 'Prev'; $ConfigIn{'RESULTSPAGE_TEXT_NEXT_BUTTON'} = 'Next'; $ConfigIn{'SEARCHPAGE_SHOW_SEARCH_LIBRARY'} = 'Y'; $ConfigIn{'SEARCHPAGE_TEXT_SEARCH'} = 'Search'; $ConfigIn{'SEARCHPAGE_TEXT_LIBRARY_NAME'} = 'Shell Point Library'; #leave blank for dynamic name generation $ConfigIn{'SEARCHPAGE_SHOW_ENTER_FIELDS'} = 'Y'; $ConfigIn{'SEARCHPAGE_TEXT_ENTER_FIELDS'} = 'Enter field(s) to search, select the checkbox for an exact phrase match'; $ConfigIn{'SEARCHPAGE_SHOW_EXACT_PHRASE_CHECKBOX'} = 'Y'; $ConfigIn{'SEARCHPAGE_TEXT_SEARCH_BUTTON'} = 'Search'; $ConfigIn{'SEARCHPAGE_TEXT_CLEAR_BUTTON'} = 'Clear'; $ConfigIn{'RESULTSPAGE_SHOW_LIBRARY_NAME'} = 'Y'; $ConfigIn{'RESULTSPAGE_TEXT_LIBRARY_NAME'} = 'Shell Point Library'; #leave blank for dynamic name generation $ConfigIn{'RESULTSPAGE_SHOW_YOUR_SEARCH_FOUND'} = 'Y'; $ConfigIn{'RESULTSPAGE_TEXT_YOUR_SEARCH_FOUND'} = 'Your Search Found'; $ConfigIn{'RESULTSPAGE_TEXT_MATCHES'} = 'Match(es)'; $ConfigIn{'RESULTSPAGE_TEXT_REQUEST_NAME'} = 'Name:'; $ConfigIn{'RESULTSPAGE_TEXT_REQUEST_EMAIL'} = 'Phone Number/Email Address:'; $ConfigIn{'RESULTSPAGE_TEXT_REQUEST_COMMENTS'} = 'Comments:'; $ConfigIn{'RESULTSPAGE_TEXT_REQUEST_BUTTON'} = 'Request To Borrow Checked Item(s)'; $ConfigIn{'RESULTSPAGE_TEXT_RESULT_#'} = 'Result #'; $ConfigIn{'RESULTSPAGE_SHOW_RESULT_#'} = 'Y'; $ConfigIn{'RESULTSPAGE_TEXT_FROM'} = ', from'; $ConfigIn{'RESULTSPAGE_TEXT_DATABASE'} = ''; $ConfigIn{'REQUESTPAGE_TEXT_REQUESTING'} = 'Requesting Item(s):'; $ConfigIn{'REQUESTPAGE_TEXT_THANKYOU'} = 'Your Items Have Been Requested, Thank You'; $ConfigIn{'RESULTSPAGE_TEXT_RETURN'} = "(Please press your browser's \'Back\' button
to return to Search Results)"; $ConfigIn{'EMAIL_TEXT_BORROW'} = 'Borrow Request'; $ConfigIn{'EMAIL_TEXT_TITLE1'} = '******************************************************'; $ConfigIn{'EMAIL_TEXT_TITLE2'} = ' Borrow Request Form'; $ConfigIn{'EMAIL_TEXT_TITLE3'} = ' from Library Search'; $ConfigIn{'EMAIL_TEXT_TITLE4'} = '******************************************************'; $ConfigIn{'EMAIL_TEXT_LIBRARY'} = 'Library : '; $ConfigIn{'EMAIL_TEXT_NAME'} = 'Name Of Requestor: '; $ConfigIn{'EMAIL_TEXT_EMAIL'} = 'Phone/Email : '; $ConfigIn{'EMAIL_TEXT_DATE'} = 'Date/Time : '; $ConfigIn{'EMAIL_TEXT_FOOTER1'} = '******************************************************'; $ConfigIn{'EMAIL_TEXT_COMMENTS'} = 'COMMENTS: '; $ConfigIn{'EMAIL_TEXT_REQUESTED_ITEM'} = '***************** Requested Item *****************'; $ConfigIn{'EMAIL_FIELD_DETAIL_LINE1'} = 1; $ConfigIn{'EMAIL_FIELD_DETAIL_LINE2'} = 2; $ConfigIn{'EMAIL_FIELD_DETAIL_LINE3'} = 5; $ConfigIn{'EMAIL_FIELD_DETAIL_LINE4'} = 6; $ConfigIn{'EMAIL_FIELD_DETAIL_LINE5'} = 0; $ConfigIn{'EMAIL_FIELD_DETAIL_LINE6'} = 0; $ConfigIn{'EMAIL_FIELD_DETAIL_LINE7'} = 0; $ConfigIn{'EMAIL_FIELD_DETAIL_LINE8'} = 0; $ConfigIn{'EMAIL_FIELD_DETAIL_LINE9'} = 0; $ConfigIn{'EMAIL_FIELD_DETAIL_LINE10'} = 0; $ConfigIn{'EMAIL_FIELD_DETAIL_LINE11'} = 0; $ConfigIn{'EMAIL_FIELD_DETAIL_LINE12'} = 0; $ConfigIn{'EMAIL_FIELD_DETAIL_LINE13'} = 0; $ConfigIn{'EMAIL_FIELD_DETAIL_LINE14'} = 0; # # Set up name arrays for weekdays and month names. # @weekdays=( "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"); @months=( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); # # Translate timezone-localized 'time' into a "struct tm" array. # ($sec, $min, $hour, $mday, $month, $year, $wday, $yday, $ds) = localtime(time); if ($sec < 10) {$sec = ("0$sec");} # Put a zero in front of the seconds, if needed to make 2 digits if ($min < 10) {$min = ("0$min");} # Same with minutes # # Save the year for use in the copyright message. # $cpr_year=1900+$year; # # Generate a datestring for use when generating mail. # $mailheader_date="$weekdays[$wday], $mday $months[$month] $cpr_year " . "$hour:$min:$sec"; &ReadConf; &PrintLinks; # Print The Commands > WWW &PerformAction; # perform the specified action. or default. &PrintFooter; # Print The Footer Information > WWW exit; ############################################################################# # Sub Procedures ############################################################ ############################################################################# ############################################ # PrintHeader # Purpose: To print the initial html code # at the top of the page. ############################################ sub PrintHeader1 { print "Content-type: text/html\n\n"; print < Library Search NCP } sub PrintHeader2 { print < NCP print " \n"; # print " \n"; print "
\n"; print "

\n"; } ############################################ # PrintLinks # Purpose: To Print the available commands # to the screen. ############################################ sub PrintLinks { print " "; if ($ConfigIn{'SHOW_ABOUT_LINK'} =~ /^y/i) {print "[$ConfigIn{'TEXT_ABOUT_LINK'}] ";} if ($ConfigIn{'SHOW_LIST_LIBRARIES_LINK'} =~ /^y/i) {print "[$ConfigIn{'TEXT_LIST_LIBRARIES_LINK'}] ";} if ($ConfigIn{'SHOW_CONTACT_ADMIN_LINK'} =~ /^y/i) {print "[$ConfigIn{'TEXT_CONTACT_ADMIN_LINK'}] ";} if ($ConfigIn{'SHOW_SEARCH_LINK'} =~ /^y/i) { if ($in{'dbNum'} ne '') { print "[$ConfigIn{'TEXT_SEARCH_LINK'}] "; } } print "\n
\n"; } ############################################ # PerformAction # Purpose: To perform the action requested # ############################################ sub PerformAction { if ($in{'action'} < 2 or $in{'action'} > 5) { &ListDatabases; return; } if ($in{'dbNum'} eq '' or $in{'dbNum'} < 1 or $in{'dbNum'} > $NumDbLineNames) { &ListDatabases; return; } my $LoggedIn = undef; if ($databasedata[($in{'dbNum'}*10)+2] eq '*' or $pwd eq $databasedata[($in{'dbNum'}*10)+2]) { $LoggedIn = 1; } unless ($LoggedIn) { if (defined $in{'CGISESSID'} or defined $in{'pwd'}) { print "

Invalid Password"; } &PrintLoginForm; } else { # Get the number of fields in database. Newer db's have 21 fields instead of 14. # The extra search boxes are only displayed if fields are present on file. foreach $LibName (@{$DbLineNames[$in{'dbNum'}]}) { open(SEARCH, $LibDef{$LibName}[2]); $NumDbFields = scalar(split(/\t/, )); close(SEARCH); #print "
Lib Name:$LibName, Lib Filename:$LibDef{$LibName}[2] - $NumDbFields
"; #print "
$NumDbFields"; if ($NumDbFields != 14 && $NumDbFields != 21) { print "

Unrecognized number of data fields in database file: $NumDbFields"; print "
(Database filename: $LibDef{$LibName}[2])"; print "

Please contact Jaywil at info\@jaywil.com for an update or to resolve this problem.

"; &PrintFooter; exit; } $LibDef{$LibName}[3] = $NumDbFields; #Assigned here instead of in ReadConf so user can search db's that have correct #'s of fields $MaxNumDbFields = $NumDbFields if $NumDbFields > $MaxNumDbFields; } if ($in{'action'} eq 3) { &SearchForm; } if ($in{'action'} eq 4) { &SearchResults; } if ($in{'action'} eq 5) { if (defined $in{'BtnPrev'}) { # $carryon=1; &SearchResults; } elsif (defined $in{'BtnNext'}) { # $carryon=1; &SearchResults; } elsif (defined ($in{'BtnRequest'})) { &makeRequest; } else { # Redisplay search results, if any other button is pressed. # $carryon=1; &SearchResults; } } } } ############################################ # SearchForm # Purpose: To Get Database Searching info # from the viewer. ############################################ sub SearchForm { if ($ConfigIn{'SHOW_VISITOR_NUMBER'} =~ /^y/i) { print "

$ConfigIn{'TEXT_VISITOR_NUMBER'} " .&getCounterValue("count-lib-$databasedata[$in{'dbNum'}*10].txt") ."

"; } if ($ConfigIn{'SEARCHPAGE_SHOW_SEARCH_LIBRARY'} =~ /^y/i) { print "

$ConfigIn{'SEARCHPAGE_TEXT_SEARCH'} "; if ($ConfigIn{'SEARCHPAGE_TEXT_LIBRARY_NAME'} eq '') { print $databasedata[$in{'dbNum'}*10]; } else { print $ConfigIn{'SEARCHPAGE_TEXT_LIBRARY_NAME'}; } print "

"; } if ($ConfigIn{'SEARCHPAGE_SHOW_ENTER_FIELDS'} =~ /^y/i) { print "

$ConfigIn{'SEARCHPAGE_TEXT_ENTER_FIELDS'}

"; } print < NCP if (defined $sid) { print ""; } elsif (defined $in{'pwd'}) { print ""; } print < NCP for ($i=1;$i<=14;$i++) { last if ($MaxNumDbFields == 14 && $i == 8); if (eval("\$SearchFieldSearchable$i") ne "N") { print " " . chr(13); print " " . eval("\$SearchFieldLabel$i") . ":" . chr(13); print "   "; if ($ConfigIn{'SEARCHPAGE_SHOW_EXACT_PHRASE_CHECKBOX'} =~ /^y/i) { print ""; } print "" . chr(13); print " " . chr(13); } } print <
NCP } ############################################ # SearchResults # Purpose: To find entries.. # ############################################ sub SearchResults { if (defined $in{'BtnNext'}) { $FirstNumDisplayed=$in{'PrevFirstNum'}+10; } if (defined $in{'BtnPrev'}) { $FirstNumDisplayed=$in{'PrevFirstNum'}-10; } &SearchDatabase; if ($ConfigIn{'RESULTSPAGE_SHOW_LIBRARY_NAME'} =~ /^y/i) { print "

"; if ($ConfigIn{'RESULTSPAGE_TEXT_LIBRARY_NAME'} eq '') { print $databasedata[$in{'dbNum'}*10]; } else { print $ConfigIn{'RESULTSPAGE_TEXT_LIBRARY_NAME'}; } print "

\n"; } if ($ConfigIn{'RESULTSPAGE_SHOW_YOUR_SEARCH_FOUND'} =~ /^y/i) { print "

$ConfigIn{'RESULTSPAGE_TEXT_YOUR_SEARCH_FOUND'} $NumBooksFound $ConfigIn{'RESULTSPAGE_TEXT_MATCHES'}

"; } if ($NumBooksFound eq 0) { &PrintFooter; exit(0); } if ($FirstNumDisplayed > $NumBooksFound) { $FirstNumDisplayed = $NumBooksFound; } if (($FirstNumDisplayed) <= 0) { $FirstNumDisplayed = 1; } $LastNumDisplayed = $FirstNumDisplayed + 9; if ($LastNumDisplayed > $NumBooksFound) { $LastNumDisplayed = $NumBooksFound; } print "$FirstNumDisplayed-$LastNumDisplayed of $NumBooksFound "; print "
"; print ""; print ""; if (defined $sid) { print ""; } elsif (defined $in{'pwd'}) { print ""; } for ($i=1;$i<=14;$i++) { last if ($NumDbFields == 14 && $i == 8); $FieldValue = eval("\$in{Field$i}"); if ($FieldValue ne "") { print ""; } if (eval("\$in{chkExactMatch$i}") ne "") { print ""; } } print ""; # Print request-a-book area, if it has not be turned off in lib.conf; if ($AllowRequests =~ /^Y/i) { print <
NCP print " \n"; print " \n"; print " \n \n"; print " \n"; print " \n"; print <
$ConfigIn{'RESULTSPAGE_TEXT_REQUEST_NAME'}    $ConfigIn{'RESULTSPAGE_TEXT_REQUEST_EMAIL'}
$ConfigIn{'RESULTSPAGE_TEXT_REQUEST_COMMENTS'}
" . chr(13); print "
NCP # Print the books which have already been checked. # if ($carryon eq 1) { print " \n"; for ($QryStrReqNum=1;$QryStrReqNum<$NumBooksFound;$QryStrReqNum++) { if ($in{$QryStrReqNum} eq "on") { print " \n"; print " \n \n \n"; } } print "
  • Checked: $SearchResults[($QryStrReqNum*22+1)]   
  • (#$QryStrReqNum"; if (defined $LibDef{$LibName}[1]) { # if (defined $DbLineNames[$in{'dbNum'}][1]) { -delete this line if no problems print ", from '$SearchResults[($QryStrReqNum*22)]'"; } print ")"; # Only print the field for the 'xx=on' query string item if we're not going to be printing it later as part of this screen's search results. if ($QryStrReqNum < $FirstNumDisplayed || $QryStrReqNum > $LastNumDisplayed) { print ""; } print "
    \n"; # } print "

    " . chr(13); } # End of Request-a-book area. print "
    "; # Print buttons at top of page if ($LastNumDisplayed <= 10) {$DisablePrev = 'disabled'}; print " " . chr(13); if ($LastNumDisplayed == $NumBooksFound) {$DisableNext = 'disabled'}; print " " . chr(13); print "
    "; # Start looping through search results for ($SearchResultNum=$FirstNumDisplayed;$SearchResultNum<=$LastNumDisplayed;$SearchResultNum++) { print " " . chr(13); print " "; # Setup checkbox code for requesting books, if requesting not turned off if ($AllowRequests =~ /^Y/i) { $RequestBoxCode = " "; } if ($SearchFieldDisplayed1 ne "N") { print " " . chr(13); } if ($SearchFieldDisplayed2 ne "N") { print " " . chr(13); } if ($SearchFieldDisplayed3 ne "N") { print " " . chr(13); } if ($SearchFieldDisplayed4 ne "N") { print " " . chr(13); } if ($SearchFieldDisplayed5 ne "N") { print " " . chr(13); } if ($SearchFieldDisplayed6 ne "N") { print " " . chr(13); } if ($SearchFieldDisplayed7 ne "N") { print " " . chr(13); } # 7 new fields. Nov 30/2006. M.Whiting # if ($LibDef{$SearchResults[($SearchResultNum*22)]}[3] > 14) { ($_ = $SearchResults[($SearchResultNum*22)]) =~ tr/a-z/A-Z/; if ($LibDef{$_}[3] > 14) { # if ($LibDef{$SearchResults[($SearchResultNum*22)]}[3] > 14) { for ($i=8; $i<=14 ; $i++) { if (eval("\$SearchFieldDisplayed$i") ne "N") { print " " . chr(13); } } } print "
    $ConfigIn{'RESULTSPAGE_TEXT_RESULT_#'}"; if ($ConfigIn{'RESULTSPAGE_SHOW_RESULT_#'} =~ /^y/i) { print $SearchResultNum; } if (defined $DbLineNames[$in{'dbNum'}][1]) { print "$ConfigIn{'RESULTSPAGE_TEXT_FROM'}"; if ($ConfigIn{'RESULTSPAGE_TEXT_DATABASE'} eq '') { print " '$SearchResults[($SearchResultNum*22)]'"; } else { print "$ConfigIn{'RESULTSPAGE_TEXT_DATABASE'}"; } } print "
    $RequestBoxCode"; $RequestBoxCode = ""; print "$SearchFieldLabel1 $SearchResults[($SearchResultNum*22)+1]"; if ($SearchResults[($SearchResultNum*22)+2] ne '') {print " : $SearchResults[($SearchResultNum*22)+2]";} if ($SearchResults[($SearchResultNum*22)+3] ne '') {print " ($SearchResults[($SearchResultNum*22)+3])";} print "
    $RequestBoxCode"; $RequestBoxCode = ""; print "$SearchFieldLabel2 $SearchResults[($SearchResultNum*22)+4]"; if ($SearchResults[($SearchResultNum*22)+5] ne '') { print ", $SearchResults[($SearchResultNum*22)+5]"; } if ($SearchResults[($SearchResultNum*22)+6] ne '') { print ", $SearchResults[($SearchResultNum*22)+6]"; } print "
    $RequestBoxCode"; $RequestBoxCode = ""; print "$SearchFieldLabel3$SearchResults[($SearchResultNum*22)+8]
    $RequestBoxCode"; $RequestBoxCode = ""; print "$SearchFieldLabel4 $SearchResults[($SearchResultNum*22)+11]"; if ($SearchResults[($SearchResultNum*22)+12] ne '') {print "
    $SearchResults[($SearchResultNum*22)+12]";} if ($SearchResults[($SearchResultNum*22)+13] ne '') {print "
    $SearchResults[($SearchResultNum*22)+13]";} if ($SearchResults[($SearchResultNum*22)+14] ne '') {print "
    $SearchResults[($SearchResultNum*22)+14]";} print "
    $RequestBoxCode"; $RequestBoxCode = ""; print "$SearchFieldLabel5 $SearchResults[($SearchResultNum*22)+9]
    $RequestBoxCode"; $RequestBoxCode = ""; print "$SearchFieldLabel6 $SearchResults[($SearchResultNum*22)+10]
    $RequestBoxCode"; $RequestBoxCode = ""; print "$SearchFieldLabel7$SearchResults[($SearchResultNum*22)+7]
    $RequestBoxCode"; $RequestBoxCode = ""; print eval("\$SearchFieldLabel$i") . "$SearchResults[($SearchResultNum*22)+7+$i]

    " . chr(13); } if ($LastNumDisplayed <= 10) {$DisablePrev = 'disabled'}; print " " . chr(13); if ($LastNumDisplayed == $NumBooksFound) {$DisableNext = 'disabled'}; print " " . chr(13); print " " . chr(13); } ############################################ # SearchDatabase # Purpose: Does the actual search # ############################################ sub SearchDatabase { # Bail if all the match strings are empty. $ValidFieldFound = ""; foreach ($in{'Field1'},$in{'Field2'},$in{'Field3'},$in{'Field4'}, $in{'Field5'},$in{'Field6'},$in{'Field7'},$in{'Field8'}, $in{'Field9'},$in{'Field10'},$in{'Field11'},$in{'Field12'}, $in{'Field13'},$in{'Field14'}) { $_ =~ s/(^\s+|\s+$)//; # Strip any leadIng & trailing whitespace from each field if ($_ ne '') {$ValidFieldFound = "Y";} } unless ($ValidFieldFound) { print "

    No search parameters given!

    "; &PrintFooter; exit; } # Set the book counter and an initial empty slot of # the @SearchResults array. The rest of the code elsewhere in this script # doesn't seem to BELIEVE in zero-based perl arrays. # $NumBooksFound=0; push(@SearchResults, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""); # Open the database file and read it line by line. Try to match every # criteria against each line. If all criteria match a line, push() that # line into the @SearchResults array. # foreach $LibName (@{$DbLineNames[$in{'dbNum'}]}) { open (SEARCH, $LibDef{$LibName}[2]); while () { @BookDataFields = split(/\t/, $_); foreach (@BookDataFields) {s/^\"//; s/\"$//;}; #Remove doublequotes from db fields, they screw up checking for whitespace at start/end of field #Start searching next if ($in{'Field1'} ne '' #By default, the Title search field && $BookDataFields[0] !~ m/(\A|$in{chkExactMatch1})$in{'Field1'}(\Z|$in{chkExactMatch1})/i && $BookDataFields[1] !~ m/(\A|$in{chkExactMatch1})$in{'Field1'}(\Z|$in{chkExactMatch1})/i && $BookDataFields[2] !~ m/(\A|$in{chkExactMatch1})$in{'Field1'}(\Z|$in{chkExactMatch1})/i); next if ($in{'Field2'} ne '' #By default, the Author search field && $BookDataFields[3] !~ m/(\A|$in{chkExactMatch2})$in{'Field2'}(\Z|$in{chkExactMatch2})/i && $BookDataFields[4] !~ m/(\A|$in{chkExactMatch2})$in{'Field2'}(\Z|$in{chkExactMatch2})/i && $BookDataFields[5] !~ m/(\A|$in{chkExactMatch2})$in{'Field2'}(\Z|$in{chkExactMatch2})/i); next if ($in{'Field3'} ne '' && $BookDataFields[7] !~ m/(\A|$in{chkExactMatch3})$in{'Field3'}(\Z|$in{chkExactMatch3})/i); #By def, Category next if ($in{'Field4'} ne '' #By default, the Subject search field && $BookDataFields[10] !~ m/(\A|$in{chkExactMatch4})$in{'Field4'}(\Z|$in{chkExactMatch4})/i && $BookDataFields[11] !~ m/(\A|$in{chkExactMatch4})$in{'Field4'}(\Z|$in{chkExactMatch4})/i && $BookDataFields[12] !~ m/(\A|$in{chkExactMatch4})$in{'Field4'}(\Z|$in{chkExactMatch4})/i && $BookDataFields[13] !~ m/(\A|$in{chkExactMatch4})$in{'Field4'}(\Z|$in{chkExactMatch4})/i); $in{chkExactMatch5} =~ s/.+/\\s/; #Dewey 'exact-match' filter only searches for whitespace, as periods are signicant in Dewey's. next if ($in{'Field5'} ne '' && $BookDataFields[8] !~ m/(\A|$in{chkExactMatch5})$in{'Field5'}(\Z|$in{chkExactMatch5})/i); #By def, Dewey next if ($in{'Field6'} ne '' && $BookDataFields[9] !~ m/(\A|$in{chkExactMatch6})$in{'Field6'}(\Z|$in{chkExactMatch6})/i); #By def, ISBN next if ($in{'Field7'} ne '' && $BookDataFields[6] !~ m/(\A|$in{chkExactMatch7})$in{'Field7'}(\Z|$in{chkExactMatch7})/i); #By def, Publisher # Nov.20/2006. M.Whiting. Seven new fields added to the data file exported from RM. # Check if new format before trying to do search. if ($LibDef{$LibName}[3] > 14) { next if ($in{'Field8'} ne '' && $BookDataFields[14] !~ m/(\A|$in{chkExactMatch8})$in{'Field8'}(\Z|$in{chkExactMatch8})/i); next if ($in{'Field9'} ne '' && $BookDataFields[15] !~ m/(\A|$in{chkExactMatch9})$in{'Field9'}(\Z|$in{chkExactMatch9})/i); next if ($in{'Field10'} ne '' && $BookDataFields[16] !~ m/(\A|$in{chkExactMatch10})$in{'Field10'}(\Z|$in{chkExactMatch10})/i); next if ($in{'Field11'} ne '' && $BookDataFields[17] !~ m/(\A|$in{chkExactMatch11})$in{'Field11'}(\Z|$in{chkExactMatch11})/i); next if ($in{'Field12'} ne '' && $BookDataFields[18] !~ m/(\A|$in{chkExactMatch12})$in{'Field12'}(\Z|$in{chkExactMatch12})/i); next if ($in{'Field13'} ne '' && $BookDataFields[19] !~ m/(\A|$in{chkExactMatch13})$in{'Field13'}(\Z|$in{chkExactMatch13})/i); next if ($in{'Field14'} ne '' && $BookDataFields[20] !~ m/(\A|$in{chkExactMatch14})$in{'Field14'}(\Z|$in{chkExactMatch14})/i); } # If we get to this point we have a match. $NumBooksFound++; # Add the extra 7 slots for older libsearch databases. if ($LibDef{$LibName}[3] == 14) { push(@BookDataFields, "", "", "", "", "", "", ""); } # Push library name into first of 22 slots allotted for this book result push(@SearchResults, $LibDef{$LibName}[0]); # Push @BookDataFields into the other 21 slots of the array push(@SearchResults, @BookDataFields); } close(SEARCH); } } ############################################ # PrintFooter # Purpose: To Print The footer info to the # WWW ############################################ sub PrintFooter { print <


    (c) copyright $cpr_year Shell Point Retirement Community

    Click here to return to $orgName.

    NCP } ############################################ # ListDatabases # Purpose: To list the available databases # ############################################ sub ListDatabases { if ($ConfigIn{'SHOW_VISITOR_NUMBER'} =~ /^y/i) { print "

    $ConfigIn{'TEXT_VISITOR_NUMBER'} ".&getCounterValue("count-list-libs.txt")."

    \n"; } if ($ConfigIn{'SHOW_TOTAL_LIBRARY_DATABASES'} =~ /^y/i) { print "

    $ConfigIn{'TEXT_TOTAL_LIBRARY_DATABASES'} $NumDbLineNames

    "; } for ($a=1;$a<=$NumDbLineNames;$a++) { if (($databasedata[($a*10)+2] eq "*") || ($databasedata[($a*10)+2] eq "")) { print "

    $databasedata[($a*10)+0]"; } else { print "

    $databasedata[($a*10)+0]"; } if (($ConfigIn{'SHOW_NUM_DATABASE_ITEMS'} eq "Y") || ($ConfigIn{'SHOW_PASSWORD_REQUIRED'} eq "Y")) { print " -"; } if ($ConfigIn{'SHOW_PASSWORD_REQUIRED'} eq "Y") { print " ("; if (($databasedata[($a*10)+2] ne "*") && ($databasedata[($a*10)+2] ne "")) { print "$ConfigIn{'TEXT_PASSWORD_REQUIRED'}"; } else { print $ConfigIn{'TEXT_NO_PASSWORD_REQUIRED'}; } print ")"; } if ($ConfigIn{'SHOW_NUM_DATABASE_ITEMS'} eq "Y") { print " [$databasedata[($a*10)+6] item(s)]"; } } } ############################################ # makeRequest # Purpose: Request Item(s) # ############################################ sub makeRequest { if (($in{'name'} eq '') || ($in{'email'} eq '')) { $errMsg = " Missing Email/Phone or Name
    \n" } &SearchDatabase; $selected = 0; for($a=1;$a<=$NumBooksFound;$a++) { if ($in{$a} eq "on") { $selected++; } } if ($selected==0) { $errMsg = " No Items Selected!
    \n"; } if (defined $errMsg) { print $errMsg; print "Please hit the back button on your browser and make the\n"; print "necessary corrections\n"; return; } print "$databasedata[($in{'dbNum'}*10)+0]

    "; print "$ConfigIn{'REQUESTPAGE_TEXT_REQUESTING'}

    "; $i=0; for($a=1;$a<=$NumBooksFound;$a++) { if ($in{$a} eq "on") { print " $SearchResults[($a*22+1)]
    "; } } foreach $LibName (@{$DbLineNames[$in{'dbNum'}]}) { $FoundOne = "N"; for($a=1;$a<=$NumBooksFound;$a++) { if (($in{$a} eq "on") && ($SearchResults[($a*22)] eq $LibDef{$LibName}[0])) { $FoundOne = "Y"; #print "
    Found: $a, $SearchResults[($a*22)]"; } } next if $FoundOne eq "N"; open (MAIL, "|$mailProg") || die "Can't create pipe to $mailProg!\n"; print MAIL "Date: $mailheader_date -0500\n"; # Print only the email address, if so requested from lib.conf. Some servers don't handle the # presence of the person's real-life name very well. May 18/2004-M.Whiting $recipient = $LibDef{$LibName}[1]; # delete this line if no problems April 10/08 # $recipient = $LibDef{$DbLineNames[$in{'dbNum'}][$DbLineFileNum]}[1]; # print "
    sending re:$LibName to [$recipient]"; if ($SmblatEmailOnly =~ /^Y/i) { print MAIL "To: $recipient\n"; print MAIL "From: $adminEmail\n"; } else { print MAIL "To: Library Admin <$recipient>\n"; print MAIL "From: $adminName <$adminEmail>\n"; } print MAIL "Subject: $ConfigIn{'EMAIL_TEXT_BORROW'}\n"; print MAIL "Organization: $orgName\n"; # Pass an instruction to the smblat program, if requested from lib.conf print MAIL "SMTPServer: $SMTPServer\n" if (defined $SMTPServer); # Add a parameter to instruct the smblat program, if requested from lib.conf - May 18/2004-M.Whiting print MAIL "SmblatDebug: $SmblatDebug\n" if (defined $SmblatDebug); print MAIL "\n"; print MAIL "$ConfigIn{'EMAIL_TEXT_TITLE1'}\n"; print MAIL "$ConfigIn{'EMAIL_TEXT_TITLE2'}\n"; print MAIL "$ConfigIn{'EMAIL_TEXT_TITLE3'}\n"; print MAIL "$ConfigIn{'EMAIL_TEXT_TITLE4'}\n"; # print MAIL "$ConfigIn{'EMAIL_TEXT_LIBRARY'}$DbLineNames[$in{'dbNum'}][$DbLineFileNum]\n"; print MAIL "$ConfigIn{'EMAIL_TEXT_LIBRARY'}$LibDef{$LibName}[0]\n"; print MAIL "$ConfigIn{'EMAIL_TEXT_NAME'}$in{'name'}\n"; print MAIL "$ConfigIn{'EMAIL_TEXT_EMAIL'}$in{'email'}\n"; print MAIL "$ConfigIn{'EMAIL_TEXT_DATE'}$mailheader_date\n"; print MAIL "$ConfigIn{'EMAIL_TEXT_FOOTER1'}\n"; print MAIL "$ConfigIn{'EMAIL_TEXT_COMMENTS'}$in{'comm'}\n"; for($a=1;$a<=$NumBooksFound;$a++) { if (($in{$a} eq "on") && ($SearchResults[($a*22)] eq $LibDef{$LibName}[0])) { print MAIL "\n$ConfigIn{'EMAIL_TEXT_REQUESTED_ITEM'}\n"; for ($i=1; $i<=14; $i++) { $FieldNum = eval("\$ConfigIn{'EMAIL_FIELD_DETAIL_LINE$i'}"); if ($FieldNum > 0) { if ($FieldNum == 1) {$ArrayPosition = 1;} if ($FieldNum == 2) {$ArrayPosition = 4;} if ($FieldNum == 3) {$ArrayPosition = 8;} if ($FieldNum == 4) {$ArrayPosition = 11;} if ($FieldNum == 5) {$ArrayPosition = 9;} if ($FieldNum == 6) {$ArrayPosition = 10;} if ($FieldNum == 7) {$ArrayPosition = 7;} if ($FieldNum >= 8) {$ArrayPosition = $FieldNum+7;} print MAIL eval("\$SearchFieldLabel$FieldNum") . " : $SearchResults[($a*22)+$ArrayPosition]\n"; } } } } print MAIL "\n\n(c) copyright $cpr_year $orgName.\n"; close (MAIL); } print "

    $ConfigIn{'REQUESTPAGE_TEXT_THANKYOU'}"; print "


    $ConfigIn{'RESULTSPAGE_TEXT_RETURN'}

    " . chr(13); } ############################################ # PrintLoginForm # Purpose: To Print The Login Form # ############################################ sub PrintLoginForm { print <

    Login To $databasedata[($in{'dbNum'}*10)+0]

    Password:



    NCP } ############################################ # getCounterValue("filename") # # Increment and return the counter in "filename" in the counter directory. ############################################ sub getCounterValue { local $count = 0; open (COUNTER, "+>>".$countpath.$dirsep.$_[0]); flock(COUNTER, $LOCK_EX); seek(COUNTER, 0, 0); $count = unless (eof(COUNTER)); truncate(COUNTER, 0); print COUNTER (++$count); close(COUNTER); return $count; } ############################################ # ShowEnvVar # Purpose: For Jaywil debugging purposes, # outputs all server environment # variables to the screen. # Added Jan/2004. M.Whiting. ############################################ sub ShowEnvVar { # Note this procedure won't produce much under IIS. IIS requires you to # explicity specify each parameter you want to see, running through them # in a foreach loop won't coax them out of the server. print "Content-type: text/html\n\n"; print "\n"; print "

    Note: This page is for debugging purposes by Jaywil Software.

    "; print "Please copy and paste this page into your email program
    "; print "and send it to Jaywil Software. Thank-you.


    "; print "

    Start of Environment Variables:

    "; foreach $key (sort keys(%ENV)) { print "$key = $ENV{$key}
    "; } print "

    End of Environment Variables

    "; exit; } ############################################ # GetQueryData # Purpose: To Get Information From The Query # String passed from The WWW ############################################ sub GetQueryData { if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); } else { @pairs = split(/&/, $ENV{'QUERY_STRING'}); } # Now digest the data, putting it into a more useful format. foreach $pair (@pairs) { ($key, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/\cM//; # print "$key = $value
    \n"; # eval("\$$key = \"$value\""); $in{$key} = $value; } local $QueryString = $ENV{'QUERY_STRING'}; # # Replace '+' chars with spaces and de-hex the query string. # $QueryString =~ s/\+/ /g; $QueryString =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge; $x=0; foreach $_ (split(/\&/, $QueryString )) { if ($_ =~ /show_var/i) { &ShowEnvVar(); } $x++; } # Handle any password or session variable in the query string. June 2007. M.Whiting # This can only be run before anything is outputed to the screen, for the browser redirection to work $pwd = undef; if (defined $UseSession) { if (defined $in{'pwd'} or defined $in{'CGISESSID'}) { use CGI; use CGI::Session; $cgi = new CGI; $sid = $cgi->param('CGISESSID') || undef; $session = new CGI::Session("driver:File", $sid, {Directory=>$SessionFilePath}) or die CGI::Session->errstr(); $sid = $session->id(); if (defined $in{'pwd'}) { # Store password just entered, then redirect with session id in query string # instead of pwd text in the query string (so it can't be bookmarked) $pwd = $in{'pwd'}; $session->param("pwd", $pwd); $session->save_param($cgi); $session->flush(); print 'Status: 302 Moved', "\r\n", 'Location: http://',$ENV{SERVER_NAME},$ENV{SCRIPT_NAME},'?dbNum=1&action=3&CGISESSID=', $sid, "\r\n\r\n"; exit; } elsif (defined $in{'CGISESSID'}) { $pwd = $session->param("pwd"); } } } else { if (defined $in{'pwd'}) {$pwd = $in{'pwd'}} } } ############################################ # FindConf # Purpose: For Windows servers, to check # various locations for lib.conf # This will also execute for any # Unix server that can't find it ############################################ sub FindConf { # Take SCRIPT_NAME environment variable and strip off the first directory. On some NT servers this is a virtual folder. $ShortenedScriptName = $ENV{SCRIPT_NAME}; $ShortenedScriptName =~ s/^\///; until ($ShortenedScriptName =~ /^[\/|\\]/) { $ShortenedScriptName =~ s/^.//; } $CwdDir = getcwd(); # Do the checking while (!(-e $libConf)) { if (++$FileCheckCount== 1) {$libConf = "$CwdDir$ENV{SCRIPT_NAME}";} elsif ($FileCheckCount == 2) {$libConf = "$ENV{PATH_TRANSLATED}$ENV{SCRIPT_NAME}";} elsif ($FileCheckCount == 3) {$libConf = "$CwdDir$ShortenedScriptName";} elsif ($FileCheckCount == 4) {$libConf = "$ENV{PATH_TRANSLATED}$ShortenedScriptName";} else { $FileCheckCount--; print "Content-type: text/html\n\n"; print "
    Lib.conf file not found! ($FileCheckCount checks)
    "; print "Please contact Jaywil Software for assistance.
    "; exit; } $script2 = $libConf; # SCRIPT_NAME includes this file's filename, not lib.conf, so switch them, whichever name it is. $libConf =~ s/libsearch.exe/lib.conf/i; $libConf =~ s/libsearch.cgi/lib.conf/i; } # Session file path is the same as lib.conf, partly because lib.conf also contains the # pwd in plain text, and because we need an easy to determine file location relevant # to the libsearch program. (lib.conf has not been read in yet to use a user-set variable # as there can be no output to the screen yet when the pwd is first set (browser redirection)) ($SessionFilePath = $libConf) =~ s/lib.conf//i; $SessionFilePath = $SessionFilePath . 'tmp/'; if (!(-e $SessionFilePath)) {mkdir $SessionFilePath;} if (!(-e $SessionFilePath)) { print "Content-type: text/html\n\n"; print "
    Temp folder for session file path not found!
    "; print "Path attempted: $SessionFilePath
    "; print "Please contact Jaywil Software for assistance.
    "; exit; } } ############################################ # ReadConf # Purpose: To Get information from the # configuration file ############################################ ###### In the config file, elements are ":" separated -- this makes ###### it hard to enter a dos/windows style fully qualified pathname ###### because such paths require a drive specification with a colon, ###### eg: d:\srv\http\netutils.ccjclearline.com\cgi. The below code ###### handles such pathnames gracefully. sub ReadConf { $NumDbLineNames = 0; open (NCP, $libConf) || print ("can't open lib.conf"); @data = ; close(NCP); foreach $stream (@data) { chomp($stream); @config = split(/:/, $stream); $NumFields = scalar(@config); ($confvar = shift(@config)) =~ s/(^\s+|\s+$)//g; next if (scalar(@config) == 0); if ($confvar eq "DATABASE") { $NumDbLineNames++; $a = $NumDbLineNames*10; $b = 0; ($databasedata[$a++] = $config[$b++]) =~ s/(^\s+|\s+$)//g; #name of library ($databasedata[$a++] = $config[$b++]) =~ s/(^\s+|\s+$)//g; #location of library ($databasedata[$a++] = $config[$b++]) =~ s/(^\s+|\s+$)//g; #library password ($databasedata[$a++] = $config[$b++]) =~ s/(^\s+|\s+$)//g; #email one - maintainer? ($databasedata[$a++] = $config[$b++]) =~ s/(^\s+|\s+$)//g; #email two # The next element is the path and filename that contains the library # data. If the path contains colons (like c:/sample.txt) the split operation # will separate the path into several fields at the colons. Check for # extra fields and append them back together. $databasedata[$a] = $config[$b++]; if ($NumFields > 8) { for ($i=1;$i<=$NumFields-8;$i++) { $databasedata[$a] = $databasedata[$a] . ":" . $config[$b++]; } } # Split the library data into a new array at commas & store into $DbLineNames array for later validation. @_ = split(/,/, $databasedata[$a]); $DbLineNames[$NumDbLineNames] = [@_]; $databasedata[++$a] = $config[$b]; # number of records } if ($confvar eq "LIBRARY_DEFINITION") { # Remove leading/trailing spaces from Library Definition fields # $config[0] is the library name, convert to uppercase & use that to # create a hash to store all the location info. Note that element 0 # of the hash is the same name in mixed case. ($Keyname = $config[0]) =~ tr/a-z/A-Z/; ($LibDef{$Keyname}[0] = $config[0]) =~ s/(^\s+|\s+$)//g; # multi-case name ($LibDef{$Keyname}[1] = $config[1]) =~ s/(^\s+|\s+$)//g; # email ($LibDef{$Keyname}[2] = $config[2]) =~ s/(^\s+|\s+$)//g; # library data location # If the library path contains colons (like c:/sample.txt) the earlier split operation # separated the path into several fields at the colons. Check for # extra fields and append them back together into one field. # This loop depends on there being no other fields after the library data location field (a little # different than what happens with the splitting up of the DATABASE line. if ($NumFields > 4) { # Loop through extra indices, subtract 1 from $NumFields for first lib.conf line not in config array, and 1 for the diff in zero vs 1-based array counting for ($i=3;$i<=$NumFields-2;$i++) { # Attached indices beyond the library data location field back to it (they # were 'split' on a colon which was part of the location name $LibDef{$Keyname}[2] = $LibDef{$Keyname}[2] . ":" . $config[$i]; } } } # Handle normal config vars, removing leading or trailing whitespaces. ($virtual = $config[0]) =~ s/(^\s+|\s+$)//g if ($confvar eq "VIRTUAL"); ($logoImage = $config[0]) =~ s/(^\s+|\s+$)//g if ($confvar eq "LOGO_IMAGE"); ($adminEmail = $config[0]) =~ s/(^\s+|\s+$)//g if ($confvar eq "ADMINEMAIL"); ($aboutpage = $config[0]) =~ s/(^\s+|\s+$)//g if ($confvar eq "ABOUTPAGE"); ($adminName = $config[0]) =~ s/(^\s+|\s+$)//g if ($confvar eq "ADMINNAME"); ($dirsep = $config[0]) =~ s/(^\s+|\s+$)//g if ($confvar eq "DIRSEP"); ($script = $config[0]) =~ s/(^\s+|\s+$)//g if ($confvar eq "CGISCRIPT"); ($orgName = $config[0]) =~ s/(^\s+|\s+$)//g if ($confvar eq "ORG_NAME"); ($SMTPServer = $config[0]) =~ s/(^\s+|\s+$)//g if ($confvar eq "SMTPSERVER"); ($AllowRequests = $config[0]) =~ s/(^\s+|\s+$)//g if ($confvar eq "ALLOW_REQUESTS"); ($SmblatDebug = $config[0]) =~ s/(^\s+|\s+$)//g if ($confvar eq "SMBLAT_DEBUG"); ($SmblatEmailOnly = $config[0]) =~ s/(^\s+|\s+$)//g if ($confvar eq "SMBLAT_EMAIL_ONLY"); ($MultiLocEnableCode = $config[0]) =~ s/(^\s+|\s+$)//g if ($confvar eq "MULTILOC_ENABLE_CODE"); if (substr($confvar,0,18) eq "SEARCH_FIELD_LABEL") { eval('($SearchFieldLabel' . substr($confvar,18,2) . ' = $config[0]) =~ s/(^\s+|\s+$)//g'); } if (substr($confvar,0,23) eq "SEARCH_FIELD_SEARCHABLE") { # remove any leading whitespace, only first alpha character is kept. $config[0] =~ s/^\s//g; eval('$SearchFieldSearchable' . substr($confvar,23,2) . ' = uc(substr("$config[0]",0,1))'); } if (substr($confvar,0,22) eq "SEARCH_FIELD_DISPLAYED") { # remove any leading whitespace, only first alpha character is kept. $config[0] =~ s/^\s//g; eval('$SearchFieldDisplayed' . substr($confvar,22,2) . ' = uc(substr("$config[0]",0,1))'); } # Handle config vars that might have colons in them (removing lead/trailing whitespaces) # This is harmless if the value had no colons in it. ($countpath = join(":", @config)) =~ s/(^\s+|\s+$)//g if ($confvar eq "COUNTPATH"); ($virtual = join(":", @config)) =~ s/(^\s+|\s+$)//g if ($confvar eq "VIRTUAL"); ($orgUrl = join(":", @config)) =~ s/(^\s+|\s+$)//g if ($confvar eq "ORG_URL"); ($mailProg = join(":", @config)) =~ s/(^\s+|\s+$)//g if ($confvar eq "MAILPROG"); ($LocalDataPath = join(":", @config)) =~ s/(^\s+|\s+$)//g if ($confvar eq "LOCAL_DATA_PATH"); # Handle all & any new config vars. April 2007. M.Whiting $ConfigIn{$confvar} = join(":", @config); if ($confvar !~ /TEXT/) {$ConfigIn{$confvar} =~ s/(^\s+|\s+$)//g;} #Strip whitespace for non *TEXT* fields if ($confvar =~ /SHOW/) {$ConfigIn{$confvar} =~ tr/[a-z]/[A-Z]/;} #Change Y/N fields to uppercase } # All config info is stored, so print the rest of the header info &PrintHeader2; if (defined $in{"ShowLibConfVar"}) {print "lib.conf variable ",$in{"ShowLibConfVar"},": [",$ConfigIn{$in{"ShowLibConfVar"}},"]"; exit;} unless (defined $LocalDataPath) {$LocalDataPath = getcwd() . "/";} # Test that $LocalDataPath exists. This is an issue in Winserver 2003 unless (-e $LocalDataPath) { print "
    LOCAL_DATA_PATH is invalid ($LocalDataPath)"; print "
    Please contact Jaywil Software at info\@jaywil.com for assistance."; exit; } for $DbLineNum (1 .. $NumDbLineNames) { for $DbLineFileNum (0 .. $#{$DbLineNames[$DbLineNum]}) { $_ = $DbLineNames[$DbLineNum][$DbLineFileNum]; if ($_ =~ /^(www|http)/i ) { print "
    '$databasedata[$DbLineNum*10]' database line specifies"; print "
    library named '$_'."; print "
    Cannot direct to a file using http. Contact Jaywil Software about the multi-library version of Web Search."; exit; } if ($_ !~ /.txt/i ) { $_ =~ tr/a-z/A-Z/; #convert lib def name to all uppercase if (defined $LibDef{$_}) { $DbLineNames[$DbLineNum][$DbLineFileNum] = $_; } else { print "
    '$databasedata[$DbLineNum*10]' database line specifies"; print "
    library named '$_'."; print "
    No corresponding library definition statement was found in lib.conf file."; print "
    Please enter a library definition or check spelling."; print "

    (You can contact Jaywil at info\@jaywil.com if you need assistance)

    "; exit; } } else { if (defined $DbLineNames[$DbLineNum][1]) { print "
    Multiple library locations specified on '$databasedata[$DbLineNum*10]' database line in lib.conf file."; print "

    Please contact Jaywil Software about the multi-library version of Web Search.

    "; exit; } else { # convert db name to uppercase to use as the key in the hash. Note that element 0 # of the hash is the same name in mixed case. ($Keyname = $databasedata[$DbLineNum*10]) =~ tr/a-z/A-Z/; ($LibDef{$Keyname}[0] = $databasedata[$DbLineNum*10]) =~ s/(^\s+|\s+$)//g; # library name ($LibDef{$Keyname}[1] = $databasedata[$DbLineNum*10+4]) =~ s/(^\s+|\s+$)//g; # email ($LibDef{$Keyname}[2] = $_) =~ s/(^\s+|\s+$)//g; # library data location $DbLineNames[$DbLineNum][$DbLineFileNum] = $Keyname; } } } } # Run through all the Library Definitions, downloading remote files & assigning local filenames $iTemp = 0; foreach $LibName (keys %LibDef) { $_ = $LibDef{$LibName}[2]; # put the file location into $_ if ($_ !~ /^(www|http)/i ) { #If no www/http reference, it's a local file if (!(-e $_)) { print "

    File not found for library named '$LibName'"; print "
    (filename: $_)"; exit; } } else { if ($_ =~ /^www/i ) {$_ = "http://" . $_;} ($DestFilename = $_) =~ s/^.+\///; # remove the path before the filename. $DestFilename = $LocalDataPath."RemoteFile".++$iTemp."-".$DestFilename; if (-e $DestFilename) { $returncode = mirror($_, $DestFilename); } else { $returncode = getstore($_, $DestFilename); #one server had trouble with mirroring if file didn't already exist } if (is_error($returncode)) { print "

    Problem getting remote database file: $_"; print "

    Transfer Error Message: "; print status_message($returncode); print "
    (HTTP error code # $returncode)"; print "

    Please contact Jaywil at info\@jaywil.com if you need assistance.

    "; print exit; } #print "
    done ... " .status_message($returncode); $LibDef{$LibName}[2] = $DestFilename; #Reassign remote library path with local path } } # Set password timeout, now that any default override has been read in from lib.conf if (defined $session and defined $ConfigIn{'PASSWORD_TIMEOUT'}) { $session->expire($ConfigIn{'PASSWORD_TIMEOUT'}); } }