) {
_html($_);
}
close(PAGEFOOT);
}
sub _activetimes
{
# The most actives times on the channel
my $self = shift;
my (%output, $class);
$self->_headline($self->_template_text('activetimestopic'));
my @toptime = sort { $self->{stats}->{times}{$b} <=> $self->{stats}->{times}{$a} } keys %{ $self->{stats}->{times} };
my $highest_value = $self->{stats}->{times}{$toptime[0]};
my @now = localtime($self->{cfg}->{timestamp});
my $image;
for my $hour (sort keys %{ $self->{stats}->{times} }) {
my $size = ($self->{stats}->{times}{$hour} / $highest_value) * 100;
my $percent = ($self->{stats}->{times}{$hour} / $self->{stats}->{parsedlines}) * 100;
$percent =~ s/(\.\d)\d+/$1/;
if ($size < 1 && $size != 0) {
# Opera doesn't understand '0.xxxx' in the height="xx" attr,
# so we simply round up to 1.0 here.
$size = 1.0;
}
$image = "pic_v_".(int($hour/6)*6);
$image = $self->{cfg}->{$image};
$output{$hour} = "$percent%
{cfg}->{piclocation}/$image\" width=\"15\" height=\"$size\" alt=\"$percent\" /> | \n";
}
_html("\n");
for ($b = 0; $b < 24; $b++) {
$a = sprintf("%02d", $b);
if (!defined($output{$a}) || $output{$a} eq "") {
_html("| 0% | ");
} else {
_html($output{$a});
}
}
_html("
");
# Remove leading zero
$toptime[0] =~ s/0(\d)/$1/;
for ($b = 0; $b < 24; $b++) {
if ($toptime[0] == $b) {
# Highlight the top time
$class = 'hirankc10center';
} else {
$class = 'rankc10center';
}
_html("| $b | ");
}
_html("
");
if($self->{cfg}->{showlegend} == 1) {
$self->_legend();
}
}
sub _activenicks
{
# The most active nicks (those who wrote most lines)
my $self = shift;
$self->_headline($self->_template_text('activenickstopic'));
_html("{cfg}->{tablewidth}\">");
_html("| | "
. "" . $self->_template_text('nick') . " | "
. "" . $self->_template_text('numberlines') . " | "
. ($self->{cfg}->{showtime} ? "".$self->_template_text('show_time')." | " : "")
. ($self->{cfg}->{showwords} ? "".$self->_template_text('show_words')." | " : "")
. ($self->{cfg}->{showwpl} ? "".$self->_template_text('show_wpl')." | " : "")
. ($self->{cfg}->{showcpl} ? "".$self->_template_text('show_cpl')." | " : "")
. ($self->{cfg}->{showlastseen} ? "".$self->_template_text('show_lastseen')." | " : "")
. ($self->{cfg}->{showrandquote} ? "".$self->_template_text('randquote')." | " : "")
);
my @active;
my $nicks;
if ($self->{cfg}->{sortbywords}) {
@active = sort { $self->{stats}->{words}{$b} <=> $self->{stats}->{words}{$a} } keys %{ $self->{stats}->{words} };
$nicks = scalar keys %{ $self->{stats}->{words} };
} else {
@active = sort { $self->{stats}->{lines}{$b} <=> $self->{stats}->{lines}{$a} } keys %{ $self->{stats}->{lines} };
$nicks = scalar keys %{ $self->{stats}->{lines} };
}
if ($self->{cfg}->{activenicks} > $nicks) { $self->{cfg}->{activenicks} = $nicks; }
my $have_userpics;
for (my $c = 0; $c < $self->{cfg}->{activenicks}; $c++) {
my $nick = $active[$c];
if ($self->{users}->{userpics}{$nick} && $self->{cfg}->{userpics} !~ /n/i) {
$have_userpics = 1;
_html("" . $self->_template_text('userpic') ." | ");
last;
}
}
_html("
");
for (my $i = 0; $i < $self->{cfg}->{activenicks}; $i++) {
my $c = $i + 1;
my $nick = $active[$i];
my $visiblenick = $active[$i];
my $randomline;
if (not defined $self->{stats}->{sayings}{$nick}) {
if ($self->{stats}->{actions}{$nick}) {
$randomline = $self->{stats}->{actionlines}{$nick};
} else {
$randomline = "";
}
} else {
$randomline = $self->{stats}->{sayings}{$nick};
}
if ($randomline) {
$randomline = $self->_format_line($randomline);
}
# Add a link to the nick if there is any
if ($self->{users}->{userlinks}{$nick}) {
$visiblenick = $self->_replace_links($self->{users}->{userlinks}{$nick}, $nick);
}
my $color = $self->generate_colors($c);
my $class = 'rankc';
if ($c == 1) {
$class = 'hirankc';
}
my $lastseen;
if ($self->{cfg}->{showlastseen}) {
$lastseen = $self->{stats}->{days} - $self->{stats}->{lastvisited}{$nick};
if ($lastseen == 0) {
$lastseen = $self->_template_text('today');
} elsif ($lastseen == 1) {
$lastseen = "$lastseen " .$self->_template_text('lastseen1');
} else {
$lastseen = "$lastseen " .$self->_template_text('lastseen2');
}
}
_html("| $c | ");
my $line = $self->{stats}->{lines}{$nick};
my $w = $self->{stats}->{words}{$nick} ? $self->{stats}->{words}{$nick} : 0;
my $ch = $self->{stats}->{lengths}{$nick};
my $sex = $self->{users}->{sex}{$nick};
_html(""
: ($sex eq 'f' ? " class=\"female\">" : " class=\"bot\">")) : ">")
."$visiblenick | "
. ($self->{cfg}->{showlinetime} ?
"".$self->_user_linetimes($nick,$active[0])." | "
: "$line | ")
. ($self->{cfg}->{showtime} ?
"".$self->_user_times($nick)." | "
: "")
. ($self->{cfg}->{showwords} ?
($self->{cfg}->{showwordtime} ?
"".$self->_user_wordtimes($nick,$active[0])." | "
: "$w | ")
: "")
. ($self->{cfg}->{showwpl} ?
"".sprintf("%.1f",$w/$line)." | "
: "")
. ($self->{cfg}->{showcpl} ?
"".sprintf("%.1f",$ch/$line)." | "
: "")
. ($self->{cfg}->{showlastseen} ?
"$lastseen | "
: "")
. ($self->{cfg}->{showrandquote} ?
"\"$randomline\" | "
: "")
);
my $height = $self->{cfg}->{picheight};
my $width = $self->{cfg}->{picwidth};
if ($self->{users}->{userpics}{$nick} && $self->{cfg}->{userpics} !~ /n/i) {
_html("");
if (defined $self->{users}->{biguserpics}{$nick}) {
if ($self->{users}->{biguserpics}{$nick} =~ /^http:\/\//i) {
_html("{users}->{biguserpics}{$nick}\">");
} else {
_html("{cfg}->{imagepath}$self->{users}->{biguserpics}{$nick}\">");
}
}
if ($width ne '') {
if ($self->{users}->{userpics}{$nick} =~ /^http:\/\//i) {
_html(" {users}->{userpics}{$nick}\" width=\"$width\" height=\"$height\" alt=\"$nick\" />");
} else {
_html(" {cfg}->{imagepath}$self->{users}->{userpics}{$nick}\" width=\"$width\" height=\"$height\" alt=\"$nick\" />");
}
} else {
if ($self->{users}->{userpics}{$nick} =~ /^http:\/\//i) {
_html(" {users}->{userpics}{$nick}\" alt=\"$nick\" />");
} else {
_html(" {cfg}->{imagepath}$self->{users}->{userpics}{$nick}\" alt=\"$nick\" />");
}
}
if (defined $self->{users}->{biguserpics}{$nick}) {
_html("");
}
_html(" | ");
} elsif ($self->{cfg}->{defaultpic} ne '' && $self->{cfg}->{userpics} !~ /n/i) {
if ($self->{cfg}->{defaultpic} =~ /^http:\/\//i) {
_html(" {cfg}->{defaultpic}\" alt=\"\" /> | ");
} else {
_html(" {cfg}->{imagepath}$self->{cfg}->{defaultpic}\" alt=\"\" /> | ");
}
}
_html("
");
}
_html("
");
# Almost as active nicks ('These didn't make it to the top..')
my $toshow = $self->{cfg}->{activenicks2} - $self->{cfg}->{activenicks};
my $remain = $self->{cfg}->{activenicks} + $toshow;
unless ($toshow > $nicks) {
$remain = $self->{cfg}->{activenicks} + $self->{cfg}->{activenicks2};
if ($remain > $nicks) {
$remain = $nicks;
}
if ($self->{cfg}->{activenicks} < $remain) {
_html("
" . $self->_template_text('nottop') . "");
for (my $i = $self->{cfg}->{activenicks}; $i < $remain; $i++) {
unless ($i % 5) { if ($i != $self->{cfg}->{activenicks}) { _html("
"); } }
my $items;
if ($self->{cfg}->{sortbywords}) {
$items = $self->{stats}->{words}{$active[$i]};
} else {
$items = $self->{stats}->{lines}{$active[$i]};
}
my $sex = $self->{users}->{sex}{$active[$i]};
_html("| "
. ($sex ? ($sex eq 'm' ? ""
: ($sex eq 'f' ? "" : "")) : "")
."$active[$i] ($items)"
. ($sex ? "" : "")
." | ");
}
_html("
");
}
}
my %hash;
$hash{totalnicks} = $nicks - $remain;
if ($hash{totalnicks} > 0) {
_html("
" . $self->_template_text('totalnicks', %hash) . "
");
}
}
sub generate_colors
{
my $self = shift;
my $c = shift;
my $h = $self->{cfg}->{hicell};
$h =~ s/^#//;
$h = hex $h;
my $h2 = $self->{cfg}->{hicell2};
$h2 =~ s/^#//;
$h2 = hex $h2;
my $f_b = $h & 0xff;
my $f_g = ($h & 0xff00) >> 8;
my $f_r = ($h & 0xff0000) >> 16;
my $t_b = $h2 & 0xff;
my $t_g = ($h2 & 0xff00) >> 8;
my $t_r = ($h2 & 0xff0000) >> 16;
my $blue = sprintf "%0.2x", abs int(((($t_b - $f_b) / $self->{cfg}->{activenicks}) * +$c) + $f_b);
my $green = sprintf "%0.2x", abs int(((($t_g - $f_g) / $self->{cfg}->{activenicks}) * +$c) + $f_g);
my $red = sprintf "%0.2x", abs int(((($t_r - $f_r) / $self->{cfg}->{activenicks}) * +$c) + $f_r);
return "#$red$green$blue";
}
sub _html
{
my $html = shift;
print OUTPUT "$html\n";
}
sub _questions
{
# Persons who asked the most questions
my $self = shift;
my %qpercent;
foreach my $nick (sort keys %{ $self->{stats}->{questions} }) {
if ($self->{topactive}{$nick} || !$self->{cfg}->{showonlytop}) {
if ($self->{stats}->{lines}{$nick} > 100) {
$qpercent{$nick} = ($self->{stats}->{questions}{$nick} / $self->{stats}->{lines}{$nick}) * 100;
$qpercent{$nick} =~ s/(\.\d)\d+/$1/;
}
}
}
my @question = sort { $qpercent{$b} <=> $qpercent{$a} } keys %qpercent;
if (@question) {
my %hash = (
nick => $question[0],
per => $qpercent{$question[0]}
);
my $text = $self->_template_text('question1', %hash);
_html("$text");
if (@question >= 2) {
my %hash = (
nick => $question[1],
per => $qpercent{$question[1]}
);
my $text = $self->_template_text('question2', %hash);
_html(" $text");
}
_html(" |
");
} else {
_html("| " . $self->_template_text('question3') . " |
");
}
}
sub _shoutpeople
{
# The ones who speak with exclamation marks!
my $self = shift;
my %spercent;
foreach my $nick (sort keys %{ $self->{stats}->{shouts} }) {
if ($self->{topactive}{$nick} || !$self->{cfg}->{showonlytop}) {
if ($self->{stats}->{lines}{$nick} > 100) {
$spercent{$nick} = ($self->{stats}->{shouts}{$nick} / $self->{stats}->{lines}{$nick}) * 100;
$spercent{$nick} =~ s/(\.\d)\d+/$1/;
}
}
}
my @shout = sort { $spercent{$b} <=> $spercent{$a} } keys %spercent;
if (@shout) {
my %hash = (
nick => $shout[0],
per => $spercent{$shout[0]}
);
my $text = $self->_template_text('shout1', %hash);
_html("$text");
if (@shout >= 2) {
my %hash = (
nick => $shout[1],
per => $spercent{$shout[1]}
);
my $text = $self->_template_text('shout2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('shout3');
_html("| $text |
");
}
}
sub _capspeople
{
# The ones who speak ALL CAPS.
my $self = shift;
my %cpercent;
foreach my $nick (sort keys %{ $self->{stats}->{allcaps} }) {
if ($self->{topactive}{$nick} || !$self->{cfg}->{showonlytop}) {
if ($self->{stats}->{lines}{$nick} > 100) {
$cpercent{$nick} = $self->{stats}->{allcaps}{$nick} / $self->{stats}->{lines}{$nick} * 100;
$cpercent{$nick} =~ s/(\.\d)\d+/$1/;
}
}
}
my @caps = sort { $cpercent{$b} <=> $cpercent{$a} } keys %cpercent;
if (@caps) {
my %hash = (
nick => $caps[0],
per => $cpercent{$caps[0]},
line => $self->_format_line($self->{stats}->{allcaplines}{$caps[0]})
);
my $text = $self->_template_text('allcaps1', %hash);
if($self->{cfg}->{showshoutline}) {
my $exttext = $self->_template_text('allcapstext', %hash);
_html("$text $exttext ");
} else {
_html(" |
$text");
}
if (@caps >= 2) {
my %hash = (
nick => $caps[1],
per => $cpercent{$caps[1]}
);
my $text = $self->_template_text('allcaps2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('allcaps3');
_html("| $text |
");
}
}
sub _violent
{
# They attacked others (words defined by $self->{cfg}->{violent})
my $self = shift;
my @aggressors = sort { $self->{stats}->{violence}{$b} <=> $self->{stats}->{violence}{$a} }
keys %{ $self->{stats}->{violence} };
@aggressors = $self->_istoponly(@aggressors);
if(@aggressors) {
my %hash = (
nick => $aggressors[0],
attacks => $self->{stats}->{violence}{$aggressors[0]},
line => $self->_format_line($self->{stats}->{violencelines}{$aggressors[0]})
);
my $text = $self->_template_text('violent1', %hash);
if($self->{cfg}->{showviolentlines}) {
my $exttext = $self->_template_text('violenttext', %hash);
_html("$text $exttext ");
} else {
_html(" |
$text");
}
if (@aggressors >= 2) {
my %hash = (
nick => $aggressors[1],
attacks => $self->{stats}->{violence}{$aggressors[1]}
);
my $text = $self->_template_text('violent2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('violent3');
_html("| $text |
");
}
# They got attacked
my @victims = sort { $self->{stats}->{attacked}{$b} <=> $self->{stats}->{attacked}{$a} }
keys %{ $self->{stats}->{attacked} };
@victims = $self->_istoponly(@victims);
if(@victims) {
my %hash = (
nick => $victims[0],
attacks => $self->{stats}->{attacked}{$victims[0]},
line => $self->_format_line($self->{stats}->{attackedlines}{$victims[0]})
);
my $text = $self->_template_text('attacked1', %hash);
if($self->{cfg}->{showviolentlines}) {
my $exttext = $self->_template_text('attackedtext', %hash);
_html("$text $exttext ");
} else {
_html(" |
$text");
}
if (@victims >= 2) {
my %hash = (
nick => $victims[1],
attacks => $self->{stats}->{attacked}{$victims[1]}
);
my $text = $self->_template_text('attacked2', %hash);
_html(" $text");
}
_html(" |
");
}
}
sub _gotkicks
{
# The persons who got kicked the most
my $self = shift;
my @gotkick = sort { $self->{stats}->{gotkicked}{$b} <=> $self->{stats}->{gotkicked}{$a} }
keys %{ $self->{stats}->{gotkicked} };
@gotkick = $self->_istoponly(@gotkick);
if (@gotkick) {
my %hash = (
nick => $gotkick[0],
kicks => $self->{stats}->{gotkicked}{$gotkick[0]},
line => $self->_format_line($self->{stats}->{kicklines}{$gotkick[0]})
);
my $text = $self->_template_text('gotkick1', %hash);
if ($self->{cfg}->{showkickline}) {
my $exttext = $self->_template_text('kicktext', %hash);
_html("$text $exttext ");
} else {
_html(" |
$text");
}
if (@gotkick >= 2) {
my %hash = (
nick => $gotkick[1],
kicks => $self->{stats}->{gotkicked}{$gotkick[1]}
);
my $text = $self->_template_text('gotkick2', %hash);
_html(" $text");
}
_html(" |
");
}
}
sub _mostjoins
{
my $self = shift;
my @joins = sort { $self->{stats}->{joins}{$b} <=> $self->{stats}->{joins}{$a} }
keys %{ $self->{stats}->{joins} };
@joins = $self->_istoponly(@joins);
if (@joins) {
my %hash = (
nick => $joins[0],
joins => $self->{stats}->{joins}{$joins[0]}
);
my $text = $self->_template_text('joins', %hash);
_html("| $text |
");
}
}
sub _mostwords
{
# The person who got words the most
my $self = shift;
my @words = sort { $self->{stats}->{words}{$b} <=> $self->{stats}->{words}{$a} }
keys %{ $self->{stats}->{words} };
@words = $self->_istoponly(@words);
if (@words) {
my %hash = (
nick => $words[0],
words => $self->{stats}->{words}{$words[0]}
);
my $text = $self->_template_text('words1', %hash);
_html("$text");
if (@words >= 2) {
my %hash = (
oldnick => $words[0],
nick => $words[1],
words => $self->{stats}->{words}{$words[1]}
);
my $text = $self->_template_text('words2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('kick3');
_html("| $text |
");
}
}
sub _mostkicks
{
# The person who kicked the most
my $self = shift;
my @kicked = sort { $self->{stats}->{kicked}{$b} <=> $self->{stats}->{kicked}{$a} }
keys %{ $self->{stats}->{kicked} };
@kicked = $self->_istoponly(@kicked);
if (@kicked) {
my %hash = (
nick => $kicked[0],
kicked => $self->{stats}->{kicked}{$kicked[0]}
);
my $text = $self->_template_text('kick1', %hash);
_html("$text");
if (@kicked >= 2) {
my %hash = (
oldnick => $kicked[0],
nick => $kicked[1],
kicked => $self->{stats}->{kicked}{$kicked[1]}
);
my $text = $self->_template_text('kick2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('kick3');
_html("| $text |
");
}
}
sub _mostmonologues
{
# The person who had the most monologues (speaking to himself)
my $self = shift;
my @monologue = sort { $self->{stats}->{monologues}{$b} <=> $self->{stats}->{monologues}{$a} }
keys %{ $self->{stats}->{monologues} };
@monologue = $self->_istoponly(@monologue);
if (@monologue) {
my %hash = (
nick => $monologue[0],
monos => $self->{stats}->{monologues}{$monologue[0]}
);
my $text = $self->_template_text('mono1', %hash);
_html("$text");
if (@monologue >= 2) {
my %hash = (
nick => $monologue[1],
monos => $self->{stats}->{monologues}{$monologue[1]}
);
my $text = $self->_template_text('mono2', %hash);
_html(" $text");
}
_html(" |
");
}
}
sub _linelengths
{
# The person(s) who wrote the longest lines
my $self = shift;
my %len;
foreach my $nick (sort keys %{ $self->{stats}->{lengths} }) {
if ($self->{topactive}{$nick} || !$self->{cfg}->{showonlytop}) {
if ($self->{stats}->{lines}{$nick} > 100) {
$len{$nick} = $self->{stats}->{lengths}{$nick} / $self->{stats}->{lines}{$nick};
$len{$nick} =~ s/(\.\d)\d+/$1/;
}
}
}
my @len = sort { $len{$b} <=> $len{$a} } keys %len;
my $all_lines = 0;
my $totallength;
foreach my $nick (keys %{ $self->{stats}->{lines} }) {
$all_lines += $self->{stats}->{lines}{$nick};
$totallength += $self->{stats}->{lengths}{$nick};
}
my $totalaverage;
if ($all_lines > 0) {
$totalaverage = $totallength / $all_lines;
$totalaverage =~ s/(\.\d)\d+/$1/;
}
if (@len) {
my %hash = (
nick => $len[0],
letters => $len{$len[0]}
);
my $text = $self->_template_text('long1', %hash);
_html("$text ");
if (@len >= 2) {
%hash = (
avg => $totalaverage
);
$text = $self->_template_text('long2', %hash);
_html("$text |
");
}
}
# The person(s) who wrote the shortest lines
if (@len) {
my %hash = (
nick => $len[$#len],
letters => $len{$len[$#len]}
);
my $text = $self->_template_text('short1', %hash);
_html("$text ");
if (@len >= 2) {
%hash = (
nick => $len[$#len - 1],
letters => $len{$len[$#len - 1]}
);
$text = $self->_template_text('short2', %hash);
_html("$text |
");
}
}
}
sub _mostfoul
{
my $self = shift;
my %spercent;
foreach my $nick (sort keys %{ $self->{stats}->{foul} }) {
if ($self->{topactive}{$nick} || !$self->{cfg}->{showonlytop}) {
if ($self->{stats}->{lines}{$nick} > 15) {
$spercent{$nick} = $self->{stats}->{foul}{$nick} / $self->{stats}->{words}{$nick} * 100;
$spercent{$nick} =~ s/(\.\d)\d+/$1/;
}
}
}
my @foul = sort { $spercent{$b} <=> $spercent{$a} } keys %spercent;
if (@foul) {
my %hash = (
nick => $foul[0],
per => $spercent{$foul[0]},
line => $self->_format_line($self->{stats}{foullines}{$foul[0]}),
);
my $text = $self->_template_text('foul1', %hash);
if($self->{cfg}->{showfoulline}) {
my $exttext = $self->_template_text('foultext', %hash);
_html("$text $exttext ");
} else {
_html(" |
$text");
}
if (@foul >= 2) {
my %hash = (
nick => $foul[1],
per => $spercent{$foul[1]}
);
my $text = $self->_template_text('foul2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('foul3');
_html("| $text |
");
}
}
sub _mostsad
{
my $self = shift;
my %spercent;
foreach my $nick (sort keys %{ $self->{stats}->{frowns} }) {
if ($self->{topactive}{$nick} || !$self->{cfg}->{showonlytop}) {
if ($self->{stats}->{lines}{$nick} > 100) {
$spercent{$nick} = $self->{stats}->{frowns}{$nick} / $self->{stats}->{lines}{$nick} * 100;
$spercent{$nick} =~ s/(\.\d)\d+/$1/;
}
}
}
my @sadface = sort { $spercent{$b} <=> $spercent{$a} } keys %spercent;
if (@sadface) {
my %hash = (
nick => $sadface[0],
per => $spercent{$sadface[0]}
);
my $text = $self->_template_text('sad1', %hash);
_html("$text");
if (@sadface >= 2) {
my %hash = (
nick => $sadface[1],
per => $spercent{$sadface[1]}
);
my $text = $self->_template_text('sad2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('sad3');
_html("| $text |
");
}
}
sub _mostop
{
my $self = shift;
my @ops = sort { $self->{stats}->{gaveops}{$b} <=> $self->{stats}->{gaveops}{$a} }
keys %{ $self->{stats}->{gaveops} };
@ops = $self->_istoponly(@ops);
my @deops = sort { $self->{stats}->{tookops}{$b} <=> $self->{stats}->{tookops}{$a} }
keys %{ $self->{stats}->{tookops} };
@deops = $self->_istoponly(@deops);
if (@ops) {
my %hash = (
nick => $ops[0],
ops => $self->{stats}->{gaveops}{$ops[0]}
);
my $text = $self->_template_text('mostop1', %hash);
_html("$text");
if (@ops >= 2) {
my %hash = (
nick => $ops[1],
ops => $self->{stats}->{gaveops}{$ops[1]}
);
my $text = $self->_template_text('mostop2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('mostop3');
_html("| $text |
");
}
if (@deops) {
my %hash = (
nick => $deops[0],
deops => $self->{stats}->{tookops}{$deops[0]}
);
my $text = $self->_template_text('mostdeop1', %hash);
_html("$text");
if (@deops >= 2) {
my %hash = (
nick => $deops[1],
deops => $self->{stats}->{tookops}{$deops[1]}
);
my $text = $self->_template_text('mostdeop2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('mostdeop3');
_html("| $text |
");
}
}
sub _mostvoice
{
my $self = shift;
my @voice = sort { $self->{stats}->{gavevoice}{$b} <=> $self->{stats}->{gavevoice}{$a} }
keys %{ $self->{stats}->{gavevoice} };
@voice = $self->_istoponly(@voice);
my @devoice = sort { $self->{stats}->{tookvoice}{$b} <=> $self->{stats}->{tookvoice}{$a} }
keys %{ $self->{stats}->{tookvoice} };
@devoice = $self->_istoponly(@devoice);
if (@voice) {
my %hash = (
nick => $voice[0],
voices => $self->{stats}->{gavevoice}{$voice[0]}
);
my $text = $self->_template_text('mostvoice1', %hash);
_html("$text");
if (@voice >= 2) {
my %hash = (
nick => $voice[1],
voices => $self->{stats}->{gavevoice}{$voice[1]}
);
my $text = $self->_template_text('mostvoice2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('mostvoice3');
_html("| $text |
");
}
if (@devoice) {
my %hash = (
nick => $devoice[0],
devoices => $self->{stats}->{tookvoice}{$devoice[0]}
);
my $text = $self->_template_text('mostdevoice1', %hash);
_html("$text");
if (@devoice >= 2) {
my %hash = (
nick => $devoice[1],
devoices => $self->{stats}->{tookvoice}{$devoice[1]}
);
my $text = $self->_template_text('mostdevoice2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('mostdevoice3');
_html("| $text |
");
}
}
sub _mosthalfop
{
my $self = shift;
my @halfops = sort { $self->{stats}->{gavehalfops}{$b} <=> $self->{stats}->{gavehalfops}{$a} }
keys %{ $self->{stats}->{gavehalfops} };
@halfops = $self->_istoponly(@halfops);
my @dehalfops = sort { $self->{stats}->{tookhalfops}{$b} <=> $self->{stats}->{tookhalfops}{$a} }
keys %{ $self->{stats}->{tookhalfops} };
@dehalfops = $self->_istoponly(@dehalfops);
if (@halfops) {
my %hash = (
nick => $halfops[0],
halfops => $self->{stats}->{gavehalfops}{$halfops[0]}
);
my $text = $self->_template_text('mosthalfop1', %hash);
_html("$text");
if (@halfops >= 2) {
my %hash = (
nick => $halfops[1],
halfops => $self->{stats}->{gavehalfops}{$halfops[1]}
);
my $text = $self->_template_text('mosthalfop2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('mosthalfop3');
_html("| $text |
");
}
if (@dehalfops) {
my %hash = (
nick => $dehalfops[0],
dehalfops => $self->{stats}->{tookhalfops}{$dehalfops[0]}
);
my $text = $self->_template_text('mostdehalfop1', %hash);
_html("$text");
if (@dehalfops >= 2) {
my %hash = (
nick => $dehalfops[1],
dehalfops => $self->{stats}->{tookhalfops}{$dehalfops[1]}
);
my $text = $self->_template_text('mostdehalfop2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('mostdehalfop3');
_html("| $text |
");
}
}
sub _mostactions
{
# The person who did the most /me's
my $self = shift;
my @actions = sort { $self->{stats}->{actions}{$b} <=> $self->{stats}->{actions}{$a} }
keys %{ $self->{stats}->{actions} };
@actions = $self->_istoponly(@actions);
if (@actions) {
my %linehash =
my %hash = (
nick => $actions[0],
actions => $self->{stats}->{actions}{$actions[0]},
line => $self->_format_line($self->{stats}->{actionlines}{$actions[0]})
);
my $text = $self->_template_text('action1', %hash);
if($self->{cfg}->{showactionline}) {
my $exttext = $self->_template_text('actiontext', %hash);
_html("$text $exttext ");
} else {
_html(" |
$text");
}
if (@actions >= 2) {
my %hash = (
nick => $actions[1],
actions => $self->{stats}->{actions}{$actions[1]}
);
my $text = $self->_template_text('action2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('action3');
_html("| $text |
");
}
}
sub _mostsmiles
{
# The person(s) who smiled the most :-)
my $self = shift;
my %spercent;
foreach my $nick (sort keys %{ $self->{stats}->{smiles} }) {
if ($self->{topactive}{$nick} || !$self->{cfg}->{showonlytop}) {
if ($self->{stats}->{lines}{$nick} > 100) {
$spercent{$nick} = $self->{stats}->{smiles}{$nick} / $self->{stats}->{lines}{$nick} * 100;
$spercent{$nick} =~ s/(\.\d)\d+/$1/;
}
}
}
my @smiles = sort { $spercent{$b} <=> $spercent{$a} } keys %spercent;
if (@smiles) {
my %hash = (
nick => $smiles[0],
per => $spercent{$smiles[0]}
);
my $text = $self->_template_text('smiles1', %hash);
_html("$text");
if (@smiles >= 2) {
my %hash = (
nick => $smiles[1],
per => $spercent{$smiles[1]}
);
my $text = $self->_template_text('smiles2', %hash);
_html(" $text");
}
_html(" |
");
} else {
my $text = $self->_template_text('smiles3');
_html("| $text |
");
}
}
sub _lasttopics
{
my $self = shift;
if ($self->{stats}->{topics}) {
my %topic_seen;
my %hash = (
total => scalar @{ $self->{stats}->{topics} }
);
my $ltopic = $#{ $self->{stats}->{topics} };
my $tlimit = 0;
$self->{cfg}->{topichistory} -= 1;
if ($ltopic > $self->{cfg}->{topichistory}) {
$tlimit = $ltopic - $self->{cfg}->{topichistory};
}
for (my $i = $ltopic; $i >= $tlimit; $i--) {
my $topic = $self->{stats}->{topics}[$i]{topic};
# This code makes sure that we don't see the same topic twice
next if ($topic_seen{$topic});
$topic_seen{$topic} = 1;
# Strip off the quotes (')
$topic =~ s/^\'(.*)\'$/$1/;
my $nick = $self->{stats}->{topics}[$i]{nick};
my $hour = $self->{stats}->{topics}[$i]{hour};
my $min = $self->{stats}->{topics}[$i]{min};
$hash{nick} = $self->_format_word($nick);
$hash{time} = "$hour:$min";
_html('| ' . $self->_format_line($topic) . ' | ');
_html('' . $self->_template_text('bylinetopic', %hash) . ' |
');
}
_html("| " . $self->_template_text('totaltopic', %hash) . " |
");
} else {
_html("| " . $self->_template_text('notopic') ." |
");
}
}
sub _template_text
{
# This function is for the homemade template system. It receives a name
# of a template and a hash with the fields in the template to update to
# its corresponding value
my $self = shift;
my $template = shift;
my %hash = @_;
my $text;
unless ($text = $self->{tmps}->{lc($self->{cfg}->{lang})}{$template}) {
# Fall back to English if the language template doesn't exist
if ($text = $self->{tmps}->{en}{$template}) {
print "Note: No translation in '$self->{cfg}->{lang}' for '$template' - falling back to English..\n"
unless ($self->{cfg}->{silent});
} else {
die("No such template '$template' in language file.\n");
}
}
$hash{channel} = $self->{cfg}->{channel};
foreach my $key (sort keys %hash) {
$text =~ s/\[:$key\]/$hash{$key}/;
if ($self->{cfg}->{charset} =~ /iso-8859-1/i) {
$text =~ s/ü/ü/go;
$text =~ s/ö/ö/go;
$text =~ s/ä/ä/go;
$text =~ s/ß/ß/go;
$text =~ s/å/å/go;
$text =~ s/æ/æ/go;
$text =~ s/ø/ø/go;
$text =~ s/Å/Å/go;
$text =~ s/Æ/Æ/go;
$text =~ s/Ø/Ø/go;
}
}
if ($text =~ /\[:[^:]*?:[^:]*?:[^:]*?:\]/o) {
$text =~ s/\[:([^:]*?):([^:]*?):([^:]*?):\]/$self->_get_subst($1,$2,$3,\%hash)/geo;
}
if ($text =~ /\[:[^:]*?:[^:]*?:]/o) {
$text =~ s/\[:([^:]*?):([^:]*?):]/$self->_get_subst($1,$2,undef,\%hash)/geo;
}
return $text;
}
sub _format_word
{
# This function formats a word -- should ONLY be called on words used alone (EG: not whole line printed)
my ($self, $word) = @_;
$word = htmlentities($word, $self->{cfg}->{charset});
$word = $self->_replace_links($word);
return $word;
}
sub _format_line
{
# This function formats a action/normal line to be more readable, and calls any other function
# that should be executed on every line.
my ($self, $line) = @_;
my $hashref;
if ($hashref = $self->{cfg}->{analyzer}->{parser}->normalline($line)) {
$line = '<' . $hashref->{nick} . '> ' . $hashref->{saying};
} elsif ($hashref = $self->{cfg}->{analyzer}->{parser}->actionline($line)) {
$line = '* ' . $hashref->{nick} . ' ' . $hashref->{saying};
} elsif ($hashref = $self->{cfg}->{analyzer}->{parser}->thirdline($line)) {
if (defined($hashref->{kicker})) {
$line = '*** ' . $hashref->{nick} . ' was kicked by ' . $hashref->{kicker};
$line .= ' (' . $hashref->{kicktext} . ')'
if (defined($hashref->{kicktext}));
} elsif (defined($hashref->{newtopic})) {
$line = '*** ' . $hashref->{nick} . ' changes topic to \'' . $hashref->{newtopic} . '\'';
} elsif (defined($hashref->{newmode})) {
$line = '*** ' . $hashref->{nick} . ' sets mode ' . $hashref->{newmode};
$line .= ' ' . $hashref->{modechanges}
if (defined($hashref->{kicktext}));
} elsif (defined($hashref->{newjoin})) {
$line = '*** Joins: ' . $hashref->{nick};
} elsif (defined($hashref->{newnick})) {
$line = '*** ' . $hashref->{nick} . ' is now known as ' . $hashref->{newnick};
} elsif (defined($hashref->{newtopic})) {
$line = '*** ' . $hashref->{nick} . ' changes topic to: ' . $hashref->{newtopic};
}
}
$line = htmlentities($line, $self->{cfg}->{charset});
$line = $self->_replace_links($line);
return $line;
}
sub _get_subst
{
# This function looks at the user definition and see if there is sex
# defined. If yes, return the appropriate value. If no, just return the
# default he/she value.
my $self = shift;
my ($m,$f,$d,$hash) = @_;
if ($hash->{nick} && $self->{users}->{sex}{$hash->{nick}}) {
if ($self->{users}->{sex}{$hash->{nick}} eq 'm') {
return $m;
} elsif ($self->{users}->{sex}{$hash->{nick}} eq 'f') {
return $f;
}
}
return defined($d) ? $d : "$m/$f";
}
sub _mostusedword
{
# Word usage statistics
my $self = shift;
my %usages;
foreach my $word (keys %{ $self->{stats}->{wordcounts} }) {
# Skip people's nicks.
next if is_nick($word);
next if (length($word) < $self->{cfg}->{wordlength});
$usages{$word} = $self->{stats}->{wordcounts}{$word};
}
my @popular = sort { $usages{$b} <=> $usages{$a} } keys %usages;
if (@popular) {
$self->_headline($self->_template_text('mostwordstopic'));
_html("{cfg}->{tablewidth}\">");
_html("| | " . $self->_template_text('word') . " | ");
_html("" . $self->_template_text('numberuses') . " | ");
_html("" . $self->_template_text('lastused') . " |
");
my $count = 0;
for(my $i = 0; $count < $self->{cfg}->{wordhistory}; $i++) {
last unless $i < $#popular;
# Skip nicks. It's far more efficient to do this here than when
# @popular is created.
next if is_ignored($popular[$i]);
my $a = $count + 1;
my $popular = $self->_format_word($popular[$i]);
my $wordcount = $self->{stats}->{wordcounts}{$popular[$i]};
my $lastused = $self->_format_word($self->{stats}->{wordnicks}{$popular[$i]});
my $class;
if ($a == 1) {
$class = 'hirankc';
} else {
$class = 'rankc';
}
_html("| $a | ");
_html("$popular | ");
_html("$wordcount | ");
_html("$lastused | ");
_html("
");
$count++;
}
_html("
");
}
}
sub _mostwordsperline
{
# The person who got the most words per line
my $self = shift;
my %wpl = ();
my $numlines = 0;
my ($avg, $numwords);
foreach my $nick (keys %{ $self->{stats}->{words} }) {
if ($self->{topactive}{$nick} || !$self->{cfg}->{showonlytop}) {
$wpl{$nick} = sprintf("%.2f", $self->{stats}->{words}{$nick}/$self->{stats}->{lines}{$nick});
$numlines += $self->{stats}->{lines}{$nick};
$numwords += $self->{stats}->{words}{$nick};
}
}
if ($numlines > 0) {
$avg = sprintf("%.2f", $numwords/$numlines);
}
my @wpl = sort { $wpl{$b} <=> $wpl{$a} } keys %wpl;
if (@wpl) {
my %hash = (
nick => $wpl[0],
wpl => $wpl{$wpl[0]}
);
my $text = $self->_template_text('wpl1', %hash);
_html("$text");
$hash{avg} = $avg;
$text = $self->_template_text('wpl2', %hash);
_html(" $text");
_html(" |
");
}
}
sub _mostreferencednicks
{
# List showing the most referenced nicks
my $self = shift;
my %usages;
foreach my $word (sort keys %{ $self->{stats}->{wordcounts} }) {
next if !exists $self->{stats}->{lines}{$word};
next if is_ignored($word);
$usages{$word} = $self->{stats}->{wordcounts}{$word};
}
my @popular = sort { $usages{$b} <=> $usages{$a} } keys %usages;
if (@popular) {
$self->_headline($self->_template_text('referencetopic'));
_html("{cfg}->{tablewidth}\">");
_html("| | " . $self->_template_text('nick') . " | ");
_html("" . $self->_template_text('numberuses') . " | ");
_html("" . $self->_template_text('lastused') . " |
");
for(my $i = 0; $i < $self->{cfg}->{nickhistory}; $i++) {
last unless $i < $#popular;
my $a = $i + 1;
my $popular = $popular[$i];
my $wordcount = $self->{stats}->{wordcounts}{$popular[$i]};
my $lastused = $self->{stats}->{wordnicks}{$popular[$i]};
my $class;
if ($a == 1) {
$class = 'hirankc';
} else {
$class = 'rankc';
}
_html("| $a | ");
_html("$popular | ");
_html("$wordcount | ");
_html("$lastused | ");
_html("
");
}
_html("
");
}
}
sub _mosturls
{
# List showing the most referenced URLs
my $self = shift;
my @sorturls = sort { $self->{stats}->{urlcounts}{$b} <=> $self->{stats}->{urlcounts}{$a} }
keys %{ $self->{stats}->{urlcounts} };
if (@sorturls) {
$self->_headline($self->_template_text('urlstopic'));
_html("{cfg}->{tablewidth}\">");
_html("| | " . $self->_template_text('url') . " | ");
_html("" . $self->_template_text('numberuses') . " | ");
_html("" . $self->_template_text('lastused') . " |
");
for(my $i = 0; $i < $self->{cfg}->{urlhistory}; $i++) {
last unless $i < @sorturls;
my $a = $i + 1;
my $sorturl = $sorturls[$i];
my $urlcount = $self->{stats}->{urlcounts}{$sorturls[$i]};
my $lastused = $self->{stats}->{urlnicks}{$sorturls[$i]};
if (length($sorturl) > 60) {
$sorturl = substr($sorturl, 0, 60);
}
my $class;
if ($a == 1) {
$class = 'hirankc';
} else {
$class = 'rankc';
}
_html("| $a | ");
_html("$sorturl | ");
_html("$urlcount | ");
_html("$lastused | ");
_html("
");
}
_html("
");
}
}
sub _legend
{
# A legend showing the timebars and their associated time.
my $self = shift;
_html("");
_html(" {cfg}->{piclocation}/$self->{cfg}->{pic_h_0}\" width=\"40\" height=\"15\" align=\"middle\" alt=\"0-5\" /> = 0-5 | ");
_html(" {cfg}->{piclocation}/$self->{cfg}->{pic_h_6}\" width=\"40\" height=\"15\" align=\"middle\" alt=\"6-11\" /> = 6-11 | ");
_html(" {cfg}->{piclocation}/$self->{cfg}->{pic_h_12}\" width=\"40\" height=\"15\" align=\"middle\" alt=\"12-17\" /> = 12-17 | ");
_html(" {cfg}->{piclocation}/$self->{cfg}->{pic_h_18}\" width=\"40\" height=\"15\" align=\"middle\" alt=\"18-23\" /> = 18-23 | ");
_html("
\n");
}
sub _replace_links
{
# Sub to replace urls and e-mail addys to links
my ($self, $str, $nick) = @_;
# Regular expressions are taken from match_urls() and match_email() in
# Common.pm
my $texturl = $self->_template_text("newwindow");
my $textmail = $self->_template_text("mailto");
my (@str) = split(/ /,$str);
foreach (@str) {
if (m/(http|https|ftp|telnet|news)(:\/\/[-a-zA-Z0-9_\/~:@]+\.[-a-zA-Z0-9.,_~=:&@%?#\/+]+)/o) {
my $nick = $nick || $1 . $2;
$_ = "" . $self->_split_long_text($nick) . '';
} elsif (m/(^|[^:])\b([-a-zA-Z0-9._]+@[-a-zA-Z0-9_]+\.[-a-zA-Z0-9._]+)/o) {
my $nick = $nick || $1 . $2;
$_ = "$1" . $self->_split_long_text($nick) . "<\/a>";
} else {
$_ = $self->_split_long_text($_);
}
}
return join(' ', @str);
}
sub _split_long_text
{
my ($self, $str) = @_;
$str =~ s/(\S{$self->{cfg}->{quotewidth}})(?!\s)/$1-
/og;
return($str);
}
sub _user_linetimes
{
my $self = shift;
my $nick = shift;
my $top = shift;
my $bar = "";
my $len = ($self->{stats}->{lines}{$nick} / $self->{stats}->{lines}{$top}) * 100;
for (my $i = 0; $i <= 3; $i++) {
next if not defined $self->{stats}->{line_times}{$nick}[$i];
my $w = int(($self->{stats}->{line_times}{$nick}[$i] / $self->{stats}->{lines}{$nick}) * $len);
if ($w) {
my $pic = 'pic_h_'.(6*$i);
$bar .= "
{cfg}->{piclocation}/$self->{cfg}->{$pic}\" border=\"0\" width=\"$w\" height=\"15\" align=\"middle\" alt=\"\" />";
}
}
return "$bar $self->{stats}->{lines}{$nick}";
}
sub _user_wordtimes
{
my $self = shift;
my $nick = shift;
my $top = shift;
my $bar = "";
my $len = ($self->{stats}->{words}{$nick} / $self->{stats}->{words}{$top}) * 100;
for (my $i = 0; $i <= 3; $i++) {
next if not defined $self->{stats}->{word_times}{$nick}[$i];
my $w = int(($self->{stats}->{word_times}{$nick}[$i] / $self->{stats}->{words}{$nick}) * $len);
if ($w) {
my $pic = 'pic_h_'.(6*$i);
$bar .= "
{cfg}->{piclocation}/$self->{cfg}->{$pic}\" border=\"0\" width=\"$w\" height=\"15\" align=\"middle\" alt=\"\" />";
}
}
return "$bar $self->{stats}->{words}{$nick}";
}
sub _user_times
{
my $self = shift;
my ($nick) = @_;
my $bar = "";
my $itemstat = ($self->{cfg}->{sortbywords} ? 'words' : 'lines');
my $timestat = ($self->{cfg}->{sortbywords} ? 'word_times' : 'line_times');
for (my $i = 0; $i <= 3; $i++) {
next if not defined $self->{stats}->{$timestat}{$nick}[$i];
my $w = int(($self->{stats}->{$timestat}{$nick}[$i] / $self->{stats}->{$itemstat}{$nick}) * 40);
if ($w) {
my $pic = 'pic_h_'.(6*$i);
$bar .= "
{cfg}->{piclocation}/$self->{cfg}->{$pic}\" border=\"0\" width=\"$w\" height=\"15\" alt=\"\" />";
}
}
return $bar;
}
sub _mostnicks
{
# List showing the user with most used nicks
my $self = shift;
my @sortnicks = sort { keys %{ $self->{stats}->{nicks}->{$b} } <=> keys %{ $self->{stats}->{nicks}->{$a} } }
keys %{ $self->{stats}->{nicks} };
if (keys %{ $self->{stats}->{nicks}->{$sortnicks[0]} } > 1) {
$self->_headline($self->_template_text('mostnickstopic'));
my $names1 = $self->_template_text('names1');
my $names2 = $self->_template_text('names2');
my $nick_txt = $self->_template_text('nick');
my $names_txt = $self->_template_text('names');
_html("{cfg}->{tablewidth}\">");
_html("| | $nick_txt | ");
_html("$names_txt |
");
for(my $i = 0; $i < $self->{cfg}->{mostnickshistory}; $i++) {
next if is_ignored($sortnicks[$i]);
last unless $i < @sortnicks;
my $nickcount = keys %{ $self->{stats}->{nicks}->{$sortnicks[$i]} };
my $nickused = join(", ", values %{ $self->{stats}->{nicks}->{$sortnicks[$i]} });
next unless ($nickcount > 1);
my $a = $i + 1;
my $class = $a == 1 ? 'hirankc' : 'rankc';
my $n = $nickcount > 1 ? $names1 : $names2;
_html("| $a | ");
_html("$sortnicks[$i] ($nickcount $n) | ");
_html("$nickused | ");
_html("
");
}
_html("
");
}
}
sub _mostactivebyhour
{
# Charts for most active nicks by hour (0-5, 6-11, 12-17, 18-23)
my $self = shift;
my $sortnicks;
my $lastline=-1;
my $maxlines=0;
foreach my $period (0,1,2,3) {
my @sortnicks =
sort
{
(defined $self->{stats}->{line_times}{$b}[$period]?$self->{stats}->{line_times}{$b}[$period]:0)
<=>
(defined $self->{stats}->{line_times}{$a}[$period]?$self->{stats}->{line_times}{$a}[$period]:0)
}
keys %{ $self->{stats}->{line_times} } ;
for(my $i = 0; $i < $self->{cfg}->{activenicksbyhour}; $i++) {
next if ! $sortnicks[$i];
next if is_ignored($sortnicks[$i]);
last unless $i < @sortnicks;
my $nick=$sortnicks[$i];
my $count=$self->{stats}->{line_times}{$nick}[$period] || 0;
last unless $nick;
last unless $count;
$sortnicks->[$period][$i]=$nick;
if ($lastline<$i) {
$lastline=$i;
}
if ($maxlines<$count) {
$maxlines=$count;
}
}
}
if ($lastline>=0) {
$self->_headline($self->_template_text('activenickbyhourtopic'));
_html("{cfg}->{tablewidth}\">");
_html("| | ");
_html("0-5 | ");
_html("6-11 | ");
_html("12-17 | ");
_html("18-23 | ");
_html("
");
for(my $i = 0; $i <= $lastline; $i++) {
my $a = $i + 1;
my $class = $a == 1 ? 'hirankc' : 'rankc';
_html("| $a | ");
foreach my $period (0,1,2,3) {
my $nick=$sortnicks->[$period][$i];
if ($nick) {
my $count=$self->{stats}->{line_times}{$nick}[$period];
if ($count) {
_html("".$nick." - ".$count);
if ($self->{cfg}->{showmostactivebyhourgraph}) {
my $pic = 'pic_h_'.(6*$period);
my $w = int(($count / $maxlines) * 100);
_html("
{cfg}->{piclocation}/$self->{cfg}->{$pic}\" border=\"0\" width=\"$w\" height=\"15\" align=\"middle\" alt=\"\" />");
}
_html(" | ");
} else {
_html(" | ");
}
} else {
_html(" | ");
}
}
_html("
");
}
_html("
");
}
}
sub _topactive {
my $self = shift;
my @top_active;
my $top_nicks;
if ($self->{cfg}->{sortbywords}) {
@top_active = sort { $self->{stats}->{words}{$b} <=> $self->{stats}->{words}{$a} }
keys %{ $self->{stats}->{words} };
$top_nicks = scalar keys %{ $self->{stats}->{words} };
} else {
@top_active = sort { $self->{stats}->{lines}{$b} <=> $self->{stats}->{lines}{$a} }
keys %{ $self->{stats}->{lines} };
$top_nicks = scalar keys %{ $self->{stats}->{lines} };
}
if ($self->{cfg}->{activenicks} > $top_nicks) {
$self->{cfg}->{activenicks} = $top_nicks;
}
if (($self->{cfg}->{activenicks}+$self->{cfg}->{activenicks2}) > $top_nicks) {
$self->{cfg}->{activenicks2} = $top_nicks-$self->{cfg}->{activenicks};
}
(@top_active) = @top_active[0..($self->{cfg}->{activenicks}+$self->{cfg}->{activenicks2}-1)];
foreach (@top_active) {
$self->{topactive}{$_} = 1;
}
}
sub _istoponly {
my $self = shift;
my (@nicks_tmp) = @_;
my @nicks;
my $cnt=0;
if ($self->{cfg}->{showonlytop}) {
foreach my $nick (@nicks_tmp) {
if ($self->{topactive}{$nick}) {
push(@nicks, $nick);
}
}
return(@nicks);
} else {
return(@nicks_tmp);
}
}
1;
__END__
=head1 NAME
Pisg::HTMLGenerator - class to create a static HTML page out of data parsed
=head1 DESCRIPTION
C uses the hash returned by Pisg::Parser::Logfile and turns it into a static HTML page.
=head1 SYNOPSIS
use Pisg::HTMLGenerator;
$generator = new Pisg::HTMLGenerator(
cfg => $cfg,
stats => $stats,
users => $users,
tmps => $tmps
);
=head1 CONSTRUCTOR
=over 4
=item new ( [ OPTIONS ] )
This is the constructor for a new Pisg::HTMLGenerator object. C are passed in a hash like fashion using key and value pairs.
Possible options are:
B - hashref containing configuration variables, created by the Pisg module.
B - reference to the hash returned by Pisg::Parser::Logfile containing all stats.
B - reference to a hash containg user information
B - reference to a hash containing the language templates.
=back
=head1 AUTHOR
Morten Brix Pedersen
=head1 COPYRIGHT
Copyright (C) 2001-2002 Morten Brix Pedersen. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the terms of the GPL, license is included with the distribution of
this file.
=cut