egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pisg Stats - by Morten Brix Pedersen

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Shell & Bouncer Help
View previous topic :: View next topic  
Author Message
Football
Master


Joined: 26 Dec 2008
Posts: 205
Location: Quakenet, #Football

PostPosted: Tue Mar 02, 2010 3:10 pm    Post subject: Pisg Stats - by Morten Brix Pedersen Reply with quote

Hey, I`ve modified and trying to modify even more the Pisg Stats.
I`m trying to alter the 'Most Active Gender' to 'Most Active Supporters'
As can be seen in this link:

http://www.eplonline.co.uk/chanstats/stats.html

I don't know how to add further 'genders' or in this case 'teams', and could use some help

You should notice that in this code, everywhere that was written "Male" I replaced it with "Man Utd"; "Female" was replaced with "Chelsea" and "Bots" were replaced with "Liverpool", please help me add another option, let's call it "Tottenham", and I could continue adding others from there..

The file I configured is HTMLgenerator.pm;


package Pisg::HTMLGenerator;

# $Id: HTMLGenerator.pm,v 1.189 2007/09/07 23:17:23 df7cb Exp $
#
# Copyright and license, as well as documentation(POD) for this module is
# found at the end of the file.

use strict;
$^W = 1;

# test for Text::Iconv
my $have_iconv = 1;
eval 'use Text::Iconv';
$have_iconv = 0 if $@;

sub new
{
my $type = shift;
my %args = @_;
my $self = {
cfg => $args{cfg},
stats => $args{stats},
users => $args{users},
tmps => $args{tmps},
topactive => {},
};

# Import common functions in Pisg::Common
require Pisg::Common;
Pisg::Common->import();

bless($self, $type);
return $self;
}

sub create_output
{
# This subroutine calls all the subroutines which create their
# individual stats. The name of the functions is somewhat saying - if
# you don't understand it, most subs have a better explanation in the
# sub itself.

my $self = shift;
$self->{cfg}->{lang} = shift;

# save table width as multiplie files would just increase tablewidth
my $tablewidth_original = $self->{cfg}->{tablewidth};

# remove old iconv if it exist as it could mess up recode.
delete $self->{iconv} if $self->{iconv};

my $lang_charset = $self->{tmps}->{$self->{cfg}->{lang}}{lang_charset};
if($lang_charset and $lang_charset ne $self->{cfg}->{charset}) {
if($have_iconv) {
# convert from template charset to our
$self->{iconv} = Text::Iconv->new($lang_charset, $self->{cfg}->{charset});
} else {
print "Text::Iconv is not installed, skipping charset conversion of language templates\n"
unless ($self->{cfg}->{silent});
}
}

$self->_topactive();

if($self->{cfg}->{bignumbersthreshold} =~ /^sqrt/) {
$self->{cfg}->{bignumbersthreshold} = int(sqrt($self->{stats}->{topactive_lines}));
}

my $fname = $self->{cfg}->{outputfile};
$fname =~ s/\%t/$self->{cfg}->{outputtag}/g;
$fname =~ s/\%l/$self->{cfg}->{lang}/g;
print "Now generating HTML ($self->{cfg}->{lang}) in $fname...\n"
unless ($self->{cfg}->{silent});

open (OUTPUT, "> $fname") or
die("$0: Unable to open outputfile($fname): $!\n");

if ($self->{cfg}->{showlines}) {
$self->{cfg}->{tablewidth} += 40;
}
if ($self->{cfg}->{showtime}) {
$self->{cfg}->{tablewidth} += 40;
}
if ($self->{cfg}->{showlinetime}) {
$self->{cfg}->{tablewidth} += 100;
}
if ($self->{cfg}->{showwordtime}) {
$self->{cfg}->{tablewidth} += 100;
}
if ($self->{cfg}->{showwords}) {
$self->{cfg}->{tablewidth} += 40;
}
if ($self->{cfg}->{showwpl}) {
$self->{cfg}->{tablewidth} += 40;
}
if ($self->{cfg}->{showcpl}) {
$self->{cfg}->{tablewidth} += 40;
}
if ($self->{cfg}->{userpics}) {
$self->{cfg}->{tablewidth} += $self->{cfg}->{userpics} * ($self->{cfg}->{picwidth} || 60);
}
$self->{cfg}->{headwidth} = $self->{cfg}->{tablewidth} - 4;
$self->_htmlheader();
$self->_pageheader()
if ($self->{cfg}->{pagehead} ne 'none');

if ($self->{cfg}->{dailyactivity}) {
$self->_activedays();
}

if ($self->{cfg}->{showactivetimes}) {
$self->_activetimes();
}

if ($self->{cfg}->{showactivenicks}) {
$self->_activenicks();
}

if ($self->{cfg}->{showmostactivebyhour}) {
$self->_mostactivebyhour();
}

if ($self->{cfg}->{showbignumbers}) {
$self->_headline($self->_template_text('bignumtopic'));
_html("<table width=\"$self->{cfg}->{tablewidth}\">"); # Needed for sections
$self->_questions();
$self->_shoutpeople();
$self->_capspeople();
$self->_violent();
$self->_mostsmiles();
$self->_mostsad();
$self->_linelengths();
$self->_mostwords();
$self->_mostwordsperline();
_html("</table>"); # Needed for sections
}

if ($self->{cfg}->{showmostnicks}) {
$self->_mostnicks();
}

if ($self->{cfg}->{showactivegenders}) {
$self->_activegenders();
}

if ($self->{cfg}->{showmuw}) {
$self->_mostusedword();
}

if ($self->{cfg}->{showmrn}) {
$self->_mostreferencednicks();
}

if ($self->{cfg}->{showsmileys}) {
$self->_smileys();
}

if ($self->{cfg}->{showkarma}) {
$self->_karma();
}

if ($self->{cfg}->{showmru}) {
$self->_mosturls();
}

if ($self->{cfg}->{showcharts}) {
$self->_charts();
}

if ($self->{cfg}->{showbignumbers}) {
$self->_headline($self->_template_text('othernumtopic'));
_html("<table width=\"$self->{cfg}->{tablewidth}\">"); # Needed for sections
$self->_gotkicks();
$self->_mostkicks();
$self->_mostop() if $self->{cfg}->{showops};
$self->_mosthalfop() if $self->{cfg}->{showhalfops};
$self->_mostvoice() if $self->{cfg}->{showvoices};
$self->_mostactions();
$self->_mostmonologues();
$self->_mostjoins();
$self->_mostfoul();
_html("</table>"); # Needed for sections
}

if ($self->{cfg}->{showtopics}) {
$self->_headline($self->_template_text('latesttopic'));
_html("<table width=\"$self->{cfg}->{tablewidth}\">"); # Needed for sections

$self->_lasttopics();

_html("</table>"); # Needed for sections
}

my %hash = ( lines => $self->{stats}->{parsedlines} );
_html($self->_template_text('totallines', %hash) . "<br /><br />");

$self->_pagefooter()
if ($self->{cfg}->{pagefoot} ne 'none');

$self->_htmlfooter();

close(OUTPUT);

# restore tablewidth
$self->{cfg}->{tablewidth} = $tablewidth_original;
}

sub _htmlheader
{
my $self = shift;
my %hash = (
network => $self->{cfg}->{network},
maintainer => $self->{cfg}->{maintainer},
days => $self->{stats}->{days},
nicks => scalar keys %{ $self->{stats}->{lines} }
);

my $CSS;
if($self->{cfg}->{colorscheme} =~ /([^\/.]+)\.[^\/]+$/) { # use external CSS file
$CSS = "<link rel=\"stylesheet\" type=\"text/css\" title=\"$1\" href=\"$self->{cfg}->{colorscheme}\" />";
} elsif($self->{cfg}->{colorscheme} ne "none") { # read the chosen CSS file
my $css_file = $self->{cfg}->{cssdir} . $self->{cfg}->{colorscheme} . ".css";
open(FILE, $css_file) or open (FILE, $self->{cfg}->{search_path} . "/$css_file") or die("$0: Unable to open stylesheet $css_file: $!\n");
{
local $/; # enable "slurp" mode
$CSS = "<style type=\"text/css\" title=\"$self->{cfg}->{colorscheme}\">\n". <FILE>. "</style>";
$CSS =~ s/\/\*/\/\* <!--/g;
$CSS =~ s/\*\//--> \*\//g;
}
close FILE;
}

# use alternate CSS file
if($self->{cfg}->{altcolorscheme} ne "none" and $self->{cfg}->{altcolorscheme} =~ /[^\w]/) {
foreach (split /\s+/, $self->{cfg}->{altcolorscheme}) {
/([^\/.]+)\.[^\/]+$/;
$CSS .= "\n<link rel=\"alternate stylesheet\" type=\"text/css\" title=\"$1\" href=\"$_\" />";
}
}

my $title = $self->_template_text('pagetitle1', %hash);
if($self->{cfg}->{colorscheme} ne "none") {
_html( <<HTML );
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=$self->{cfg}->{charset}" />
<title>$title</title>
$CSS
</head>
<body>
<div align="center">
HTML
}
_html("<span class=\"title\">$title</span><br />");
_html("<br />");
_html($self->_template_text('pagetitle2', %hash) . " " . $self->get_time());

_html("<br />" . $self->_template_text('pagetitle3', %hash) . "<br /><br />");

}

sub get_time
{
my $self = shift;
my ($tday, %hash);

my $month = $self->_template_text('month', %hash);
my $day = $self->_template_text('day', %hash);

my @month = split(" ", $month);
my @day = split(" ", $day);

# Get the Date from the users computer
my $timezone = $self->{cfg}->{timeoffset} * 3600;
my ($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime(time+$timezone);

$year += 1900; # Y2K Patch

$min =~ s/^(.)$/0$1/; # Fixes the display of mins/secs below
$sec =~ s/^(.)$/0$1/; # it displays 03 instead of 3

if ($hour > '23') { # Checks to see if it Midnight
$hour = 12; # Makes it display the hour 12
$tday = "AM"; # Display AM
} elsif($hour > '12') { # Get rid of the Military time and
$hour -= 12; # put it into normal time
$tday = "PM"; # If past Noon and before Midnight set
} else {
$tday = "AM"; # If it's past Midnight and before Noon
} # set the time as AM

# Use 24 hours pr. day
if ($tday eq "PM" && $hour < '12') {
$hour += 12;
}

return "$day[$wday] $mday $month[$mon] $year - $hour:$min:$sec";
}


sub _htmlfooter
{
my $self = shift;

my %hash;

my $pisg_hp = $self->_template_text('pisghomepage');
$hash{pisg_url} = "<a href=\"http://pisg.sourceforge.net/\" title=\"$pisg_hp\" class=\"background\">pisg</a>";

my $author_hp = $self->_template_text('authorhomepage');
$hash{author_url} = "<a href=\"http://mbrix.dk/\" title=\"$author_hp\" class=\"background\">Morten Brix Pedersen</a>";

$hash{version} = $self->{cfg}->{version};

my $hours = $self->_template_text('hours');
my $mins = $self->_template_text('minutes');
my $secs = $self->_template_text('seconds');
my $and = $self->_template_text('and');

my $h = $self->{stats}->{processtime}{hours};
my $m = $self->{stats}->{processtime}{mins};
my $s = $self->{stats}->{processtime}{secs};
$hash{time} = "$h $hours $m $mins $and $s $secs";

my $stats_gen = $self->_template_text('stats_gen_by', %hash);
my $author_text = $self->_template_text('author', %hash);
my $stats_text = $self->_template_text('stats_gen_in', %hash);

_html( <<HTML );
<span class="small">
$stats_gen<br />
$author_text<br />
$stats_text
</span>
HTML

_html( sprintf( qq(<!-- NFiles = "%s"; Format = "%s"; Lang = "%s"; LangFile = "%s"; Charset = "%s"; LogCharset = "%s"; LogCharsetFallback = "%s"; LogPrefix = "%s"; LogSuffix = "%s"; NickTracking = "%s"; TimeOffset = "%s" -->),
$self->{cfg}->{nfiles},
$self->{cfg}->{format},
$self->{cfg}->{lang},
$self->{cfg}->{langfile},
$self->{cfg}->{charset},
$self->{cfg}->{logcharset},
$self->{cfg}->{logcharsetfallback},
$self->{cfg}->{logprefix},
$self->{cfg}->{logsuffix},
$self->{cfg}->{nicktracking},
$self->{cfg}->{timeoffset}
));

if($self->{cfg}->{colorscheme} ne "none") {
_html( <<HTML );
</div>
</body>
</html>
HTML
}
}

sub _headline
{
my $self = shift;
my ($title) = (@_);
_html( <<HTML );
<br />
<table width="$self->{cfg}->{headwidth}" cellpadding="1" cellspacing="0" border="0">
<tr>
<td class="headlinebg">
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="headtext">$title</td>
</tr>
</table>
</td>
</tr>
</table>
HTML
}

sub _pageheader
{
my $self = shift;
unless(open(PAGEHEAD, $self->{cfg}->{pagehead})) {
warn("$0: Unable to open $self->{cfg}->{pagehead} for reading: $!\n");
return;
}
while (<PAGEHEAD>) {
chomp;
_html($_);
}
close(PAGEHEAD);
}

sub _pagefooter
{
my $self = shift;
unless(open(PAGEFOOT, $self->{cfg}->{pagefoot})) {
warn("$0: Unable to open $self->{cfg}->{pagefoot} for reading: $!\n");
return;
}
while (<PAGEFOOT>) {
chomp;
_html($_);
}
close(PAGEFOOT);
}

sub _activedays
{
# The most actives days on the channel
my $self = shift;
my $days = $self->{stats}->{days};
my $ndays = $self->{cfg}->{dailyactivity};

my $highest_value = 1;
for (my $day = $days; $day > $days - $ndays ; $day--) {
if (defined($self->{stats}->{day_lines}->[$day])) {
if ($self->{stats}->{day_lines}->[$day] > $highest_value) {
$highest_value = $self->{stats}->{day_lines}->[$day];
}
} else {
#there are only $days - $day days Smile
$ndays = $days - $day;
last;
}
}

my %hash = (
n => $ndays
);
$self->_headline($self->_template_text('dailyactivitytopic', %hash));

_html("<table border=\"0\"><tr>");

for (my $day = $days - $ndays + 1; $day <= $days ; $day++) {
my $lines = $self->{stats}->{day_lines}[$day];
_html("<td align=\"center\" valign=\"bottom\" class=\"asmall\">$lines<br />");
for (my $time = 4; $time >= 0; $time--) {
if (defined($self->{stats}->{day_times}[$day][$time])) {
my $size = int(($self->{stats}->{day_times}[$day][$time] / $highest_value) * 100);

my $image = "pic_v_".$time*6;
$image = $self->{cfg}->{$image};
_html("<img src=\"$self->{cfg}->{piclocation}/$image\" width=\"15\" height=\"$size\" alt=\"$size\" title=\"$size\" /><br />") if $size;

}
}
_html("</td>");
}

_html("</tr><tr>");

for (my $day = $ndays - 1; $day >= 0 ; $day--) {
_html("<td class=\"rankc10center\" align=\"center\">$day</td>");
}

_html("</tr></table>");

if($self->{cfg}->{showlegend} == 1) {
$self->_legend();
}
}

sub _activetimes
{
# The most actives times on the channel
my $self = shift;

my (%output);

$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]};

for my $hour (sort keys %{ $self->{stats}->{times} }) {

my $size = int(($self->{stats}->{times}{$hour} / $highest_value) * 100);
my $percent = sprintf("%.1f", ($self->{stats}->{times}{$hour} / $self->{stats}->{parsedlines}) * 100);
my $lines_per_hour = $self->{stats}->{times}{$hour};

my $image = "pic_v_".(int($hour/6)*6);
$image = $self->{cfg}->{$image};

$output{$hour} = "<td align=\"center\" valign=\"bottom\" class=\"asmall\">$percent%<br /><img src=\"$self->{cfg}->{piclocation}/$image\" width=\"15\" height=\"$size\" alt=\"$lines_per_hour\" title=\"$lines_per_hour\"/></td>" if $size;
}

_html("<table border=\"0\"><tr>");

for ($b = 0; $b < 24; $b++) {
$a = sprintf("%02d", $b);

if (!defined($output{$a})) {
_html("<td align=\"center\" valign=\"bottom\" class=\"asmall\">0%</td>");
} else {
_html($output{$a});
}
}

_html("</tr><tr>");

# Remove leading zero
$toptime[0] =~ s/^0//;

for ($b = 0; $b < 24; $b++) {
# Highlight the top time
my $class = $toptime[0] == $b ? 'hirankc10center' : 'rankc10center';
_html("<td class=\"$class\" align=\"center\">$b</td>");
}

_html("</tr></table>");

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'));

my $output = "";
$output .= "<table border=\"0\" width=\"$self->{cfg}->{tablewidth}\"><tr>";
$output .= "<td>&nbsp;</td>";
$output .= "<td class=\"tdtop\"><b>" . $self->_template_text('nick') . "</b></td>";

$output .= "<td class=\"tdtop\"><b>" . $self->_template_text('numberlines') . "</b></td>" if ($self->{cfg}->{showlines});
$output .= "<td class=\"tdtop\"><b>" . $self->_template_text('show_time') . "</b></td>" if ($self->{cfg}->{showtime});
$output .= "<td class=\"tdtop\"><b>" . $self->_template_text('show_words') . "</b></td>" if ($self->{cfg}->{showwords});
$output .= "<td class=\"tdtop\"><b>" . $self->_template_text('show_wpl') . "</b></td>" if ($self->{cfg}->{showwpl});
$output .= "<td class=\"tdtop\"><b>" . $self->_template_text('show_cpl') . "</b></td>" if ($self->{cfg}->{showcpl});
$output .= "<td class=\"tdtop\"><b>" . $self->_template_text('show_lastseen') . "</b></td>" if ($self->{cfg}->{showlastseen});
$output .= "<td class=\"tdtop\"><b>" . $self->_template_text('randquote') . "</b></td>" if ($self->{cfg}->{showrandquote});

$output .= "\n";

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; }

for (my $c = 0; $c < $self->{cfg}->{activenicks}; $c++) {
last unless $self->{cfg}->{userpics};
my $nick = $active[$c];
if ($self->{users}->{userpics}{$nick} or $self->{cfg}->{defaultpic}) {
$output .= "<td class=\"tdtop\"";
$output .= " colspan=\"$self->{cfg}->{userpics}\"" if ($self->{cfg}->{userpics} > 1);
$output .= "><b>" . $self->_template_text('userpic') ."</b></td>";
last;
}
}

$output .= "\n</tr>";
_html($output);
undef $output;

for (my $i = 0; $i < $self->{cfg}->{activenicks}; $i++) {
my $c = $i + 1;
my $nick = $active[$i];
my $visiblenick;

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 and quote nick
if ($self->{users}->{userlinks}{$nick}) {
$visiblenick = $self->_format_word($self->{users}->{userlinks}{$nick}, $nick);
} else {
$visiblenick = $self->_format_word($nick);
}

my $style = $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};
my %hash = ( days => $lastseen );
if ($lastseen == 0) {
$lastseen = $self->_template_text('today');
} elsif ($lastseen == 1) {
$lastseen = $self->_template_text('lastseen1', %hash);
} else {
$lastseen = $self->_template_text('lastseen2', %hash);
}
}

_html("<tr><td class=\"$class\" align=\"left\">$c</td>");

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};

my $output = "";
$output .= "<td $style>";

# Hilight nick with gendercolors
if ($sex and $sex eq 'm') {
$output .= "<span class=\"Chelsea\">";
} elsif ($sex and $sex eq 'f') {
$output .= "<span class=\"Man Utd\">";
} elsif ($sex and $sex eq 'b') {
$output .= "<span class=\"Liverpool\">";
} else {
$output .= "<span>";
}
$output .= $visiblenick;
$output .= "</span></td>";

if ($self->{cfg}->{showlines}) {
if ($self->{cfg}->{showlinetime}) {
$output .= "<td $style nowrap=\"nowrap\">" . $self->_user_linetimes($nick,$active[0]) . "</td>";
} else {
$output .= "<td $style>$line</td>";
}
}

$output .= "<td $style>" . $self->_user_times($nick) . "</td>" if ($self->{cfg}->{showtime});

if ($self->{cfg}->{showwords}) {
if ($self->{cfg}->{showwordtime}) {
$output .= "<td $style nowrap=\"nowrap\">" . $self->_user_wordtimes($nick,$active[0]) . "</td>";
} else {
$output .= "<td $style>$w</td>";
}
}

$output .= "<td $style>" . sprintf("%.1f", $w/$line) . "</td>" if ($self->{cfg}->{showwpl});
$output .= "<td $style>" . sprintf("%.1f", $ch/$line) . "</td>" if ($self->{cfg}->{showcpl});
$output .= "<td $style>$lastseen</td>" if ($self->{cfg}->{showlastseen});
$output .= "<td $style>\"$randomline\"</td>" if ($self->{cfg}->{showrandquote});

_html($output);
undef $output;


if ($self->{cfg}->{userpics} && $i % $self->{cfg}->{userpics} == 0) {
for my $ii (0 .. $self->{cfg}->{userpics} - 1) {
last if $i + $ii >= $self->{cfg}->{activenicks};
$self->_user_pic($active[$i + $ii], $style);
}
}
_html("</tr>");
}

_html("</table><br />");

# 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("<br /><b><i>" . $self->_template_text('nottop') . "</i></b><table><tr>");
for (my $i = $self->{cfg}->{activenicks}; $i < $remain; $i++) {
my $visiblenick;
my $nick = $active[$i];
if ($i != $self->{cfg}->{activenicks} and ($i - $self->{cfg}->{activenicks}) % 5 == 0) {
_html("</tr><tr>");
}
my $items;
if ($self->{users}->{userlinks}{$nick}) {
$visiblenick = $self->_format_word($self->{users}->{userlinks}{$nick}, $nick);
} else {
$visiblenick = $self->_format_word($nick);
}
if ($self->{cfg}->{sortbywords}) {
$items = $self->{stats}->{words}{$active[$i]};
} else {
$items = $self->{stats}->{lines}{$active[$i]};
}
my $sex = $self->{users}->{sex}{$active[$i]};

my $output = "";
$output .= "<td class=\"rankc10\">";

if ($sex and $sex eq 'm') {
$output .= "<span class=\"Chelsea\">";
} elsif ($sex and $sex eq 'f') {
$output .= "<span class=\"Man Utd\">";
} elsif ($sex and $sex eq 'b') {
$output .= "<span class=\"Liverpool\">";
} else {
$output .= "<span>";
}
$output .= "$visiblenick ($items)";
$output .= "</span></td>";

_html($output);
undef $output;

}
_html("</tr></table>");
}
}

my %hash;
$hash{totalnicks} = $nicks - $remain;
if ($hash{totalnicks} > 0) {
_html("<br /><b>" . $self->_template_text('totalnicks', %hash) . "</b><br />");
}
}

sub generate_colors
{
my $self = shift;
my $c = shift;

# if hicell or hicell2 is "", do not print the class as it could mess up the gendercode
return "" if not (length $self->{cfg}->{hicell} and length $self->{cfg}->{hicell2});

my $h = $self->{cfg}->{hicell} or return "class=\"hicell\"";
$h =~ s/^#//;
$h = hex $h;
my $h2 = $self->{cfg}->{hicell2} or return "class=\"hicell\"";
$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 "style=\"background-color: #$red$green$blue\"";
}

sub _html
{
my $html = shift;
print OUTPUT "$html\n" or die "Could not write to disk: $!\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} > $self->{cfg}->{bignumbersthreshold}) {
$qpercent{$nick} = sprintf("%.1f", ($self->{stats}->{questions}{$nick} / $self->{stats}->{lines}{$nick}) * 100);
}
}
}

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("<tr><td class=\"hicell\">$text");
if (@question >= 2) {
my %hash = (
nick => $question[1],
per => $qpercent{$question[1]}
);

my $text = $self->_template_text('question2', %hash);
_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");

} else {
_html("<tr><td class=\"hicell\">" . $self->_template_text('question3') . "</td></tr>");
}
}

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} > $self->{cfg}->{bignumbersthreshold}) {
$spercent{$nick} = sprintf("%.1f", ($self->{stats}->{shouts}{$nick} / $self->{stats}->{lines}{$nick}) * 100);
}
}
}

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("<tr><td class=\"hicell\">$text");
if (@shout >= 2) {
my %hash = (
nick => $shout[1],
per => $spercent{$shout[1]}
);

my $text = $self->_template_text('shout2', %hash);
_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");

} else {
my $text = $self->_template_text('shout3');
_html("<tr><td class=\"hicell\">$text</td></tr>");
}

}

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} > $self->{cfg}->{bignumbersthreshold}) {
$cpercent{$nick} = sprintf("%.1f", $self->{stats}->{allcaps}{$nick} / $self->{stats}->{lines}{$nick} * 100);
}
}
}

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("<tr><td class=\"hicell\">$text<br /><span class=\"small\">$exttext</span>");
} else {
_html("<tr><td class=\"hicell\">$text");
}
if (@caps >= 2) {
my %hash = (
nick => $caps[1],
per => $cpercent{$caps[1]}
);

my $text = $self->_template_text('allcaps2', %hash);
_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");

} else {
my $text = $self->_template_text('allcaps3');
_html("<tr><td class=\"hicell\">$text</td></tr>");
}
}

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("<tr><td class=\"hicell\">$text<br /><span class=\"small\">$exttext</span>");
} else {
_html("<tr><td class=\"hicell\">$text");
}
if (@aggressors >= 2) {
my %hash = (
nick => $aggressors[1],
attacks => $self->{stats}->{violence}{$aggressors[1]}
);

my $text = $self->_template_text('violent2', %hash);
_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");
} else {
my $text = $self->_template_text('violent3');
_html("<tr><td class=\"hicell\">$text</td></tr>");
}


# 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("<tr><td class=\"hicell\">$text<br /><span class=\"small\">$exttext</span>");
} else {
_html("<tr><td class=\"hicell\">$text");
}
if (@victims >= 2) {
my %hash = (
nick => $victims[1],
attacks => $self->{stats}->{attacked}{$victims[1]}
);

my $text = $self->_template_text('attacked2', %hash);
_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");
}
}

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("<tr><td class=\"hicell\">$text<br /><span class=\"small\">$exttext</span>");
} else {
_html("<tr><td class=\"hicell\">$text");
}

if (@gotkick >= 2) {
my %hash = (
nick => $gotkick[1],
kicks => $self->{stats}->{gotkicked}{$gotkick[1]}
);

my $text = $self->_template_text('gotkick2', %hash);
_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");
}
}

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("<tr><td class=\"hicell\">$text</td></tr>");
}
}

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("<tr><td class=\"hicell\">$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("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");
} else {
my $text = $self->_template_text('words3');
_html("<tr><td class=\"hicell\">$text</td></tr>");
}
}

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("<tr><td class=\"hicell\">$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("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");
} else {
my $text = $self->_template_text('kick3');
_html("<tr><td class=\"hicell\">$text</td></tr>");
}
}

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("<tr><td class=\"hicell\">$text");
if (@monologue >= 2) {
my %hash = (
nick => $monologue[1],
monos => $self->{stats}->{monologues}{$monologue[1]}
);

my $text = $self->_template_text('mono2', %hash);
_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");
}
}

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} > $self->{cfg}->{bignumbersthreshold}) {
$len{$nick} = sprintf("%.1f", $self->{stats}->{lengths}{$nick} / $self->{stats}->{lines}{$nick});
}
}
}

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 = sprintf("%.1f", $totallength / $all_lines);
}

if (@len) {
my %hash = (
nick => $len[0],
letters => $len{$len[0]}
);

my $text = $self->_template_text('long1', %hash);
_html("<tr><td class=\"hicell\">$text<br />");

if (@len >= 2) {
%hash = (
avg => $totalaverage
);

$text = $self->_template_text('long2', %hash);
_html("<span class=\"small\">$text</span></td></tr>");
} else {
_html("</td></tr>");
}
}

# 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("<tr><td class=\"hicell\">$text<br />");

if (@len >= 2) {
%hash = (
nick => $len[$#len - 1],
letters => $len{$len[$#len - 1]}
);

$text = $self->_template_text('short2', %hash);
_html("<span class=\"small\">$text</span></td></tr>");
} else {
_html("</td></tr>");
}
}
}

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) {
my $dec = $self->{cfg}->{showfouldecimals};
$dec = 1 if($dec < 0); # default to 1
$spercent{$nick} = sprintf("%.${dec}f", $self->{stats}->{foul}{$nick} / $self->{stats}->{words}{$nick} * 100);
}
}
}

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("<tr><td class=\"hicell\">$text<br /><span class=\"small\">$exttext</span>");
} else {
_html("<tr><td class=\"hicell\">$text");
}

if (@foul >= 2) {
my %hash = (
nick => $foul[1],
per => $spercent{$foul[1]}
);

my $text = $self->_template_text('foul2', %hash);
_html("<br /><span class=\"small\">$text</span>");
}

_html("</td></tr>");
} else {
my $text = $self->_template_text('foul3');

_html("<tr><td class=\"hicell\">$text</td></tr>");
}
}


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} > $self->{cfg}->{bignumbersthreshold}) {
$spercent{$nick} = sprintf("%.1f", $self->{stats}->{frowns}{$nick} / $self->{stats}->{lines}{$nick} * 100);
}
}
}

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("<tr><td class=\"hicell\">$text");

if (@sadface >= 2) {
my %hash = (
nick => $sadface[1],
per => $spercent{$sadface[1]}
);

my $text = $self->_template_text('sad2', %hash);

_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");
} else {
my $text = $self->_template_text('sad3');
_html("<tr><td class=\"hicell\">$text</td></tr>");
}
}


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("<tr><td class=\"hicell\">$text");

if (@ops >= 2) {
my %hash = (
nick => $ops[1],
ops => $self->{stats}->{gaveops}{$ops[1]}
);

my $text = $self->_template_text('mostop2', %hash);
_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");
} else {
my $text = $self->_template_text('mostop3');
_html("<tr><td class=\"hicell\">$text</td></tr>");
}

if (@deops) {
my %hash = (
nick => $deops[0],
deops => $self->{stats}->{tookops}{$deops[0]}
);
my $text = $self->_template_text('mostdeop1', %hash);

_html("<tr><td class=\"hicell\">$text");

if (@deops >= 2) {
my %hash = (
nick => $deops[1],
deops => $self->{stats}->{tookops}{$deops[1]}
);
my $text = $self->_template_text('mostdeop2', %hash);

_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");
} else {
my $text = $self->_template_text('mostdeop3');
_html("<tr><td class=\"hicell\">$text</td></tr>");
}
}

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("<tr><td class=\"hicell\">$text");

if (@voice >= 2) {
my %hash = (
nick => $voice[1],
voices => $self->{stats}->{gavevoice}{$voice[1]}
);

my $text = $self->_template_text('mostvoice2', %hash);
_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");
} else {
my $text = $self->_template_text('mostvoice3');
_html("<tr><td class=\"hicell\">$text</td></tr>");
}

if (@devoice) {
my %hash = (
nick => $devoice[0],
devoices => $self->{stats}->{tookvoice}{$devoice[0]}
);
my $text = $self->_template_text('mostdevoice1', %hash);

_html("<tr><td class=\"hicell\">$text");

if (@devoice >= 2) {
my %hash = (
nick => $devoice[1],
devoices => $self->{stats}->{tookvoice}{$devoice[1]}
);
my $text = $self->_template_text('mostdevoice2', %hash);

_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");
} else {
my $text = $self->_template_text('mostdevoice3');
_html("<tr><td class=\"hicell\">$text</td></tr>");
}

}

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("<tr><td class=\"hicell\">$text");

if (@halfops >= 2) {
my %hash = (
nick => $halfops[1],
halfops => $self->{stats}->{gavehalfops}{$halfops[1]}
);

my $text = $self->_template_text('mosthalfop2', %hash);
_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");
} else {
my $text = $self->_template_text('mosthalfop3');
_html("<tr><td class=\"hicell\">$text</td></tr>");
}

if (@dehalfops) {
my %hash = (
nick => $dehalfops[0],
dehalfops => $self->{stats}->{tookhalfops}{$dehalfops[0]}
);
my $text = $self->_template_text('mostdehalfop1', %hash);

_html("<tr><td class=\"hicell\">$text");

if (@dehalfops >= 2) {
my %hash = (
nick => $dehalfops[1],
dehalfops => $self->{stats}->{tookhalfops}{$dehalfops[1]}
);
my $text = $self->_template_text('mostdehalfop2', %hash);

_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");
} else {
my $text = $self->_template_text('mostdehalfop3');
_html("<tr><td class=\"hicell\">$text</td></tr>");
}
}

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("<tr><td class=\"hicell\">$text<br /><span class=\"small\">$exttext</span>");
} else {
_html("<tr><td class=\"hicell\">$text");
}

if (@actions >= 2) {
my %hash = (
nick => $actions[1],
actions => $self->{stats}->{actions}{$actions[1]}
);

my $text = $self->_template_text('action2', %hash);
_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");
} else {
my $text = $self->_template_text('action3');
_html("<tr><td class=\"hicell\">$text</td></tr>");
}
}


sub _mostsmiles
{
# The person(s) who smiled the most Smile
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} > $self->{cfg}->{bignumbersthreshold}) {
$spercent{$nick} = sprintf("%.1f", $self->{stats}->{smiles}{$nick} / $self->{stats}->{lines}{$nick} * 100);
}
}
}

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("<tr><td class=\"hicell\">$text");
if (@smiles >= 2) {
my %hash = (
nick => $smiles[1],
per => $spercent{$smiles[1]}
);

my $text = $self->_template_text('smiles2', %hash);
_html("<br /><span class=\"small\">$text</span>");
}
_html("</td></tr>");

} else {

my $text = $self->_template_text('smiles3');
_html("<tr><td class=\"hicell\">$text</td></tr>");
}
}

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} = $nick;
$hash{time} = "$hour:$min";
$hash{days} = $self->{stats}->{days} - $self->{stats}->{topics}[$i]{days};
if ($hash{days} == 0) {
$hash{date} = $self->_template_text('today');
} elsif ($hash{days} == 1) {
$hash{date} = $self->_template_text('lastseen1', %hash);
} else {
$hash{date} = $self->_template_text('lastseen2', %hash);
}

_html('<tr><td class="hicell"><i>' . $self->_format_line($topic) . '</i></td>');
_html('<td class="hicell"><b>' . $self->_template_text('bylinetopic', %hash) . '</b></td></tr>');
}
_html("<tr><td align=\"center\" colspan=\"2\" class=\"asmall\">" . $self->_template_text('totaltopic', %hash) . "</td></tr>");
} else {
_html("<tr><td class=\"hicell\">" . $self->_template_text('notopic') ."</td></tr>");
}
}

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}->{$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 template for '$template' in language file.\n");
}
}
if($self->{iconv}) {
$text = $self->{iconv}->convert($text);
die("Could not convert charset for template '$template'.\n") unless $text;
}

$hash{channel} = $self->{cfg}->{channel};
# the nick is sanitized here, everything else outside of _template_text
$hash{nick} = $self->_format_word($hash{nick}) if $hash{nick};

foreach my $key (sort keys %hash) {
$text =~ s/\[:$key\]/$hash{$key}/;
}

if ($text =~ /\[:[^:]*?:[^:]*?:[^:]*?:\
_________________
Idling at #Football, Quakenet.
Back to top
View user's profile Send private message
JEAH
Voice


Joined: 25 Jul 2010
Posts: 4
Location: Chicago, IL, USA

PostPosted: Sun Jul 25, 2010 11:19 am    Post subject: Reply with quote

I think your best bet for this kind of help is going to be on the PISG developer/user mailing list.

Check out https://lists.sourceforge.net/lists/listinfo/pisg-general
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Shell & Bouncer Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber