#!/usr/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" #perl2exe_exclude "Compress/Bzip2.pm" #perl2exe_include "HTTP/Message.pm" #perl2exe_include "DateTime.pm" #Net::SMTP related: #perl2exe_exclude "Convert/EBCDIC.pm" #perl2exe_exclude "Mac/InternetConfig.pm" #perl2exe_exclude "Authen/SASL.pm" #perl2exe_exclude "Carp/Heavy.pm" use CGI::Carp qw(fatalsToBrowser); use ExtUtils::Installed; #use DateTime; ############################################ # 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. # ############################################################################# # Programming changes # Oct.2008 - Emailing requests changed from using sendmail (unix) or # smblat.exe (Windows) to using Perl Net::SMTP module ############################################################################# ############################################################################# # Start of Main Program Section # *NOTE* no changes are required in this file whatsoever.. view lib.conf ############################################################################# # &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"); # } # if ($ENV{SCRIPT_NAME} =~ ".exe") {$script = "libsearch.exe"; $OS = "Windows"} else {$script = "libsearch.cgi"; $OS = "Unix";} $libConf = "lib.conf"; $Jaywil_support_email = 'support@resourcemate.com'; if (!($ENV{SCRIPT_NAME} =~ /$script/)) { print "Content-type: text/html\n\n"; print "
Stated script name doesn't match environment variable: $ENV{SCRIPT_NAME}
"; print "Please contact Jaywil Software for assistance.
"; exit; } # Find the configuration file. # Original file path check for Unix-type servers & some NT servers too. This has always worked for Unix, so don't touch it! ($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 = "https://www.google.com/search/"; $logoImage = "logo.gif"; $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"; ###### These may be overriden by the ORG_NAME, and ORG_URL config ###### vars respectively. $orgName = "Our Favourite Org, Inc."; $orgUrl = "https://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"; ###### 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) $SearchFieldLabel8 = "User1"; $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_LINK_COLOR'} = 'Black'; $ConfigIn{'VISITED_LINK_COLOR'} = 'Black'; $ConfigIn{'ACTIVE_LINK_COLOR'} = 'Black'; $ConfigIn{'HOVER_LINK_COLOR'} = 'Black'; $ConfigIn{'SHOW_ABOUT_LINK'} = 'Y'; $ConfigIn{'SHOW_LIST_LIBRARIES_LINK'} = 'Y'; $ConfigIn{'SHOW_CONTACT_ADMIN_LINK'} = 'Y'; $ConfigIn{'SHOW_SEARCH_LINK'} = 'Y'; $ConfigIn{'SHOW_VISITOR_NUMBER'} = 'Y'; $ConfigIn{'SHOW_TOTAL_LIBRARY_DATABASES'} = 'Y'; $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{'SEARCHPAGE_SHOW_SEARCH_LIBRARY'} = 'Y'; $ConfigIn{'SEARCHPAGE_TEXT_SEARCH'} = 'Search'; $ConfigIn{'SEARCHPAGE_TEXT_LIBRARY_NAME'} = ''; # leave blank for dynamic name generation $ConfigIn{'SEARCHPAGE_SHOW_ENTER_FIELDS'} = 'Y'; $ConfigIn{'SEARCHPAGE_TEXT_ENTER_FIELDS'} = 'Enter text for a search:'; # $ConfigIn{'SEARCHPAGE_MATCH_LIST_DEFAULT'} = 1; # don't set for old users $ConfigIn{'SEARCHPAGE_TEXT_MATCH_ANY'} = 'Find Any Word'; $ConfigIn{'SEARCHPAGE_TEXT_MATCH_ALL'} = 'Find All Words'; $ConfigIn{'SEARCHPAGE_TEXT_MATCH_PHRASE'} = 'Match Phrase'; $ConfigIn{'SEARCHPAGE_SHOW_WHOLE_WORD_CHECKBOX'} = 'Y'; $ConfigIn{'SEARCHPAGE_TEXT_WHOLE_WORD_MATCH'} = '(Whole Word Match)'; $ConfigIn{'SEARCHPAGE_TEXT_SEARCH_BUTTON'} = 'Search'; $ConfigIn{'SEARCHPAGE_TEXT_CLEAR_BUTTON'} = 'Clear'; # $ConfigIn{'SEARCHPAGE_SEARCH_DEFAULT'} = 'A'; # don't set for old version users $ConfigIn{'SEARCHPAGE_TEXT_BASIC_LINK'} = 'Basic Search Screen'; $ConfigIn{'SEARCHPAGE_TEXT_ADVANCED_LINK'} = 'Advanced Search Screen'; $ConfigIn{'SEARCHPAGE_BUTTONS_PER_LINE'} = 4; $ConfigIn{'SEARCHPAGE_BUTTON_WIDTH'} = ''; # leave blank to size buttons at their own pixel size $ConfigIn{'SEARCHPAGE_BUTTON1_FILENAME'} = 'btnSearchTitle.jpg'; $ConfigIn{'SEARCHPAGE_BUTTON2_FILENAME'} = 'btnSearchAuthor.jpg'; $ConfigIn{'SEARCHPAGE_BUTTON3_FILENAME'} = 'btnSearchCategory.jpg'; $ConfigIn{'SEARCHPAGE_BUTTON4_FILENAME'} = 'btnSearchSubject.jpg'; $ConfigIn{'SEARCHPAGE_BUTTON5_FILENAME'} = 'btnSearchDewey.jpg'; $ConfigIn{'SEARCHPAGE_BUTTON6_FILENAME'} = 'btnSearchISBN.jpg'; $ConfigIn{'SEARCHPAGE_BUTTON7_FILENAME'} = 'btnSearchPublisher.jpg'; $ConfigIn{'SEARCHPAGE_BUTTON8_FILENAME'} = ''; $ConfigIn{'SEARCHPAGE_BUTTON9_FILENAME'} = ''; $ConfigIn{'SEARCHPAGE_BUTTON10_FILENAME'} = ''; $ConfigIn{'SEARCHPAGE_BUTTON11_FILENAME'} = ''; $ConfigIn{'SEARCHPAGE_BUTTON12_FILENAME'} = ''; $ConfigIn{'SEARCHPAGE_BUTTON13_FILENAME'} = ''; $ConfigIn{'SEARCHPAGE_BUTTON14_FILENAME'} = ''; $ConfigIn{'RESULTSPAGE_SHOW_LIBRARY_NAME'} = 'Y'; $ConfigIn{'RESULTSPAGE_TEXT_LIBRARY_NAME'} = ''; #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_DEFAULT_REQUEST_EMAIL_PHONE'} = 'Email'; $ConfigIn{'RESULTSPAGE_TEXT_REQUEST_EMAIL'} = 'Phone/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_SHOW_IMAGE'} = 'N'; $ConfigIn{'RESULTSPAGE_SIZE_IMAGE_WIDTH'} = '125'; $ConfigIn{'RESULTSPAGE_TEXT_FROM'} = ', from'; $ConfigIn{'RESULTSPAGE_TEXT_DATABASE'} = ''; $ConfigIn{'RESULTSPAGE_TEXT_PREV_BUTTON'} = 'Prev'; $ConfigIn{'RESULTSPAGE_TEXT_NEXT_BUTTON'} = 'Next'; $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'} = 'Email/Phone : '; $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; &PrintHeaderLinks; # Print The Commands > WWW &PerformAction; # perform the specified action. &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"; } ############################################ # PrintHeaderLinks # Purpose: To Print the available commands # to the screen. ############################################ sub PrintHeaderLinks { print "\n"; 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'}] ";} #mail link is in unicode so that isn't as easy for spam bots to id (hopefully), email in variable is also 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"; print "\n"; } ############################################ # PerformAction # Purpose: To perform the action requested # ############################################ sub PerformAction { # Check expiry for users hosted at Jaywil # if (defined $ConfigIn{'EXPIRES'}) { # ($mm, $dd, $yy) = split('/',$ConfigIn{'EXPIRES'}); # my $RMExpiryDate = DateTime->new(year=>$yy,month=>$mm,day=>$dd+1); # if (time() > $RMExpiryDate->epoch) { # print "

Your hosting subscription has expired.


Please contact Jaywil Software to renew.

Thank-you.


"; # PrintFooter(); # exit; # } # } 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 (@{$DbLineNames[$in{'dbNum'}]}) { $LibName=$_; open(LIBRARY_FILE, $LibDef{$LibName}[2]); $filerecord=; $LibDef{$LibName}[4]=substr($filerecord, rindex($filerecord, '"')+1); #Preserve the line terminator for this library file # print "
terminator:$LibDef{$LibName}[4]
"; $NumDbFields = scalar(split(/\t/, )); close(LIBRARY_FILE); # print "
Lib Name:$LibName, Lib Filename:$LibDef{$LibName}[2] - $NumDbFields
"; if (($NumDbFields != 14) && ($NumDbFields != 21) && ($NumDbFields != 22)) { print "

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

Please contact Jaywil Software at support\@resourcemate.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 { print "

\n \n
"; if ($ConfigIn{'SHOW_VISITOR_NUMBER'} =~ /^y/i) { print " $ConfigIn{'TEXT_VISITOR_NUMBER'} " . &getCounterValue("count-lib-$databasedata[$in{'dbNum'}*10].txt"); } print ""; # Print alternate search link if ($SearchType ne '') { print "$AltSearchText"; } print "

"; 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 ($SearchType ne '') { print " \n"; } if (defined $sid) { print " "; } elsif (defined $in{'pwd'}) { print " "; } if ($SearchType ne 'B') { # for Advanced Search print " "; for ($i=1;$i<=14;$i++) { last if ($MaxNumDbFields == 14 && $i == 8); #not affected by addition of 22nd field (it's unsearchable) if (eval("\$SearchFieldSearchable$i") ne "N") { print " \n"; if ($ConfigIn{'SEARCHPAGE_SHOW_WHOLE_WORD_CHECKBOX'} =~ /^y/i) { print " \n"; } print " \n"; print " \n"; if (defined $ConfigIn{'SEARCHPAGE_MATCH_LIST_DEFAULT'}) { print " \n"; } if ($ConfigIn{'SEARCHPAGE_SHOW_WHOLE_WORD_CHECKBOX'} =~ /^y/i) { print " \n"; $ConfigIn{'SEARCHPAGE_TEXT_WHOLE_WORD_MATCH'} = ""; # Only print this text onscreen once. } print " \n"; } } print <
NCP } else { # Basic search (with graphical buttons) print "   \n"; if (defined $ConfigIn{'SEARCHPAGE_MATCH_LIST_DEFAULT'}) { print " \n"; } if ($ConfigIn{'SEARCHPAGE_SHOW_WHOLE_WORD_CHECKBOX'} =~ /^y/i) { print " $ConfigIn{'SEARCHPAGE_TEXT_WHOLE_WORD_MATCH'}\n"; $ConfigIn{'SEARCHPAGE_TEXT_WHOLE_WORD_MATCH'} = ""; # Only print this text onscreen once. } print "


\n"; my $ImageCount=0; if ($ConfigIn{'SEARCHPAGE_BUTTON_WIDTH'}) {$ImageWidthCode = 'width=' . $ConfigIn{'SEARCHPAGE_BUTTON_WIDTH'}; } for ($i=1;$i<=14;$i++) { last if ($MaxNumDbFields == 14 && $i == 8); #not affected by addition of 22nd field (it's unsearchable) # print "
".eval("\$ConfigIn{'SEARCHPAGE_BUTTON".$i."_FILENAME'}"); if (eval("\$SearchFieldSearchable$i") ne "N" and eval("\$ConfigIn{'SEARCHPAGE_BUTTON".$i."_FILENAME'}") ne '_') { print " \n"; if (++$ImageCount == $ConfigIn{'SEARCHPAGE_BUTTONS_PER_LINE'}) {print "
\n"; $ImageCount = 0;} } } } 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'}

\n"; } 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 \n"; print "
\n"; print " \n"; print " \n"; if (defined $SearchType) { print " \n"; } if (defined $sid) { print ""; } elsif (defined $in{'pwd'}) { print ""; } if ($SearchType ne 'B') { for ($i=1;$i<=14;$i++) { #unaffected by addition of 22nd field (it's unsearchable anyway) last if ($NumDbFields == 14 && $i == 8); $SearchFieldValue = eval("\$in{SearchField$i}"); if ($SearchFieldValue ne "") { print " \n"; if (defined $ConfigIn{'SEARCHPAGE_MATCH_LIST_DEFAULT'}) { # don't use this function if not in lib.conf (older users) print " \n"; } if (eval("\$in{chkWholeWord$i}") ne "") { print " \n"; } } } } else { print " \n"; print " \n"; if (defined $ConfigIn{'SEARCHPAGE_MATCH_LIST_DEFAULT'}) { # don't use this function if not in lib.conf (older users) print " \n"; } if (defined $in{'chkWholeWord'}) { print " \n"; } } print " \n"; # Print request-a-book area, if it has not be turned off in lib.conf; if ($AllowRequests =~ /^Y/i) { print <
                        " . eval("\$SearchFieldLabel$i") . ":  \n"; print " $ConfigIn{'SEARCHPAGE_TEXT_WHOLE_WORD_MATCH'}
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. print " \n"; for ($QryStrReqNum=1;$QryStrReqNum<$NumBooksFound;$QryStrReqNum++) { if ($in{$QryStrReqNum} eq "on") { print " \n"; print " \n \n \n"; } } print "
  • Checked: $SearchResults[($QryStrReqNum*$NumArrayFields+1)]   
  • (#$QryStrReqNum"; if (defined $LibDef{$LibName}[1]) { print ", from '$SearchResults[($QryStrReqNum*$NumArrayFields)]'"; } 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 "
    \n"; # Print buttons at top of page if ($LastNumDisplayed <= 10) {$DisablePrev = 'disabled'}; print " \n"; if ($LastNumDisplayed == $NumBooksFound) {$DisableNext = 'disabled'}; print " \n"; print "
    \n"; # Start looping through search results for ($SearchResultNum=$FirstNumDisplayed;$SearchResultNum<=$LastNumDisplayed;$SearchResultNum++) { print " \n"; #outer table print " \n"; # end of first row with colspan # start 2nd row of outer table, cell 1 holds an inner table with the text of the search results # if there are images, it will be in cell 2 of 2. if ($ConfigIn{'RESULTSPAGE_SHOW_IMAGE'} =~ /^y/i) { print " \n"; # End of inner table and first cell # Start second cell showing result image, if it exists if ($ConfigIn{'RESULTSPAGE_SHOW_IMAGE'} =~ /^y/i) { print " \n"; } 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*$NumArrayFields)]'"; } else { print "$ConfigIn{'RESULTSPAGE_TEXT_DATABASE'}"; } } print "
    \n"; } else { print "
    \n"; } # Start inner table with text of search results. print " " . chr(13); # 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 ($_ = $SearchResults[($SearchResultNum*$NumArrayFields)]) =~ tr/a-z/A-Z/; if ($LibDef{$_}[3] > 14) { for ($i=8; $i<=14 ; $i++) { if (eval("\$SearchFieldDisplayed$i") ne "N") { print " " . chr(13); } } } print "
    "; print $RequestBoxCode; $RequestBoxCode = ""; print "$SearchFieldLabel1 $SearchResults[($SearchResultNum*$NumArrayFields)+1]"; if ($SearchResults[($SearchResultNum*$NumArrayFields)+2] ne '') {print " : $SearchResults[($SearchResultNum*$NumArrayFields)+2]";} if ($SearchResults[($SearchResultNum*$NumArrayFields)+3] ne '') {print " ($SearchResults[($SearchResultNum*$NumArrayFields)+3])";} print "
    "; print $RequestBoxCode; $RequestBoxCode = ""; print "$SearchFieldLabel2 $SearchResults[($SearchResultNum*$NumArrayFields)+4]"; if ($SearchResults[($SearchResultNum*$NumArrayFields)+5] ne '') { print ", $SearchResults[($SearchResultNum*$NumArrayFields)+5]"; } if ($SearchResults[($SearchResultNum*$NumArrayFields)+6] ne '') { print ", $SearchResults[($SearchResultNum*$NumArrayFields)+6]"; } print "
    "; print $RequestBoxCode; $RequestBoxCode = ""; print "$SearchFieldLabel3$SearchResults[($SearchResultNum*$NumArrayFields)+8]
    "; print $RequestBoxCode; $RequestBoxCode = ""; print "$SearchFieldLabel4 $SearchResults[($SearchResultNum*$NumArrayFields)+11]"; if ($SearchResults[($SearchResultNum*$NumArrayFields)+12] ne '') {print "
    $SearchResults[($SearchResultNum*$NumArrayFields)+12]";} if ($SearchResults[($SearchResultNum*$NumArrayFields)+13] ne '') {print "
    $SearchResults[($SearchResultNum*$NumArrayFields)+13]";} if ($SearchResults[($SearchResultNum*$NumArrayFields)+14] ne '') {print "
    $SearchResults[($SearchResultNum*$NumArrayFields)+14]";} print "
    "; print $RequestBoxCode; $RequestBoxCode = ""; print "$SearchFieldLabel5 $SearchResults[($SearchResultNum*$NumArrayFields)+9]
    "; print $RequestBoxCode; $RequestBoxCode = ""; print "$SearchFieldLabel6 $SearchResults[($SearchResultNum*$NumArrayFields)+10]
    "; print $RequestBoxCode; $RequestBoxCode = ""; print "$SearchFieldLabel7$SearchResults[($SearchResultNum*$NumArrayFields)+7]
    "; print $RequestBoxCode; $RequestBoxCode = ""; print eval("\$SearchFieldLabel$i") . "$SearchResults[($SearchResultNum*$NumArrayFields)+7+$i]
    "; # $ImageHTTPDir = $virtual . $ConfigIn{'RESULTSPAGE_IMAGE_PATH'}; #virtual getting removed $ImageHTTPDir = $ConfigIn{'RESULTSPAGE_IMAGE_PATH'}; $ImageLocalDir = $ConfigIn{'RESULTSPAGE_IMAGE_PATH'}; if ($ConfigIn{'RESULTSPAGE_IMAGE_PATH_LOCAL'} ne '') { # Windows needs a separate path parameter to better specify where that local folder is, unix does nicely with the RESULTSPAGE_IMAGE_PATH parameter $ImageLocalDir = $ConfigIn{'RESULTSPAGE_IMAGE_PATH_LOCAL'}; } $ImageTest = $ImageLocalDir . $SearchResults[($SearchResultNum*$NumArrayFields)+22]; $ImageWidth = $ConfigIn{'RESULTSPAGE_SIZE_IMAGE_WIDTH'}; #print "ImageTest:$ImageTest
    ImageLocalDir:$ImageLocalDir
    "; if ((-e $ImageTest) and $SearchResults[($SearchResultNum*$NumArrayFields)+22] ne "") { #print "Found image path (test)!
    "; $ImagePath = $ImageHTTPDir . $SearchResults[($SearchResultNum*$NumArrayFields)+22]; $HtmlTemp = ''; # identify non-picture filenames and make them links if ($SearchResults[($SearchResultNum*$NumArrayFields)+22] !~ /\.jpg|\.gif|\.png/i) { #print "non-pic file
    "; $_ = $SearchResults[($SearchResultNum*$NumArrayFields)+22]; ($filename, $fileext) = (/^(.*?)\.?([^\.]*)$/); if ($ConfigIn{'RESULTSPAGE_IMAGE_ICONS'} =~ /$fileext|all/i) { print ""; $ImageTest = $ImageLocalDir . "_icon_" . $fileext . ".png"; if (-e $ImageTest) { $ImagePath = $ImageHTTPDir . "_icon_" . $fileext . ".png"; } else { $ImagePath = $ImageHTTPDir . "_icon_link.png"; } $ImageWidth = 41; $HtmlTemp = ''; } else {$ImagePath = '';} } unless ($ImagePath eq '') { print ""; # pic is in 2nd cell of outer table. print $HtmlTemp; #print "ImagePath2:$ImagePath
    "; } } print "
    \n"; # End of outer table print "
    " . 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 { my $iStartField = 1; my $iMaxSearchFields = 7; # original num of db fields if ($LibDef{$LibName}[3] > 14) {$iMaxSearchFields = 14}; # newer db's # Transfer all $SearchField/$Fieldxx into a new field so that we can manipulate the new field without # changing the original details, which are needed intact to pass to the next screen. my @array; unless ($SearchType eq "B") { #do the original Advanced search, must be able to handle a blank value @array = ($in{'SearchField1'}, $in{'SearchField2'}, $in{'SearchField3'}, $in{'SearchField4'}, $in{'SearchField5'}, $in{'SearchField6'}, $in{'SearchField7'}, $in{'SearchField8'}, $in{'SearchField9'}, $in{'SearchField10'},$in{'SearchField11'},$in{'SearchField12'}, $in{'SearchField13'},$in{'SearchField14'}); for ($i=1; $i<=$iMaxSearchFields; $i++) { if (defined $ConfigIn{'SEARCHPAGE_MATCH_LIST_DEFAULT'}) { $MatchOption[$i] = eval("\$in{'MatchOption$i'}"); # do evals once here to speed up looping later } else { $MatchOption[$i] = "Phrase"; # for older version users } $chkWholeWord[$i] = eval("\$in{'chkWholeWord$i'}"); } } else {#convert basic search details into an advanced search format if (defined $in{'ButtonNum'}) { $ButtonNum = $in{'ButtonNum'}; } else { for ($ButtonNum=1; $ButtonNum<$iMaxSearchFields; $ButtonNum++) { # Image buttons return values as SearchButton1.x and .y=coordinates in all browsers. # Some browsers also return it as SearchButton1=value, but not all (and Firefox does in 3.x but not 4.x) # So we must use variable name to identify which button pressed, instead of variable value Mar 2011 if (eval("\$in{'SearchButton$ButtonNum.x'}") ne '') {last;} # note that keyboard submission of form returns .x value of 0, so don't check just for 'defined' } } if (defined $ConfigIn{'SEARCHPAGE_MATCH_LIST_DEFAULT'}) { $MatchOption[$ButtonNum] = $in{'MatchOption'}; } else { $MatchOption[$ButtonNum] = "Phrase"; # for older version users } $chkWholeWord[$ButtonNum] = $in{'chkWholeWord'}; for ($i=1; $i<$ButtonNum; $i++) {push (@array, "")} push (@array, $in{'SearchField'}); $iStartField = ($iMaxSearchFields = $ButtonNum); } # print "Type:$SearchType
    i:$i, ButtonNum:$ButtonNum, SearchButton1.x:$in{'SearchButton1.x'}
    SearchField1:$in{'SearchField1'}
    MatchOption[1]:$MatchOption[1]
    "; $ValidFieldFound = ""; my $i=0; foreach (@array) { $_ =~ s/(^\s+|\s+$)//; # Strip any leading & trailing whitespace from each field $SearchTerm[++$i] = $_; if ($SearchTerm[$i] ne '') { $ValidFieldFound = "Y"; $SearchTerm[$i] =~ s/([\$\\\?\Q*[]+{}()^'"@.\E])/\\$1/g; # Substitute in escape backslash for characters regex sees as metacharacters. } } # print "1:",$in{'SearchField1'},",",$SearchTerm[1],"
    2:",$SearchTerm[2],"
    3:",$SearchTerm[3],"
    "; # Bail if all the match strings are empty. unless ($ValidFieldFound) { print "

    No search parameters given!

    "; &PrintFooter; exit; } # Set the results counter and an initial empty slot of # the @SearchResults array. There should be as many quotes in the empty # array creation as the number in $NumArrayFields. # $NumBooksFound=0; $NumArrayFields = 23; # should be 1 more than number of fields on the newest db files exported from RM. 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'}]}) { $/ = $LibDef{$LibName}[4]; open (LIBRARY_FILE, $LibDef{$LibName}[2]); LIBRARY_RECORD: while () { chomp($_); @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 for ($i=$iStartField; $i<=$iMaxSearchFields; $i++) { undef $FoundOne; undef $FoundAll; if ($SearchTerm[$i] ne '') { unless ($MatchOption[$i] eq "Phrase") { @SplitSearchTerms = split(/\s+/,$SearchTerm[$i]); } else { @SplitSearchTerms[0] = $SearchTerm[$i]; } foreach (@SplitSearchTerms) { if ($i == 1) { # By default, the Title search field if ($BookDataFields[0] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i || $BookDataFields[1] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i || $BookDataFields[2] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i ) {$FoundOne = "Y"} else {$FoundAll = "N"} } elsif ($i == 2) { # By default, the Author search field if ($BookDataFields[3] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i || $BookDataFields[4] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i || $BookDataFields[5] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i ) {$FoundOne = "Y"} else {$FoundAll = "N"} } elsif ($i == 3) { # By default, the Category search field if ($BookDataFields[7] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i ) {$FoundOne = "Y"} else {$FoundAll = "N"} } elsif ($i == 4) { # By default, the Subject search field if ($BookDataFields[10] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i || $BookDataFields[11] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i || $BookDataFields[12] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i || $BookDataFields[13] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i ) {$FoundOne = "Y"} else {$FoundAll = "N"} } elsif ($i == 5) { # By default, Dewey $in{'chkWholeWord5'} =~ s/.+/\\s/; #Dewey: change 'exact-match' filter only searches for whitespace, as periods are significant in Dewey's. if ($BookDataFields[8] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i ) {$FoundOne = "Y"} else {$FoundAll = "N"} } elsif ($i == 6) { # By default, ISBN if ($BookDataFields[9] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i ) {$FoundOne = "Y"} else {$FoundAll = "N"} } elsif ($i == 7) { # By default, Publisher if ($BookDataFields[6] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i ) {$FoundOne = "Y"} else {$FoundAll = "N"} } elsif ($i >= 8) { # Seven new fields added to the data file exported from RM. Nov.20/2006 if ($i == 8) { if ($BookDataFields[14] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i ) {$FoundOne = "Y"} else {$FoundAll = "N"} } elsif ($i == 9) { if ($BookDataFields[15] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i ) {$FoundOne = "Y"} else {$FoundAll = "N"} } elsif ($i == 10) { if ($BookDataFields[16] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i ) {$FoundOne = "Y"} else {$FoundAll = "N"} } elsif ($i == 11) { if ($BookDataFields[17] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i ) {$FoundOne = "Y"} else {$FoundAll = "N"} } elsif ($i == 12) { if ($BookDataFields[18] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i ) {$FoundOne = "Y"} else {$FoundAll = "N"} } elsif ($i == 13) { if ($BookDataFields[19] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i ) {$FoundOne = "Y"} else {$FoundAll = "N"} } elsif ($i == 14) { if ($BookDataFields[20] =~ m/(\A|$chkWholeWord[$i])$_(\Z|$chkWholeWord[$i])/i ) {$FoundOne = "Y"} else {$FoundAll = "N"} } } # print "FoundOne:$FoundOne FoundAll:$FoundAll
    "; next LIBRARY_RECORD if ($MatchOption[$i] =~ m/(All|Phrase)/ and $FoundAll eq "N"); } next LIBRARY_RECORD if ($FoundOne ne "Y"); } } # If we get to this point we have a match. $NumBooksFound++; # Add the extra slots for older libsearch databases, to pad array up to # of fields of newest db's if ($LibDef{$LibName}[3] == 14) { push(@BookDataFields, "", "", "", "", "", "", "", ""); } elsif ($LibDef{$LibName}[3] == 21) { push(@BookDataFields, ""); } # Push library name into first slot of results array (array has 1 slot more than the db file does) push(@SearchResults, $LibDef{$LibName}[0]); # Push @BookDataFields into the remaining slots of the array push(@SearchResults, @BookDataFields); } close(LIBRARY_FILE); } } ############################################ # PrintFooter # Purpose: To Print The footer info to the # WWW ############################################ sub PrintFooter { print "\n"; print "\n"; &PrintFooterLinks; print < (c) copyright $cpr_year $orgName.
    NCP } ############################################ sub PrintFooterLinks { # 10 new links. Oct 2009. M.Whiting print "
     \n"; for ($i=1; $i<=10 ; $i++) { if ((eval("\$ConfigIn{'ADDITIONAL_LINK_LABEL$i'}") ne "") && (eval("\$ConfigIn{'ADDITIONAL_LINK_URL$i'}" ) ne "")) { print " "; print eval("\$ConfigIn{'ADDITIONAL_LINK_LABEL$i'}"); print "
    "; if ($ConfigIn{'ADDITIONAL_LINK_DOUBLESPACE'} =~ /^y/i) {print '
    '} print "\n"; } } print "
     
    "; } ############################################ # 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

    \n"; } for ($a=1;$a<=$NumDbLineNames;$a++) { my $action = 2; if (($databasedata[($a*10)+2] eq "*") || ($databasedata[($a*10)+2] eq "")) { $action = 3; } 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 "")) { #mail link is in unicode so that isn't as easy for spam bots to id (hopefully), email in variable is also 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 { &SearchDatabase; $selected = 0; for($a=1;$a<=$NumBooksFound;$a++) { if ($in{$a} eq "on") { $selected++; } } my $errMsg; if ($selected==0) { $errMsg = "No Items Selected!"; } if ($in{'txtName'} eq '') { $errMsg = "Missing Name for Request!" } if ($in{'txtEmailPhone'} eq '') { $errMsg = "Missing Email/Phone Number for Request!" } if (defined $errMsg) { print "


    $errMsg\n"; print "

    Please press the back button on your browser and make the 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*$NumArrayFields+1)]
    "; } } foreach $LibName (@{$DbLineNames[$in{'dbNum'}]}) { $FoundOne = "N"; for($a=1;$a<=$NumBooksFound;$a++) { if (($in{$a} eq "on") && ($SearchResults[($a*$NumArrayFields)] eq $LibDef{$LibName}[0])) { $FoundOne = "Y"; #print "
    Found: $a, $SearchResults[($a*$NumArrayFields)]"; } } next if $FoundOne eq "N"; #Validate email if ($in{'txtEmailPhone'} =~ /^(\w|\-|\_|\.)+\@((\w|\-|\_)+\.)+[a-zA-Z]{2,}$/gi) { $emailFrom = $in{'txtEmailPhone'}; } else { $emailFrom = $adminEmail; } unless (defined $ConfigIn{'SENDMAIL'}) { # Use SMTP for email unless a Sendmail server declaration is made use Net::SMTP; $SMTPServer = 'localhost' unless (defined $SMTPServer); $NetSMTP = Net::SMTP->new($SMTPServer, Timeout => 60 ) || die "Unable to open connection to SMTP server named '$SMTPServer'.\nError Message: $! \n"; $NetSMTP->mail($emailFrom); $NetSMTP->to($LibDef{$LibName}[1]); # print "sending from [$emailFrom] to [$LibDef{$LibName}[1]]"; $NetSMTP->data(); } else { # Sendmail open (MAIL, "|$ConfigIn{'SENDMAIL'}") || die "Can't open connection to sendmail! (path: $ConfigIn{'SENDMAIL'})\nPlease contact Jaywil Software at support\@resourcemate.com for assistance.\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 if ($SmblatEmailOnly =~ /^Y/i) { &MakeRequest_Subloop("To: $LibDef{$LibName}[1]\n"); &MakeRequest_Subloop("From: $emailFrom\n"); } else { &MakeRequest_Subloop("To: Libary Admin <$LibDef{$LibName}[1]>\n"); &MakeRequest_Subloop("From: $adminName <$emailFrom>\n"); } &MakeRequest_Subloop("Date: $mailheader_date -0500\n"); &MakeRequest_Subloop("Subject: $ConfigIn{'EMAIL_TEXT_BORROW'}\n"); &MakeRequest_Subloop("Organization: $orgName\n"); &MakeRequest_Subloop("\n"); &MakeRequest_Subloop("$ConfigIn{'EMAIL_TEXT_TITLE1'}\n"); &MakeRequest_Subloop("$ConfigIn{'EMAIL_TEXT_TITLE2'}\n"); &MakeRequest_Subloop("$ConfigIn{'EMAIL_TEXT_TITLE3'}\n"); &MakeRequest_Subloop("$ConfigIn{'EMAIL_TEXT_TITLE4'}\n"); &MakeRequest_Subloop("$ConfigIn{'EMAIL_TEXT_LIBRARY'}$LibDef{$LibName}[0]\n"); &MakeRequest_Subloop("$ConfigIn{'EMAIL_TEXT_NAME'}$in{'txtName'}\n"); &MakeRequest_Subloop("$ConfigIn{'EMAIL_TEXT_EMAIL'}$in{'txtEmailPhone'}\n"); &MakeRequest_Subloop("$ConfigIn{'EMAIL_TEXT_DATE'}$mailheader_date\n"); &MakeRequest_Subloop("$ConfigIn{'EMAIL_TEXT_FOOTER1'}\n"); &MakeRequest_Subloop("$ConfigIn{'EMAIL_TEXT_COMMENTS'}$in{'txtComments'}\n"); for($a=1;$a<=$NumBooksFound;$a++) { if (($in{$a} eq "on") && ($SearchResults[($a*$NumArrayFields)] eq $LibDef{$LibName}[0])) { &MakeRequest_Subloop("\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;} &MakeRequest_Subloop(eval("\$SearchFieldLabel$FieldNum") . " : $SearchResults[($a*$NumArrayFields)+$ArrayPosition]\n"); } } } } &MakeRequest_Subloop("\n\n(c) copyright $cpr_year $orgName.\n"); # Close the email unless (defined $ConfigIn{'SENDMAIL'}) { $NetSMTP->dataend(); $NetSMTP->quit; } else { #Sendmail close (MAIL); } } print "

    $ConfigIn{'REQUESTPAGE_TEXT_THANKYOU'}"; print "


    $ConfigIn{'RESULTSPAGE_TEXT_RETURN'}

    " . chr(13); } ############################################ # PrintLoginForm # Purpose: To Print The Login Form # ############################################ sub MakeRequest_Subloop { my ($text) = @_; # print "
    Text:$text"; unless (defined $ConfigIn{'SENDMAIL'}) { $NetSMTP->datasend($text); } else { print MAIL $text; } } ############################################ # 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. #mail link is in unicode so that isn't as easy for spam bots to id (hopefully), email in variable is also 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"; $in{$key} = $value; if ($key =~ /show_var/i) {&ShowEnvVar()}; if ($key =~ /encrypt/i) {&EncryptEmailAddress($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; # 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(); # Hunt around for lib.conf if (!(-e $libConf)) { if (-e "$ENV{SCRIPT_NAME}") { $ScriptPath = "$ENV{SCRIPT_NAME}"; } elsif (-e "$CwdDir$ENV{SCRIPT_NAME}") { $ScriptPath = "$CwdDir$ENV{SCRIPT_NAME}"; } elsif (-e "$ENV{PATH_TRANSLATED}$ENV{SCRIPT_NAME}") { $ScriptPath = "$ENV{PATH_TRANSLATED}$ENV{SCRIPT_NAME}"; } elsif (-e "$CwdDir$ShortenedScriptName") { $ScriptPath = "$CwdDir$ShortenedScriptName"; } elsif (-e "$ENV{PATH_TRANSLATED}$ShortenedScriptName") { $ScriptPath = "$ENV{PATH_TRANSLATED}$ShortenedScriptName"; } else { print "Content-type: text/html\n\n"; print "
    Lib.conf file not found!
    "; #mail link is in unicode so that isn't as easy for spam bots to id (hopefully), email in variable is also print "Please contact Jaywil Software for assistance.
    "; exit; } # create $libConf variable with the path that worked, and lib.conf as filename ($libConf = $ScriptPath) =~ s/$script/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
    "; #mail link is in unicode so that isn't as easy for spam bots to id (hopefully), email in variable is also 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 - for password request ($databasedata[$a++] = $config[$b++]) =~ s/(^\s+|\s+$)//g; #email two - for requests, unless there are LIB_DEF statements in lib.conf, they are used instead # 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"); ($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"); ($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 HTML header (some header info is in config file) &PrintHeader2; # Decrypt all email addresses if required, now that encryption indicator from lib.conf is stored if ($ConfigIn{'EMAIL_ADDRESSES_ENCRYPTED'} =~ /^y/i) { for ($loopnum=1;$loopnum<=$NumDbLineNames;$loopnum++) { $databasedata[$loopnum*10+3] = DecryptEmailAddress($databasedata[$loopnum*10+3]); #password request email $databasedata[$loopnum*10+4] = DecryptEmailAddress($databasedata[$loopnum*10+4]); #book request email } foreach $LibName (keys %LibDef) { $LibDef{$LibName}[1] = DecryptEmailAddress($LibDef{$LibName}[1]); } $adminEmail = DecryptEmailAddress($adminEmail); } # Check for other stuff 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 support\@resourcemate.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 Software at support\@resourcemate.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 Software for 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'}); } # Set search type for future screens, if not already set. $SearchType = ($in{'Type'}) || $ConfigIn{'SEARCHPAGE_SEARCH_DEFAULT'} ; #could be set by url parameters or lib.conf, or just the script default $SearchType = uc(substr($SearchType,0,1)); if ($SearchType eq "A") { $AltSearchType = "B"; $AltSearchText = $ConfigIn{'SEARCHPAGE_TEXT_BASIC_LINK'}; } else { $AltSearchType = "A"; $AltSearchText = $ConfigIn{'SEARCHPAGE_TEXT_ADVANCED_LINK'}; } } sub EncryptEmailAddress { $_ = $_[0]; print "Content-type: text/html\n\n"; print "

    Library Search - Email Encryption

    "; print "

    This is a simple screen to show you what the encrypted form of an email
    "; print "address should be. Copy & paste the encrypted text below into your lib.conf file.
    "; print "Please contact Jaywil Software for assistance.
    "; print "

    Starting email is: $_"; my $ascii_offset = 10; my @text_as_arr=split(//,$_); my @newarr = undef; #designed to handle ascii codes 33 through 126 foreach $character (@text_as_arr) { # print "
    [$character]"; if (ord($character)<=(126-$ascii_offset)) { push @newarr, chr(ord($character)+$ascii_offset); # print ",[",chr(ord($character)+$ascii_offset),"],",ord($character)+$ascii_offset; } else { push @newarr, chr(ord($character)+$ascii_offset-94); # print ",[",chr(ord($character)+$ascii_offset-94),"],",ord($character)+$ascii_offset-94; } } my $newstring = join "", @newarr; ($displaystring = $newstring) =~ s/New encrypted text for lib.conf:
    $displaystring"; exit; } sub DecryptEmailAddress { my $plain_text_address = undef; my $ascii_offset = 10; my $encrypted_email = $_[0]; my @encrypted_as_single_chars=split(//,$encrypted_email); my @newarr = undef; #designed to handle ascii codes 33 through 126 foreach $character (@encrypted_as_single_chars) { #print "
    [$character]"; if (ord($character)>=(33+$ascii_offset)) { push @newarr, chr(ord($character)-$ascii_offset); # print ",[",chr(ord($character)-$ascii_offset),"],",ord($character)-$ascii_offset; } else { push @newarr, chr(ord($character)-$ascii_offset+94); # print ",[",chr(ord($character)-$ascii_offset+94),"],",ord($character)-$ascii_offset-94; } } $plain_text_address = join "", @newarr; } sub TextToUnicode { $plain_text_address = $_[0]; # print "
    plain_text_address:",$plain_text_address,""; # Take the (decrypted) email address & change to unicode characters, they display fine on # the browser but don't look like anything useful in the source code (anti-spam bot method). my @plaintext_as_single_chars=split(//,$plain_text_address); @newarr = undef; foreach $character (@plaintext_as_single_chars) { # print "
    [$character]"; push @newarr, "&#".ord($character).";"; # print ",[",$character,"],","&# ".ord($character).";"; } my $unicode_address = join "", @newarr; # print "
    unicode_address:",$unicode_address,"

    "; # print "----------------------------------

    "; return $unicode_address; }