All pastes #25887 Raw Edit

Unnamed

public text v1 · immutable
#25887 ·published 2005-10-18 21:24 UTC
rendered paste body
# *****************************************************************************
#!/bin/perl -w
# Duzan, Tyler		Created 10/18/05	Modified 10/18/05
# 
# Licensed under the GPL v2 or later, see license.txt or http://gnu.org/ for
# more information.
# 
# Simple log analyzer that will compare an array of regex against an Apache log
# file to find any referral spammers that you haven't banned yet, and report
# their IP addresses to you.
#
# Thanks to Kaos Havoc for explaining how to do most of this.
# *****************************************************************************
use warnings;
print ("\n");

#declare my variables
@loglines;
@testlines;

#populate my arrays
open (FILE, "blacklist.txt");
while (<FILE>) {
	chomp ($_);
	push(@testlines,$_);
}
close (FILE);
open (FILE, "access.log");
while (<FILE>) {
	chomp ($_);
	push(@loglines,$_);
}
close (FILE);
open (FILE, "output.txt");
#do my comparison
foreach ($logline (@loglines)) {
	foreach ($testline (@testlines)) {
		if ($logline =~ $testline) {
			print FILE ("$logline\n");
		}
	}
}