#! /usr/bin/perl

#####################################################
# Program: remove_ip_num.pl                         #
# Fjerner enkelte logginger fra access_log          #
# Fra stat-ip-nummer, /admin/, /temp/ og map_access #
# Laget: 980607 - Knut A. Mork                      #
#####################################################

# Variabler

$log_file = "/var/lib/httpd/logs/almashriq/access_log";
$tmp_log  = "/var/lib/httpd/logs/almashriq/tmp_log";
$ip_file  = "/home/almash/admin/statistics/stat-ip-nummer";

open (IPFILE, $ip_file);

while (<IPFILE>)
{
    if ($_ =~ /^([^#\s]+)/)
    {
	$ip[$i] = $1;
	$i++;
    }
}

close (IPFILE);

$kommando = "egrep -v '";

while (<@ip>)
{
    $kommando = $kommando . "^$_ -|";
}

$kommando = $kommando . "GET /admin/|GET /cgi-bin/last_visitors.pl|GET /temp/' $log_file > $tmp_log";

system ($kommando);
system ("cat $tmp_log > $log_file");
system ("rm $tmp_log");
