#!/usr/bin/perl use CGI; $debug = 0; $report = 0; $basedir = "/home/clients/mediaink"; $show_dir = "cafe/work"; $wmd = "/$show_dir"; $amd = "$basedir/$show_dir"; $ifile = "$basedir/maillist"; $Keyword = "MIWorkV"; $cafe = "/cafe/"; $MainArea = '/cafe/work/index3.cgi'; $query = new CGI; $home = "homequery.html"; $type = $query->param("type"); $key = $query->param("$Keyword"); $debug = 1 if $type eq "debug"; $viz = $query->param("viz"); $script = $ENV{'SCRIPT_NAME'}; $timeout = 4460; $viz = 'new' unless $viz; # cookie, this contains the URL of the page, this is the thing that Netscape # supports. # #($name,$cookie) = split(/=/,$ENV{'HTTP_COOKIE'}); $cookies = $ENV{'HTTP_COOKIE'}; #$cookie =~ s/([^URL]*)URL=([^;]*);.*/$2/; #$cookies =~ /URL=([^;]*)/; #$cookies = $1; while ($cookies =~ s/^([^;]*);//) { $r .= $1; GrabCookies ($1); } if ($cookies =~ /^([^=]*=.*)/) { GrabCookies ($1); } $key = $cookie{"$Keyword"} if $cookie{"$Keyword"}; #$email = $cookie{"Email"} if $cookie{"$Keyword"}; #$eml = $query->param("$Keyword"); $emaip = $query->param("Email"); $renew = $query->param("renew"); $declined = $query->param("decline"); $emaic = $cookie{'Email'}; foreach $k (keys %cookie) { $emaic = $cookie{$k} if $k =~ /email/i; } $email = $emaic; $email = $emaip if $emaip; sub GrabCookies { my ($i) = @_; $i =~ /^([^=]+)=(.*)$/; $cookie{$1} = $2; } $host = $ENV{'HTTP_HOST'}; $now = time(); $cexp = $now+$timeout; ($exp = gmtime($cexp)) =~ s/ /, /; if ($key) { $c1 = "$Keyword=$key;expires=$exp"; $viz = $key; } else { $c1 = "$Keyword=$cexp;expires=$exp"; $viz = "$cexp"; } #print $query->header(-cookie=>[$c1,$c2], # -location=>'media2/index2.cgi'); if ($email && $email ne 'none') { $c1 = "Email=$email;expires=$exp"; } else { $email = 'none'; $c1 = "Email=$email;expires=$exp"; } # Mail list dbmopen (%mlist, "$ifile", 0666); $mlist{$email} = $now unless $mlist{$email}; $mlist{$email} = $now if $renew; $mlist{"$email-lastvisit"} = localtime(); $mlist{"$email-fstvisit"} = localtime() unless $mlist{"$email-fstvisit"}; $mlist{"$email-totalvisit"}++; # If request has the sub directory, It will Forward to that # else this wil forward to main area. # # $viz is the session tag time, check for expiration. # $gotop = $query->param('media'); $gotoc = $cookie{'media'}; foreach $k (keys %cookie) { $gotoc = $cookie{"$k"} if $k =~ /media/; } $location = $gotop || $gotoc; $goto = "$wmd/$location" unless $goto; $here = $ENV{'REQUEST_URI'}; unless ($location) { ($location = $here) =~ s%^$wmd\/(.*)$%$1%; $location =~ s/\?.+$//; if ($location !~ /\/$/) { $location =~ s%\/[^\/]+$%/%; } } $l1 = "media=$location;expires=$exp"; $expired = $mlist{"$email"} + $timeout; if ($declined) { print $query->header(-location=>"$cafe"); } elsif ($email eq 'none') { # Session is NOT started $mlist{$email} = $now; print $query->header(-cookie=>[$c1,$l1]); if ($debug) { print start_html('Hello'); print "
NEW Session
Catched \$email is $email
Session in progress and forwarded to $goto
Catched $mlist{$email} + $timeout is $expired Greater than $now
Session in progress and you are here
Catched $mlist{$email} + $timeout is $expired Greater than $now
Expired session
Catched $mlist{$email} + $timeout is $expired LESS than $now
"; $z = $expired - $now; print "
"; print '
khjjdhfehfuehfeuhfeuhfuehf
"; } sub passthru { my ($uri, $alt, $o) = @_; $r .= "open ". `pwd` . " home.html"; if (open (I, "./home.html")) { while () { if (/\<\!--\#include\s+file=(\S+)/) { $o .= "INCLUDE START
" if $debug; if ($alt) { if (-e "$alt") { $o .= &included("$alt"); } else { $o .= &included("../$alt"); } } else { $o .= &included("$1"); } $o .= "INCLUDE END
" if $debug; } else { $o .= "$_"; } } } else { $o = 'Check back later'; } $o; } sub included { my ($file, $d, $o) = @_; $d = `pwd`; $file =~ s/\"//g; $o .= "File is $d/$file
" if $debug; if (open (C, "./$file")) { while (