#!/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";
# 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 = \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 "