1 #! /usr/local/bin/perl -T 2 3 use strict; 4 5 use warnings; 6 7 use DBI; 8 9 use CGI; 10 11 use CGI::Carp; This Line Isn't Really In The Actual Program 12 13 use Time::HiRes qw ( gettimeofday tv_interval); 14 15 my $now = [gettimeofday]; 16 17 use Fcntl qw(:flock); 18 19 $ENV{'PATH'} = '/bin:/usr/bin'; 20 21 $ENV{'IFS'} = ''; 22 23 open LOG, ">>/web/webdata/w1sdm/73/database.log" or die "Cannot open log file\n$!\n"; 24 25 flock (LOG, LOCK_EX()); 26 27 my @days = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); 28 29 my @months = (" ", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "D 30 31 my ($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6]; 32 33 my $time = sprintf("%02d:%02d:%02d",$hour,$min,$sec); 34 35 $year += 1900; 36 37 ++$mon; 38 39 my $date = "$days[$wday], $months[$mon] $mday, $year at $time"; 40 41 print LOG "Date: $date\n"; 42 43 my $dir = "/web/webdata/w1sdm"; 44 45 our ($db_connected_flag, $dbh); 46 47 my $q = new CGI; 48 49 my $title = lc($q->param('title')); 50 51 my $author = lc($q->param('author')); 52 53 my $form_month = $q->param('issue_month'); 54 55 my $form_year = $q->param('issue_year'); 56 57 my $info = "Search submission time: $date\n\n
\n\nBrowser: $ENV{'HTTP_USER_AGENT'}\n\n
\n\nIP Address: $ENV{'REMOTE_ADDR'}\n\ 58 59 print LOG "Browser: $ENV{'HTTP_USER_AGENT'}\nIP Address: $ENV{'REMOTE_ADDR'}\nTitle: $title\nAuthor: $author\nMonth: $form_month\nY 60 61 my ($author_search_terms, $title_search_terms, $mysql_command, @mysql_data, @rows, $html, @search_terms); 62 63 if ($author) { $author_search_terms = clean($author); } 64 65 if ($title) { $title_search_terms = clean($title); } 66 67 $html = load_file("$dir/73/templates/results.html"); 68 69 $mysql_command = "SELECT * FROM data WHERE"; 70 71 if ($author_search_terms) { 72 73 ($mysql_command, @mysql_data) = expand_terms($mysql_command, 'author', $author_search_terms, @mysql_data); 74 75 } 76 77 if ($title_search_terms) { 78 79 ($mysql_command, @mysql_data) = expand_terms($mysql_command, 'title', $title_search_terms, @mysql_data); 80 81 } 82 83 if ($form_month) { 84 85 ($mysql_command, @mysql_data) = append_term($mysql_command, 'month', $form_month, @mysql_data); 86 87 $html =~ s/