#!/usr/bin/perl use File::Basename;. push (@INC,(fileparse($0))[1]);. require "lightsquid.cfg";. require "common.pl";. ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime;. $year=sprintf("%02d",$year+1900);. $month=sprintf("%02d",$mon+1);. $filter="$year$month";. @daylist=glob("$reportpath/$filter*");. foreach $daypath (sort @daylist) {. open FF,"<$daypath/.total";. # GetRealName($daypath,"?"); # init realname for day. <FF>;. <FF>;. while (<FF>) {. ($user,$size,$hit)=split;. $h{$user}{size}+=$size;. $h{$user}{hit}+=$hit;. }. close FF;. }. open FF,"</etc/squid/limit";. while (<FF>) {. ($user,$limit)=split;. $tt{$user}{limit}=$limit;. }. close FF;. open FF,">","/etc/squid/blocked_users";. foreach $user (sort {$h{$b}{size}<=>$h{$a}{size}} keys %h) {. print FF ("$user\n") if ($h{$user}{size} > $tt{$user}{limit});. }. close FF;. |