To do this, you need a log file that captures the query that is sent to the
Ultraseek search engine. We will show two alternatives for logging queries typed into your search text box.
#path to your PERL interpreter
#!/usr/bin/perl
##############################################################
# Make sure that these PERL modules are installed on your web
# server
##############################################################
use LWP::Simple;
use Time::localtime;
use CGI;
##############################################################
# HTML page header
##############################################################
$req = new CGI;
print $req->header();
##############################################################
# pass the query to Ultraseek and assign result to scratch
##############################################################
$query = $ENV{QUERY_STRING};
# for Chattanooga
$_ = get("http://search.tennessee.edu/utc/query.html?"."$query");
# for Institute of Agriculture
$_ = get("http://search.tennessee.edu/utia/query.html?"."$query");
# for Institute of Public Service
$_ = get("http://search.tennessee.edu/utips/query.html?"."$query");
# for Knoxville
$_ = get("http://search.tennessee.edu/utk/query.html?"."$query");
# for Martin
$_ = get("http://search.tennessee.edu/utm/query.html?"."$query");
# for Memphis
$_ = get("http://search.tennessee.edu/utmem/query.html?"."$query");
# for UTSI
$_ = get("http://search.tennessee.edu/utsi/query.html?"."$query");
# for UT system-wide
$_ = get("http://search.tennessee.edu/query.html?"."$query");
# VERY IMPORTANT!! YOU MUST ALTER THE PATH BELOW TO POINT TO WHERE
#THIS SCRIPT RESIDES ON YOUR SERVER!!
s/query.html/http:\/\/www.your.machine.edu\/path\/to\/this\/script/g;
# use full urls for images and stylesheet
s/\/images/http:\/\/search.tennessee.edu\/images/g;
s/images\/UT_plain.gif/http:\/\/search.tennessee.edu\/images\/UT_plain.gif/g;
s/default.css/http:\/\/search.tennessee.edu\/default.css/g;
s/<div class=search>/<\/center>\n<div class=search>/g;
# replace the default search box with a customized one
# user can pack a customized search box into the $query_box
$query_box = "<p>\n<br>\n<form name=seek method=GET \
# VERY IMPORTANT!! YOU MUST ALTER THE PATH BELOW TO POINT TO WHERE
THIS SCRIPT RESIDES ON YOUR SERVER!!
action=http://www.your.machine.edu/path/to/this/script \
<table cellspacing=0 cellpadding=6 border=1 width=100% class=query>\
<tr>\
<td>\
<input type=hidden name=col value=\"utk\"> \
<input type=text name=qt size=40> \
<input type=hidden name=qp value=\"+site:www.cs.utk.edu\"> \
<br><input type=submit value=\"Search\">\n \
<a href=\"http://www.ultraseek.com/\"><img alt=\"\" \
src=\"http://search.tennessee.edu/images/littlelogo.gif\"
width=126 height=30 border=0 align=right><\/a>\
<\/td>\
<\/tr>\
<\/table>\n<\/form>";
s/\<form(.|\n)+\/form>/$query_box/;
##############################################################
#print out the edited result which is an HTML document
##############################################################
print;
##############################################################
# logging capability
##############################################################
@variables = split(/&/, $query);
$flag = 1;
while($flag == 1) {
$temp = shift(@variables);
# retrieve the qt variable
if ($temp =~ /^qt=/) {
$qt = $temp;
@qta = split(/=/, $qt);
$qt = @qta[1];
$flag = 0;
}
}
open (QTHANDLE, ">> logs/qt_log.txt") or die;
# output the qt variable together with remote host name and
# the current time to the log file
print QTHANDLE "$qt\t$ENV{REMOTE_HOST}\t", ctime(), "\n";
close(QTHANDLE);