#!/usr/planet/bin/perl5 require ("include/bbn.pm"); use Msql; $prefix = "client-html/source" ; $preprefix = "/home/www/proof/htdocs"; #= END DEFINITIONS ======================================================= # carve off the session id from the file name @path = split('/', substr($ENV{'PATH_INFO'}, 1), 2); $SID = $path[0]; $fyle = "$prefix/$path[1]"; $shortfyle = "$path[1]"; &cgi_receive; &cgi_decode; #========================================================================= # Make the database connection $dbh = Connect Msql; if (!$dbh) { &do_msql_error; exit; } SelectDB $dbh $DB; # look up session id in the DB, see if it is fresh $query = "select dateused, datemade from $TBL_SESSION where session='$SID'"; $sth = Query $dbh $query; if ($sth) { @result = FetchRow $sth; } else { &reportStaleSession ; } # session id is there... now see if it is fresh $curtime = time(); $dateused = $result[0]; $datemade = $result[1]; if (($curtime - $dateused) > $MAX_IDLE) { &reportStaleSession } else { # update the date use field with current time $query = "update $TBL_SESSION set dateused=$curtime where session='$SID'"; $sth = Query $dbh $query ; if (!$sth) { &do_msql_error } ; } # figure out if the requested file is html or not... # by looking for the ".html" or ".htm" file extension if ($fyle =~ /.htm$/) { $fyle =~ s/.htm$/.html/ } # a hack file bug fix if ($fyle =~ /.html$/) { &cgi_head; open(FYLE,"$preprefix/$fyle") || open(FYLE,"$preprefix/$shortfyle") || die "

Sorry... we can't seem to open the requested file

\n"; #==================================================================== # parse the html file and process it dynamically # 1) insert the RER stuff near the top # 2) look for special comment # /) { $line = $line.; } print $line; $line =~ s///; $_ = $line; @keys = split; # now get the translation table open(KTBL, "<$KEYTABLE") || die "Sorry... we can't get keyword translation table\n"; foreach $item () { @pair = split(' ',$item,2); $kwtt{$pair[0]} = $pair[1]; } } else { # nothing interesting found in this line print $line; } } # end while if ($keys[0]) { print "
\n"; print "

\n"; # dih 12/30/95: open(DIRF, "<$SESSION_PATH$SID/curdir"); $_ = ; $curdir = $_; tr/a-z/A-Z/; $capdir = $_; close DIRF; print "You are searching across "; if ($capdir ne 'SOURCE') { print "CatoSource listings only in the $capdir directory."; } else { print "ALL CatoSource listings."; } print "



\n"; print "To find related providers, check one or more keywords"; print " and search again."; print "
You may also change to another type of search using "; print "the icons below.
\n"; print "

\n"; $i = 0; while ($keys[$i]) { print "\n"; if ($kwtt{$keys[$i]}) { print "$kwtt{$keys[$i]}\n"; } else { print "$keys[$i]\n"; } $i = $i + 1; } print "
\n"; print "
\n"; if ($#keys > 0) { print "What type of match would you like?\n"; print "
\n"; print "Match ANY keyword (or)\n"; print "Match ALL keywords (and)\n"; print "
\n"; } else { print "\n"; } print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "\n"; # now generate toolkit imagemap with proper map file print "
\n"; if ($hasRER) { $TTLNS = $TITLE; $TTLNS =~ s/%20//g ; $csmapfyle = $SESSION_PATH.$SID."/combined-ico.cli.".$TTLNS.".map" ; if (!(-e $csmapfyle)) { # make the customer-specific map file $mapfyle = $SESSION_PATH.$SID."/combined-ico.cli.map" ; open(MAP,"<$mapfyle") || die "Can't open MAP file for reading"; open(CSMAP,">$csmapfyle") || die "Can't open Client MAP file for writing"; while ($lyne = ) { $lyne =~ s/rer\?sid=/rer\?customer=$TITLE\&sid=/ ; print CSMAP $lyne; } close CSMAP; close MAP; } print "\n"; } else { print "\n"; } print "\n"; print "
\n"; } } else { # file is not html... just dump the file to output as is print ; } ##################################################################### #### SUBROUTINES #################################################### sub reportStaleSession { &cgi_header; print "

Session Id is Stale

\n"; print "Please re-enter CatoSource to "; print "get a fresh session."; print "

\n"; print "\n"; exit; } sub do_msql_error { &cgi_header; print "

Unable to connect to database

\n"; print "The database is currently down for maintenance.\n"; print "Please try connecting again in a few minutes.\n"; print "

\n"; print "\n"; exit; }