#
# (c) The SmoothWall Team
#
-# $Id: proxylog.dat,v 1.4.2.25 2005/07/07 17:32:24 eoberlander Exp $
-#
use strict;
my %cgiparams=();
my %logsettings=();
my %ips=();
+my %users=();
my %selected=();
my %checked=();
my @log=();
my $errormessage = '';
+my %color = ();
+my %mainsettings = ();
+&General::readhash("${General::swroot}/main/settings", \%mainsettings);
+&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
+
my @shortmonths = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
'Sep', 'Oct', 'Nov', 'Dec' );
my @longmonths = ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr{'march'},
$cgiparams{'MONTH'} = $temp[1];
$cgiparams{'DAY'} = $temp[2];
$cgiparams{'SOURCE_IP'} = $temp[3];
+ $cgiparams{'USERNAME'} = &Header::escape($temp[4]);
}
if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) ||
my $filter = $cgiparams{'ENABLE_FILTER'} eq 'on' ? $cgiparams{'FILTER'} : '';
my $sourceip = $cgiparams{'SOURCE_IP'};
my $sourceall = $cgiparams{'SOURCE_IP'} eq 'ALL' ? 1 : 0;
+my $username = $cgiparams{'USERNAME'};
+my $usersall = $cgiparams{'USERNAME'} eq 'ALL' ? 1 : 0;
my $lines = 0;
my $temp = ();
eval($thiscode);
if ($@ ne '')
{
- $errormessage = "$Lang::tr{'bad ignore filter'}.$@<P>";
+ $errormessage = "$Lang::tr{'bad ignore filter'}.$@<p>";
$filter = '';
} else {
my $loop = 1;
READ:while (<FILE>) {
my ($datetime,$do,$ip,$ray,$me,$far,$url,$so) = split;
$ips{$ip}++;
+ $users{$so}++;
# for debug
#$lastdatetime = $datetime;
# collect lines between date && filter
if (( ($datetime>$mintime)&&($datetime<$maxtime)) && !($url =~ /$filter/) &&
- ((($ip eq $sourceip) || $sourceall)))
+ ((($ip eq $sourceip) || $sourceall)) &&
+ ((($so eq $username) || $usersall)))
{
# when standart viewing, just keep in memory the correct slices
# it starts a '$start' and size is $viewport
# If export, then keep all lines...
if ($cgiparams{'ACTION'} eq $Lang::tr{'export'}){
- $log[$lines++] = "$datetime $ip $url";
+ $log[$lines++] = "$datetime $ip $so $url";
} else {
if ($lines++ < ($start + $Header::viewsize)) {
- push(@log,"$datetime $ip $url");
+ push(@log,"$datetime $ip $so $url");
if (@log > $Header::viewsize) {
shift (@log);
}
}
close (FILE);
}
- $gzindex--; # will try next gz file eg 40,39,38,.... because it may have holes when ipcop stopped
+ $gzindex--; # will try next gz file eg 40,39,38,.... because it may have holes when ipfire stopped
# for a long time
}
print "IPFire proxy log\r\n";
print "$Lang::tr{'date'}: $daystr\r\n";
print "Source IP: $cgiparams{'SOURCE_IP'}\r\n";
+ print "Username: $cgiparams{'USERNAME'}\r\n";
if ($cgiparams{'ENABLE_FILTER'} eq 'on') {
print "Ignore filter: $cgiparams{'FILTER'}\r\n"; }
print "\r\n";
if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log = reverse @log; }
foreach $_ (@log) {
- my ($datetime,$ip,$url) = split;
+ my ($datetime,$ip,$so,$url) = split;
my ($SECdt, $MINdt, $HOURdt, $DAYdt, $MONTHdt, $YEARdt) = localtime($datetime);
$SECdt = sprintf ("%.02d",$SECdt);
$MINdt = sprintf ("%.02d",$MINdt);
$HOURdt = sprintf ("%.02d",$HOURdt);
if ($cgiparams{'DAY'}==0) { # full month
$DAYdt = sprintf ("%.02d",$DAYdt);
- print "$DAYdt/$HOURdt:$MINdt:$SECdt $ip $url\n";
+ print "$DAYdt/$HOURdt:$MINdt:$SECdt $ip $so $url\n";
} else {
- print "$HOURdt:$MINdt:$SECdt $ip $url\n";
+ print "$HOURdt:$MINdt:$SECdt $ip $so $url\n";
}
}
exit;
}
$selected{'SOURCE_IP'}{$cgiparams{'SOURCE_IP'}} = "selected='selected'";
+$selected{'USERNAME'}{$cgiparams{'USERNAME'}} = "selected='selected'";
$checked{'ENABLE_FILTER'}{'off'} = '';
$checked{'ENABLE_FILTER'}{'on'} = '';
<option value='ALL' $selected{'SOURCE_IP'}{'ALL'}>$Lang::tr{'caps all'}</option>
END
;
-foreach my $ip (keys %ips) {
+foreach my $ip (sort keys %ips) {
print "<option value='$ip' $selected{'SOURCE_IP'}{$ip}>$ip</option>\n"; }
print <<END
</select>
</td>
</tr>
+<tr>
+ <td width='60%' colspan='6'> </td>
+ <td width='25%' class='base'>$Lang::tr{'advproxy NCSA username'}:</td>
+ <td width='15%'>
+ <select name='USERNAME'>
+ <option value='ALL' $selected{'USERNAME'}{'ALL'}>$Lang::tr{'caps all'}</option>
+END
+;
+foreach my $so (sort keys %users) {
+ $so = &Header::escape($so);
+ print "<option value='$so' $selected{'USERNAME'}{$so}>$so</option>\n"; }
+print <<END
+ </select>
+ </td>
+</tr>
<tr>
<td class='base'>$Lang::tr{'ignore filter'}:</td>
<td colspan='5'><input type='text' name='FILTER' value='$cgiparams{'FILTER'}' size='40' /></td>
print "<p><b>$Lang::tr{'web hits'} $daystr: $lines</b></p>";
if ($lines != 0) { &oldernewer(); }
print <<END
-<table width='100%'>
+<table width='100%' class='tbl'>
<tr>
-<td width='10%' align='center' class='boldbase'><b>$Lang::tr{'time'}</b></td>
-<td width='15%' align='center' class='boldbase'><b>$Lang::tr{'source ip'}</b></td>
-<td width='75%' align='center' class='boldbase'><b>$Lang::tr{'website'}</b></td>
+<th width='10%' align='center' class='boldbase'><b>$Lang::tr{'time'}</b></th>
+<th width='15%' align='center' class='boldbase'><b>$Lang::tr{'source ip'}</b></th>
+<th width='12%' align='center' class='boldbase'><b>$Lang::tr{'advproxy NCSA username'}</b></th>
+<th width='63%' align='center' class='boldbase'><b>$Lang::tr{'website'}</b></th>
</tr>
END
;
my $ll = 0;
+my $col='';
foreach $_ (@log)
{
if ($ll % 2) {
- print "<tr bgcolor='${Header::table1colour}'>\n"; }
+ print "<tr>";
+ $col="bgcolor='$color{'color20'}'"; }
else {
- print "<tr bgcolor='${Header::table2colour}'>\n"; }
- my ($datetime,$ip,$url) = split;
+ print "<tr>";
+ $col="bgcolor='$color{'color22'}'"; }
+ my ($datetime,$ip,$so,$url) = split;
my ($SECdt, $MINdt, $HOURdt, $DAYdt, $MONTHdt, $YEARdt) = localtime($datetime);
$SECdt = sprintf ("%.02d",$SECdt);
$MINdt = sprintf ("%.02d",$MINdt);
$DAYdt='';
}
print <<END
- <td align='center'>$DAYdt$HOURdt:$MINdt:$SECdt</td>
- <td align='center'>$ip</td>
- <td align='left'><a href='$url' title='$url' target='_new'>$part</a></td>
+ <td align='center' $col>$DAYdt$HOURdt:$MINdt:$SECdt</td>
+ <td align='center' $col>$ip</td>
+ <td align='center' $col>$so</td>
+ <td align='left' $col><a href='$url' title='$url' target='_new'>$part</a></td>
</tr>
END
;
print "<td align='center' width='50%'>";
if ($prev != -1) {
- print "<a href='/cgi-bin/logs.cgi/proxylog.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{'SOURCE_IP'}'>$Lang::tr{'older'}</a>"; }
+ print "<a href='/cgi-bin/logs.cgi/proxylog.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{'SOURCE_IP'},$cgiparams{'USERNAME'}'>$Lang::tr{'older'}</a>"; }
else {
print "$Lang::tr{'older'}"; }
print "</td>\n";
print "<td align='center' width='50%'>";
if ($next >= 0 ) {
- print "<a href='/cgi-bin/logs.cgi/proxylog.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{'SOURCE_IP'}'>$Lang::tr{'newer'}</a>"; }
+ print "<a href='/cgi-bin/logs.cgi/proxylog.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{'SOURCE_IP'},$cgiparams{'USERNAME'}'>$Lang::tr{'newer'}</a>"; }
else {
print "$Lang::tr{'newer'}"; }
print "</td>\n";