#!/usr/local/bin/perl use Socket; sub midread { open (MIDS, "mids"); while (defined($line = )) { chomp $line; if ($line =~ /^(.+)\:\s*(.+)$/) { @{$mids{$1}} = split(", ", $2); } } } sub analyze { my @rows = @_; my $row; my %hosts = (); my $iaddr; print "
";

	foreach $row (@rows)
	{
		next if ($row =~ /^204.182.55.132/);
		next if ($row =~ /^204.182.55.29/);

#		if ($row =~ /^65.3.201.234/)
#		{
#			print "$row";
#			next;
#		}
		if ($row =~ /^(\d+\.\d+\.\d+\.\d+)(.*)$/)
		{
			if ($mids{$1})
			{
				print "$1 (" . $mids{$1}->[0] . qq|)$2\n|;
				next;
			}
#			else
#			{
#				print qq|$1$2|;
#				next;
#			}
		}
		print "$row";
	}

	print "
"; } midread(); print "Content-type: text/html\n\n"; print "\n"; print "Web Page Stats\n"; print "\n"; if ($ENV{QUERY_STRING}) { if ($ENV{QUERY_STRING} =~ m/^zoom\=(\d+\.\d+\.\d+\.\d+).*/) { $ipaddr = $1; $iaddr = inet_aton($ipaddr); $name = gethostbyaddr($iaddr, AF_INET); if ($name =~ m/.*\.(\w+\.\w+)$/) { $whois = "whois $1\n"; $whois .= `/usr/bin/whois $1`; } print "
\n";
		print "$ipaddr [$name]\n";
		print "
\n"; print "$whois\n"; print "
\n"; exit; } if ($ENV{QUERY_STRING} =~ m/^log\=(\d)/) { if (($1 > 0) && ($1 < 8)) { $day = $1 - 1; @today = `gzcat /var/log/httpd/access.log.$day.gz | grep chucky`; analyze(@today); exit; } } } @today = `cat /var/log/httpd/access.log | grep chucky`; analyze(@today); print "\n"; print "\n"; 1;