lightsquid-1.8/0000775000076500000240000000000011223223552012204 5ustar eslstafflightsquid-1.8/.htaccess0000644000076500000240000000007010227203176014000 0ustar eslstaffOptions FollowSymLinks ExecCGI DirectoryIndex index.cgi lightsquid-1.8/bigfiles.cgi0000755000076500000240000000435110501735342014463 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt print "Content-Type: text/html\n\n"; use File::Basename; push (@INC,(fileparse($0))[1]); use CGI; require "lightsquid.cfg"; require "common.pl"; $co=new CGI; $year =$co->param('year'); $month =$co->param('month'); $day =$co->param('day'); $filteruser =$co->param('user'); InitTPL("bigfiles",$co->param('tpl')); $n=1; $total=0; $workperiod=" $day $MonthName[$month] $year"; open FF,"<$reportpath/$year$month$day/.bigfiles" || MyDie("cant' open .bigfile"); $N=0; while () { ($user,$time,$size,$link)=split; if ($filteruser ne "") { next unless ($filteruser eq $user); }; $N++; $total+=$size; $printsize=FineDec($size); $rowattr = ($N & 1)?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $url_L=URLEncode("user_detail.cgi?year=$year&month=$month&day=$day&user=$user"); $url_B="$user"; $url_L =~ s/#/%23/; $tmp=$hTPL{bigfile}; $tmp=~s/##BFILENUM##/$N/; $tmp=~s/##BFILETIME##/$time/; $tmp=~s/##BFILEUSER_L##/$url_L/; $tmp=~s/##BFILEUSER_B##/$url_B/; $tmp=~s/##BFILESIZE##/$printsize/; $tmp=~s/##BFILELINK##/$link/; $tmp=~s/##ROWATTR##/$rowattr/; $tpl{bigfile} .= $tmp; } close FF; $printsize=FineDec($total); $tmp=$hTPL{bigfile}; $tmp=~s/##BFILENUM##/ /; $tmp=~s/##BFILETIME##/ /; $tmp=~s/##BFILEUSER_L##//; $tmp=~s/##BFILEUSER_B##/TOTAL/; $tmp=~s/##BFILESIZE##/$printsize/; $tmp=~s/##BFILELINK##/ /; $tmp=~s/##ROWATTR##/$hTPLVARIABLE{total}/; $tpl{bigfile} .= $tmp; ReplaceTPL(DATE,$workperiod); ReplaceTPL(REPORTUSER,$filteruser); ApplyTPL(); HideTPL("reportuser") if ($filteruser eq ""); PrintTPL(); __END__ 2004-09-09 ADD : skip all files starting with . 2005-04-17 ADD : TemplateEngine 2005-07-01 ADD : TOTAL size 2005-08-30 ADD : Color flipper 2005-09-08 ADD : user now URL to day_detail for user 2005-10-01 ADD : _L,_B 2005-11-07 ADD : URL_Encode 2006-06-28 ADD : die -> MyDie 2006-06-28 ADD : &tpl= support 2006-09-13 ADD : &user= filter by USER lightsquid-1.8/check-setup.pl0000755000076500000240000001504111136060434014757 0ustar eslstaff#!/usr/bin/perl print "LightSquid Config Checker, (c) 2005-9 Sergey Erokhin GNU GPL\n\n"; die "perl module File::Basename not found, please install !\n" if (!eval { require File::Basename }); use File::Basename;push (@INC,(fileparse($0))[1]); die "can't access to lightsquid.cfg !!!\n" if (!eval { require "lightsquid.cfg" }); die "can't access to common.pl !!!\n" if (!eval { require "common.pl" }); die "no: CGI.PM found, please install\n" if (!eval { require CGI }); die "can't access to $logpath `access.log` file\ncheck \$logpath variable or privilege\n" unless (-f "$logpath/access.log"); die "Invalid access.log format or can't check format type ...\n" if (CheckLogType("$logpath/access.log")); print "LogPath : $logpath\n"; open F,"<$logpath/access.log" or die "can't access to `access.log` file, check privilege\n"; close F; print "reportpath: $reportpath\n"; die "can't found report folder `$reportpath`\nplease check \$reportpath variable, create if need\n" unless (-d "$reportpath"); open F,">$reportpath/test.txt" or die "can't create file in $reportpath folder, check privilege\n"; close F; unlink "$reportpath/test.txt"; print "Lang : $langpath/$lang\n"; open F,"<$langpath/$lang.lng" or die "can't open language file $langpath/$lang.lng, check \$lang variable\n"; close F; print "Template : $tplpath/$templatename\n"; open F,"<$tplpath/$templatename/index.html" or die "can't open template $tplpath/$templatename folder, check \$templatename variable\n"; close F; print "Ip2Name : $ip2namepath/ip2name.$ip2name\n"; open F,"<$ip2namepath/ip2name.$ip2name" or die "can't open file $ip2namepath/ip2name.$ip2name file, check \$ip2name variable\n"; close F; print "\n"; die "\$skipurl variable empty !, read documentation !!!\n" if ($skipurl eq ""); if ($graphreport) { die "no: GD.PM found, please install or set \$graphreport=0 to disable\n" if (!eval { require GD }); require GD; die "no: GD::Polygon modules, please install or set \$graphreport=0 to disable\n" if (!eval { my $poly1 = new GD::Polygon }); die "no: GD trouble, please install or set \$graphreport=0 to disable\n" if (!eval { $im = new GD::Image(720,480) }); if ($ttffont ne "") { die "can't access to TTF font $font file, check \$font variable or set \$ttffont = \"\" to disable\n" unless (-f $ttffont); die "no: TTF support in GD, please install, or set \$ttffont = \"\" to disable\n" if (!eval { $im = new GD::Image(720,480) ;$im->stringFT(0,$ttffont,7,0.0,0,437,"Hello World") }); } die "Variable \$graphmaxuser should be >0 !!!\n" if ($graphmaxuser == 0); die "Variable \$graphmaxall should be >0 !!!\n" if ($graphmaxall == 0); } #check $skipurl, warning if they contain . char if ($skipurl =~ m/\./) { $tmp=$skipurl; $skipurl =~ s/\\\.//gs; if ($skipurl =~ m/\./) { print "WARNING: \$skipurl variable contain unescaped '.' char !!!\n"; print "WARNING: if you use \. as regular expression metacharacter please use '' instead \"\" and escape . via \\\. \n"; print "WARNING: \$skipurl now ->$tmp<\n"; } } print "\nall check passed, now try access to cgi part in browser\n"; sub CheckLogType($) { my $LogFile = shift; my @a; my $EmulatedFormat1 = 0; my $EmulatedFormat2 = 0; my $NativeFormat1 = 0; my $NativeFormat2 = 0; my $TestedLine = 0; my $ret = 0; my @LogName; $LogName[0] ="Native"; $LogName[1] ="Emulated"; my $warning; # print "FILE: $LogFile\n"; unless ( -z $LogFile ) { open FLOG, "<", "$LogFile"; while () { chomp; $line=$_; next if ( $line eq "" ); $TestedLine++; @a = split /\s+/, $line; $NativeFormat1++ if ( ( $a[0] = ~ m/\d+\.\d+/ ) and ( $a[1] =~ m/\d+/ ) and ( $a[4] =~ m/\d+/ ) ); # 0 1 2 3 4 5 #970313965.619 1249 denis.local TCP_MISS/200 2598 GET http://www.emalecentral.com/tasha/thm_4374x013.jpg - DIRECT/www.emalecentral.com image/jpeg # timestamp elapsed host type size method url user hierarechy type #1125191043.218 3 192.168.1.240 TCP_DENIED/403 1411 GET http://ar.atwola.com/image/93159194/icq - NONE/- text/html #1125191043.219 0 192.168.1.240 TCP_DENIED/403 1403 GET http://ar.atwola.com/file/adsEnd.js - NONE/- text/html $NativeFormat2++ if ( ($#a == 9) ); #emulated httpd log # 0 1 2 3 4 5 #192.168.3.40 - - [15/Apr/2005:11:46:35 +0300] "GET http://mail.yandex.ru/mboxjscript? HTTP/1.0" 200 2262 TCP_MISS :DIRECT $EmulatedFormat1++ if ( ( $a[3] = ~ m/\[\d{1,2}\// ) and ( $a[4] =~ m/\d{1,4}\]/ ) and ( $a[5] =~ m/\"/ ) ); # 192.168.3.40 - - [15 /Apr /2005 :11 :46 :35 +0300] "GET http://mail.yandex.ru/mboxjscript? HTTP/1.0" 200 2262 TCP_MISS :DIRECT $EmulatedFormat2++ if ( $line =~ m/^(\d{1,3}\.){3}\d{1,3}\s+\S+\s+\S+\s\[\d{1,2}\/\S{1,3}\/\d{4}\:\d{1,2}\:\d{1,2}\:\d{1,2}\s[+-]\d{1,4}\] \".*\S+\:\S+$/); } close FLOG; if ( $TestedLine == 0 ) { die "WARNING: log file is empty!, can't check log file format !!!!!\n"; } $n1 = Percent( $TestedLine, $NativeFormat1 ); $n2 = Percent( $TestedLine, $NativeFormat2 ); $e1 = Percent( $TestedLine, $EmulatedFormat1 ); $e2 = Percent( $TestedLine, $EmulatedFormat2 ); if ($debug) { print "dbg: tested : $TestedLine\n"; print "dbg: native1 : $NativeFormat1 :: $n1\n"; print "dbg: native2 : $NativeFormat2 :: $n2\n"; print "dbg: emulate1: $EmulatedFormat1 :: $e1\n"; print "dbg: emulate2: $EmulatedFormat2 :: $e2\n"; } if ( $e1 > 90 ) { $detected = 1; $warning = "Log format Look like CUSTOM log, Lightsquid can't parse this format! Please check documentation !" if ( $e2 < 60 ); } if ( $n1 > 90 ) { $detected = 0; $warning = "Log format Look like CUSTOM log, Lightsquid can't parse this format! Please check documentation !" if ( $n2 < 60 ) ; } } else { $warning="log file is empty!, can't check log file format !!!!!\n"; } if ( $detected != $squidlogtype ) { print "WARNING: \$squidlogtype=$squidlogtype in lightsquid.conf, it's mean expected log type is '$LogName[$squidlogtype]'\n"; print "WARNING: but your access.log look like `$type`, please correct config file -> `\$squidlogtype=$detected`\n"; $ret=1; } if ( $warning ne "" ) { $ret=1;print "WARNING: $warning\n"}; return $ret; } sub Percent($$) { my $total = shift; my $val1 = shift; return sprintf( "%.2f", ( $val1 * 100 ) / $total ); } lightsquid-1.8/common.pl0000644000076500000240000002203711223223552014033 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt use Time::Local; #month name @MonthName = (00, "##MSG_MONTH01##","##MSG_MONTH02##","##MSG_MONTH03##","##MSG_MONTH04##", "##MSG_MONTH05##","##MSG_MONTH06##","##MSG_MONTH07##","##MSG_MONTH08##", "##MSG_MONTH09##","##MSG_MONTH10##","##MSG_MONTH11##","##MSG_MONTH12##", ); # ------------------------------------------- common funcion sub FineDec($) { my $val=shift; my $ret=$val; if ($DecOutType eq "class") { if ($val>=1000*1024*1024) {$ret=sprintf("%3.1f G",$val/(1024*1024*1024));} elsif ($val>= 1024*1024) {$ret=sprintf("%3.1f M",$val/( 1024*1024));} else { $ret=$val;} } $ret =~ s/(\d{1,3})(?=(?:\d\d\d)+(?!\d))/$1$decdelimiter/gx; return $ret; } sub GetTxtDate($) { my $date = shift; $date =~ m/^(\d\d\d\d)(\d\d)(\d\d)/; return "$3 $MonthName[$2] $1"; } sub GetWeekDayDate($) { my $date = shift; $date =~ m/^(\d\d\d\d)(\d\d)(\d\d)/; my $wday= (localtime(timelocal(0,0,0,$3,$2-1,$1)))[6]; return $wday; } $hFeatures{0}=1; # -------------------------------------------- .features support sub GetFeatures($$$) { my $path=shift; my $featuresname=shift; my $featuresdefault=shift; my $fname; my $fval; unless (defined $hFeatures{$path}{__init__}) { open Fftr,"<$path/.features"; while () { chomp; ($fname,$fval)=split /\s/,$_,2; $fname =~ s/://; $hFeatures{$path}{$fname}=$fval; } close Fftr; $hFeatures{$path}{__init__}=1; } $fval=(defined $hFeatures{$path}{$featuresname})?$hFeatures{$path}{$featuresname}:$featuresdefault; return $fval; } # -------------------------------------------- .realname support #read .realname file #in : FilePath, UserID #out: realname, or ? if not userid in file sub GetRealName($$) { my $path=shift; my $userid=shift; my $fuid; my $fullname; my $fval; unless (defined $hRealName{$path}{__init__}) { open Fftr,"<$path/.realname"; while () { next if (m/^#/); next if (m/^\s+$/); chomp; ($fuid,$fullname)=split /\s/,$_,2; $fuid =~ s/://; $hRealName{$fuid}=$fullname; } close Fftr; $hRealName{__init__}=1; } $fval=(defined $hRealName{$userid})?$hRealName{$userid}:"?"; return $fval; } # -------------------------------------------- Templates support $RequiredTPLVersion="1.7"; sub InitTPL($) { InitLANG("eng"); InitLANG($lang); my $tmp=$/; my $tplname=shift; my $newtpl=shift; CheckNewTPL($newtpl); undef $/; open F,"<$tplpath/$templatename/$tplname.html" or MyDie("can't open template file $tplpath/$templatename/$tplname.html - $!\n"); $template=; close F; #check version $template =~ m//; if ($RequiredTPLVersion > $1) { print "
WARNING!!! :: Your Template ($templatename) version: $1 , Required $RequiredTPLVersion. Update template.
"; } while ($template =~ s/(.*?)//s) { $hTPL{$1}=$2; } #get VARIABLEs from TPL while ($template =~ s///s) { $hTPLVARIABLE{$1}=$2; } $/=$tmp; my $meta=qq(\n). qq(\n). qq(\n). qq(\n). qq(\n). qq(\n). qq(\n); ReplaceTPL(META,$meta); } sub CheckNewTPL($) { my $newtpl=shift; if ($newtpl) { $templatename=$newtpl; ReplaceSTRING(".cgi\\?",".cgi\?tpl=$newtpl\&"); } } sub ReplaceSTRING($$) { my $name=shift; my $value=shift; $hTPLreplaceString{$name}=$value; } sub ReplaceTPL($$) { my $name=shift; my $value=shift; $hTPLreplace{$name}=$value; } sub ReplaceTPL_URL($$$) { my $name=shift; my $value_L=shift; my $value_B=shift; $hTPLreplace{"$name"."_L"}=$value_L; $hTPLreplace{"$name"."_B"}=$value_B; } sub ApplyTPL() { my $tpl; #replace repeatable block foreach $tpl (keys %hTPL) { $template =~ s/()/$tpl{$tpl}/; } $template =~ s/##COPYRIGHT##/$COPYRIGHT/; #replace string foreach $name (keys %hTPLreplace) { $template =~ s/##$name##/$hTPLreplace{$name}/gs; } #replace string pass 2 foreach $name (keys %hTPLreplace) { $template =~ s/##$name##/$hTPLreplace{$name}/gs; } foreach $name (keys %hTPLreplaceString) { $template =~ s/$name/$hTPLreplaceString{$name}/gs; } } sub HideTPL($) { #remove section DELETED SECTION my $hidename=shift; $template =~ s/.*?//gs; } sub PrintTPL() { #delete EMPTY url link (href="") $template =~ s/(.*?)<\/a>/$1/gi; #delete not used HIDE field $template =~ s///gs; $template =~ s///gs; #delete TPL version $template =~ s///gs; #delete empty spaces in lines $template =~ s/(^\s*$)//mg; print $template; } # -------------------------------------------- Localization support sub InitLANG($) { my $langname=shift; my $lname; my $lvalue; open F,"<$langpath/$langname.lng" or MyDie("can't open language file $langpath/$langname.lng - $!\n"); while () { chomp; next if (/^#/); ($lname,$lvalue)=split /=/,$_,2; # $hTPLreplace{$lname}=$lvalue; ReplaceTPL($lname,$lvalue); } close F; } ## Group routines -------------------------------------- sub GetGroup($) { my $path=shift; my @a; open F,"<$path/.group"; while () { next if (m/^#/); next if (m/^s+$/); chomp; ($username_,$groupid_,$groupname_)=split /\s+/,$_,3; if ($showgroupid) { $hGroupName{$groupid_}="$groupid_. $groupname_" } else { $hGroupName{$groupid_}="$groupname_" }; $hGroup{$username_}=$groupid_; } close F; } sub GetGroupFile($) { my $path=shift; my @a; open F,"<$path/.group"; while () { next if (m/^#/); next if (m/^s+$/); chomp; ($username_,$groupid_,$groupname_)=split /\s+/,$_,3; if ($showgroupid) { $hGroupName{$groupid_}="$groupid_. $groupname_" } else { $hGroupName{$groupid_}="$groupname_" }; #esli v groupe est' etot chelovek to =1 $hGroupByUser{$groupid_}{$username_}=1; #esli user whodit w gruppu, to hash =1; $hUserGroup{$username_}{$groupid_}=$groupid_; } close F; $hGroupName{$NotInGroupID}="$NotInGroupName"; $hGroupName{$NotInGroupID}="$NotInGroupID. $NotInGroupName" if ($showgroupid); } # $COPYRIGHT="
LightSquid v1.8 (c) Sergey Erokhin AKA ESL
"; ##----------------------------------------------------- # Encoding and decoding. WebIn.pm # (c) Dmitry Koterov , http://www.dklab.ru sub URLEncode { my ($s)=@_; $s=~s/([^;\/?:@&=+\$,A-Za-z0-9\-_.!~*'()])/sprintf("%%%02X",ord $1)/sge; return $s } sub URLDecode { my ($s)=@_; $s=~tr/+/ /; $s=~s/%([0-9A-Fa-f]{2})/chr(hex($1))/esg; return $s } sub ErrPrintConfig($) { my $msg=shift; print "LigthSquid diagnostic.
"; print "Error : $msg
"; print "Please check config file !
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
Variablevalue
\$tplpatph$tplpath
\$templatename$templatename
\$langpatph$langpath
\$langname$lang
\$reportpath$reportpath
Access to '$reportpath' folderyes":"RED>NO !!!!!!!!!!!!"); print "
\$graphreport$graphreport
"; } sub MyDie($) { my $msg=shift; ErrPrintConfig($msg); exit; } 1; __END__ 2005-06-06 ADD :: FineDec, add "class" output type 2005-08-29 ADD :: GetWeekDayDate, and use Time::Local 2005-10-01 ADD :: add ReplaceTPL_URL, & PrintTPL, and fix -w warning 2005-10-03 ADD :: Check TPL version. warning if < $RequiredTPLVersion 2005-11-21 ADD :: insert Group routines 2006-06-28 ADD :: better error handling, die replaced by MyDie. 2006-06-28 ADD :: &tpl= support 2006-11-20 ADD :: add $showgroupid support lightsquid-1.8/day_detail.cgi0000775000076500000240000001115210551135204014771 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt print "Content-Type: text/html\n\n"; use File::Basename; push (@INC,(fileparse($0))[1]); use CGI; require "lightsquid.cfg"; require "common.pl"; $co=new CGI; #$year ="2004"; #$month="05"; #$day ="01"; #$user ="#169"; $year =$co->param('year'); $month =$co->param('month'); $day =$co->param('day'); $oversize =$co->param('oversize'); InitTPL("day_detail",$co->param('tpl')); $daypath="$reportpath/$year$month$day"; $workperiod="$day $MonthName[$month] $year"; ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat("$daypath"); ($sec_,$min_,$hour_,$mday_,$mon_,$year_,$wday_,$yday_,$isdst_)=localtime($mtime); $mon_++;$year_+=1900; $worktmp=GetFeatures($daypath,"modification",sprintf("%02d:%02d",$hour_,$min_)." :: $mday_ $MonthName[$mon_] $year_"); #forkaround for bug in version 1.7 $worktmp =~ m/(.*?\:\:\s+\S+)\s+(\S+)\s+(\S+)/; if ($3 < 1900) { $preffix=$1; $year_=$3+1900;$month_=$2; if ($month_=~ m/MONTH(\d\d)/) {$month_=$1+1;} else {$month_=1;} $worktmp ="$preffix $MonthName[$month_] $year_"; } $workperiod .= " (##MSG_UPDATE## :: $worktmp)" ; $topsitesurl="topsites.cgi?year=$year&month=$month&day=$day"; $bigfilesurl="bigfiles.cgi?year=$year&month=$month&day=$day"; open FF,"<$daypath/.total"; $totaluser=;chomp $totaluser;$totaluser=~s/^user: //; $totalsize=;chomp $totalsize;$totalsize=~s/^size: //; $totalsize=1 if ($totalsize == 0); $topsites_L="$topsitesurl"; $topsites_B="##MSG_TOP_SITES##"; $bigfiles_B="##MSG_BIG_FILES##"; if (-f "$daypath/.bigfiles") { $bigfiles_L="$bigfilesurl"; } $overmsg="##MSG_OVERSIZE_HEAD## ".FineDec($perusertrafficlimit)." ##MSG_OVERSIZE_TAIL##"; GetGroup($daypath); $N=0; while () { $N++; ($user,$size,$hit,$putpost)=split; next if ($oversize && ($size < $perusertrafficlimit)); $percent =sprintf("%2.1f",int($size*1000/$totalsize)/10); $printhit =FineDec($hit); $printsize =FineDec($size); $printputpost=FineDec($putpost); $putpostpercent=($putpost*100)/($size+1); # $printputpost .= " (".sprintf("%2.2f",$putpostpercent).")"; $timeurl_L=URLEncode("user_time.cgi?year=$year&month=$month&day=$day&user=$user"); $timeurl_B="##MSG_TIME_LINK##"; $userurl_L=URLEncode("user_detail.cgi?year=$year&month=$month&day=$day&user=$user"); $userurl_B="$user"; $realname=GetRealName($daypath,$user); # $userurl_L =~ s/#/%23/; #no URLEncode here! # sign in url !! $usergroupurl_L="group_detail.cgi?year=$year&month=$month&day=$day#$hGroup{$user}"; $usergroupurl_B=(defined $hGroup{$user})?"$hGroupName{$hGroup{$user}}":"?"; $rowattr = ($N & 1)?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $overputpostattr=(($showputpost) && ($putpostpercent < $putpostwarninglevel))?$hTPLVARIABLE{putpostnormalattr}:$hTPLVARIABLE{putpostwarningattr}; $tmp=$hTPL{user}; $tmp=~s/##USERNUM##/$N/; $tmp=~s/##TIMEURL_L##/$timeurl_L/; $tmp=~s/##TIMEURL_B##/$timeurl_B/; $tmp=~s/##USERURL_L##/$userurl_L/; $tmp=~s/##USERURL_B##/$userurl_B/; $tmp=~s/##USERCONNECT##/$printhit/; $tmp=~s/##USERBYTES##/$printsize/; $tmp=~s/##USERPUTPOST##/$printputpost/; $tmp=~s/##USERPERCENT##/$percent/; $tmp=~s/##USERGROUPURL_L##/$usergroupurl_L/; $tmp=~s/##USERGROUPURL_B##/$usergroupurl_B/; $tmp=~s/##REALNAME##/$realname/; $tmp=~s/##ROWATTR##/$rowattr/; $tmp=~s/##OVERPUTPOSTATTR##/$overputpostattr/; $tpl{user} .= $tmp; } ReplaceTPL_URL(TOPSITESURL,$topsites_L,$topsites_B); ReplaceTPL_URL(BIGFILESURL,$bigfiles_L,$bigfiles_B); ReplaceTPL(DATE,$workperiod); ReplaceTPL(OVERMSG,$overmsg); ApplyTPL(); HideTPL("timereport") if ($timereport == 0); HideTPL("group") if ($showgrouplink == 0); HideTPL("overuser") if ($oversize == 0); HideTPL("realname") if ($userealname == 0); HideTPL("putpost") if ($showputpost == 0); PrintTPL(); __END__ 2004-12-18 ADD : 2005-04-14 ADD : usertrafficlimit support 2005-04-17 ADD : TemplateEngine 2005-05-01 ADD : Time Report Support 2005-08-30 ADD : Color Flipper 2005-10-01 ADD : _L,_B 2005-10-06 ADD : group column 2005-11-07 ADD : URLEncode for link 2006-06-28 ADD : &tpl= support 2006-07-05 ADD : PutPost added 2006-07-10 ADD : .features modification: parameter support 2007-01-10 FIX : fix for correct display update time broken in v1.7 (2007 -> 107) lightsquid-1.8/doc/0000755000076500000240000000000010530431014012741 5ustar eslstafflightsquid-1.8/doc/gnugpl.txt0000644000076500000240000004307610433315100015007 0ustar eslstaff GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. lightsquid-1.8/doc/graph.txt0000644000076500000240000000072110340452656014621 0ustar eslstafffor graphics - need instaled libgd & gd.pm if you don't need graphics report - set $graphreport=0 in lightsquid.cfg please install it manualy or use automatic installation! Distributive installer command ASP Linux 10 yum yum install perl-GD Debian "Sarge" 3.1 apt-get apt-get install libgd-gd2-perl in config - two veriables adjust it for your traffic $graphmaxuser $graphmaxall they define maximum for one user report and all user try play with it lightsquid-1.8/doc/install.txt0000644000076500000240000000344610340451200015155 0ustar eslstaffInstallation Instructions: Required software: 1. Perl 2. Apache 3. Squid 4. Cron or equivalent 1. Extract lightsquid.tgz into any folder cd /var/www/htdocs/ mkdir lightsquid cd lightsquid tar -xzf lightsquid.tgz chmod +x *.cgi chmod +x *.pl chown -R apache:apache * (where apache = httpd user) 2. Configure your Apache server to allow override control if disable gloabal override is defined in httpd.conf; AddHandler cgi-script .cgi AllowOverride All Restart apache 3. Edit lightsquid.cfg 4. Edit group.cfg file if you want group user format: # anyword digit anyword userid groupnum groupname 5. Edit realname.cfg file if you want group user format: # anyword anyword userid Real Name 6. if you want graphics report check graph.txt 7. run check-setup.pl if all done try next step else check config file. 8. Try run lightparser.pl if everything is ok no messages will be produced parse old statistic ./lightparser.pl access.log.1.{gz|bz2} ./lightparser.pl access.log.2.{gz|bz2} ./lightparser.pl access.log.3.{gz|bz2} ... 9. Try to use lightsquid Using your favorite browser enter http:///lightsquid/ 10. Setup crontab to run lightparser once per hour crontab -e This example will execute parser at 55 minutes after every hour: */55 * * * * /var/www/htdocs/lightsquid/lightparser.pl today if you have small log and fast machine, you may run lightparser with smaller delay !!!warning!!! not set interval less 10 min !!!!! 11. All done! 12. If you have problems, define $debug variable in lightsquid.cfg and rerun lightparser. lightsquid-1.8/doc/logformat.txt0000644000076500000240000000072410233264154015510 0ustar eslstaff $squidlogtype - describe access.log format if you log look like this #squid native log 970313965.619 1249 denis.local TCP_MISS/200 2598 GET http://www.emral.com/013.jpg userid DIRECT set $squidlogtype = 0; if you log look like this #emulated httpd log 192.168.3.40 - - [15/Apr/2005:11:46:35 +0300] "GET http://css.yandex.ru/css/mail/search.js HTTP/1.0" 200 4199 TCP_HIT:NONE set $squidlogtype = 1; for more info see emulate_httpd_log option in squid.conflightsquid-1.8/doc/readme.txt0000644000076500000240000000550010233264110014740 0ustar eslstaffLight Squid - light squid report parser and visualizer, generate sort of report light fast no database required no additional perl modules small disk usage template html - you can create you own look; read install.txt for instalation instruction read version.txt for new features ____________________________________________________________________________________ LightSquid generate various report type index.cgi show current year & month, also show all day with report data Date USERS OVERSIZE BYTES AVERAGE CACHE HIT % 18 Apr 2005 [grp] 76 10 419 501 879 5 519 761 5.11% 17 Apr 2005 [grp] 23 6 321 906 050 13 995 915 8.02% all hyperlink on page - do some report ! link under TOTAL size - generate WHOLE MONTH report you may select another month you may select another year if you click any year - report period - whole year link under TOTAL size - generate WHOLE YEAR report hyperlink under date - show day statistic with user [grp] - show day statistic with additional group order (you may hide [grp] link in lightsquid.cfg) if enabled in config OVERSIZE - show how many user exceed per day limit - under link - per user rport day_detail.cgi topsites link - generate list all sites (where walk all users) number limited in config gile you may order list by size or by hit also you may look [who] explore this site. bigfiles link - show user & link where url exceed config variable useful for check what user download also you may view user detail report ;-) total - cummulative summ ___________________________________________________________________________________ ip2name notes you have personal configuration, i don't know it ;-) some examples see in ip2name folder ____________________________________________________________________________________ file structure .htaccess apache control file config file ----------- lightsquid.cfg main config file group.cfg group definition file for simple variant ;-)) log parser ---------- lightparser.pl access.log parser, generate report in `Report` folder web part -------- index.cgi date selector month_detail.cgi whole month report day_detail.cgi day info panel day_detail_grp.cgi day info panel order by dep. user_detail.cgi user detail report bigfiles.cgi big files report topsites.cgi top sites report whousesite.cgi top site -> who use module common.pl common subs (template engine and other) tpl\ base\ template engine templates ;-) ip2name\ example ip2name function lightsquid-1.8/doc/templates.txt0000644000076500000240000000166710233257632015526 0ustar eslstafftotaly rewrite LightSquid .cgi part now use HTML TEMPLATES, in .cgi files - only programm logic, more clear and easy modification. detail: in config now 2 new variable #html template name (see tpl folder) $templatename ="base"; #color for selected item (year, month, ...) $selectedcolor ="#44CC77"; templates in `tpl` folder, (now contain only `base` template) if you need modification - copy `base` folder in new, hack it, and modify $templatename variable templates - simple HTML file with some macros ##VARIABLE## - replaces by corresponding value repeatable block uses when build report list hided block block deleted from html if called HideTPL("oversize"); trying play with it, !!WARNING!! - all ##VARIABLE## and block must be in your file !!!!!!! templates very simple and dumb. lightsquid-1.8/doc/thanks.txt0000644000076500000240000000072610530427476015020 0ustar eslstaffPfunk Mallone - documentation spellcheck Angel IL - (update hh:mm) George Moury - Idea about PHANTOM user in report ... ## Language Translator 1 English ESL 2 Russian ESL,Vladislav Naumov 3 Italian LeOS 4 Hungarian Tibor Gnandt 5 Portuguese - Brazil Andre D. Correa 6 Bulgarian IVO GELOV 7 Spanish Alberto Uez fix 8 French laurent brichet 9 Ukrainian Mykhailo Predeus 10 Czech Betislav Kubesa lightsquid-1.8/doc/version.txt0000644000076500000240000000557510340452004015204 0ustar eslstaff 2005-04-13 1.0 initial release 2005-05-15 1.1 fix documentation bug (start in cron every 55 sec) fix bug in user_detail (displaye size, not hit) add PerUserTrafficLimit support add some fault check add debug messages in parser 2005-05-18 1.4 add TemplateEngine !!! add EmulateHTTPDLog format support fix .cgi code cleanup add html-robots instruction fix html cleanup 2005-05-26 1.5 lightparser.pl ADD ip2name function in subdir ADD .bz2 support ADD cachehit calclulation ADD oversize user calculator FIX httpdlike squid log now work. FIX mkdir 655 -> mkdir 755 ADD StartUser & StopUser function index.cgi ADD Template Engine, HIDE function ADD whole month report now support YEAR ADD GetFeatures function for access to .features file ADD all row AVERAGE report ADD StartUser, StopUser sobroutine day_detail*.cgi ADD show update time month_detail.cgi ADD now support YEAR report, tpl fix user_detail.cgi ADD now support mode=year (show whole year user report) config news # define delimiter for hunders # = " " -> 12 345 678 # = "," -> 12,345,678 # = "" -> 12345678 $decdelimiter = " "; #if you dont need oversize report , do =0 $showoversizelink = 1 #-------------------------------------------------------------------------- IP -> name #define sobroutine file for convertion from IP into name #if you want skip some ip from log - return "SKIP THIS IP" ;-) #detail see in ip2name folder, #$ip2name="dns"; $ip2name="simple" ---------------------- 2005-06-06 TPL: MSG_CODEPAGE added for better localization support 2005-11-22 1.6 - beta New Features Graphic report new language (English,Russian,Italian,Hungarian,Portuguese - Brazil,Bulgarian,Spanish) you can select how represent digit 550 980 198 or 525.5 M month/year Group report Real Name & Group in user info ... new features in template engine for better look; templates now support pictures new messages in language file WhoUseSite new column RealName & Connect MonthDetail New Column (Graph,Month,RealName) Day_Detail New Column (RealName,Group) User_Detail show Group in header, and RalName. show link Big files (if user exist in),total report also in table head bigfiles username now link to user detail. calculate total size for all file in table, fix long link bug. grou_detail totaly rewriten, now support month/year report user_month new report, show how many user eat traffic for all month day (monthdetail).calculate per week sum. graph graph report (histogram) for all user traffic and personal graph (monthdetail)).click to bar -> link to detail info lightsquid-1.8/get.cgi0000755000076500000240000000224010464066566013466 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt use File::Basename; push (@INC,(fileparse($0))[1]); use CGI; require "lightsquid.cfg"; require "common.pl"; $co=new CGI; $content= "text/html"; $css=$co->param('css');if ($css ne "") {$content= "text/css"; $file="$css.css"; } $png=$co->param('png');if ($png ne "") {$content= "image/png"; $file="images/$png.png";} $gif=$co->param('gif');if ($gif ne "") {$content= "image/gif"; $file="images/$gif.gif";} $jpg=$co->param('jpg');if ($jpg ne "") {$content="image/jpeg"; $file="images/$jpg.jpg";} CheckNewTPL($co->param('tpl')); open F,"<","$tplpath/$templatename/$file" or MyDie("$!\n"); binmode F; local $/; $body=; close F; binmode STDOUT; print "Content-Type: $content\n\n"; print $body; __END__ 2005-09-16 ADD : Inital release for v 1.6 2006-06-28 ADD : die -> MyDie 2006-06-28 ADD : &tpl= support lightsquid-1.8/graph.cgi0000755000076500000240000002505511121277242014003 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt use File::Basename; push( @INC, ( fileparse($0) )[1] ); require "lightsquid.cfg"; require "common.pl"; if (!eval { require GD }) { print "Content-Type: text/html\n\n"; MyDie("LightSquid can't show graphics report ...
GD-GRAPH library is unavailable, please install it or set \$graphreport=0 in lightsquid.cfg for disable graphics ...") } use GD; use CGI; use CGI::Carp qw (fatalsToBrowser); $co = new CGI; $year = $co->param('year'); $month = $co->param('month'); $user = $co->param('user'); $mode = $co->param('mode'); $png = $co->param('png'); $mminy=60-50; $mmaxy=420-50; my @MAP; sub fixnum($) { my $num = shift; if ( $num >= 1000 * 1024 * 1024 * 1024 ) { return sprintf( "%3.1fT", $num / ( 1024 * 1024 * 1024 * 1024 ) ); } if ( $num >= 1000 * 1024 * 1024 ) { return sprintf( "%3.1fG", $num / ( 1024 * 1024 * 1024 ) ); } if ( $num >= 1024 * 1024 ) { return sprintf( "%3dM", int( $num / ( 1024 * 1024 ) ) ); } return sprintf( "%3dK", int( $num / (1024) ) ); } ## end sub fixnum($) sub GetY($) { my $value = shift; my $all = $mmaxy - 30; my $diapazon = 5; my $indep = $all / $diapazon; my $tmp = $all / $max; if ( $max < $value ) { $value = $max; } my $y = $mmaxy - $value * $tmp; return int($y); } ## end sub GetY($) sub bar($$) { my $day = shift; my $value = shift; my $xx = 44 + $day * 20; $value = 1 if ( $value == 0 ); $maxaverage+=$value; $maxaverageday++; my $y = GetY($value); # add data for MAP structure if ($png == 0) { my $xx2=$xx+17; my $yy2=$mmaxy+5; $MAP[$day]="$xx, $y, $xx2,$yy2"; $maxcntr++ if ( $value > $max ); return; } $im->filledRectangle( $xx, $y, $xx + 11, $mmaxy + 5, $bcolor3 ); # main BAR my $poly1 = new GD::Polygon; $poly1->addPt( $xx + 7, $y - 5 ); $poly1->addPt( $xx, $y ); # top 3d polygon $poly1->addPt( $xx + 11, $y ); $poly1->addPt( $xx + 17, $y - 5 ); $im->filledPolygon( $poly1, $bcolor1 ); my $poly2 = new GD::Polygon; $poly2->addPt( $xx + 17, $y - 5 ); $poly2->addPt( $xx + 11, $y ); # right 3d BAR $poly2->addPt( $xx + 11, $mmaxy + 6 ); $poly2->addPt( $xx + 17, $mmaxy ); $im->filledPolygon( $poly2, $bcolor2 ); #text box if ( $value < $max ) { $textcolor = $dimgray; $boxcolor = $goldenrod; } else { $textcolor = $white; $boxcolor = $red; } $im->line( $xx + 8, $y - 2, $xx + 8, $y - 10, $dimgray ); $im->filledRectangle( $xx - 2, $y - 20, $xx + 18, $y - 10, $boxcolor ); $im->rectangle( $xx - 2, $y - 20, $xx + 18, $y - 10, $goldenrod2 ); $im->string( gdTinyFont, $xx - 1, $y - 19, fixnum($value), $textcolor ); undef $poly1; undef $poly2; } ## end sub bar($$) sub InitGraph() { # allocate some colors $white = $im->colorAllocate( 255, 255, 255 ); $red = $im->colorAllocate( 255, 0, 0 ); $lavender = $im->colorAllocate( 230, 230, 250 ); $white = $im->colorAllocate( 255, 255, 255 ); $gray = $im->colorAllocate( 192, 192, 192 ); $silver = $im->colorAllocate( 211, 211, 211 ); $black = $im->colorAllocate( 0, 0, 0 ); $blue = $im->colorAllocate( 35, 35, 227 ); $dimgray = $im->colorAllocate( 105, 105, 105 ); $darkblue = $im->colorAllocate( 0, 0, 139 ); $goldenrod = $im->colorAllocate( 234, 234, 174 ); $goldenrod2 = $im->colorAllocate( 207, 181, 59 ); %colors = ( blue => [ [ 62, 80, 167 ], [ 40, 51, 101 ], [ 57, 73, 150 ] ], green => [ [ 120, 166, 129 ], [ 84, 113, 82 ], [ 158, 223, 167 ] ], yellow => [ [ 185, 185, 10 ], [ 111, 111, 10 ], [ 166, 166, 10 ] ], brown => [ [ 97, 45, 27 ], [ 60, 30, 20 ], [ 88, 41, 26 ] ], red => [ [ 185, 10, 10 ], [ 111, 10, 10 ], [ 166, 10, 10 ] ], orange => [ [ 255, 233, 142 ], [ 220, 163, 72 ], [ 255, 198, 107 ] ], ); ${bcolor.$_} = $im->colorAllocate( @{ $colors{$barcolor}[$_-1] } ) for (1..3); $im->rectangle( 0, 0, 719, $mmaxy + 39, $dimgray ); #border $im->filledRectangle( 60, $mminy, 700, $mmaxy, $silver ); #main area $poly1 = new GD::Polygon; #left 3d border $poly1->addPt( 50, $mminy + 5 ); $poly1->addPt( 50, $mmaxy + 5 ); $poly1->addPt( 60, $mmaxy ); $poly1->addPt( 60, $mminy ); $im->filledPolygon( $poly1, $gray ); $poly2 = new GD::Polygon; #down 3d border $poly2->addPt( 60, $mmaxy ); $poly2->addPt( 50, $mmaxy + 5 ); $poly2->addPt( 690, $mmaxy + 5 ); $poly2->addPt( 700, $mmaxy ); $im->filledPolygon( $poly2, $gray ); $im->line( 50, $mminy + 5, 50, $mmaxy + 10, $black ); #black outer $im->line( 45, $mmaxy + 5, 690, $mmaxy + 5, $black ); $im->line( 50, $mmaxy + 5, 60, $mmaxy, $black ); $im->line( 60, $mmaxy, 60, $mminy, $black ); $im->line( 700, $mminy, 700, $mmaxy, $black ); $im->line( 690, $mmaxy + 5, 700, $mmaxy, $black ); $im->line( 60, $mmaxy, 700, $mmaxy, $black ); #bottom border grid for ( $x = 70 ; $x <= 680 ; $x += 20 ) { $im->line( $x, $mmaxy + 5, $x, $mmaxy + 8, $dimgray ); } #print days $weekday=GetWeekDayDate("$year$month"."01"); $x = 65; for ( $i = 1 ; $i <= 31 ; $i++ ) { $color=$dimgray; $color=$red if ($weekday==0); $color=$red if (($weekday==6) && ($weekendmode eq "both")); $weekday++; $weekday=0 if ($weekday==7); $im->string( gdSmallFont, $x - 1, $mmaxy + 8, sprintf( "%02d", $i ), $color ); $x += 20; } ## end for ( $i = 1 ; $i <= 31... #legend #50M show line and value at value 50mb #50M- show only line #50M. skip this value #MONTH $gridvalues{month} = [ "50M-", "100M", "150M-", "200M", "250M-", "300M", "350M-", "400M", "450M-", "500M", "550M.", "600M", "700M", "800M", "900M", "1G", "2G", "3G", "4G", "5G", "6G", "7G", "8G", "9G" , "10G" , "15G" , "20G", "25G", "30G" ]; #USER $gridvalues{user} = [ "5M", "10M", "15M", "20M", "25M", "30M", "35M", "40M", "45M", "50M", "55M", "60M.", "70M", "80M.", "90M", "1G", "2G", "3G", "4G", "5G" ]; $hh{"K"} = 1024; $hh{"M"} = 1024 * 1024; $hh{"G"} = 1024 * 1024 * 1024; $hh{"T"} = 1024 * 1024 * 1024 * 1024; for ( $i = 0 ; $i < $#{ $gridvalues{$mode} } + 1 ; $i++ ) { $gridvalues{$mode}[$i] =~ m/(\d*)(\D)([\.-])?/; $flag = $3; next if ( $flag eq "." ); $v = $1 * $hh{$2}; $y = GetY($v) - 5; next if ( $v > $max ); $im->line( 60, $y, 700, $y, $dimgray ); $im->line( 50, $y + 5, 60, $y, $dimgray ); $im->line( 47, $y + 5, 50, $y + 5, $dimgray ); next if ( $flag eq "-" ); $im->string( gdSmallFont, 21, $y - 2, fixnum($v), $dimgray ); } ## end for ( $i = 0 ; $i < $#{... #axis name $im->stringUp( gdLargeFont, 20 - 15, 248 - 9, "BYTES", $dimgray ); $im->string( gdLargeFont, 330 + 15, $mmaxy + 20, "DAYS", $dimgray ); } ## end sub InitGraph($$$) #################################################################################### if ( $mode eq "user" ) { $max = $graphmaxuser; $varname="graphmaxuser";} if ( $mode eq "month" ) { $max = $graphmaxall; $varname="graphmaxall";} $max=1 if ($max == 0); #div0 protection if ( $png == 1 ) { print "Content-type: image/png\n\n"; # create a new image $im = new GD::Image( 720, $mmaxy + 40 ); InitGraph(); } else { print "Content-Type: text/html\n\n"; InitTPL("graph",$co->param('tpl')); $workperiod = "$MonthName[$month] $year"; ReplaceTPL( WORKPERIOD, $workperiod ); $graphicsurl = "graph.cgi?png=1\&year=$year\&month=$month\&mode=$mode"; $graphicsurl .= "\&user=$user" if ( $mode eq "user" ); ReplaceTPL( GRAPHICSURL, URLEncode($graphicsurl) ); if ( $mode eq "month" ) { $txtmode = "##MSG_WHOLE## ##MSG_MONTH##"; } else { $txtmode = "##MSG_USER## \"$user\""; } ReplaceTPL( MODE, $txtmode ); } $average = 0; $days = 0; $filter = "$year$month"; @daylist = glob("$reportpath/$filter*"); foreach $daypath ( sort @daylist ) { open FF, "<$daypath/.total"; $tmp = ; $size = ; chomp $size; $size =~ s/^size: //; $daypath =~ m/(\d\d\d\d)(\d\d)(\d\d)/; if ( $mode eq "month" ) { bar( $3, $size ); $average += $size; } elsif ( $mode eq "user" ) { while () { ( $user_, $size, $hit ) = split; if ( $user_ eq $user ) { bar( $3, $size ); $average += $size; } } } ## end elsif ( $mode eq "user" ) $days++; close FF; } ## end foreach $daypath ( sort @daylist) if ( $png == 1 ) { #average bar if ( $days > 0 ) { $y = GetY( int( $average / $days ) ); $im->line( 60, $y, 700, $y, $red ); $im->line( 56, $y + 2, 60, $y, $red ); } ## end if ( $days > 0 ) binmode STDOUT; # Convert the image to PNG and print it on standard output print eval {$im->png} || $im->gif; #use gif if png not supported by libgd (Konstantin M. Mefodichev) } ## end if ( $png == 1 ) else { $url=($mode eq "user")?"user_detail.cgi":"day_detail.cgi"; $url.=qq(?year=$year&month=$month); $url.=($mode eq "user")?"\&user=$user":""; $url = URLEncode($url); $day="00"; for ($i=1;$i<$#MAP+1;$i++) { $day++; $tmp=$hTPL{imagemap}; $tmp=~s/##MAPURL##/$url\&day=$day/; $tmp=~s/##MAPCOORD##/$MAP[$i]/; $tpl{imagemap} .= $tmp; } ReplaceTPL( IMGMAP, $imgmap ); $maxaverage /= ($maxaverageday+1); ReplaceTPL( VARVALUE,sprintf("%1.2f",int(($maxaverage+($maxaverage*0.30))/(1024*1024*1024/10)+1)/10)); ReplaceTPL( VARNAME,$varname); HideTPL("warning") if ($maxcntr < 7); ApplyTPL(); PrintTPL(); } ## end else [ if ( $png == 1 ) __END__ 2005-11-07 ADD : some HW perl trick 2005-11-07 ADD : url encode 2006-06-28 ADD : &tpl= support 2006-09-05 ADD : warning and recomended max value 2006-09-13 ADD : error to browser 2006-11-23 ADD : FIX recomendation warning 2008-11-28 FIX : try to use gif if png not supported by libgd : div0 protection added 2008-12-14 FIX : No more err500 in browser if no GD is installed ADD : Terabyte support ;) lightsquid-1.8/group.cfg.src0000644000076500000240000000025310230563634014612 0ustar eslstaffesl 01 SysAdmin karlos 01 SysAdmin thy 01 SysAdmin Ivanov 02 Developer Ivanov2 02 Developer Petrov 03 Commerial Petrova 03 Commerial vasyav 04 room 312 petyava 04 room 312lightsquid-1.8/group_detail.cgi0000755000076500000240000001503410477230136015360 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt print "Content-Type: text/html\n\n"; use File::Basename; push (@INC,(fileparse($0))[1]); use CGI; require "lightsquid.cfg"; require "common.pl"; $NotInGroupID="00"; $NotInGroupName="##MSG_NOT_IN_GROUP##"; $co=new CGI; $year =$co->param('year'); $month=$co->param('month'); $day =$co->param('day'); $mode =$co->param('mode') || "day"; InitTPL("group_detail",$co->param('tpl')); if ($mode eq "month") { $workperiod="##MSG_WHOLE## ##MSG_MONTH## - $year $MonthName[$month]"; $mask = "$year$month*"; } elsif ($mode eq "year") { $workperiod="##MSG_WHOLE## ##MSG_YEAR## - $year"; $mask = "$year*"; } else { $mode="day"; $workperiod="$day $MonthName[$month] $year"; $mask = "$year$month$day"; } #additional info in DAY mode if ($mode eq "day") { ($dev,$ino,$mode_,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat("$reportpath/$mask"); ($sec_,$min_,$hour_,$mday_,$mon_,$year_,$wday_,$yday_,$isdst_)=localtime($mtime); $mon_++;$year_+=1900; $workperiod .= " (##MSG_UPDATE## :: ".sprintf("%02d:%02d",$hour_,$min_)." :: $mday_ $MonthName[$mon_] $year_)"; $topsitesurl="topsites.cgi?year=$year&month=$month&day=$day"; $bigfilesurl="bigfiles.cgi?year=$year&month=$month&day=$day"; $topsites_L="$topsitesurl"; $topsites_B="##MSG_TOP_SITES##"; $bigfiles_B="##MSG_BIG_FILES##"; if (-f "$reportpath/$mask/.bigfiles") { $bigfiles_L="$bigfilesurl"; } } @datelist=sort glob "$reportpath/$mask*"; $totalsize=0; foreach $workday (sort @datelist) { GetGroupFile($workday); GetRealName($workday,"?"); open FF,"<$workday/.total" or MyDie("can't open file $workday/.total
"); $user=;#chomp $user;$user=~s/^user: //; $size=;#chomp $size;$size=~s/^size: //; while () { $N++; ($user,$size,$hit)=split; $hUserTotal{$user}+=$size; $hUserTotalHit{$user}+=$hit; $totalsize+=$size; } close FF } #---------------------------------------------------------------------------------- #numerate user position in all list & add NOT IN GROUP $N=0; foreach $user (sort {$hUserTotal{$b} <=> $hUserTotal{$a}} keys %hUserTotal) { $N++; $hUserPosition{$user}=$N; unless (exists $hUserGroup{$user}) { #GetGroupFile - not clear $hGroupByUser{$NotInGroupID}{$user}=1; $hUserGroup {$user}{$NotInGroupID}=$NotInGroupID; } } #---------------------------------------------------------------------------------- #calculate TotalSize by group (all user in group sum) foreach $grp (sort keys %hGroupByUser) { foreach $user (sort keys %{$hGroupByUser{$grp}}) { next unless (defined $hUserTotal{$user}); #skip if user not use internet $hGroupTotalSize{$grp}+=$hUserTotal{$user}; } } #----------------------------------------------------------------------------------- #out: group list ordered by size $N=0; foreach $grp (sort {$hGroupTotalSize{$b}<=>$hGroupTotalSize{$a}} keys %hGroupName) { next if (0 == $hGroupTotalSize{$grp}); $size =$hGroupTotalSize{$grp}; # print "$hGroupName{$grp} -> $percent ->$size\n"; $N++; $gprintsize=FineDec($size); $depurl_L="#$grp"; $depurl_B="$hGroupName{$grp}"; $gpercent =sprintf("%2.1f",int($size*1000/$totalsize)/10); $rowattr = ($N & 1)?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $tmp=$hTPL{grouplist}; $tmp=~s/##GROUPLISTNUM##/$N/; $tmp=~s/##GROUPLISTNAMEURL_L##/$depurl_L/; $tmp=~s/##GROUPLISTNAMEURL_B##/$depurl_B/; $tmp=~s/##GROUPLISTBYTES##/$gprintsize/; $tmp=~s/##GROUPLISTPERCENT##/$gpercent/; $tmp=~s/##GROUPROWATTR##/$rowattr/; $tpl{grouplist} .= $tmp; } $row=0; #foreach $grp (sort {$hGroupTotalSize{$b}<=>$hGroupTotalSize{$a}} keys %hGroupByUser) { foreach $grp (sort keys %hGroupByUser) { next if (0 == $hGroupTotalSize{$grp}); # print "$grp -> $hGroupName{$grp} -> $hGroupTotalSize{$grp}\n"; $groupstarturl_L="$grp"; $groupstarturl_B="$hGroupName{$grp}"; $tmp=$hTPL{groupstart}; $tmp=~s/##GROUPSTARTURL_L##/$groupstarturl_L/; $tmp=~s/##GROUPSTARTURL_B##/$groupstarturl_B/; $tpl{user} .= $tmp; foreach $user (sort {$hUserTotal{$b} <=> $hUserTotal{$a}} keys %{$hGroupByUser{$grp}}) { next unless (defined $hUserTotal{$user}); #skip if user not use internet # print "\t$hUserPosition{$user}. $user\t$hUserTotal{$user}\n"; $row++; $url_B="$user"; $realname=GetRealName($daypath,$user); if ($mode eq "day") { $url_L="user_detail.cgi?year=$year&month=$month&day=$day&user=$user"; } elsif ($mode eq "month") { $url_L="user_detail.cgi?year=$year&month=$month&day=$day&user=$user&mode=month"; } else { $url_L=""; } $url_L = URLEncode($url_L); $size =$hUserTotal{$user}; $printhit =FineDec($hUserTotalHit{$user}); $printsize=FineDec($size); $percent =sprintf("%2.1f",int($size*1000/$totalsize)/10); $N =$hUserPosition{$user}; $timeurl_L=URLEncode("user_time.cgi?year=$year&month=$month&day=$day&user=$user"); $timeurl_B="##MSG_TIME_LINK##"; $rowattr = ($row & 1)?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $tmp=$hTPL{user}; $tmp=~s/##USERNUM##/$N/; $tmp=~s/##USERURL_L##/$url_L/; $tmp=~s/##USERURL_B##/$url_B/; $tmp=~s/##REALNAME##/$realname/; $tmp=~s/##TIMEURL_L##/$timeurl_L/; $tmp=~s/##TIMEURL_B##/$timeurl_B/; $tmp=~s/##USERDEP##/$grp/; $tmp=~s/##USERCONNECT##/$printhit/; $tmp=~s/##USERBYTES##/$printsize/; $tmp=~s/##USERPERCENT##/$percent/; $tmp=~s/##ROWATTR##/$rowattr/; $tpl{user} .= $tmp; } $gprintsize=FineDec($hGroupTotalSize{$grp}); $gpercent =sprintf("%2.1f",int($hGroupTotalSize{$grp}*1000/$totalsize)/10); $tmp=$hTPL{groupend}; $tmp=~s/##GROUPENDBYTES##/$gprintsize/; $tmp=~s/##GROUPENDPERCENT##/$gpercent/; $tpl{user} .= $tmp } #generate HTML ReplaceTPL_URL(TOPSITESURL,URLEncode($topsites_L),$topsites_B); ReplaceTPL_URL(BIGFILESURL,URLEncode($bigfiles_L),$bigfiles_B); ReplaceTPL(DATE,$workperiod); ApplyTPL(); HideTPL("dayinfo") if ($mode ne "day"); HideTPL("timereport") if (($timereport == 0) or ($mode ne "day")); HideTPL("realname") if ($userealname == 0); PrintTPL(); __END__ 2005-11-07 ADD : URLEncode 2006-06-28 ADD : die -> MyDie 2006-06-28 ADD : &tpl= support lightsquid-1.8/index.cgi0000755000076500000240000001551510501740372014011 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt print "Content-Type: text/html\n\n"; use File::Basename; push (@INC,(fileparse($0))[1]); require "lightsquid.cfg"; require "common.pl"; use CGI; use CGI::Carp qw (fatalsToBrowser); $co=new CGI; ($tmp,$tmp,$tmp,$tmp,$mon,$tmpyear) = localtime; $year =$co->param('year' ) || ($tmpyear+1900); $month=$co->param('month') || sprintf("%02d",$mon+1); InitTPL("index",$co->param('tpl')); if ($month ne "all") { $workperiod=" $MonthName[$month] $year"; } else { $workperiod=" $year "; $month=""; } #----------------------------------- find defined month & years @days=sort glob("$reportpath/*"); foreach $day (@days) { if ($day =~ m/(\d\d\d\d)(\d\d)(\d\d)/) { $yearhash {$1}=1; } if ($day =~ m/$year(\d\d)(\d\d)/) { $monthhash{$1}=1; } } ## YEAR row ______________________________________________ @yearlist=sort keys %yearhash; $yearcnt=$#yearlist+1; if ($yearcnt == 0) { ErrPrintConfig("report folder '$reportpath' not contain any valid data! Please run lightparser.pl (and check 'report' folder content)"); print "
folder content:
"; foreach $file (@days) { print "$file
"; } exit; } $yearspan=12/$yearcnt; foreach $yearname (sort keys %yearhash) { $yearselected=($yearname eq $year)?qq{$hTPLVARIABLE{yearselected}}:""; $yearurl_L= qq(index.cgi?year=$yearname&month=all); $yearurl_B= qq($yearname); $yearoptionselected = ($yearname eq $year)?" selected":""; $yearoption = qq($yearname); $tmp=$hTPL{year}; $tmp=~s/##YEARCOLSPAN##/$yearspan/; $tmp=~s/##YEARSELECTED##/$yearselected/; $tmp=~s/##YEARURL_L##/$yearurl_L/; $tmp=~s/##YEARURL_B##/$yearurl_B/; $tmp=~s/##YEAROPTION##/$yearoption/; $tpl{year} .= $tmp; } ## MONTH row ____________________________________________ $monthtmp="01"; for ($i=1;$i<=12;$i++) { $monthselected=($monthtmp eq $month)?qq{$hTPLVARIABLE{monthselected}}:""; $monthurl_L=(defined $monthhash{$monthtmp} )?"index.cgi?year=$year\&month=$monthtmp":""; $monthurl_B="$monthtmp"; $monthtmp++; $tmp=$hTPL{month}; $tmp=~s/##MONTHSELECTED##/$monthselected/; $tmp=~s/##MONTHURL_L##/$monthurl_L/; $tmp=~s/##MONTHURL_B##/$monthurl_B/; $tpl{month} .= $tmp; } ## -- @days=sort glob("$reportpath/$year$month*"); @days=reverse @days; foreach $daypath (@days) { open FF,"<$daypath/.total" || MyDie("can't open file $daypath/.total
"); $user=;chomp $user;$user=~s/^user: //; $size=;chomp $size;$size=~s/^size: //; close FF; $overuser=GetFeatures($daypath,"overuser","?"); $cachehit=GetFeatures($daypath,"cachehit%","?"); $cachehittotal+=$cachehit; $daypath =~ m#$reportpath/(.*)#; $date=$1; $weekday=GetWeekDayDate($date); $average=($user != 0)?int($size/$user):0; $totalsize+=$size; $totalaverage+=$average; $totaluser+=$user; $totaloveruser+=$overuser; $printaverage=FineDec($average); $printsize =FineDec($size); $printdate =GetTxtDate($date); $date =~ m/^(\d\d\d\d)(\d\d)(\d\d)/; $urldate="year=$1&month=$2&day=$3"; $daydate_L ="day_detail.cgi?$urldate"; $daydate_B ="$printdate"; $daygroup_L="group_detail.cgi?$urldate";$daygroup_B="##MSG_GRP##"; $overuser_L=(($overuser eq "?") || ($overuser == 0))?"":"$daydate_L&oversize=1"; $overuser_B="$overuser"; $dayattr = ($weekday & 1 )?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $dayattr = $hTPLVARIABLE{sundayattr} if ($weekday == 0); $dayattr = $hTPLVARIABLE{saturdayattr} if (($weekendmode eq "both") && ($weekday == 6));; $tmp=$hTPL{day}; $tmp=~s/##DAYDATE_L##/$daydate_L/; $tmp=~s/##DAYDATE_B##/$daydate_B/; $tmp=~s/##DAYGROUP_L##/$daygroup_L/; $tmp=~s/##DAYGROUP_B##/$daygroup_B/; $tmp=~s/##DAYUSERS##/$user/; $tmp=~s/##DAYOVERUSERS_L##/$overuser_L/; $tmp=~s/##DAYOVERUSERS_B##/$overuser_B/; $tmp=~s/##DAYBYTES##/$printsize/; $tmp=~s/##DAYAVERAGE##/$printaverage/; $tmp=~s/##DAYCACHEHIT##/$cachehit/; $tmp=~s/##DAYATTR##/$dayattr/; $tpl{day} .= $tmp; } $days=($#days+1); if ($days==0) {$days=0.00000001;} #;-), dirty hack $printtotalsize = FineDec($totalsize); $printtotalaverage = FineDec(int($totalaverage/$days)); $printaveragehit = sprintf ("%3.2f",$cachehittotal/$days); $printaverageuser = int($totaluser/$days); $printaverageoveruser = int($totaloveruser/$days); $month="all" if ($month eq ""); $printtotalsize_L = "month_detail.cgi?year=$year&month=$month"; $printtotalsize_B = "$printtotalsize"; ReplaceTPL(WORKPERIOD,$workperiod); ReplaceTPL(TOTAL_L,$printtotalsize_L); ReplaceTPL(TOTAL_B,$printtotalsize_B); ReplaceTPL(TOTALAVERAGE,$printtotalaverage); ReplaceTPL(AVERAGEHIT,$printaveragehit); ReplaceTPL(USERAVERAGE,$printaverageuser); ReplaceTPL(OVERUSERAVERAGE,$printaverageoveruser); ReplaceTPL_URL( TOP_MONTH,"topsites.cgi?year=$year&month=$month&mode=month", "##MSG_MONTH##"); ReplaceTPL_URL( TOP_YEAR ,"topsites.cgi?year=$year&month=$month&mode=year" , "##MSG_YEAR##"); ReplaceTPL_URL(TOTAL_MONTH,"month_detail.cgi?year=$year&month=$month", "##MSG_MONTH##"); ReplaceTPL_URL(TOTAL_YEAR ,"month_detail.cgi?year=$year&month=all", "##MSG_YEAR##"); ReplaceTPL_URL(GROUP_MONTH,"group_detail.cgi?year=$year&month=$month&mode=month","##MSG_MONTH##"); ReplaceTPL_URL(GROUP_YEAR ,"group_detail.cgi?year=$year&mode=year", "##MSG_YEAR##"); ReplaceTPL_URL(MONTH_GRAPH,"graph.cgi?year=$year&month=$month&mode=month", ""); ApplyTPL(); HideTPL("monthtop") if ($month eq "all"); HideTPL("oversize") if ($showoversizelink == 0); HideTPL("group") if ($showgrouplink == 0); HideTPL("graph") if ($graphreport == 0); PrintTPL(); __END__ 2004-09-01 FIX : show only month for current year ... 2004-12-18 ADD : if MODE == MONTH -> totalsize - link month_detail.cgi 2005-01-02 ADD : default - current year 2005-04-14 ADD : check empty report folder! 2005-04-17 ADD : Template Engine 2005-04-19 ADD : error check, add .oversize & .cachehit field support 2005-04-21 ADD : Template Engine, HIDE function 2005-04-22 ADD : move cahchehit -> .features 2005-05-01 ADD : TopSites & Total report box 2005-08-29 ADD : color flipper & sunday color, 2005-09-06 ADD : colorselected now defined in TPL file 2005-09-15 ADD : if month="all" then not show MONTH table at top, (also changed TPL file) 2005-10-01 ADD : now all URL in TPL (_L,_B), TPL also changed ;-) 2006-06-28 ADD : die -> MyDie 2006-06-28 ADD : &tpl= support 2006-09-13 ADD : error to browser lightsquid-1.8/ip2name/0000755000076500000240000000000010551135142013535 5ustar eslstafflightsquid-1.8/ip2name/ip2name.abils0000664000076500000240000000253710551135142016115 0ustar eslstaff#convert user -> ip , get user name from abills database #support ABILS billing system http://abills.asmodeus.com.ua/ #(c) wazzup, posted on LightSquid Forum 20 Dec 2006 06:23 am use DBI; use Socket; my $dbh; sub StartIp2Name() { $dbh = DBI->connect("DBI:mysql:database=abills;host=localhost","abills", "abillspasswd" ) || die $DBI::errstr; } sub Ip2Name($$$) { # $Lhost,$user,$Ltimestamp my $ip=shift; my $user_name=shift; my $time=shift; my $ret; my $result1 = $dbh->prepare("select started, user_name, framed_ip_address from dv_calls where( framed_ip_address='".unpack('N',inet_aton($ip))."')and (startedexecute(); if (my $ln = $result1->fetchrow_hashref()) { $ret=$ln->{'user_name'}; } else { my $result = $dbh->prepare("select start,users.id , ip from dv_log ,users where (users.uid=dv_log.uid) and (ip='".unpack('N',inet_aton($ip))."')and (start < FROM_UNIXTIME('".$time."')) order by start DESC"); $result->execute(); if (my $ln = $result->fetchrow_hashref()) { $ret=$ln->{'id'}; } else { $ret=$ip; } $result->finish(); } $result1->finish(); return $ret; } sub StopIp2Name() { $dbh->disconnect(); } #warning !!! 1; lightsquid-1.8/ip2name/ip2name.demo0000644000076500000240000000123510454300536015742 0ustar eslstaff#contributor: esl #return user, if defined ;-) #return hostname if defined, #if hostname not definet, for homensubnet return 192.168.1.10 -> #010 #else - return ip #skip ip 192.168.1.250 $homesubnet = "192.168.1."; sub StartIp2Name() { } sub Ip2Name($$$) { # $Lhost,$user,$Ltimestamp my $IP=shift; my $userid=shift; my $user=$IP; return $userid if ($userid ne "-"); my $user2 = `host $user`; $user2 =~ m/domain name pointer (.*?).$/; $user2 = $1; if ($user2 =~ m/$oursubnet(\d*)/) {$user = sprintf("#%03d",$1);} else {$user = $user2;} return $user; } sub StopIp2Name() { } #WARNING !!!!! 1; lightsquid-1.8/ip2name/ip2name.dhcp0000644000076500000240000000256210531362036015737 0ustar eslstaff#contributor: esl #resolve hostname, cache it for speedup #dhcpd.conf contain user info in comments #look like #|#leo-a-2 (igor server) #|host lena43{ #| hardware ethernet 00:0E:2E:6C:73:01; #| fixed-address 192.168.40.43; #|} #in StartIp2Name extract IP, usernikc, and username # also init hRealName hash used for creating realname.cfg ... use Socket; sub StartIp2Name() { my $body = ReadDHCPConfig(); while ($body =~ m/(\#[^\n]*\n)?host (.*?)\s?\{(.*?)\}/sig) { my $comment=$1; chomp $comment; my $tmp=$3; my $host=$2; $tmp =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/; my $ip=$1; #try extract comp name my $comp=""; my $user=""; if ($comment =~ m/#\s?(\S*)(\s?\((.*?)\))?/) { $comp = $1; $user= $3; } my $id=lc $comp; if ($id ne ""){ $hIP{$ip}=$id; $hRealName{$id}=$user if ($user ne ""); } } } sub Ip2Name($$$) { # $Lhost,$user,$Ltimestamp my $ip=shift; if (!defined $hIP{$ip}) { my $iaddr = inet_aton($ip); my $user = scalar gethostbyaddr($iaddr, AF_INET); # if gethostbyaddr failed to get host, use ip $user=$ip unless (defined $user); $hIP{$ip}=$user; } return $hIP{$ip}; } sub StopIp2Name() { } sub ReadDHCPConfig() { local $/; my $file; open FFAAAA,"<","/etc/dhcpd.conf"; $file=; close FFAAAA; return $file; } #warning !!!! 1; lightsquid-1.8/ip2name/ip2name.dns0000644000076500000240000000073710454277352015621 0ustar eslstaff#contributor: esl #resolve hostname, cache it for speedup # -- vim: filetype=perl use Socket; sub StartIp2Name() { } sub Ip2Name($$$) { # $Lhost,$user,$Ltimestamp my $ip=shift; if (!defined $hIP{$ip}) { my $iaddr = inet_aton($ip); my $user = scalar gethostbyaddr($iaddr, AF_INET); # if gethostbyaddr failed to get host, use ip $user=$ip unless (defined $user); $hIP{$ip}=$user; } return $hIP{$ip}; } sub StopIp2Name() { } #warning !!!! 1; lightsquid-1.8/ip2name/ip2name.ip0000644000076500000240000000031010517353714015425 0ustar eslstaff#contributor: esl #do nothing #always return IP sub StartIp2Name() { } sub Ip2Name($$$) { # $Lhost,$user,$Ltimestamp my $Lhost=shift; return $Lhost; } sub StopIp2Name() { } #warning !!! 1; lightsquid-1.8/ip2name/ip2name.list0000644000076500000240000000121210454300012015751 0ustar eslstaff#ESL #convert user -> ip , get user name from file #file format # #192.168.0.96 User1 #192.168.0.106 User2 #192.168.0.105 User3 # #if user not found -> return IP sub StartIp2Name() { my $ipfile = "/etc/squid/users.txt"; open (F, "<$ipfile") || die ("ERROR: Can't open $ipfile!!! \n"); while () { chomp; ($ip,$user) = split; $hIP2NAME{$ip}=$user; } close (F); } sub Ip2Name($$$) { # $Lhost,$user,$Ltimestamp my $ip=shift; my $ret; if (defined $hIP2NAME{$ip}) { $ret=$hIP2NAME{$ip}; } else { $ret=$ip; } return $ret; } sub StopIp2Name() { } #warning !!! 1; lightsquid-1.8/ip2name/ip2name.simple0000644000076500000240000000043110463456166016317 0ustar eslstaff#contributor: esl #do nothing #simple version sub StartIp2Name() { } sub Ip2Name($$$) { # $Lhost,$user,$Ltimestamp my $Lhost=shift; my $user =shift; return $user if ($user ne "-"); #return user if defined !!!!! return $Lhost; } sub StopIp2Name() { } #warning !!! 1; lightsquid-1.8/ip2name/ip2name.smb0000644000076500000240000000123610464072612015602 0ustar eslstaff#contributor: esl #resolve hostname use windows pc name, cache it for speedup #tested on samba Version 3.0.20-0.110.2asp #wait from nmblookup string in format # MAIN <00> - M #if no name found, return IP use Socket; sub StartIp2Name() { } sub Ip2Name($$$) { my $ip=shift; if (!defined $hIP{$ip}) { my $smb=`nmblookup -A $ip`; if ($smb=~m/\s+(\S+)\s+\<00\> -\s+\S\s\/s) { $user=$1; } else { $user=$ip; } # if gethostbyaddr failed to get host, use ip $user=$ip unless (defined $user); $hIP{$ip}=$user; } return $hIP{$ip}; } sub StopIp2Name() { } #warning !!!! 1; lightsquid-1.8/ip2name/ip2name.squidauth0000644000076500000240000000052610464072624017034 0ustar eslstaff#contributor: esl #specialy for squid with turned on user authentication #simple version sub StartIp2Name() { } sub Ip2Name($$$) { # $Lhost,$user,$Ltimestamp my $Lhost=shift; my $user =shift; $user =URLDecode($user); #decode user name return $user if ($user ne "-"); return $Lhost; } sub StopIp2Name() { } #warning !!! 1; lightsquid-1.8/ip2name/ip2name.squidlist0000644000076500000240000000146310464072634017050 0ustar eslstaff#contributor : vovich2005 # #convert user -> ip , get user name from file #file format # #192.168.0.96/255.255.255.255 # User1 #192.168.0.106/255.255.255.255 # User2 #192.168.0.105/255.255.255.255 # User3 # #if user not found -> return IP sub StartIp2Name() { } sub Ip2Name($$$) { my $ip=shift; my $ipfile = "/etc/squid/users.txt"; my $ipaddr = shift; open (F, "<".$ipfile) || die ("ERROR: Can't open ".$ipfile."!!!\n"); while () { if (/$ipaddr/){ chomp; @FLD = split (' ', $_); @IP = split ('/', $FLD[0]); if ($ipaddr eq $IP[0]) { $res = $FLD[2]; last; } } else { $res = $ipaddr; } } close (F); return $res; } sub StopIp2Name() { } #warning !!! 1; lightsquid-1.8/ip2name/ip2name.squidlist20000644000076500000240000000143710464072642017132 0ustar eslstaff#contributor : vovich2005 #modification : ESL (use hash for speed up resolve) # #convert user -> ip , get user name from file #file format # #192.168.0.96/255.255.255.255 # User1 #192.168.0.106/255.255.255.255 # User2 #192.168.0.105/255.255.255.255 # User3 # #if user not found -> return IP sub StartIp2Name() { my $ipfile = "/etc/squid/users.txt"; open (F, "<".$ipfile) || die ("ERROR: Can't open ".$ipfile."!!!\n"); while () { chomp; @FLD = split (' ', $_); @IP = split ('/', $FLD[0]); $hIP2NAME{$IP[0]}=$FLD[2]; } close (F); } sub Ip2Name($$$) { my $ipaddr = shift; if (defined $hIP2NAME{$ipaddr}){ $res = $hIP2NAME{$ipaddr}; } else { $res = $ipaddr; } return $res; } sub StopIp2Name() { } #warning !!! 1; lightsquid-1.8/lang/0000755000076500000240000000000010530431020013112 5ustar eslstafflightsquid-1.8/lang/bg.lng0000644000076500000240000000230010307652322014213 0ustar eslstaff#Version : 1.5 #Translator: IVO GELOV #Date : 07 Seo 2005 #Lang : bulgarian MSG_CODEPAGE=windows-1251 MSG_HEADER= . Squid . MSG_ACCESSED_SITE= MSG_AVERAGE= MSG_BIG_FILE_DOWNLOAD_REPORT= MSG_BIG_FILES= MSG_BYTES= MSG_CONNECT= MSG_CUMULATIVE= MSG_DATE= MSG_GROUP= MSG_GRP= MSG_HIT%=Cache Hit % MSG_MONTH= MSG_NUM= MSG_NOT_IN_GROUP= MSG_OVERSIZE= MSG_OVERSIZE_HEAD=, MSG_OVERSIZE_TAIL= MSG_REPORT= MSG_SIZE= MSG_TIME= MSG_TOP_SITES= MSG_TOTAL= MSG_TOTAL_AVERAGE=/ MSG_TIME_REPORT= MSG_TIME_LINK=[T] MSG_URL=URL MSG_USER= MSG_USER_WHO_USE_SITE=, MSG_UPDATE= MSG_USERS= MSG_WHO= MSG_WHOLE= MSG_WORK_PERIOD= MSG_YEAR= # MSG_MONTH01= MSG_MONTH02= MSG_MONTH03= MSG_MONTH04= MSG_MONTH05= MSG_MONTH06= MSG_MONTH07= MSG_MONTH08= MSG_MONTH09= MSG_MONTH10= MSG_MONTH11= MSG_MONTH12= lightsquid-1.8/lang/check_lng.pl0000644000076500000240000000250410477225456015415 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt print "LightSquid lang file check utilite. compare your lang file with ENG file\n"; $lang=lc $ARGV[0]; $lang =~ s/\.lng//i; if ($lang eq "") { print "usage check_lang LANG\n"; print " check_lang ru\n"; exit (-1); } print "check \"$lang.lng\" file\n"; open F,") { chomp; next if (/^#/); ($lname,$lvalue)=split /=/,$_,2; $hENG{$lname}=$lvalue; } close F; open F,"<$lang.lng" or die "can't open language file $lang.lng - $!\n"; while () { chomp; next if (/^#/); ($lname,$lvalue)=split /=/,$_,2; $hFILE{$lname}=$lvalue; } close F; foreach $key (sort keys %hENG) { unless (defined $hFILE{$key}) { $notdefined .= "\t$key\n"; } } print "\nnot defined in $lang.lng:\n $notdefined\n" if ($notdefined ne ""); foreach $key (sort keys %hFILE) { unless (defined $hENG{$key}) { $mistype .= "\t$key\n"; } } print "\nnot defined in eng.lng - mistype ?? :\n $mistype\n" if ($mistype ne ""); lightsquid-1.8/lang/check_tpl_lng.pl0000644000076500000240000000434510477232566016301 0ustar eslstaff#/bin/perl $lang=lc $ARGV[0]; $lang =~ s/\.lng//i; $lang="eng" if ($lang eq ""); $tpl=lc $ARGV[1]; $tpl="base" if ($tpl eq ""); sub ReadTPL() { my @filename=glob("../tpl/$tpl/*.html"); my $body; local $/; foreach $name (@filename) { # print "name: $name\n"; open FF,"<","$name" or die "can't open file $name\n"; $body=; close FF; while ($body =~ m/##(MSG.*?)##/gs) { # print "\t$1\n";; $hMSG{$1}+=$1; $hFILE{$1}{$name}=1; } } } sub ReadCGI() { my @filename=glob("../*.cgi"); my $body; local $/; foreach $name (@filename) { # print "name: $name\n"; open FF,"<","$name" or die "can't open file $name\n"; $body=; close FF; while ($body =~ m/##(MSG.*?)##/gs) { # print "\t$1\n";; $hMSG{$1}+=$1; $hFILE{$1}{$name}=1; } } } $hMSG{"MSG_MONTH01"}=$hMSG{"MSG_MONTH02"}=$hMSG{"MSG_MONTH03"}=$hMSG{"MSG_MONTH04"}=1; $hMSG{"MSG_MONTH05"}=$hMSG{"MSG_MONTH06"}=$hMSG{"MSG_MONTH07"}=$hMSG{"MSG_MONTH08"}=1; $hMSG{"MSG_MONTH09"}=$hMSG{"MSG_MONTH10"}=$hMSG{"MSG_MONTH11"}=$hMSG{"MSG_MONTH12"}=1; open F,") { chomp; next if (/^#/); ($lname,$lvalue)=split /=/,$_,2; $hENG{$lname}=$lvalue; } close F; open F,"<$lang.lng" or die "can't open language file $lang.lng - $!\n"; while () { chomp; next if (/^#/); ($lname,$lvalue)=split /=/,$_,2; $hLNG{$lname}=$lvalue; } close F; ReadTPL(); ReadCGI(); print "Check 1, all defination in templates must be in LNG file ...\n"; foreach $msg (sort keys %hMSG) { unless (defined $hLNG{$msg}) { print "\"$msg\" (en:\"$hENG{$msg}\") used in \n"; foreach $file (sort keys %{$hFILE{$msg}}) { print "\t\t\t$file\n"; $cnt1++; } } } print "passed, All OK\n" if ($cnt1 == 0); print "failed, $cnt1 error found\n" if ($cnt1 != 0); print "\nCheck 2, check unused defination in LNG file ...\n"; foreach $msg (sort keys %hLNG) { unless (defined $hMSG{$msg}) { print "\"$msg\" defined, but not use\n"; $cnt2++; } } print "passed, All OK\n" if ($cnt2 == 0); print "failed, $cnt2 error found\n" if ($cnt2 != 0); lightsquid-1.8/lang/cz.lng0000644000076500000240000000251510451443542014251 0ustar eslstaff#Version : 1.6 #Translator: Betislav Kubesa #Date : #Lang : Czech MSG_CODEPAGE=windows-1250 MSG_%BYTES=%BAJT MSG_ACCESSED_SITE=Navtven odkazy MSG_AVERAGE=Prmr MSG_BIG_FILE_DOWNLOAD_REPORT=Pehled soubor "pes limit" MSG_BIG_FILES=Soubory pes limit MSG_BYTES=Bajt MSG_CALENDAR=Kalend MSG_CONNECT=Pipojen MSG_CUMULATIVE=Mezisouet MSG_DATE=Datum MSG_DAYLIST=Data MSG_GROUP=Skupina MSG_GRP=skup MSG_GRAPH_LINK=[G] MSG_GRAPH_REPORT=Graf MSG_HIT%=Hit % MSG_MONTH=MSC MSG_NUM=# MSG_NOT_IN_GROUP=nen ve skupin MSG_OVERSIZE=Pes limit MSG_OVERSIZE_HEAD=Uivatel pes limit MSG_OVERSIZE_TAIL=bajt podle uivatele MSG_REPORT=Report MSG_SIZE=Velikost MSG_HEADER=Statistika uivatelskch pstup SQUIDu MSG_TIME=as MSG_TOP_SITES=Top odkazy MSG_TOTAL=Celkem MSG_TOTAL_AVERAGE=Celkem/Prmr MSG_TIME_REPORT=as MSG_TIME_LINK=[T] MSG_URL=URL MSG_UPDATE=aktualizace MSG_USER=Uivatel MSG_USER_MONTH=[M] MSG_USER_WHO_USE_SITE=Uivatel pouvajc odkaz MSG_USERID=USERID MSG_USERS=Uivatel MSG_WHO=kdo MSG_WHOLE=Cel MSG_WORK_PERIOD=Obdob MSG_YEAR=ROK MSG_REALNAME=Skuten jmno MSG_WEEKSUM=Tdenn souhrn. # MSG_MONTH01=leden MSG_MONTH02=nor MSG_MONTH03=bezen MSG_MONTH04=duben MSG_MONTH05=kvten MSG_MONTH06=erven MSG_MONTH07=ervenec MSG_MONTH08=srpen MSG_MONTH09=z MSG_MONTH10=jen MSG_MONTH11=listopad MSG_MONTH12=prosinec lightsquid-1.8/lang/eng.lng0000644000076500000240000000245711113624720014406 0ustar eslstaff#Version : 1.7 #Translator: Sergey Erokhin #Date : #Lang : English MSG_CODEPAGE=US-ASCII MSG_ACCESSED_SITE=Accessed site MSG_AVERAGE=Average MSG_BIG_FILE_DOWNLOAD_REPORT=Big File Download Report MSG_BIG_FILES=Big Files MSG_BIG_FILES_USER=User download "Big Files" MSG_BYTES=Bytes MSG_CALENDAR=Calendar MSG_CONNECT=Connect MSG_CUMULATIVE=Cumulative MSG_DATE=Date MSG_DAYLIST=Dates MSG_GROUP=Group MSG_GRP=grp MSG_GRAPH_LINK=[G] MSG_GRAPH_REPORT=Graph MSG_HIT%=Hit % MSG_MONTH=MONTH MSG_NUM=# MSG_NOT_IN_GROUP=no in group MSG_OVERSIZE=Oversize MSG_OVERSIZE_HEAD=Users who exceed MSG_OVERSIZE_TAIL=bytes, per user quota MSG_PUTPOST=PutPost MSG_REPORT=Report MSG_SIZE=Size MSG_HEADER=Squid user access report MSG_TIME=Time MSG_TOP_SITES=Top Sites MSG_TOTAL=Total MSG_TOTAL_AVERAGE=Total/Average MSG_TIME_REPORT=Time MSG_TIME_LINK=[T] MSG_URL=URL MSG_UPDATE=update MSG_USER=User MSG_USER_MONTH=[M] MSG_USER_WHO_USE_SITE=User Who Use Site MSG_USERS=Users MSG_WHO=who MSG_WHOLE=Whole MSG_WORK_PERIOD=Work Period MSG_YEAR=YEAR MSG_REALNAME=Real Name MSG_WEEKSUM=Week Sum. MSG_WARNING=Warning!!! MSG_RECOMENDATION=i recomend set # MSG_MONTH01=Jan MSG_MONTH02=Feb MSG_MONTH03=Mar MSG_MONTH04=Apr MSG_MONTH05=May MSG_MONTH06=Jun MSG_MONTH07=Jul MSG_MONTH08=Aug MSG_MONTH09=Sep MSG_MONTH10=Oct MSG_MONTH11=Nov MSG_MONTH12=Dec lightsquid-1.8/lang/fr.lng0000644000076500000240000000215710333646652014254 0ustar eslstaffMSG_CODEPAGE=ISO-8859-1 MSG_%BYTES=%OCTETS MSG_ACCESSED_SITE=Site(s) Accd(s) MSG_AVERAGE=Moyenne MSG_BIG_FILE_DOWNLOAD_REPORT=Rapport des Gros Fichiers Downloads MSG_BIG_FILES=Gros Fichiers MSG_BYTES=Octets MSG_CONNECT=Connexion(s) MSG_CUMULATIVE=Somme MSG_DATE=Date MSG_GROUP=Groupe MSG_GRP=grp MSG_HIT%=Hit % MSG_MONTH=MOIS MSG_NUM=# MSG_NOT_IN_GROUP=Pas dans un groupe MSG_OVERSIZE=Quota Dpass MSG_OVERSIZE_HEAD=Uilisateurs ayant dpass le quota MSG_OVERSIZE_TAIL=octets, par quota utilisateur MSG_REPORT=Rapport MSG_SIZE=Taille MSG_HEADER=Squid rapport d'accs utilisateur MSG_TIME=Temps MSG_TOP_SITES=Top Sites MSG_TOTAL=Total MSG_TOTAL_AVERAGE=Total/Moyenne MSG_TIME_REPORT=Temps MSG_TIME_LINK=[T] MSG_URL=URL MSG_UPDATE=Rafrachir MSG_USER=Utilisateur MSG_USER_WHO_USE_SITE=Utilisateurs ayant visit le site MSG_USERID=USERID MSG_USERS=Utilisateurs MSG_WHO=qui MSG_WHOLE=Tout MSG_WORK_PERIOD=Periode de travail MSG_YEAR=ANNEE # MSG_MONTH01=Jan MSG_MONTH02=Fev MSG_MONTH03=Mar MSG_MONTH04=Avr MSG_MONTH05=Mai MSG_MONTH06=Jun MSG_MONTH07=Jul MSG_MONTH08=Aou MSG_MONTH09=Sep MSG_MONTH10=Oct MSG_MONTH11=Nov MSG_MONTH12=Dec lightsquid-1.8/lang/hu.lng0000644000076500000240000000224310251117336014244 0ustar eslstaff#Version : 1.5 #Translator: Tibor Gnandt #Date : 03 Jun 2005 #Lang : hungarian MSG_CODEPAGE=ISO-8859-2 MSG_%BYTES=%BJTOK MSG_ACCESSED_SITE=Megltogatott oldalak MSG_AVERAGE=tlag MSG_BIG_FILE_DOWNLOAD_REPORT=Nagy llomnyok letltse MSG_BIG_FILES=Nagymret llomnyok MSG_BYTES=Bjtok MSG_CONNECT=Kapcsolds MSG_CUMULATIVE=sszeg MSG_DATE=Dtum MSG_GROUP=Csoport MSG_GRP=csop MSG_HIT%=Tallat % MSG_MONTH=HNAP MSG_NUM=# MSG_NOT_IN_GROUP=nincs a csoportban MSG_OVERSIZE=Tlmretes MSG_OVERSIZE_HEAD=A felhasznl tllpte a(z) MSG_OVERSIZE_TAIL= bjtot MSG_REPORT=jelents MSG_SIZE=Mret MSG_HEADER=Proxy forgalom elemzs MSG_TIME=Id MSG_TOP_SITES=Nagyforgalm oldalak MSG_TOTAL=sszesen MSG_TOTAL_AVERAGE=ssz/tlag MSG_TIME_REPORT=Id MSG_TIME_LINK=[Id] MSG_URL=URL MSG_UPDATE=frisstve MSG_USER=Felhasznl MSG_USER_WHO_USE_SITE=Ltogatsok MSG_USERID=FELH.NV MSG_USERS=Felhasznlk MSG_WHO=ki? MSG_WHOLE=Teljes MSG_WORK_PERIOD=Idszak MSG_YEAR=V # MSG_MONTH01=Jan MSG_MONTH02=Feb MSG_MONTH03=Mar MSG_MONTH04=Apr MSG_MONTH05=Maj MSG_MONTH06=Jun MSG_MONTH07=Jul MSG_MONTH08=Aug MSG_MONTH09=Sze MSG_MONTH10=Okt MSG_MONTH11=Nov MSG_MONTH12=Dec lightsquid-1.8/lang/it.lng0000644000076500000240000000223110251116704014237 0ustar eslstaff#Version : 1.5 #Translator: LeOS , #Date : 12-Maj-2005 MSG_CODEPAGE=ISO-8859-1 MSG_%BYTES=%BYTES MSG_ACCESSED_SITE=Sito visitato MSG_AVERAGE=Media MSG_BIG_FILE_DOWNLOAD_REPORT=Grandi File Scaricati MSG_BIG_FILES=Grandi Files MSG_BYTES=Bytes MSG_CONNECT=Numero accessi MSG_CUMULATIVE=Totale MSG_DATE=Data MSG_GROUP=Gruppo MSG_GRP=grp MSG_HIT%=Click % MSG_MONTH=MESE MSG_NUM=# MSG_NOT_IN_GROUP=nessun gruppo MSG_OVERSIZE=Sovradimensionato MSG_OVERSIZE_HEAD=Utenti che hanno superato il limite MSG_OVERSIZE_TAIL=bytes, per quota utente MSG_REPORT=Rapporto MSG_SIZE=Dimensione MSG_HEADER=Rapporto accesso utenti Squid MSG_TIME=Ora MSG_TOP_SITES=Siti maggiormente visitati MSG_TOTAL=Totale MSG_TOTAL_AVERAGE=Totale/Media MSG_TIME_REPORT=Ora MSG_TIME_LINK=[ora] MSG_URL=URL MSG_UPDATE=aggiorna MSG_USER=Utente MSG_USER_WHO_USE_SITE=Utente che usa il Sito MSG_USERID=USERID MSG_USERS=Utenti MSG_WHO=chi MSG_WHOLE=Tutto MSG_WORK_PERIOD=Periodo MSG_YEAR=ANNO # MSG_MONTH01=Gen MSG_MONTH02=Feb MSG_MONTH03=Mar MSG_MONTH04=Apr MSG_MONTH05=Mag MSG_MONTH06=Giu MSG_MONTH07=Lug MSG_MONTH08=Ago MSG_MONTH09=Set MSG_MONTH10=Ott MSG_MONTH11=Nov MSG_MONTH12=Dic lightsquid-1.8/lang/pt_br.lng0000644000076500000240000000232310307372420014734 0ustar eslstaff#Version : 1.6 #Translator: Andre D. Correa #Date : 01-Sep-2005 MSG_CODEPAGE=ISO-8859-1 MSG_%BYTES=%BYTES MSG_ACCESSED_SITE=Sites acessados MSG_AVERAGE=Média MSG_BIG_FILE_DOWNLOAD_REPORT=Relatório de arquivo grandes MSG_BIG_FILES=Arquivos grandes MSG_BYTES=Bytes MSG_CONNECT=Conexões MSG_CUMULATIVE=Soma MSG_DATE=Data MSG_GROUP=Grupo MSG_GRP=grp MSG_HIT%=Hit % MSG_MONTH=MÊS MSG_NUM=# MSG_NOT_IN_GROUP=sem grupo MSG_OVERSIZE=Acima do limit MSG_OVERSIZE_HEAD=Usuários que acessaram MSG_OVERSIZE_TAIL=bytes, por quota do usuá.rio MSG_REPORT=Relatório MSG_SIZE=Tamanho MSG_HEADER=Relatório de Acesso MSG_TIME=Hora MSG_TOP_SITES=Top Sites MSG_TOTAL=Total MSG_TOTAL_AVERAGE=Total/Média MSG_TIME_REPORT=Hora MSG_TIME_LINK=[T] MSG_URL=URL MSG_UPDATE=Atualizar MSG_USER=Usuário MSG_USER_WHO_USE_SITE=Usuários que acessaram MSG_USERID=USERID MSG_USERS=Usuários MSG_WHO=quem MSG_WHOLE=Todos MSG_WORK_PERIOD=Período MSG_YEAR=ANO MSG_MONTH01=Jan MSG_MONTH02=Fev MSG_MONTH03=Mar MSG_MONTH04=Abr MSG_MONTH05=Mai MSG_MONTH06=Jun MSG_MONTH07=Jul MSG_MONTH08=Ago MSG_MONTH09=Set MSG_MONTH10=Out MSG_MONTH11=Nov MSG_MONTH12=Dez lightsquid-1.8/lang/ru-koi8.lng0000644000076500000240000000300710501732260015122 0ustar eslstaff#Version : 1.7 #Translator: Sergey Erokhin, Vladislav Naumov (bugfix, rewrite) ;-) #Date : 23 Jun 2005, last update 05 sep 2006 #Lang : russian - koi8-r MSG_CODEPAGE=koi8-r MSG_HEADER=ޣ , - Squid. MSG_ACCESSED_SITE=ݣ MSG_AVERAGE= MSG_BIG_FILE_DOWNLOAD_REPORT=ޣ MSG_BIG_FILES= MSG_BIG_FILES_USER= MSG_BYTES= MSG_CONNECT= MSG_CUMULATIVE= MSG_DATE= MSG_GROUP= MSG_GRP=. MSG_HIT%=Cache Hit % MSG_MONTH= MSG_NUM= MSG_NOT_IN_GROUP= MSG_OVERSIZE= MSG_OVERSIZE_HEAD=, MSG_OVERSIZE_TAIL= MSG_REPORT=(ޣ) MSG_SIZE= MSG_TIME= MSG_TOP_SITES= MSG_TOTAL= MSG_TOTAL_AVERAGE=/ MSG_TIME_REPORT= MSG_TIME_LINK=[T] MSG_URL=URL MSG_USER= MSG_USER_WHO_USE_SITE=, MSG_UPDATE= MSG_USERS= MSG_WHO= MSG_WHOLE= MSG_WORK_PERIOD=ޣ MSG_YEAR= MSG_WARNING=!!! MSG_RECOMENDATION= MSG_DAYLIST= MSG_GRAPH_LINK=[G] MSG_GRAPH_REPORT= MSG_PUTPOST=PutPost MSG_REALNAME=.. MSG_USER_MONTH=[M] MSG_WEEKSUM= MSG_CALENDAR= # MSG_MONTH01= MSG_MONTH02= MSG_MONTH03= MSG_MONTH04= MSG_MONTH05= MSG_MONTH06= MSG_MONTH07= MSG_MONTH08= MSG_MONTH09= MSG_MONTH10= MSG_MONTH11= MSG_MONTH12= lightsquid-1.8/lang/ru.lng0000644000076500000240000000300410501732176014255 0ustar eslstaff#Version : 1.7 #Translator: Sergey Erokhin, Vladislav Naumov (bugfix, rewrite) ;-) #Date : 23 Jun 2005, last update 05 sep 2006 #Lang : russian MSG_CODEPAGE=windows-1251 MSG_HEADER= , - Squid. MSG_ACCESSED_SITE= MSG_AVERAGE= MSG_BIG_FILE_DOWNLOAD_REPORT= MSG_BIG_FILES= MSG_BIG_FILES_USER= MSG_BYTES= MSG_CONNECT= MSG_CUMULATIVE= MSG_DATE= MSG_GROUP= MSG_GRP=. MSG_HIT%=Cache Hit % MSG_MONTH= MSG_NUM= MSG_NOT_IN_GROUP= MSG_OVERSIZE= MSG_OVERSIZE_HEAD=, MSG_OVERSIZE_TAIL= MSG_REPORT=() MSG_SIZE= MSG_TIME= MSG_TOP_SITES= MSG_TOTAL= MSG_TOTAL_AVERAGE=/ MSG_TIME_REPORT= MSG_TIME_LINK=[T] MSG_URL=URL MSG_USER= MSG_USER_WHO_USE_SITE=, MSG_UPDATE= MSG_USERS= MSG_WHO= MSG_WHOLE= MSG_WORK_PERIOD= MSG_YEAR= MSG_WARNING=!!! MSG_RECOMENDATION= MSG_DAYLIST= MSG_GRAPH_LINK=[G] MSG_GRAPH_REPORT= MSG_PUTPOST=PutPost MSG_REALNAME=.. MSG_USER_MONTH=[M] MSG_WEEKSUM= MSG_CALENDAR= # MSG_MONTH01= MSG_MONTH02= MSG_MONTH03= MSG_MONTH04= MSG_MONTH05= MSG_MONTH06= MSG_MONTH07= MSG_MONTH08= MSG_MONTH09= MSG_MONTH10= MSG_MONTH11= MSG_MONTH12= lightsquid-1.8/lang/sp.lng0000644000076500000240000000227710330665304014262 0ustar eslstaff#Version : 1.5 #Translator: Alberto Uez #Date : 23 Jun 2005 #Lang : spain MSG_CODEPAGE=ISO-8859-1 MSG_%BYTES=%BYTES MSG_ACCESSED_SITE=Sitios accedidos MSG_AVERAGE=Promedio MSG_BIG_FILE_DOWNLOAD_REPORT=Informe de mayores archivos MSG_BIG_FILES=Archivos mas grandes MSG_BYTES=Bytes MSG_CONNECT=Conexiones MSG_CUMULATIVE=Total MSG_DATE=Fecha MSG_GROUP=Grupo MSG_GRP=grp MSG_HIT%=Hit % MSG_MONTH=MES MSG_NUM=# MSG_NOT_IN_GROUP=sin grupo MSG_OVERSIZE=Excedidos MSG_OVERSIZE_HEAD=Usuarios que excedieron MSG_OVERSIZE_TAIL=bytes, por cuota de usuario MSG_REPORT=Informe MSG_SIZE=Tamaño MSG_HEADER=Informe de accesos de usuarios de Squid MSG_TIME=Hora MSG_TOP_SITES=Sitios Top MSG_TOTAL=Total MSG_TOTAL_AVERAGE=Total/Promedio MSG_TIME_REPORT=Hora MSG_TIME_LINK=[T] MSG_URL=URL MSG_UPDATE=actualizado MSG_USER=Usuario MSG_USER_WHO_USE_SITE=Usuario que accedió al sitio MSG_USERID=ID USUARIO MSG_USERS=Usuarios MSG_WHO=quien MSG_WHOLE=Todo el MSG_WORK_PERIOD=Período comprendido MSG_YEAR=AÑO # MSG_MONTH01=Ene MSG_MONTH02=Feb MSG_MONTH03=Mar MSG_MONTH04=Abr MSG_MONTH05=May MSG_MONTH06=Jun MSG_MONTH07=Jul MSG_MONTH08=Ago MSG_MONTH09=Sep MSG_MONTH10=Oct MSG_MONTH11=Nov MSG_MONTH12=Dic lightsquid-1.8/lang/ua.lng0000644000076500000240000000225310451446534014245 0ustar eslstaff#Translator: Sergey Erokhin, Mykhailo Predeus ;-) #Date : 10.04.06 #Lang : ukrainian MSG_CODEPAGE=windows-1251 MSG_HEADER= , - Squid. MSG_ACCESSED_SITE=³ MSG_AVERAGE= MSG_BIG_FILE_DOWNLOAD_REPORT= MSG_BIG_FILES= ʲ MSG_BYTES= MSG_CONNECT=' MSG_CUMULATIVE= MSG_DATE= MSG_GROUP= MSG_GRP=. MSG_HIT%=Cache Hit % MSG_MONTH=̲ MSG_NUM= MSG_NOT_IN_GROUP= MSG_OVERSIZE= MSG_OVERSIZE_HEAD=, MSG_OVERSIZE_TAIL= MSG_REPORT=() MSG_SIZE= MSG_TIME= MSG_TOP_SITES= MSG_TOTAL= MSG_TOTAL_AVERAGE=/ MSG_TIME_REPORT= MSG_TIME_LINK=[T] MSG_URL=URL MSG_USER= MSG_USER_WHO_USE_SITE=, MSG_UPDATE= MSG_USERS= MSG_WHO= MSG_WHOLE= MSG_WORK_PERIOD=ϳ MSG_YEAR=PIK # MSG_MONTH01=ѳ MSG_MONTH02= MSG_MONTH03= MSG_MONTH04= MSG_MONTH05= MSG_MONTH06= MSG_MONTH07= MSG_MONTH08= MSG_MONTH09= MSG_MONTH10= MSG_MONTH11= MSG_MONTH12= lightsquid-1.8/lightparser.pl0000755000076500000240000003671711223230604015100 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt #parse access.log # make per user report in 'report' direcotry #usage: lightparse.pl {param} #if param omit - parse full access.log file # today - only current day # yesterday - yesterday # data in format YYYYMMDD - parse day # access.log.{\d}.{gz|bz2} - parse file (for process archived) # function prototypes sub MakeReport(); sub InitSkipUser(); sub getLPS($$); sub LockLSQ(); sub UnLockLSQ(); sub LOCKREMOVER(); use File::Basename; use Time::Local; push (@INC,(fileparse($0))[1]); require "lightsquid.cfg"; require "common.pl"; #include ip2name function require "ip2name/ip2name.$ip2name"; $SIG{INT} = \&LOCKREMOVER; # traps keyboard interrupt my $lockfilepath ="$lockpath/lockfile"; my $skipurlcntr = 0; my $skip4xxcntr = 0; my $skipfilterdatecntr= 0; my $firstrun = 1; my $totallines = 0; my $parsedlines = 0; my $daylines = 0; my $catname ="cat"; my $filename ="access.log"; undef $workday; exit unless (LockLSQ()); #Lock LSQ (block multiple instance) if ($skipurl eq "") { $skipurl = "skipurl MUST be defined!!!"; print "WARNING !!! \$skipurl is empty\n"; } ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime; $month=sprintf("%02d",$mon+1);; my $filterdatestart=0; my $filterdatestop =timelocal(59,59,23,31,12-1,2020-1900)+1000; $fToday=1 if ($ARGV[0] eq "today"); $fToday=1 if ($ARGV[0] eq "yesterday"); if ($fToday) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime; $filterdate=sprintf("%04d%02d%02d",$year+1900,$mon+1,$mday);; $filterdatestart=timelocal( 0, 0, 0,$mday,$mon,$year); $filterdatestop =timelocal(59,59,23,$mday,$mon,$year); print ">>> filter today: $filterdate\n" if ($debug); } if ($ARGV[0] eq "yesterday") { $filterdatestart=$filterdatestart-(24*60*60); $filterdatestop =$filterdatestop -(24*60*60); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($filterdatestart); $filterdate=sprintf("%04d%02d%02d",$year+1900,$mon+1,$mday);; print ">>> filter yesterday: $filterdate\n" if ($debug); } if ($ARGV[0] =~ m/^(\d\d\d\d)(\d\d)(\d\d)$/) { $filterdate=$ARGV[0]; $filterdatestart=timelocal( 0, 0, 0,$3,$2-1,$1); $filterdatestop =timelocal(59,59,23,$3,$2-1,$1); print ">>> filter date: $filterdate\n" if ($debug); } if ($ARGV[0] =~ m/access\.log\.(\d)/) { $filename=$ARGV[0]; $catname="zcat" if ($ARGV[0] =~ m/\.gz$/); $catname="bzcat" if ($ARGV[0] =~ m/\.bz2$/); } print ">>> use file :: $logpath/$filename\n" if ($debug); #open FF, "$logpath\\$filename" || die "can't access log file\n"; open FF, "$catname $logpath/$filename|" || die "can't access log file\n"; InitSkipUser(); StartIp2Name(); undef %bigfile; $bigfilecnt=0; while () { chomp; $totallines++; if (0 == $squidlogtype) { #squid native log #970313965.619 1249 denis.local TCP_MISS/200 2598 GET http://www.emalecentral.com/tasha/thm_4374x013.jpg - DIRECT/www.emalecentral.com image/jpeg # timestamp elapsed host type size method url user hierarechy type #speed optimization for FILTERDATE mode $Ltimestamp=substr $_,0,11; if ($Ltimestamp<$filterdatestart or $Ltimestamp>$filterdatestop) { print ">>>> skipDafteFilter URL $Lurl\n$_" if ($debug2 >= 2 ); $skipfilterdatecntr++; next; }; ($Ltimestamp,$Lelapsed,$Lhost,$Ltype,$Lsize,$Lmethod,$Lurl,$Luser,$Lhierarchy,$Lconttype,@Lrest)=split; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($Ltimestamp); $mon++; #fix, month start from 0 $date =sprintf("%04d%02d%02d",$year+1900,$mon,$mday); #check row with invalid record if ( ($#Lrest >= 0) && ($#Lrest < 4) ) { $str=$_; #maybe two concatenated record (first - truncated) if ($str =~ m/(\d+\.\d+\s+\d+\s+(\d{1,3}\.){3}\d{1,3}\s+\w+\/\d+\s+\d+\w+\s+\S+\s+\S+\s+\S+\s+\w+\/\S+\s(-|([a-zA-Z\-]+\/[a-zA-Z\-]+)))$/) { $newstr=$1; ($Ltimestamp,$Lelapsed,$Lhost,$Ltype,$Lsize,$Lmethod,$Lurl,$Luser,$Lhierarchy,$Lconttype)=split /\s+/,$newstr; } else { # maybe source url contain SPACES, try concatenate ... while ($#Lrest != -1) { $Lurl.="_$Luser";$Luser=$Lhierarchy;$Lhierarchy=$Lconttype;$Lconttype=shift @Lrest; } #do some sanity check unless (($Lhierarchy =~ m/\w+\/\S+/) and ($Lconttype =~ m/-|([a-zA-Z\-]+\/[a-zA-Z\-]+)/)) { $notrecoveredlines++; next; } } $recoveredlines++; } } else { #emulated httpd log #192.168.3.40 - - [15/Apr/2005:11:46:35 +0300] "GET http://mail.yandex.ru/mboxjscript? HTTP/1.0" 200 2262 TCP_MISS :DIRECT #192.168.3.40 - - [15/Apr/2005:11:46:35 +0300] "GET http://css.yandex.ru/css/mail/search.js HTTP/1.0" 200 4199 TCP_HIT:NONE #192.168.3.12 - - [15/Apr/2005:11:46:35 +0300] "CONNECT aero.lufthansa.com:443 HTTP/1.0" 200 35992 TCP_MISS:DIRE # ($Lhost, $Luser,$Luser2,$Ldate, $u2, $Lmethod,$Lurl, $u3, $Ltype,$Lsize,$u4)=split ($Lhost,$Luser,$Luser2,$Ldate,$u2,$Lmethod,$Lurl,$u3,$Ltype,$Lsize,$u4)=split; $Ldate =~ m#^\[(\d\d)/(...)/(\d\d\d\d):(\d\d):(\d\d):(\d\d)#; $mday=$1;$mon=$month2dec{$2};$year=$3-1900; $hour=$4;$min=$5;$sec=$6; $date =sprintf("%04d%02d%02d",$year+1900,$mon,$mday); if ($filterdate) { if ($date ne $filterdate) { print ">>>> skipDafteFilter URL $Lurl\n$_" if ($debug2 >= 2 ); $skipfilterdatecntr++; next; }; } if (($Luser eq "-") && ($Luser2 ne "-")) { $Luser = $Luser2; } $u4 =~ m/(.*?)\s?:(.*)/; $Ltype = "$1/$Ltype"; } #if ($squidlogtype) if ($year < 2000-1900) { ; #invalid record print ">>>> skipn Bad Year $Lurl\n$_" if ($debug2 >= 1 ); $skipbadyear++; next; } #skip intranet if ($Lurl =~ m/$skipurl/o) { print ">>>> skipURL $Lurl\n$_" if ($debug2 >= 2 ); $skipurlcntr++; next; }; # skip Access denied records (TODO: report) if ($Ltype =~ m#DENIED#io) { $skipDenied++; print ">>>> skipDenied $Ltype\n$_" if ($debug2 >= 2); next; }; if ($Ltype =~ m/HIT/) { $CacheHIT+=$Lsize; } else { $CacheMISS+=$Lsize; } $parsedlines++; if ($date ne $workday) { # close prev day, prepare for new if ($firstrun) { undef $firstrun; $workday=$date; } else { MakeReport(); undef %totalsize; undef %sitesize; undef %sitehit;undef %totalhit;undef %totalputpost; undef %hashhost;undef %hashname; undef %bigfile; $bigfilecnt=0; undef %sitetime;undef %sitetimesize; $daylines=0; $workday=$date; $sqlreq=0; $CacheHIT=0;$CacheMISS=0; } } $daylines++; $user=lc $Luser; $user = Ip2Name($Lhost,$user,$Ltimestamp); next if (defined $hSkipUser{$user}); #simplified some common banner system & counters $url=$Lurl; $url =~ s/([a-z]+:\/\/)??.*\.(spylog\.com)/$1www.$2/o; $url =~ s/([a-z]+:\/\/)??.*\.(yimg\.com)/$1www.$2/o; $url =~ s/([a-z]+:\/\/)??.*\.(adriver\.ru)/$1www.$2/o; $url =~ s/([a-z]+:\/\/)??.*\.(bannerbank\.ru)/$1www.$2/o; $url =~ s/([a-z]+:\/\/)??.*\.(mail\.ru)/$1www.$2/o; $url =~ s/([a-z]+:\/\/)??.*\.(adnet\.ru)/$1www.$2/o; $url =~ s/([a-z]+:\/\/)??.*\.(rapidshare\.de)/$1www.$2/o; $url =~ s/([a-z]+:\/\/)??.*\.(rapidshare\.com)/$1www.$2/o; $url =~ s/([a-z]+:\/\/)??.*\.(vkontakte\.ru)/$1www.$2/o; $url =~ s/([a-z]+:\/\/)??.*\.(odnoklasniki\.ru)/$1www.$2/o; #extract site name if ($url =~ m/([a-z]+:\/\/)??([a-z0-9\-]+\.){1}(([a-z0-9\-]+\.){0,})([a-z0-9\-]+){1}(:[0-9]+)?\/(.*)/o) { $site=$2.$3.$5; } else { $site=$Lurl; } $site=$Lurl if ($site eq ""); $totalsize {$user} +=$Lsize; $totalhit {$user} ++; $totalputpost {$user} +=$Lsize if (($Lmethod eq "PUT") or ($Lmethod eq "POST")); $sitesize {$user}{$site}+=$Lsize; $sitehit {$user}{$site}++; $sitetime {$user}{$site}[$hour]+=$Lelapsed; $sitetimesize {$user}{$site}[$hour]+=$Lsize; #.bigfile support if ($Lsize > $bigfilelimit) { $bigfile [$bigfilecnt]{date}=sprintf("%02d:%02d:%02d",$hour,$min,$sec); $bigfile [$bigfilecnt]{link}=$Lurl; $bigfile [$bigfilecnt]{size}=$Lsize; $bigfile [$bigfilecnt]{user}=$user; $bigfilecnt++; } } MakeReport(); StopIp2Name(); UnLockLSQ(); if ($debug) { $worktime = ( time() - $^T ); print "run TIME: $worktime sec\n"; print "LightSquid parser statistic report\n\n"; printf( " %10u lines processed (average %.2f lines per second)\n", $totallines, getLPS( $worktime, $totallines ) ); printf( " %10u lines parsed\n", $parsedlines ); printf( " %10u lines recovered\n", $recoveredlines ); printf( " %10u lines notrecovered\n", $notrecoveredlines ); printf( " %10u lines skiped by bad year\n", $skipbadyear ); printf( " %10u lines skiped by date filter\n", $skipfilterdatecntr ); printf( " %10u lines skiped by Denied filter\n", $skipDenied ); printf( " %10u lines skiped by skipURL filter\n", $skipurlcntr ); if ( $parsedlines == 0 ) { print "\nWARNING !!!!, parsed 0 lines from total : $totallines\n"; print "please check confiuration !!!!\n"; print "may be wrong log format selected ?\n"; } } # The END --------------------------------------------------------- ##Subroutines # return Line Per Second value (check 0 values and correct) sub getLPS($$) { my $time=shift; my $lines=shift; $time||=1; $lines||=1; return ($lines/$time); } sub MakeReport() { #generate report #use global var return if ($daylines < 2); print ">>> Make Report $workday ($daylines - log line parsed)\n" if ($debug); $reppath="$reportpath/$workday"; unless ( -d $reppath ) { mkdir $reppath, 0755 or die "Can't create dir '$reppath': $!"; } open TOTALFILE,">$reppath/.total" || die "can't create file $reppath/.total - $!"; $tmp="";$tmpsize=0;$tmpuser=0;$tmpoveruser=0; foreach $tuser (sort {$totalsize{$b} <=> $totalsize{$a}} keys %totalsize) { # $tmp.="$tuser\t$totalsize{$tuser}\t$totalhit{$tuser}\t$totalputpost{$tuser}\n"; $totalputpost{$tuser}+=0; #prevent empty value $tmp.=sprintf("%-20s %15s %15s %15s\n",$tuser,$totalsize{$tuser},$totalhit{$tuser},$totalputpost{$tuser}); $tmpuser++; $tmpsize+=$totalsize{$tuser}; $tmpoveruser++ if ($totalsize{$tuser} >= $perusertrafficlimit); open REPFILE,">$reppath/$tuser" || die "can't create file $reppath/$tuser - $!"; print REPFILE "total: $totalsize{$tuser}\n"; foreach $tsite (sort {$sitesize{$tuser}{$b} <=> $sitesize{$tuser}{$a}} keys %{$sitesize{$tuser}} ) { printf REPFILE ("%-29s %12s %10s\t",$tsite,$sitesize{$tuser}{$tsite},$sitehit{$tuser}{$tsite}); if ($timereport != 0) { for ($hour=0;$hour<24;$hour++) { printf REPFILE ("%d-%s ",int($sitetime{$tuser}{$tsite}[$hour]/3600),$sitetimesize{$tuser}{$tsite}[$hour]+0); } } print REPFILE "\n"; } close REPFILE; } $CacheMISS=1 if ($CacheMISS == 0); print TOTALFILE "user: $tmpuser\n"; print TOTALFILE "size: $tmpsize\n"; print TOTALFILE "$tmp"; close TOTALFILE; my ($sec_,$min_,$hour_,$mday_,$mon_,$year_,$wday_,$yday_,$isdst_) = localtime;$mon_++;$year_+=1900; my $moddate=sprintf("%02d:%02d",$hour_,$min_)." :: $mday_ $MonthName[$mon_] $year_"; open FILE,">$reppath/.features" || die "can't create file $reppath/.features - $!"; print FILE "overuser: $tmpoveruser\n"; print FILE "cachehit%: ".sprintf("%3.2f",($CacheHIT*100)/($CacheHIT+$CacheMISS))."\n"; print FILE "cachehit: $CacheHIT\n"; print FILE "cachemiss: $CacheMISS\n"; print FILE "cacheall: ".($CacheHIT+$CacheMISS)."\n"; print FILE "modification: $moddate\n"; close FILE; unlink "$reppath/.bigfiles"; if ($bigfilecnt != 0) { open MAXFILE,">$reppath/.bigfiles" || die "can't create file $reppath/.bigfiles - $!"; for ($i=0;$i<$bigfilecnt;$i++) { print MAXFILE "$bigfile[$i]{user}\t$bigfile[$i]{date}\t$bigfile[$i]{size}\t$bigfile[$i]{link}\n"; } close MAXFILE; } #create list of user that use more than $perusertrafficlimit bytes unlink "$reppath/.overuser"; if ($tmpoveruser) { open OVERFILE,">","$reppath/.overuser" || die "can't create file $reppath/.overuser - $!"; foreach $tuser (sort {$totalsize{$b} <=> $totalsize{$a}} keys %totalsize) { print OVERFILE "$tuser\t$totalsize{$tuser}\n" if ($totalsize{$tuser} >= $perusertrafficlimit); } close OVERFILE; } CreateGroupFile($reppath); CreateRealnameFile($reppath); } sub InitSkipUser() { open F,"<$cfgpath/skipuser.cfg"; while () { chomp; next if (/^#/); $hSkipUser{$_}=1; } close F; } # Lock support sub LockLSQ() { if (-f "$lockfilepath") { #read data from `lockfile` print STDERR "Warning, `$lockfilepath` exist, maybe anoter process running !\n"; open FF,"<","$lockfilepath" or die "can't read lock file `$lockfilepath`\n"; $pid=;chomp $pid;$pid =~ s/PID: //; $ts =;chomp $ts ;$ts =~ s/Timestamp: //; close FF; #check timedelta $tsdelta=time - $ts; print STDERR "LockPID : $pid\n" ; print STDERR "tsdelta : $tsdelta second(s) (maxlocktime: $maxlocktime)\n"; return 0 if ($tsdelta<$maxlocktime); print STDERR "OLD lock file ignored and removed!\n"; UnLockLSQ(); } open FF,">","$lockfilepath" or die "can't create lock file `$lockfilepath`\n"; print FF "PID: $$\n"; $ts=time; print FF "Timestamp: $ts\n"; print FF "Creation time: ".localtime($ts)."\n"; close FF; return 1; } sub UnLockLSQ() { unlink $lockfilepath or die "can't remove lock file `$lockfilepath`\n"; } sub LOCKREMOVER() { print "INT happents, remove LOCK\n"; UnLockLSQ(); exit; } __END__ 2004-04-23 : initial version 2004-09-01 FIX : error in parse invalid file 2004-09-09 ADD : add create .bigfile file contain links greater $bigfilelimit 2004-11-08 ADD : skip 4xx records (dirty :-() TODO: do error report 2004-11-09 ADD : use DB only if not define user name... 2005-04-13 ADD : LightSquid publication cleanup 2005-04-14 ADD : $debug and $debug2 variable for generate statistic : if parsed lines = 0 print WARNING 2005-04-17 ADD : add support fot HTTPDlike log file 2005-04-19 ADD : add .bz2 support : add cache hit calculationn (if Ltype contain HIT - hit else - MISS), wrong ?? : add oversized user calculation 2005-04-20 ADD : .features file added, with additional info 2005-04-22 FIX : httpdlike parser bug; FIX : mkdir 655 -> mkdir 755 2005-04-30 ADD : Rewrite archive support, now support access.log.{D},access.log.{D}.gz,access.log.{D}.bz2 ADD : time report 2005-05-03 FIX : fix wrong .features file output 2005-05-12 FIX : empty line report only if $debug FIX : date filter now ^\d\d\d\d\d\d\d\d$ ... 2005-11-21 FIX : cosmetical changes 2006-07-02 ADD : try recovery some type of broken log record (url contain spaces, two concatenated record) : fix negative number in user file (printf -%d <2g $u <4g), now use simple print 2006-07-05 ADD : Put & Post addet into .total file 2006-07-10 ADD : SkipUser support : GetNameByIP -> IP2NAME (see doc) : $cfgpath in config : .features modification: parameter support 2006-07-29 ADD : add LOCKing, for prevent multiple LightSquid parser instance ... ADD : improve SKIP speed for native squid log format (more that 3 time !!!!) ADD : report line per second speed LPS in debug report 2006-11-23 FIX : Yet another printf trouble in time report fixed 2007-01-05 FIX : Wrong modification data writen in .features 2008-11-28 NEW : Odnoklasniki & Vkontakte agregator added FIX : Perl 5.10 fix. in several cases incorrect name was used, but size calculated correctly. 2009-06-30 NEW : .overuser supportlightsquid-1.8/lightsquid.cfg0000644000076500000240000001153511223223246015045 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2008 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt # -------------------- GLOBAL VARIABLES --------------------------- #path to additional `cfg` files $cfgpath ="/var/www/html/lightsquid"; #path to `tpl` folder $tplpath ="/var/www/html/lightsquid/tpl"; #path to `lang` folder $langpath ="/var/www/html/lightsquid/lang"; #path to `report` folder $reportpath ="/var/www/html/lightsquid/report"; #path to access.log $logpath ="/var/log/squid"; #path to `ip2name` folder $ip2namepath ="/var/www/html/lightsquid/ip2name"; #path to `lockfile` ;-) $lockpath =$reportpath; #if lockfile older $maxlocktime second, remove old lock file. $maxlocktime = 30*60; #if 1 - lightparser generate some statistic $debug = 0; #if 1 - lightparser generate skip details, 2 ..., 3 ..., .... $debug2 = 0; # -------------------- LightParser VARIABLES --------------------------- #squid log type #if native squid format (default squid, see in doc) - must be 0 #if EmulateHttpdLog ON - set 1 #digit - for speed optimization #try it set to 1 if parser generate warning # #see also month2dec below !!!! # $squidlogtype = 0; #if you want skip some sites from stat, example our local www server #WARNING !!!, don't leave this variable empty !!! #example, if you want skip LOCAL site, put it here #WARNING2 #use '' instead of "" !!!!!!!!!!! #$skipurl = 'zdd\.com|192\.168\.1\.|cnn\.com'; $skipurl = 'zzz\.zzz'; #define sobroutine file for convertion from IP into name #if you want skip some ip from log - return "SKIP THIS IP" ;-) #detail see in ip2name folder, $ip2name="simple"; #use for convert from Text to Dec convertion if EmualteHttpdLog format !!!! #fix it if need %month2dec = ( Jan => 1, Feb => 2, Mar => 3, Apr => 4, May => 5,Jun => 6, Jul => 7, Aug => 8, Sep => 9, Oct => 10, Nov => 11,Dec => 12); # -------------------- Common (Parser & Web) VARIABLES ---------------------- #create & use time report statistic (logsize = logsize*2) ;-)) $timereport = 1; # -------------------- WEB VARIABLES ---------------------------------------- #language #see `lang` folder (avaible: bg,eng,fr,hu,it,pt_br,ru,sp) $lang ="eng"; #html template name #see template folder `tpl/$templatename/` $templatename ="base"; #$templatename ="ric"; #$templatename ="base.css"; #define type of decimal output #fine 123456789 -> 123,456,789 #class 123456789 -> 117.7 G $DecOutType="class"; # define delimiter for thousands (in `fine` mode) # = " " -> 12 345 678 # = "," -> 12,345,678 # = "" -> 12345678 $decdelimiter = " "; #if you dont need Group mode, do =0 $showgrouplink = 1; #if not zero, groups look like "01. Group1", if zero - "Group1" $showgroupid = 1; #if you dont need oversize report , do =0 $showoversizelink = 1; #show how many data user send to internet $showputpost = 0; #if putpost higer this variable (in percent), highlight it $putpostwarninglevel =15; #use or not .realname files #.realname contain pair userid -> Full User Name $userealname = 1; #if url size exceed $bigfilelimit - add this file into report $bigfilelimit = 2*1024*1024; #user maximum size per day limit (oversize) $perusertrafficlimit = 10*1024*1024; # weekend display mode # both - select sunday & monday # monday - only monday $weekendmode="both"; #how many site show in TopSites report $topsiteslimit = 500; #how many site show in user time report $usertimelimit = 200; #if you want user traffic GRAPHIC report, set it in 1 #WARNING !!!, need libgd, GD.PM & other external modules !!! #please run check-setup.pl for check library !!!! $graphreport = 1; #higest value on graph report # for user month report (0.05*(...) = 50mb) $graphmaxuser=0.05*(1024*1024*1024); # for all user month report (1.05*(...) = 1 Gb) $graphmaxall =0.80*(1024*1024*1024); #color scheme for GRAPHICs, avaible "orange","blue","green","yellow","brown","red" $barcolor="orange"; #-------------------------------------------------------------------------- Group support # sub CreateGroupFile($) { my $path=shift; open Fi,"<$cfgpath/group.cfg"; open Fo,">$path/.group"; while () { print Fo $_; } close Fo; close Fi; } #-------------------------------------------------------------------------- RealName support # sub CreateRealnameFile($) { my $path=shift; open Fi,"<$cfgpath/realname.cfg"; open Fo,">$path/.realname"; while () { print Fo $_; } close Fo; close Fi; } lightsquid-1.8/month_detail.cgi0000755000076500000240000000725110464066656015365 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt # Show mont user list print "Content-Type: text/html\n\n"; use File::Basename; push (@INC,(fileparse($0))[1]); use CGI; require "lightsquid.cfg"; require "common.pl"; $co=new CGI; $year =$co->param('year'); $month=$co->param('month'); InitTPL("month_detail",$co->param('tpl')); if ($month ne "all") { $workperiod="$MonthName[$month] $year"; $filter="$year$month"; $mode="month"; $modename="##MSG_MONTH##"; } else { $workperiod="##MSG_WHOLE## $year ##MSG_YEAR##"; $filter="$year"; $mode="year"; $modename="##MSG_YEAR##"; } @daylist=glob("$reportpath/$filter*"); foreach $daypath (sort @daylist) { open FF,"<$daypath/.total"; GetRealName($daypath,"?"); # init realname for day $totaluser=;chomp $totaluser;$totaluser=~s/^user: //; $totalsize=;chomp $totalsize;$totalsize=~s/^size: //; $grandtotalsize+=$totalsize; $grandtotaluser+=$totaluser; while () { ($user,$size,$hit)=split; $h{$user}{size}+=$size; $h{$user}{hit}+=$hit; } close FF; } # $cummulative=0; $N=0; foreach $user (sort {$h{$b}{size}<=>$h{$a}{size}} keys %h) { $N++; $percent =sprintf("%2.1f",int($h{$user}{size}*1000/$grandtotalsize)/10); $printhit =FineDec($h{$user}{hit}); $printsize=FineDec($h{$user}{size}); $cummulative+=$h{$user}{size}; $printcummulativesize=FineDec($cummulative); $timeurl_L=URLEncode("user_time.cgi?year=$year&month=$month&user=$user&mode=$mode"); $timeurl_B="##MSG_TIME_LINK##"; $graphurl_L=URLEncode("graph.cgi?year=$year&month=$month&mode=user&user=$user"); $graphurl_B="##MSG_GRAPH_LINK##"; $userurl_L=URLEncode("user_detail.cgi?year=$year&month=$month&user=$user&mode=$mode"); $userurl_B="$user"; $realname=GetRealName($daypath,$user); $usermonthurl_L=URLEncode("user_month.cgi?year=$year&month=$month&user=$user"); $usermonthurl_B="##MSG_USER_MONTH##"; $rowattr = ($N & 1)?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $tmp=$hTPL{user}; $tmp=~s/##USERNUM##/$N/; $tmp=~s/##USERURL_L##/$userurl_L/; $tmp=~s/##USERURL_B##/$userurl_B/; $tmp=~s/##TIMEURL_L##/$timeurl_L/; $tmp=~s/##TIMEURL_B##/$timeurl_B/; $tmp=~s/##GRAPHURL_L##/$graphurl_L/; $tmp=~s/##GRAPHURL_B##/$graphurl_B/; $tmp=~s/##USERMONTHURL_L##/$usermonthurl_L/; $tmp=~s/##USERMONTHURL_B##/$usermonthurl_B/; $tmp=~s/##REALNAME##/$realname/; $tmp=~s/##USERCONNECT##/$printhit/; $tmp=~s/##USERBYTES##/$printsize/; $tmp=~s/##USERPERCENT##/$percent/; $tmp=~s/##ALLUSERTOTAL##/$printcummulativesize/; $tmp=~s/##ROWATTR##/$rowattr/; $tpl{user} .= $tmp; } ReplaceTPL(DATE,$workperiod); ReplaceTPL(WHOLEPERIOD,$modename); ApplyTPL(); HideTPL("timereport") if ($timereport == 0); HideTPL("graphreport") if (($graphreport == 0) || ($mode ne "month")); HideTPL("monthreport") if ($mode ne "month"); HideTPL("realname") if ($userealname == 0); PrintTPL(); __END__ 2004-12-18 : init version 2004-12-22 : add cummulative sum column 2005-01-31 : Add link User -> user month stat 2005-04-17 ADD : TemplateEngine 2005-04-19 ADD : Add skip .name: fields in .total 2005-04-25 ADD : now support YEAR report, tpl fix. 2005-05-01 ADD : time report support 2005-08-30 ADD : Color Flipper 2005-10-02 ADD : _L,_B 2005-10-06 ADD : user_month report link 2005-11-07 ADD : URLEncode 2006-06-28 ADD : &tpl= support lightsquid-1.8/realname.cfg0000644000076500000240000000010610517350260014446 0ustar eslstaff192.168.1.2 Sergey Erokhin 192.168.1.1 Jon Doe 192.168.1.3 Tech Good lightsquid-1.8/report/0000775000076500000240000000000010531362160013517 5ustar eslstafflightsquid-1.8/report/delete.me0000644000076500000240000000000010531362160015270 0ustar eslstafflightsquid-1.8/skipuser.cfg0000644000076500000240000000005010531360672014531 0ustar eslstaff#sample comment sampleuser SKIP THIS IP lightsquid-1.8/tools/0000755000076500000240000000000011223223330013334 5ustar eslstafflightsquid-1.8/tools/fixreport.pl0000755000076500000240000000242511223223330015721 0ustar eslstaff#/bin/perl $|=1; require "../lightsquid.cfg"; sub FixDay($) { my $path=shift; my @userlist=glob ("$path/*"); my $userfile; my @report; my $bug=0; my $site; my $size; my $rest; foreach $userfile (@userlist) { $bug=0; undef @report; unless (-f $userfile) { print "\nWarning !!!, subfolder '$userfile' found, VERY strange ...\n"; next; } open F,"<","$userfile" or die "can't open file '$userfile' - $!\n"; @report=; close F; # print "\t$userfile\n"; for ($i=0;$i<$#report+1;$i++) { my $str=$report[$i]; next if ($str =~ m/: /); ($site,$size,$rest)=split /\s+/,$str,3; # print "\t\t$str ->>> $site->$size\n"; if ($size < 0) { $newsize=2147483648+(2147483648+$size); print "\nBug Found : $path -> $userfile ($size -> $newsize)\n"; $bug=1; $report[$i]=sprintf("%-29s %12s %s",$site,$newsize,$rest); } } if ($bug) { # open F,">","$userfile" or die "can't open file '$userfile' - $!\n"; # print F foreach @report; # close F; } } } #MAIN @days=sort glob("$reportpath/*"); foreach $daypath (sort @days) { next unless ($daypath =~ m/\d\d\d\d\d\d\d\d/); print "$daypath\r"; FixDay($daypath); } lightsquid-1.8/tools/SiteAggregator/0000755000076500000240000000000011136116334016253 5ustar eslstafflightsquid-1.8/tools/SiteAggregator/ReportExplorer.pl0000755000076500000240000000423711136124150021610 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2009 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt # "Service" script for "SiteAggregator.pl" # script generate several statistic from you "Report" folder # for detecting "Garbage" domain # you can use this information for extending "Aggregator" function in "SiteAggregator.pl" #2008-12-18 Sergey Erokhin aka ESL. use File::Find; require "../../lightsquid.cfg"; find({ wanted => \&process, no_chdir=>1 }, "$reportpath/"); sub process() { next if (m{\/\.}); next unless (m{\/\d+\/}); # print "$_\n"; GetFileContent($_); } sub GetFileContent($) { my $file=shift; open F,"<$file" or die "can't open '$file'"; ; #skip total while () { ($site,@other)=split; if (0) { $site=~ s{(.*?)\.vkontakte\.ru}{www\.vkontakte\.ru}o; $site=~ s{(.*?)\.top\.list\.ru}{1\.top\.list\.ru}o; $site=~ s{(.*?)\.myspacecdn\.com}{www\.myspacecdn\.com}o; $site=~ s{(.*?)\.youtube\.com}{www\.youtube\.com}o; $site=~ s{(.*?)\.imageshack\.us}{www\.imageshack\.us}o; $site=~ s{(.*?)\.photobucket\.com}{www\.photobucket\.com}o; $site=~ s{u\d+\.eset\.com}{updates\.eset\.com}o; # $site=~ s{(.*?)\.}{www.}o; # $site=~ s{(.*?)\.}{www.}o; } if ($site =~ m{((.*)\.)?(.*?)\.(.*?)$}) { $l1="$3.$4"; $l2=$2; $l2="." if ($l2 eq ""); $hDOMAIN{$l1}{$l2}++; }else{ print "ERR? :: $site\n"; } } close F; } foreach $l1 (sort keys %hDOMAIN) { $subdomain=0; foreach $l2 (sort {$hDOMAIN{$l1}{$b} <=> $hDOMAIN{$l1}{$a}} keys %{$hDOMAIN{$l1}}) { $subdomain++; } $hSub{$l1}=$subdomain; } foreach $l1 (sort {$hSub{$b} <=> $hSub{$a}} keys %hSub) { next if ($hSub{$l1}<50); print "$l1\t$hSub{$l1}\n"; } foreach $l1 (sort {$hSub{$b} <=> $hSub{$a}} keys %hDOMAIN) { next if ($hSub{$l1}<50); print "$l1 ($hSub{$l1})\n"; foreach $l2 (sort {$hDOMAIN{$l1}{$b} <=> $hDOMAIN{$l1}{$a}} keys %{$hDOMAIN{$l1}}) { print "\t\t$l2\t$hDOMAIN{$l1}{$l2}\n"; } } lightsquid-1.8/tools/SiteAggregator/SiteAgregator.pl0000755000076500000240000001344311136130340021351 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2009 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt #agregate site in user reports #agregate function see in Aggregat() function #you can combine garbage like i1.site.com,i2.site.com,i3.site.com -> site.com #2008-12-18 Sergey Erokhin aka ESL. use File::Find; use Socket; require "../../lightsquid.cfg"; $| = 1; #in several cases squid doesn't resolve all ip to it's name, and leave several as ip #if you set this variable to 1, script try to resolve ip 2 name $TryToResolveIp=0; #a lot of sites my be aggtrgated in this case, but it's my be very slooooooowwwwwwww. my $oldsize=0; my $newsize=0; my $cmpfile=0; my $totalfile=0; print "Start Aggregate '$reportpath' folder (Y - for yes)?"; $answer=; chomp $answer; exit if ($answer ne "Y"); print "Let's go ...\n"; find({ wanted => \&process, no_chdir=>1 }, "$reportpath/"); print "totalfile: $totalfile\n"; print "compacted: $cmpfile\n"; print "OldSize : $oldsize\n"; print "NewSize : $newsize\n"; print "Saved : ".($oldsize-$newsize)."\n"; sub process() { my $old; my $new; next if (m{\/\.}); next unless (m{\/\d+\/}); # print "$_\n"; $old=-s $_; $new=ProcessUser($_); if ($new) { $oldsize+=$old; $newsize+=$new; $cmpfile++; } $totalfile++; } #total: 3483285 #www.mail.ru 2261579 483 0-3302 8-2248160 0-772 0-772 0-772 0-772 0-772 0-772 0-5485 0-0 0-0 0-0 0-0 0-0 0-0 0-0 0-0 0-0 0-0 0-0 0-0 0-0 0-0 0-0 #return new size if modified #or 0 if not modified; sub ProcessUser($) { my $FileName=shift; my $Modified=0; my $total; my %hSite; my @tmp; my $site,$size,$hit,@time; my $ssite; my $ttime,$tsize; my $srclen=-s $FileName; my $dstlen=0; my $dstfile=""; my $ret=0; open F,"<","$FileName" or die "can't open file >$FileName< - $!\n"; $total=; die "Invalid file format >$FileName< - first line should be total: ....\n" unless ($total =~ m/total: \d+/io); $srclen+=length($total); while () { chomp; $line=$_; ($ssite,$size,$hit,@time)=split; if ($TryToResolveIp) { $site=Aggregate(GetName($ssite)); } else { $site=Aggregate($ssite) ; } $Modified=1 if ($ssite ne $site); $hSite{$site}{size}+=$size; $hSite{$site}{hit} +=$hit; for (my $h=0;$h<24;$h++) { ($ttime,$tsize)=split /-/,$time[$h]; $hSite{$site}{hsize}[$h]+=$tsize; $hSite{$site}{htime}[$h]+=$ttime; } } close F; if ($Modified) { my $t2=0; $dstfile=$total; foreach $site (sort {$hSite{$b}{size} <=>$hSite{$a}{size}} keys %hSite) { $dstfile.=sprintf ("%-29s %12s %10s\t",$site,$hSite{$site}{size},$hSite{$site}{hit}); for ( $h = 0 ; $h < 24 ; $h++ ) { $dstfile.=sprintf("%d-%s ", $hSite{$site}{htime}[$h]+0,$hSite{$site}{hsize}[$h]+0); } $dstfile.="\n"; $t2+=$hSite{$site}{size}; } $total =~ m/total: (\d+)/io; if ($1 != $t2) { print "WARNING !!!!! size mismatch !!!!!\n"; } open F,">","$FileName" or die "can't create dst file\n"; print F $dstfile; close F; # $dstlen+=length($dstfile); # print "$FileName\t"; # print "\tsrclen: $srclen\tdstlen=$dstlen\t("; # print -s "$FileName.patch"; # print ")\n"; $ret=-s $FileName; #return new size ... } return $ret; } sub GetName($) { my $site=shift; my $ret=$site; if ($site =~ m/\d+\.\d+\.\d+\.\d+/) { print "$site -> "; unless (defined $hhIP{$site}) { my $ia=inet_aton($site); $ret=gethostbyaddr($ia, AF_INET); $ret=$site if ($ret eq ""); $hhIP{$site}=$ret; } $ret=$hhIP{$site}; print "$ret\n"; } return $ret; } sub Aggregate($) { my $site=shift; if (1) { $site=~ s{(.*?)\.vkontakte\.ru}{vkontakte\.ru}o; $site=~ s{(.*?)\.vkadre\.ru}{www\.vkadre\.ru}o; $site=~ s{(.*?)\.top\.list\.ru}{1\.top\.list\.ru}o; $site=~ s{(.*?)\.myspacecdn\.com}{www\.myspacecdn\.com}o; $site=~ s{(.*?)\.youtube\.com}{www\.youtube\.com}o; $site=~ s{(.*?)\.imageshack\.us}{www\.imageshack\.us}o; $site=~ s{(.*?)\.photobucket\.com}{www\.photobucket\.com}o; $site=~ s{u\d+\.eset\.com}{updates\.eset\.com}o; $site=~ s{ts\d+\.eset\.com}{updates\.eset\.com}o; $site=~ s{89\.202\.157\.13[5-9]}{updates\.eset\.com}o; $site=~ s{(.*?)\.depositfiles\.com}{www\.depositfiles\.com}o; $site=~ s{(.*?)\.odnoklassniki\.ru}{www\.odnoklassniki\.ru}o; $site=~ s{(.*?)\.facebook\.com}{www\.facebook\.com}o; $site=~ s{download\d+\.avast\.com}{download\.avast\.com}o; $site=~ s{.\d+\.radikal\.ru}{cdn\.radikal\.ru}o; $site=~ s{.*?\.foto\.radikal\.ru}{cdn\.foto\.radikal\.ru}o; $site=~ s{khm\d+\.google.com}{maps\.google\.com}o; $site=~ s{kh\d+\.google.com}{maps\.google\.com}o; $site=~ s{mt\d+\.google.com}{maps\.google\.com}o; $site=~ s{tbn\d+\.google.com}{tbn\.google\.com}o; $site=~ s{mlt\d+\.google.com}{mlt\.google\.com}o; $site=~ s{(.*?)\.ifolder\.ru}{www\.ifolder\.ru}o; $site=~ s{(.*?)\.mystat-in\.net}{www\.mystat-in\.net}o; $site=~ s{(.*?)\.photosight\.ru}{www\.photosight\.ru}o; $site=~ s{(.*?)\.mylivepage\.com}{www\.mylivepage\.com}o; $site=~ s{(.*?)\.imagevenue\.com}{www\.imagevenue\.com}o; $site=~ s{(.*?)\.adskape\.ru}{www\.adskape\.ru}o; $site=~ s{(.*?)\.tbn\.ru}{www\\.tbn\.ru}o; $site=~ s{(.*?)\.fotki\.com}{www\.fotki\.com}o; $site=~ s{(.*?)\.deviantart\.com}{www\.deviantart\.com}o; $site=~ s{(.*?)\.rutube\.ru}{rutube\.ru}o; # $site=~ s{(.*?)\.}{www\.}o; # $site=~ s{(.*?)\.}{www\.}o; # $site=~ s{(.*?)\.}{www\.}o; # $site=~ s{(.*?)\.}{www\.}o; # $site=~ s{(.*?)\.}{www\.}o; # $site=~ s{(.*?)\.}{www\.}o; # $site=~ s{(.*?)\.}{www\.}o; # $site=~ s{(.*?)\.}{www\.}o; # $site=~ s{(.*?)\.}{www\.}o; # $site=~ s{(.*?)\.}{www\.}o; # $site=~ s{(.*?)\.}{www\.}o; } return $site; } lightsquid-1.8/topsites.cgi0000755000076500000240000001114110464066662014556 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt print "Content-Type: text/html\n\n"; use File::Basename; push (@INC,(fileparse($0))[1]); use CGI; require "lightsquid.cfg"; require "common.pl"; $co=new CGI; $year =$co->param('year'); $month =$co->param('month'); $day =$co->param('day'); $sortorder =$co->param('order'); $sortorder ||='size'; InitTPL("topsites",$co->param('tpl')); $mode =$co->param('mode'); if ($mode eq "month") { $workperiod="##MSG_WHOLE## ##MSG_MONTH## - $year $MonthName[$month]"; $mask = "$year$month*"; } elsif ($mode eq "year") { $workperiod="##MSG_WHOLE## ##MSG_YEAR## - $year"; $mask = "$year*"; } else { $mode="day"; $workperiod="$day $MonthName[$month] $year"; $mask = "$year$month$day"; } $n=1; $printdotflag=0; #$workperiod="$day $MonthName[$month] $year"; $sorturl ="topsites.cgi?year=$year&month=$month&day=$day"; $sorturl .="&mode=$mode" if ($mode ne "day"); $sorturl .="&order"; $sortconnecturl_L = "$sorturl=hits"; $sortconnecturl_B = "##MSG_CONNECT##"; $sortbytesurl_L = "$sorturl=size"; $sortbytesurl_B = "##MSG_BYTES##"; $sortconnectattr = ($sortorder eq "hits")?"$hTPLVARIABLE{selectedattr}":""; $sortbytesattr = ($sortorder eq "size")?"$hTPLVARIABLE{selectedattr}":""; @days=sort glob("$reportpath/$mask/*"); @days=reverse @days; foreach $userpath (@days) { next if ($userpath =~ m/^\./); $userpath =~ m/\d\/(.*)$/; $user=$1; open FF,"<$userpath"; $totalsize=;chomp $totalsize;$totalsize=~s/total: //; $total+=$totalsize; while () { ($site,$size,$hit)=split; $hash{hits}{$site}+=$hit; $hash{size}{$site}+=$size; } close FF; } $whourl = "whousesite.cgi?year=$year&month=$month&day=$day"; $whourl .="&mode=$mode" if ($mode ne "day"); $whourl .="&usersite"; $N=0; foreach $site (sort {$hash{$sortorder}{$b} <=> $hash{$sortorder}{$a}} keys %{$hash{$sortorder}}) { $percent =sprintf("%2.1f",int($hash{size}{$site}*1000/$total)/10); # $percent ="0.0"; $printhit =FineDec($hash{hits}{$site}); $printsize=FineDec($hash{size}{$site}); $siteurlwho_L = "$whourl=$site"; $siteurlwho_B = "##MSG_WHO##"; $siteurl_L = "http://$site"; $siteurl_B = "$site"; $N++; if ($N > $topsiteslimit) { unless ($printdotflag) { $printdotflag=1; $rowattr = ($N & 1)?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $dotN=$N; #for color flipper $tmp=$hTPL{site}; $tmp=~s/##SITENUM##//; $tmp=~s/##SITEURLWHO_L##//; $tmp=~s/##SITEURLWHO_B##/\.\.\./; $tmp=~s/##SITEURL_L##//; $tmp=~s/##SITEURL_B##/\.\.\./; $tmp=~s/##SITECONNECT##/\.\.\./; $tmp=~s/##SITEBYTES##/\.\.\./; $tmp=~s/##SITEPERCENT##//; $tmp=~s/##ROWATTR##/$rowattr/; $tpl{site} .= $tmp; } next; } $rowattr = ($N & 1)?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $tmp=$hTPL{site}; $tmp=~s/##SITENUM##/$N/; $tmp=~s/##SITEURLWHO_L##/$siteurlwho_L/; $tmp=~s/##SITEURLWHO_B##/$siteurlwho_B/; $tmp=~s/##SITEURL_L##/$siteurl_L/; $tmp=~s/##SITEURL_B##/$siteurl_B/; $tmp=~s/##SITECONNECT##/$printhit/; $tmp=~s/##SITEBYTES##/$printsize/; $tmp=~s/##SITEPERCENT##/$percent/; $tmp=~s/##ROWATTR##/$rowattr/; $tpl{site} .= $tmp; } close FF; if ($printdotflag) { $rowattr = (($dotN+1) & 1)?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $tmp=$hTPL{site}; $tmp=~s/##SITENUM##/$N/; $tmp=~s/##SITEURLWHO_L##/$siteurlwho_L/; $tmp=~s/##SITEURLWHO_B##/$siteurlwho_B/; $tmp=~s/##SITEURL_L##/$siteurl_L/; $tmp=~s/##SITEURL_B##/$siteurl_B/; $tmp=~s/##SITECONNECT##/$printhit/; $tmp=~s/##SITEBYTES##/$printsize/; $tmp=~s/##SITEPERCENT##/$percent/; $tmp=~s/##ROWATTR##/$rowattr/; $tpl{site} .= $tmp; } $totalprint=FineDec($total); ReplaceTPL(TOTAL,$totalprint); ReplaceTPL_URL(SORTCONNECTURL,$sortconnecturl_L,$sortconnecturl_B); ReplaceTPL(SORTCONNECTATTR,$sortconnectattr); ReplaceTPL_URL(SORTBYTESURL,$sortbytesurl_L,$sortbytesurl_B); ReplaceTPL(SORTBYTESATTR,$sortbytesattr); ReplaceTPL(DATE,$workperiod); ApplyTPL(); PrintTPL(); __END__ 2004-09-09 :: ADD skip all files starting with . 2005-04-09 :: ADD show $topsiteslimit records in log (see lightsquid.cfg) 2005-04-17 :: ADD TemplateEngine 2005-05-01 :: ADD month & year mode report 2005-08-30 :: ADD color flipper 2005-09-06 :: ADD colorselected now defined in TPL file 2005-10-02 :: ADD _L,_B lightsquid-1.8/tpl/0000755000076500000240000000000010530431024012774 5ustar eslstafflightsquid-1.8/tpl/base/0000755000076500000240000000000010530431026013710 5ustar eslstafflightsquid-1.8/tpl/base/bigfiles.html0000644000076500000240000000504611223230560016367 0ustar eslstaff ##META## LightSquid :: Big Files Report
##MSG_HEADER##
##MSG_BIG_FILE_DOWNLOAD_REPORT##
##MSG_DATE##: ##DATE##
##MSG_USER##: ##REPORTUSER##
##MSG_NUM## ##MSG_TIME## ##MSG_USER## ##MSG_SIZE## ##MSG_URL##
##BFILENUM## ##BFILETIME## ##BFILEUSER_B## ##BFILESIZE## ##BFILELINK##

##COPYRIGHT##
lightsquid-1.8/tpl/base/day_detail.html0000644000076500000240000001067711222212352016706 0ustar eslstaff ##META## LightSquid :: Day detail
##MSG_HEADER##
##MSG_DATE##:  ##DATE## 
##TOPSITESURL_B## ##MSG_REPORT##
##BIGFILESURL_B## ##MSG_REPORT##
##OVERMSG##
##MSG_NUM## ##MSG_TIME_REPORT## ##MSG_USER## ##MSG_REALNAME## ##MSG_CONNECT## ##MSG_PUTPOST## ##MSG_BYTES## % ##MSG_GROUP##
##USERNUM## ##USERURL_B## ##REALNAME## ##USERCONNECT## ##USERPUTPOST####OVERPUTPOSTATTR## ##USERBYTES## ##USERPERCENT##% ##USERGROUPURL_B##

##COPYRIGHT##
lightsquid-1.8/tpl/base/graph.html0000644000076500000240000000264111222212366015705 0ustar eslstaff ##META## LightSquid :: Graphics
##MSG_HEADER##
##MSG_WORK_PERIOD##: ##WORKPERIOD##
##MODE##

##MSG_WARNING##, ##MSG_RECOMENDATION## $##VARNAME##=##VARVALUE##*(1024*1024*1024);

##COPYRIGHT##
lightsquid-1.8/tpl/base/group_detail.html0000644000076500000240000001251011222212376017257 0ustar eslstaff ##META## LightSquid :: Day detail - Group Mode
##MSG_HEADER##
##MSG_DATE##:  ##DATE## 
##TOPSITESURL_B## ##MSG_REPORT##
##BIGFILESURL_B## ##MSG_REPORT##
##MSG_NUM## ##MSG_TIME_REPORT## ##MSG_USER## ##MSG_REALNAME## ##MSG_CONNECT## ##MSG_BYTES## %
##GROUPSTARTURL_B##
##USERNUM## ##USERURL_B## ##REALNAME## ##USERCONNECT## ##USERBYTES## ##USERPERCENT##%
##GROUPENDBYTES## ##GROUPENDPERCENT##%
##MSG_NUM## ##MSG_GROUP## ##MSG_BYTES## %
##GROUPLISTNUM## ##GROUPLISTNAMEURL_B## ##GROUPLISTBYTES## ##GROUPLISTPERCENT##

##COPYRIGHT## lightsquid-1.8/tpl/base/images/0000755000076500000240000000000010530431030015150 5ustar eslstafflightsquid-1.8/tpl/base/images/datetime.png0000644000076500000240000000156210405066620017470 0ustar eslstaffPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDAT8]kHSq}}( EAAЇnAXVdYդtvl6׌t7 M}پ 7EF܏&MszJf-KS0\u I!}ًf>Ʌ]zd&."^õJ,.4 2I3(PdEى zG˅מ=M'QH;ePQxt5/ހG0/ vT\}`gDhc8 /jRTp ex+JP/)T;ƥ0o8ާx^+e/<6iFہ ~G [app@NyY&^tRE]"taC T%}N+BŨyY&^xrk᪾6W݇$+Ϊ U0L`#ZyÙZ}7?ZSNg4] 2#^99Y{]G=<[`deXg`*`1Pyp,Lhv܇{ ʾ;%Wʭgst .7~?ïOrd|_lx`-Z1vV: k³}{}~nU;b͜ @Wy|:H- (K ?0d 8=J{B%˄IENDB`lightsquid-1.8/tpl/base/images/graph.png0000644000076500000240000000103510405066574017000 0ustar eslstaffPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDAT8˥jVQF׉'j$`BWbv vv>`SAwRnqDH$)ff*.SYW+2QD=O><.M.ndG %cQl]'B /+fR9허 jp?v !!x$e߿ܽqS%ov@tHs0@ IbQ_Kr<-SGհncvarLMْ[O"KwN6*fcn 5aڲ3f3rt-0WN bB_vƚN2P+J@\hԕ6 cN'?p^XĊE]Ylna+҄JsJ,x @ *nIxd$e=OIENDB`lightsquid-1.8/tpl/base/images/printer.png0000644000076500000240000000133310405067336017360 0ustar eslstaffPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<mIDAT8ˍKSa]w8o H* a十x*AKA@u"ՆXK9y^8U;O;QGJR-X|OpixH(%,Hs$JHE_xxK zm)RA3ʮRFZƃ7PO/B%EI_e!|$HLvx|nJ`rr$A~-vP3Eծ^ J^ qP{*ئ^S2[  L@gggFq{*,$35$(oUlUt]%K70>>FӭL&_(YA000,PX__($ q"R5Cϟyg2H$nd~)Jp;;;MLL1v;8`Zz z' шQ6f__VY=nddx؁Ҹ%l:::Xvnn жN X"8:!A9IHgK^T CR)[Sÿ"'kvcxgzȬ[IENDB`lightsquid-1.8/tpl/base/index.html0000644000076500000240000001307411222212062015706 0ustar eslstaff ##META## LightSquid :: Index
##MSG_HEADER##
##MSG_WORK_PERIOD##: ##WORKPERIOD##

##MSG_CALENDAR##
##MONTHURL_B##
##MSG_TOP_SITES## ##MSG_TOTAL## ##MSG_GROUP##
##TOP_YEAR_B## ##TOTAL_YEAR_B## ##GROUP_YEAR_B##
##TOP_MONTH_B## ##TOTAL_MONTH_B## ##GROUP_MONTH_B##

##MSG_DATE## ##MSG_GROUP## ##MSG_USERS## ##MSG_OVERSIZE## ##MSG_BYTES## ##MSG_AVERAGE## ##MSG_HIT%##
##DAYDATE_B## ##DAYGROUP_B## ##DAYUSERS## ##DAYOVERUSERS_B## ##DAYBYTES## ##DAYAVERAGE## ##DAYCACHEHIT##%
##MSG_TOTAL_AVERAGE##:   ##USERAVERAGE## ##OVERUSERAVERAGE## ##TOTAL_B## ##TOTALAVERAGE## ##AVERAGEHIT##%

##COPYRIGHT##
lightsquid-1.8/tpl/base/month_detail.html0000644000076500000240000001002211222212404017234 0ustar eslstaff ##META## LightSquid :: Whole Month User Report
##MSG_HEADER##
##MSG_WHOLE## ##WHOLEPERIOD##
##MSG_WORK_PERIOD##:  ##DATE## 
##MSG_NUM## ##MSG_TIME_REPORT## ##MSG_GRAPH_REPORT## ##MSG_MONTH## ##MSG_USER## ##MSG_REALNAME## ##MSG_CONNECT## ##MSG_BYTES## % ##MSG_CUMULATIVE##
##USERNUM## ##USERMONTHURL_B## ##USERURL_B## ##REALNAME## ##USERCONNECT## ##USERBYTES## ##USERPERCENT##% ##ALLUSERTOTAL##

##COPYRIGHT##
lightsquid-1.8/tpl/base/topsites.html0000644000076500000240000000470111222212416016451 0ustar eslstaff ##META## LightSquid :: Top Site
##MSG_HEADER##
##MSG_TOP_SITES##
##MSG_WORK_PERIOD##:  ##DATE## 
##MSG_ACCESSED_SITE## ##SORTCONNECTURL_B## ##SORTBYTESURL_B## %
##SITENUM## ##SITEURLWHO_B## ##SITEURL_B## ##SITECONNECT## ##SITEBYTES## ##SITEPERCENT##%
##MSG_TOTAL## ##TOTAL##

##COPYRIGHT## lightsquid-1.8/tpl/base/user_detail.html0000644000076500000240000001037111222212424017076 0ustar eslstaff ##META## LightSquid :: User Detail
##MSG_HEADER##
##MSG_USER##:  ##USER##
##MSG_GROUP##:  ##GROUP##
##MSG_DATE##:  ##WORKPERIOD##
##BIGFILESURL_B##
##MSG_TOTAL##     ##TOTAL##
##MSG_NUM## ##MSG_ACCESSED_SITE## ##MSG_CONNECT## ##MSG_BYTES## ##MSG_CUMULATIVE## %
##NUM## ##SITEURL_B## ##SITECONNECT## ##SITEBYTES## ##SITETOTAL## ##SITEPERCENT##%
##MSG_TOTAL## ##TOTAL##

##COPYRIGHT## lightsquid-1.8/tpl/base/user_month.html0000644000076500000240000000633711222212432016767 0ustar eslstaff ##META## LightSquid :: User Month detail
##MSG_HEADER##
##MSG_USER##:  ##USER##
##MSG_WORK_PERIOD##: ##WORKPERIOD##
##MSG_TOTAL##:  ##TOTALBYTES##
##MSG_DATE## ##MSG_BYTES## ##MSG_WEEKSUM## ##MSG_CUMULATIVE##
##DAYDATE_B## ##DAYBYTES## ##WEEKSUM## ##DAYCUMULATIVE##
##MSG_TOTAL## ##TOTALBYTES##    

##COPYRIGHT##
lightsquid-1.8/tpl/base/user_time.html0000644000076500000240000001146611222212442016600 0ustar eslstaff ##META## LightSquid :: User Detail by TIME
##MSG_HEADER##
##MSG_USER##:  ##USER##
##MSG_DATE##:  ##WORKPERIOD## 
##MSG_NUM## ##MSG_ACCESSED_SITE## 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ##MSG_TOTAL##
##NUM## ##URL## ##T00## ##T01## ##T02## ##T03## ##T04## ##T05## ##T06## ##T07## ##T08## ##T09## ##T10## ##T11## ##T12## ##T13## ##T14## ##T15## ##T16## ##T17## ##T18## ##T19## ##T20## ##T21## ##T22## ##T23## ##URLSIZE##

##COPYRIGHT## lightsquid-1.8/tpl/base/whousesite.html0000644000076500000240000000564511222212450017004 0ustar eslstaff ##META## LightSquid :: Who Use Site report
##MSG_HEADER##
##SITE##
##MSG_WORK_PERIOD##:  ##DATE## 

##MSG_USER## ##MSG_REALNAME## ##MSG_CONNECT## ##MSG_SIZE## ##MSG_DAYLIST##
##WHOUSER## ##REALNAME## ##WHOCONNECT## ##WHOSIZE## ##USEDAYURL_B##
##MSG_TOTAL##   ##TOTALCONNECT## ##TOTAL##

##COPYRIGHT## lightsquid-1.8/tpl/text/0000755000076500000240000000000010530431032013757 5ustar eslstafflightsquid-1.8/tpl/text/bigfiles.html0000644000076500000240000000041210530423502016431 0ustar eslstaff ##MSG_BIG_FILE_DOWNLOAD_REPORT## ##MSG_DATE##: ##DATE## ##MSG_NUM## ##MSG_TIME## ##MSG_USER## ##MSG_SIZE## ##MSG_URL## ##BFILENUM## ##BFILETIME## ##BFILEUSER_B## ##BFILESIZE## ##BFILELINK## lightsquid-1.8/tpl/text/day_detail.html0000644000076500000240000000102110530423504016743 0ustar eslstaff LightSquid :: Day detail ##MSG_HEADER## ##MSG_DATE##: ##DATE## ##MSG_NUM## ##MSG_USER## ##MSG_REALNAME## ##MSG_CONNECT## ##MSG_BYTES## % ##MSG_GROUP## ##USERNUM## ##USERURL_B## ##REALNAME## ##USERCONNECT## ##USERBYTES## ##USERPERCENT##% ##USERGROUPURL_B## lightsquid-1.8/tpl/text/group_detail.html0000644000076500000240000000157210530423510017332 0ustar eslstaff LightSquid :: Day detail - Group Mode ##MSG_HEADER## ##MSG_DATE##: ##DATE## ##MSG_NUM## ##MSG_TIME_REPORT## ##MSG_USER## ##MSG_REALNAME## ##MSG_CONNECT## ##MSG_BYTES## % ##GROUPSTARTURL_B## ##USERNUM## ##USERURL_B## ##REALNAME## ##USERCONNECT## ##USERBYTES## ##USERPERCENT##% __ _ _ _ ##GROUPENDBYTES## ##GROUPENDPERCENT##% ##MSG_NUM## ##MSG_GROUP## ##MSG_BYTES## % ##GROUPLISTNUM## ##GROUPLISTNAMEURL_B## ##GROUPLISTBYTES## ##GROUPLISTPERCENT## lightsquid-1.8/tpl/text/index.html0000644000076500000240000000153710530423514015770 0ustar eslstaff LightSquid :: Index ----------------------------------------------------- ##MSG_HEADER## ##MSG_WORK_PERIOD##: ##WORKPERIOD## ----------------------------------------------------- ##MSG_DATE## ##MSG_GROUP## ##MSG_USERS## ##MSG_OVERSIZE## ##MSG_BYTES## ##MSG_AVERAGE## ##MSG_HIT%## ##DAYDATE_B## ##DAYGROUP_B## ##DAYUSERS## ##DAYOVERUSERS_B## ##DAYBYTES## ##DAYAVERAGE## ##DAYCACHEHIT##% ##MSG_TOTAL_AVERAGE##: ##USERAVERAGE## ##OVERUSERAVERAGE## ##TOTAL_B## ##TOTALAVERAGE## ##AVERAGEHIT##% lightsquid-1.8/tpl/text/month_detail.html0000644000076500000240000000074610530423516017333 0ustar eslstaff LightSquid :: Whole Month User Report ##MSG_HEADER## ##MSG_WHOLE## ##WHOLEPERIOD## ##MSG_WORK_PERIOD##: ##DATE## ##MSG_NUM## ##MSG_USER## ##MSG_REALNAME## ##MSG_CONNECT## ##MSG_BYTES## % ##MSG_CUMULATIVE## ##USERNUM## ##USERURL_B## ##REALNAME## ##USERCONNECT## ##USERBYTES## ##USERPERCENT##% ##ALLUSERTOTAL## lightsquid-1.8/tpl/text/topsites.html0000644000076500000240000000050110530423522016520 0ustar eslstaff LightSquid :: Top Site ##MSG_HEADER## ##MSG_TOP_SITES## ##MSG_WORK_PERIOD##: ##DATE## ##MSG_ACCESSED_SITE## ##SORTCONNECTURL_B## ##SORTBYTESURL_B## % ##SITENUM## ##SITEURL_B## ##SITECONNECT## ##SITEBYTES## ##SITEPERCENT## % ##MSG_TOTAL## ##TOTAL## lightsquid-1.8/tpl/text/user_detail.html0000644000076500000240000000071110530423526017155 0ustar eslstaff LightSquid :: User Detail ##MSG_HEADER## ##MSG_USER##: ##USER## ##MSG_GROUP##: ##GROUP## ##MSG_DATE##: ##WORKPERIOD## ##MSG_TOTAL##: ##TOTAL## ##MSG_NUM## ##MSG_ACCESSED_SITE## ##MSG_CONNECT## ##MSG_BYTES## ##MSG_CUMULATIVE## % ##NUM## ##SITEURL_B## ##SITECONNECT## ##SITEBYTES## ##SITETOTAL## ##SITEPERCENT## % ##MSG_TOTAL## ##TOTAL## lightsquid-1.8/tpl/text/user_month.html0000644000076500000240000000054510530423530017040 0ustar eslstaff LightSquid :: User Month detail ##MSG_HEADER## ##MSG_USER##: ##USER## ##MSG_WORK_PERIOD##: ##WORKPERIOD## ##MSG_TOTAL##: ##TOTALBYTES## ##MSG_DATE## ##MSG_BYTES## ##MSG_WEEKSUM## ##MSG_CUMULATIVE## ##DAYDATE_B## ##DAYBYTES## ##WEEKSUM## ##DAYCUMULATIVE## ##MSG_TOTAL## ##TOTALBYTES## lightsquid-1.8/tpl/text/whousesite.html0000644000076500000240000000106510530423534017056 0ustar eslstaff LightSquid :: Who Use Site report ##MSG_USER_WHO_USE_SITE##: ##SITE## ##MSG_WORK_PERIOD##: ##DATE## ##MSG_USER## ##MSG_REALNAME## ##MSG_CONNECT## ##MSG_SIZE## ##MSG_DAYLIST## ##WHOUSER## ##REALNAME## ##WHOCONNECT## ##WHOSIZE## ##USEDAYURL_B## ##MSG_TOTAL## ##TOTALCONNECT## ##TOTAL## lightsquid-1.8/user_detail.cgi0000755000076500000240000000765310530420204015175 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt print "Content-Type: text/html\n\n"; use File::Basename; push (@INC,(fileparse($0))[1]); use CGI; require "lightsquid.cfg"; require "common.pl"; $co=new CGI; $year =$co->param('year'); $month=$co->param('month'); $day =$co->param('day'); $user =$co->param('user'); $mode =$co->param('mode'); InitTPL("user_detail",$co->param('tpl')); if ($mode eq "month") { $workperiod="##MSG_WHOLE## ##MSG_MONTH## - $year $MonthName[$month]"; $mask = "$year$month"; } elsif ($mode eq "year") { $workperiod="##MSG_WHOLE## ##MSG_YEAR## - $year"; $mask = "$year"; } else { $workperiod="$day $MonthName[$month] $year"; $mask = "$year$month$day"; $mode = "day" } @datelist=sort glob "$reportpath/$mask*"; $calculatedtotal=0; foreach $workday (sort @datelist) { GetRealName($workday,"?"); GetGroup($workday); open FF,"<$workday/$user" || MyDie("can't open $daypath/$user"); $totalsize=;chomp $totalsize;$totalsize=~s/total: //; while () { ($site,$size,$hit)=split; $h{$site}{hit} +=$hit; $h{$site}{size}+=$size; $calculatedtotal+=$size } close FF; } #--------- # check - exist current user in .bigfiles # only in DAY mode if ($mode eq "day") { open FF,"<$reportpath/$year$month$day/.bigfiles"; while () { ($buser,$btime,$bsize,$blink)=split; $flagbigfiles=1 if ($buser eq $user); } close FF; } if ($flagbigfiles) { $bigfiles_B="##MSG_BIG_FILES_USER##"; $bigfiles_L="bigfiles.cgi?year=$year&month=$month&day=$day&user=$user"; } #--------- $N=0; $total=0; foreach $site (sort {$h{$b}{size} <=> $h{$a}{size}} keys %h) { $N++; $hit=$h{$site}{hit}; $size=$h{$site}{size}; $total+=$size; $percent =sprintf("%2.1f",int($size*1000/$calculatedtotal)/10); $printhit =FineDec($hit); $printsize =FineDec($size); $printtotal=FineDec($total); $siteurl_L="http://$site"; $siteurl_B="$site"; $rowattr = ($N & 1)?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $tmp=$hTPL{site}; $tmp=~s/##NUM##/$N/; $tmp=~s/##SITEURL_L##/$siteurl_L/g; $tmp=~s/##SITEURL_B##/$siteurl_B/g; $tmp=~s/##SITECONNECT##/$printhit/; $tmp=~s/##SITEBYTES##/$printsize/; $tmp=~s/##SITETOTAL##/$printtotal/; $tmp=~s/##SITEPERCENT##/$percent/; $tmp=~s/##ROWATTR##/$rowattr/; $tpl{site} .= $tmp; } $printtotalsize=FineDec($calculatedtotal); $printuser="$user"; $printuser .= " (".GetRealName("?",$user).")" if ($userealname != 0); ReplaceTPL(USER,$printuser); ReplaceTPL(TOTAL,$printtotalsize); ReplaceTPL(WORKPERIOD,$workperiod); ReplaceTPL(GROUP,(defined $hGroup{$user})?"$hGroupName{$hGroup{$user}}":"?"); ReplaceTPL_URL(TIMEURL,"user_time.cgi?year=$year&month=$month&day=$day&user=$user","##MSG_TIME_LINK##"); ReplaceTPL_URL(BIGFILESURL,$bigfiles_L,$bigfiles_B); ApplyTPL(); HideTPL("timereport") if (($timereport == 0) || ($mode ne "day")); HideTPL("group") if ($showgrouplink == 0); PrintTPL(); __END__ 2004-11-09 ADD : Total column, commulative total 2004-12-18 ADD : 2005-01-31 ADD : New Param (month=1) if, then show whole month user report, else only selected day 2005-04-14 FIX : in CONNECT column displayed size column 2005-04-17 ADD : TemplateEngine 2005-04-25 ADD : mode=year 2005-05-01 ADD : time report link 2005-08-30 ADD : Color Flipper 2005-09-08 ADD : if user exist in .bigfiles file, on top of report MESSAGE with link 2005-10-02 ADD : _L,_B 2005-11-01 ADD : Group name in header 2006-06-28 ADD : die -> MyDie 2006-06-28 ADD : &tpl= support 2006-09-13 ADD : add &user= in bigfiles URL 2006-11-20 ADD : /g for ##SITEURL_B## & ##SITEURL_L##, my need in some caseslightsquid-1.8/user_month.cgi0000755000076500000240000000604210530424004015051 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt use File::Basename; push( @INC, ( fileparse($0) )[1] ); use CGI; require "lightsquid.cfg"; require "common.pl"; $co = new CGI; $year = $co->param('year'); $month = $co->param('month'); $user = $co->param('user'); $mode = $co->param('mode'); print "Content-Type: text/html\n\n"; InitTPL("user_month",$co->param('tpl')); $workperiod = "$MonthName[$month] $year"; ReplaceTPL( WORKPERIOD, $workperiod ); $week_id=0; $week_date=$date; $average = 0; $days = 0; $filter = "$year$month"; @daylist = sort glob("$reportpath/$filter*"); @daylist = reverse @daylist; foreach $daypath (@daylist ) { open FF, "<$daypath/.total"; $tmp = ; $size = ; # $daypath =~ m/(\d\d\d\d)(\d\d)(\d\d)/; $daypath =~ m#$reportpath/(.*)#; $date=$1; $date =~ m/^(\d\d\d\d)(\d\d)(\d\d)/; $urldate="year=$1&month=$2&day=$3"; $printdate= GetTxtDate($date); $weekday = GetWeekDayDate($date); $weeksumtpl=""; if ($weekday == 0) { $week_id++; $weeksumtpl="##WEEKSUM$week_id##"; $weeksum[$week_id]=0; } $size="?"; while () { ( $user_, $size_, $hit ) = split; next if ( $user_ ne $user ); $cumulative += $size_; $size = $size_; } $weeksum[$week_id]+=$size if ($size ne "?"); $printsize =($size eq "?")?"?":FineDec($size); $printcumulative =FineDec($cumulative); $daydate_L =URLEncode("user_detail.cgi?$urldate&user=$user"); $daydate_B ="$printdate"; $dayattr = ($weekday & 1 )?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $dayattr = $hTPLVARIABLE{sundayattr} if ($weekday == 0); $dayattr = $hTPLVARIABLE{saturdayattr} if (($weekday == 6) && ($weekendmode eq "both")); $oversizeattr=(($perusertrafficlimit>0) && ($size > $perusertrafficlimit))?$hTPLVARIABLE{oversizedattr}:$hTPLVARIABLE{nooversizedattr}; $tmp=$hTPL{day}; $tmp=~s/##DAYDATE_L##/$daydate_L/; $tmp=~s/##DAYDATE_B##/$daydate_B/; $tmp=~s/##DAYBYTES##/$printsize/; $tmp=~s/##DAYCUMULATIVE##/$printcumulative/; $tmp=~s/##WEEKSUM##/$weeksumtpl/; $tmp=~s/##DAYATTR##/$dayattr/; $tmp=~s/##OVERSIZEATTR##/$oversizeattr/; $tpl{day} .= $tmp; $days++; close FF; } $graphurl_L=URLEncode("graph.cgi?year=$year&month=$month&mode=user&user=$user"); $graphurl_B="##MSG_GRAPH_LINK##"; ReplaceTPL_URL(GRAPHURL,$graphurl_L,$graphurl_B); ReplaceTPL(USER,$user); ReplaceTPL(WORKPERIOD,$workperiod); ReplaceTPL(TOTALBYTES,$printcumulative); for ($i=0;$i<=$week_id;$i++) { ReplaceTPL("WEEKSUM$i",FineDec($weeksum[$i])); } ApplyTPL(); PrintTPL(); __END__ 2005-10-06 ADD : Initial release 2006-06-28 ADD : &tpl= support 2006-07-01 ADD : RIC, add sunday highlight lightsquid-1.8/user_time.cgi0000777000076500000240000000770411064543134014705 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt print "Content-Type: text/html\n\n"; use File::Basename; push (@INC,(fileparse($0))[1]); use CGI; require "lightsquid.cfg"; require "common.pl"; $co=new CGI; $year =$co->param('year'); $month=$co->param('month'); $day =$co->param('day'); $user =$co->param('user'); $mode =$co->param('mode'); InitTPL("user_time",$co->param('tpl')); if ($mode eq "month") { $workperiod="##MSG_WHOLE## ##MSG_MONTH## - $year $MonthName[$month]"; $mask = "$year$month"; } elsif ($mode eq "year") { $workperiod="##MSG_WHOLE## ##MSG_YEAR## - $year"; $mask = "$year"; } else { $workperiod="$day $MonthName[$month] $year"; $mask = "$year$month$day"; } #@datelist=sort glob "$reportpath/$mask*"; @datelist=glob "$reportpath/$mask*"; $calculatedtotal=0; foreach $workday (sort @datelist) { GetRealName($workday,"?"); open FF,"<$workday/$user" || MyDie("can't open $workday/$user"); $totalsize=;chomp $totalsize;$totalsize=~s/total: //; while () { ($site,$size,$hit,@hlog)=split; $h{$site}{hit} +=$hit; $h{$site}{size} +=$size; $calculatedtotal+=$size; for ($h=0;$h<24;$h++) { ($ttime,$tsize)=split /-/,$hlog[$h]; $hsitetime{$site}[$h]+=$tsize; $htime[$h]+=$ttime; $hsize[$h]+=$tsize; } } close FF; } $tmp=$hTPL{site}; $tmp=~s/##URL##/##MSG_TOTAL##/; $tmp=~s/##NUM##//; $tmp=~s/##ROWATTR##/$hTPLVARIABLE{totalattr}/; $HH="00"; $total=0; for ($h=0;$h<24;$h++) { $size = sprintf("%.1f",$hsize[$h]/(1024*1024)); $size = "." if (0 == $hsize[$h]); $total+=$hsize[$h]; $tmp=~s/##T$HH##/$size/; $HH++; } $printsize =FineDec($total); $tmp=~s/##URLSIZE##/$printsize/; $tpl{site} .= $tmp; $tmptotal=$tmp; $N=0; $Color=0; $total=0; foreach $site (sort {$h{$b}{size} <=> $h{$a}{size}} keys %h) { $N++; $HH="00"; $size=$h{$site}{size}; next if ($N > $usertimelimit); $printsize =FineDec($size); $tmp=$hTPL{site}; $tmp=~s/##URL##/$site/; for ($h=0;$h<24;$h++) { $size = sprintf("%.1f",$hsitetime{$site}[$h]/(1024*1024)); $size = "." if (0 == $hsitetime{$site}[$h]); $tmp=~s/##T$HH##/$size/; $HH++; } $rowattr = (++$Color & 1)?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $tmp=~s/##NUM##/$N/; $tmp=~s/##URLSIZE##/$printsize/; $tmp=~s/##ROWATTR##/$rowattr/; $tpl{site} .= $tmp; } if ($N > $usertimelimit) { $HH="00"; $tmp=$hTPL{site}; $tmp=~s/##URL##/\.\.\./; $ttt="..."; for ($h=0;$h<24;$h++) { $tmp=~s/##T$HH##/$ttt/; $HH++; } $rowattr = (++$Color & 1)?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $tmp=~s/##NUM##/\.\.\./; $tmp=~s/##URLSIZE##/\.\.\./; $tmp=~s/##ROWATTR##/$rowattr/; $tpl{site} .= $tmp; $printsize =FineDec($size); $HH="00"; $tmp=$hTPL{site}; $tmp=~s/##URL##/$site/; for ($h=0;$h<24;$h++) { $size = sprintf("%.1f",$hsitetime{$site}[$h]/(1024*1024)); $size = "." if (0 == $hsitetime{$site}[$h]); $tmp=~s/##T$HH##/$size/; $HH++; } $rowattr = (++$Color & 1)?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $tmp=~s/##NUM##/$N/; $tmp=~s/##URLSIZE##/$printsize/; $tmp=~s/##ROWATTR##/$rowattr/; $tpl{site} .= $tmp; } $tpl{site} .= $tmptotal; $printtotalsize=FineDec($calculatedtotal); $printuser="$user"; $printuser .= " (".GetRealName("?",$user).")" if ($userealname != 0); ReplaceTPL(USER,$printuser); ReplaceTPL(WORKPERIOD,$workperiod); ApplyTPL(); PrintTPL(); #print $template; __END__ 2005-05-01 ADD : Initial release 2005-08-30 ADD : Color flipper, total also at bottom of page 2005-09-07 FIX : Color flipper, if records > $usertimelimit 2005-10-02 ADD : _L,_B 2006-06-28 ADD : die -> MyDie 2006-06-28 ADD : &tpl= support lightsquid-1.8/whousesite.cgi0000755000076500000240000000673210464066676015122 0ustar eslstaff#!/usr/bin/perl # # LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # detail see in gnugpl.txt print "Content-Type: text/html\n\n"; use File::Basename; push (@INC,(fileparse($0))[1]); use CGI; require "lightsquid.cfg"; require "common.pl"; $co=new CGI; $mode="day"; $year =$co->param('year'); $month =$co->param('month'); $day =$co->param('day'); $usersite =$co->param('usersite'); $mode =$co->param('mode'); InitTPL("whousesite",$co->param('tpl')); if ($mode eq "month") { $workperiod="##MSG_WHOLE## ##MSG_MONTH## - $year $MonthName[$month]"; $mask = "$year$month*"; } elsif ($mode eq "year") { $workperiod="##MSG_WHOLE## ##MSG_YEAR## - $year"; $mask = "$year*"; } else { $mode="day"; $workperiod="$day $MonthName[$month] $year"; $mask = "$year$month$day"; } #@days=sort glob("$reportpath/$year$month$day/*"); @days=sort glob("$reportpath/$mask/*"); @days=reverse @days; foreach $userpath (@days) { next if ($userpath =~ m/\^./); $userpath =~ m/\/(\d*)\/(.*)$/; $user=$2; $date=$1; GetRealName("$reportpath/$date/","?"); open FF,"<$userpath"; $totalsize=;chomp $totalsize;$totalsize=~s/total: //; while () { ($site,$size,$hit)=split; next unless ($site eq $usersite); $hash{$user}+=$size; $hhit{$user}+=$hit; $hday{$user}{$date}=1; $total +=$size; $hittotal+=$hit; } close FF; } $N=0; foreach $user (sort {$hash{$b} <=> $hash{$a}} keys %hash) { $listid=0; $N++; $printsize =FineDec($hash{$user}); $printconnect=FineDec($hhit{$user}); $usedaylist=""; # if ($mode ne "day") { foreach $date (sort keys %{$hday{$user}} ) { $date =~ m/(\d\d\d\d)(\d\d)(\d\d)/; $daylist[$listid ]{'L'}= URLEncode("user_detail.cgi?year=$1&month=$2&day=$3&user=$user"); $daylist[$listid++]{'B'}= GetTxtDate($date); } # } $rowattr = ($N & 1)?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr}; $realname = GetRealName("?",$user); $tmp=$hTPL{who}; $tmp=~s/##WHOUSER##/$user/; $tmp=~s/##REALNAME##/$realname/; $tmp=~s/##WHOCONNECT##/$printconnect/; $tmp=~s/##WHOSIZE##/$printsize/; $tmp=~s/##USEDAYURL_L##/$daylist[0]{'L'}/; $tmp=~s/##USEDAYURL_B##/$daylist[0]{'B'}/; $tmp=~s/##ROWATTR##/$rowattr/; $tpl{who} .= $tmp; for ($i=1;$i<$listid;$i++) { $tmp=$hTPL{who}; $tmp=~s/##WHOUSER##//; $tmp=~s/##REALNAME##//; $tmp=~s/##WHOCONNECT##//; $tmp=~s/##WHOSIZE##//; $tmp=~s/##USEDAYURL_L##/$daylist[$i]{'L'}/; $tmp=~s/##USEDAYURL_B##/$daylist[$i]{'B'}/; $tmp=~s/##ROWATTR##/$rowattr/; $tpl{who} .= $tmp; } } close FF; $totalprint=FineDec($total); $totalhitprint=FineDec($hittotal); ReplaceTPL(TOTAL,$totalprint); ReplaceTPL(TOTALCONNECT,$totalhitprint); ReplaceTPL(SITE,$usersite); ReplaceTPL(DATE,$workperiod); ApplyTPL(); #HideTPL("daylist") if ($mode eq "day"); HideTPL("realname") if ($userealname == 0); PrintTPL(); __END__ 2005-05-01 ADD : month & year mode support ADD : if mode (month or year) add cell with dates -> user_detail 2005-08-30 ADD : Color Flipper 2005-10-07 ADD : HIDE (DayList) 2005-11-03 FIX : remove???? hide daylis if no DAY mode 2005-11-07 ADD : URLEncode 2006-06-28 ADD : &tpl= support