#
# (c) The SmoothWall Team
#
-# $Id: proxylog.dat,v 1.4.2.25 2005/07/07 17:32:24 eoberlander Exp $
-#
use strict;
#use warnings;
#use CGI::Carp 'fatalsToBrowser';
-require 'CONFIG_ROOT/general-functions.pl';
+require '/var/ipfire/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
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/ipfire/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'},
my $tdoy = $now[7];
my $year = $now[5]+1900;
-$cgiparams{'DAY'} = $now[3];
+$cgiparams{'DAY'} = $now[3];
$cgiparams{'MONTH'} = $now[4];
$cgiparams{'SOURCE_IP'} = 'ALL';
$cgiparams{'FILTER'} = "[.](gif|jpeg|jpg|png|css|js)\$";
if ($cgiparams{'ACTION'} eq $Lang::tr{'restore defaults'})
{
$cgiparams{'FILTER'} = "[.](gif|jpeg|jpg|png|css|js)\$";
- $cgiparams{'ENABLE_FILTER'} = 'off';
+ $cgiparams{'ENABLE_FILTER'} = 'off';
}
{
my @temp = split(',',$ENV{'QUERY_STRING'});
$start = $temp[0];
$cgiparams{'MONTH'} = $temp[1];
- $cgiparams{'DAY'} = $temp[2];
+ $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)$/) ||
# Calculate time. If future date, calculate for past year !!!
if (( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) ||
- ( $cgiparams{'MONTH'} > $now[4] ) ) {
+ ( $cgiparams{'MONTH'} > $now[4] ) ) {
$xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 );
$daystr = "$longmonths[$cgiparams{'MONTH'}] $daystr, ". int($year-1);
} else {
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;
$temp_now[2] = $temp_now[1] = $temp_now[0] = 0; # start at 00:00:00
$temp_now[3] = 1 if ($cgiparams{'DAY'}==0); # All days selected, start at '1'
- my $mintime = POSIX::mktime(@temp_now);
+ my $mintime = POSIX::mktime(@temp_now);
my $maxtime;
if ($cgiparams{'DAY'}==0) { # full month
if ($temp_now[4]++ == 12){
$temp_now[4] = 0;
$temp_now[5]++;
};
- $maxtime = POSIX::mktime(@temp_now);
+ $maxtime = POSIX::mktime(@temp_now);
} else {
$maxtime = $mintime + 86400; # full day
}
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);
}
# $datetime = $maxtime; # we have read viewsize lines, stop main loop
# last READ; # exit read file
}
- }
+ }
}
# finish loop when date of lines are past maxtime
}
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 "Content-type: text/plain\n\n";
print "IPFire proxy log\r\n";
- print "$Lang::tr{'date'}: $daystr\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'} = '';
END
;
print "<option value='0'>$Lang::tr{'all'}</option>";
-for (my $day = 1; $day <= 31; $day++)
+for (my $day = 1; $day <= 31; $day++)
{
print "\t<option ";
if ($day == $cgiparams{'DAY'}) {
<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);
$url =~ /(^.{0,60})/;
my $part = $1;
- unless (length($part) < 60) { $part = "${part}..."; }
+ unless (length($part) < 60) { $part = "${part}..."; }
$url = &Header::cleanhtml($url,"y");
$part = &Header::cleanhtml($part,"y");
if ($cgiparams{'DAY'}==0) { # full month
$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";