#!/usr/bin/perl # Visitor Information # By Brian Prentice # July 1997 if (($ENV{'HTTP_REFERER'} !~ "^http://linuxenvy.com/bprentice") && ($ENV{'HTTP_REFERER'} !~ "^http://www.linuxenvy.com/bprentice")) { exit(1); } $| = 1; $visitor_file = "/var/www/html/$ARGV[0]/VisitorInfo/$ARGV[1]"; if (!(-e $visitor_file)) { exit(1); } open(FILE, "+<$visitor_file"); flock(FILE, 2); $firstline = ; if ($firstline !~ "^\n") { close(FILE); exit(1); } @subnet_numbers = split (/\./, $ENV{'REMOTE_ADDR'}); $packed_address = pack ("C4", @subnet_numbers); $remote_host = gethostbyaddr ($packed_address, 2); if ($remote_host eq "") { $remote_host = $ENV{'REMOTE_ADDR'}; } ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdat) = localtime(time); $mon = (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec)[$mon]; if ($year > 90) { $year += 1900; } else { $year += 2000; } $wday = (Sun, Mon, Tue, Wed, Thu, Fri, Sat)[$wday]; seek(FILE, 0, 2); print FILE $wday, "\t", $mday, "\t", $mon, "\t", $year, "\t", $hour, "\t", $min, "\t", $remote_host, "\n"; close(FILE); $Bytes[0] = "\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00"; $Bytes[1] = "\x80\x00\x00\xff\xff\xff\x00\x00\x00\x21"; $Bytes[2] = "\xf9\x04\x01\x00\x00\x00\x00\x2c\x00\x00"; $Bytes[3] = "\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44"; $Bytes[4] = "\x01\x00\x3b"; print "Content-type: image/gif", "\n\n"; print @Bytes; exit(0);