HTMLGenerator.pm 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857
  1. package Pisg::HTMLGenerator;
  2. # Copyright and license, as well as documentation(POD) for this module is
  3. # found at the end of the file.
  4. use strict;
  5. $^W = 1;
  6. sub new
  7. {
  8. my $type = shift;
  9. my %args = @_;
  10. my $self = {
  11. cfg => $args{cfg},
  12. stats => $args{stats},
  13. users => $args{users},
  14. tmps => $args{tmps},
  15. };
  16. # Import common functions in Pisg::Common
  17. require Pisg::Common;
  18. Pisg::Common->import();
  19. bless($self, $type);
  20. return $self;
  21. }
  22. sub create_html
  23. {
  24. # This subroutine calls all the subroutines which create their
  25. # individual stats. The name of the functions is somewhat saying - if
  26. # you don't understand it, most subs have a better explanation in the
  27. # sub itself.
  28. my $self = shift;
  29. print "Now generating HTML($self->{cfg}->{outputfile})...\n"
  30. unless ($self->{cfg}->{silent});
  31. open (OUTPUT, "> $self->{cfg}->{outputfile}") or
  32. die("$0: Unable to open outputfile($self->{cfg}->{outputfile}): $!\n");
  33. if ($self->{cfg}->{showtime}) {
  34. $self->{cfg}->{tablewidth} += 40;
  35. }
  36. if ($self->{cfg}->{showlinetime}) {
  37. $self->{cfg}->{tablewidth} += 100;
  38. }
  39. if ($self->{cfg}->{showwordtime}) {
  40. $self->{cfg}->{tablewidth} += 100;
  41. }
  42. if ($self->{cfg}->{showwords}) {
  43. $self->{cfg}->{tablewidth} += 40;
  44. }
  45. if ($self->{cfg}->{showwpl}) {
  46. $self->{cfg}->{tablewidth} += 40;
  47. }
  48. if ($self->{cfg}->{showcpl}) {
  49. $self->{cfg}->{tablewidth} += 40;
  50. }
  51. $self->{cfg}->{headwidth} = $self->{cfg}->{tablewidth} - 4;
  52. $self->_htmlheader();
  53. $self->_pageheader()
  54. if ($self->{cfg}->{pagehead} ne 'none');
  55. if ($self->{cfg}->{showactivetimes}) {
  56. $self->_activetimes();
  57. }
  58. $self->_activenicks();
  59. if ($self->{cfg}->{showmostactivebyhour}) {
  60. $self->_mostactivebyhour();
  61. }
  62. if ($self->{cfg}->{showbignumbers}) {
  63. $self->_headline($self->_template_text('bignumtopic'));
  64. _html("<table width=\"$self->{cfg}->{tablewidth}\">\n"); # Needed for sections
  65. $self->_questions();
  66. $self->_shoutpeople();
  67. $self->_capspeople();
  68. $self->_violent();
  69. $self->_mostsmiles();
  70. $self->_mostsad();
  71. $self->_linelengths();
  72. $self->_mostwords();
  73. $self->_mostwordsperline();
  74. _html("</table>"); # Needed for sections
  75. }
  76. if ($self->{cfg}->{showmostnicks}) {
  77. $self->_mostnicks();
  78. }
  79. if ($self->{cfg}->{showmuw}) {
  80. $self->_mostusedword();
  81. }
  82. if ($self->{cfg}->{showmrn}) {
  83. $self->_mostreferencednicks();
  84. }
  85. if ($self->{cfg}->{showmru}) {
  86. $self->_mosturls();
  87. }
  88. if ($self->{cfg}->{showbignumbers}) {
  89. $self->_headline($self->_template_text('othernumtopic'));
  90. _html("<table width=\"$self->{cfg}->{tablewidth}\">\n"); # Needed for sections
  91. $self->_gotkicks();
  92. $self->_mostkicks();
  93. $self->_mostop();
  94. $self->_mostvoice() if $self->{cfg}->{showvoices};
  95. $self->_mostactions();
  96. $self->_mostmonologues();
  97. $self->_mostjoins();
  98. $self->_mostfoul();
  99. _html("</table>"); # Needed for sections
  100. }
  101. $self->_headline($self->_template_text('latesttopic'));
  102. _html("<table width=\"$self->{cfg}->{tablewidth}\">\n"); # Needed for sections
  103. $self->_lasttopics()
  104. if ($self->{cfg}->{showtopics});
  105. _html("</table>"); # Needed for sections
  106. my %hash = ( lines => $self->{stats}->{totallines} );
  107. _html($self->_template_text('totallines', %hash) . "<br /><br />");
  108. $self->_pagefooter()
  109. if ($self->{cfg}->{pagefoot} ne 'none');
  110. $self->_htmlfooter();
  111. close(OUTPUT);
  112. }
  113. sub _htmlheader
  114. {
  115. my $self = shift;
  116. my $bgpic = "";
  117. my %hash = (
  118. network => $self->{cfg}->{network},
  119. maintainer => $self->{cfg}->{maintainer},
  120. days => $self->{stats}->{days},
  121. nicks => scalar keys %{ $self->{stats}->{lines} }
  122. );
  123. my $css_file = $self->{cfg}->{cssdir} . $self->{cfg}->{colorscheme} . ".css";
  124. # Get the chosen CSS file
  125. open(FILE, $css_file) or open (FILE, $self->{cfg}->{search_path} . "/$css_file") or die("$0: Unable to open stylesheet($css_file): $!\n");
  126. my @CSS = <FILE>;
  127. my $title = $self->_template_text('pagetitle1', %hash);
  128. if ($self->{cfg}->{bgpic}) {
  129. $bgpic = " background=\"$self->{cfg}->{bgpic}\"";
  130. }
  131. print OUTPUT <<HTML;
  132. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  133. <html>
  134. <head>
  135. <meta http-equiv="Content-Type" content="text/html; charset=$self->{cfg}->{charset}" />
  136. <title>$title</title>
  137. <style type="text/css">
  138. @CSS
  139. </style></head>
  140. <body$bgpic>
  141. <div align="center">
  142. HTML
  143. _html("<span class=\"title\">$title</span><br />");
  144. _html("<br />");
  145. _html($self->_template_text('pagetitle2', %hash) . " " . $self->get_time());
  146. _html("<br />" . $self->_template_text('pagetitle3', %hash) . "<br /><br />");
  147. }
  148. sub get_time
  149. {
  150. my $self = shift;
  151. my ($tday, %hash);
  152. my $month = $self->_template_text('month', %hash);
  153. my $day = $self->_template_text('day', %hash);
  154. my @month = split(" ", $month);
  155. my @day = split(" ", $day);
  156. # Get the Date from the users computer
  157. my $timezone = $self->{cfg}->{timeoffset} * 3600;
  158. my ($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime(time+$timezone);
  159. $year += 1900; # Y2K Patch
  160. $min =~ s/^(.)$/0$1/; # Fixes the display of mins/secs below
  161. $sec =~ s/^(.)$/0$1/; # it displays 03 instead of 3
  162. if ($hour > '23') { # Checks to see if it Midnight
  163. $hour = 12; # Makes it display the hour 12
  164. $tday = "AM"; # Display AM
  165. } elsif($hour > '12') { # Get rid of the Military time and
  166. $hour -= 12; # put it into normal time
  167. $tday = "PM"; # If past Noon and before Midnight set
  168. } else {
  169. $tday = "AM"; # If it's past Midnight and before Noon
  170. } # set the time as AM
  171. # Use 24 hours pr. day
  172. if ($tday eq "PM" && $hour < '12') {
  173. $hour += 12;
  174. }
  175. return "$day[$wday] $mday $month[$mon] $year - $hour:$min:$sec";
  176. }
  177. sub _htmlfooter
  178. {
  179. my $self = shift;
  180. my %hash;
  181. my $pisg_hp = $self->_template_text('pisghomepage');
  182. $hash{pisg_url} = "<a href=\"http://pisg.sourceforge.net/\" title=\"$pisg_hp\" class=\"background\">pisg</a>";
  183. my $author_hp = $self->_template_text('authorhomepage');
  184. $hash{author_url} = "<a href=\"http://wtf.dk/hp/\" title=\"$author_hp\" class=\"background\">Morten Brix Pedersen</a>";
  185. $hash{version} = $self->{cfg}->{version};
  186. my $hours = $self->_template_text('hours');
  187. my $mins = $self->_template_text('minutes');
  188. my $secs = $self->_template_text('seconds');
  189. my $and = $self->_template_text('and');
  190. my $h = $self->{stats}->{processtime}{hours};
  191. my $m = $self->{stats}->{processtime}{mins};
  192. my $s = $self->{stats}->{processtime}{secs};
  193. $hash{time} = "$h $hours $m $mins $and $s $secs";
  194. my $stats_gen = $self->_template_text('stats_gen_by', %hash);
  195. my $author_text = $self->_template_text('author', %hash);
  196. my $stats_text = $self->_template_text('stats_gen_in', %hash);
  197. print OUTPUT <<HTML;
  198. <span class="small">
  199. $stats_gen<br />
  200. $author_text<br />
  201. $stats_text
  202. </span>
  203. </div>
  204. </body>
  205. </html>
  206. HTML
  207. }
  208. sub _headline
  209. {
  210. my $self = shift;
  211. my ($title) = (@_);
  212. print OUTPUT <<HTML;
  213. <br />
  214. <table width="$self->{cfg}->{headwidth}" cellpadding="1" cellspacing="0" border="0">
  215. <tr>
  216. <td class="headlinebg">
  217. <table width="100%" cellpadding="2" cellspacing="0" border="0">
  218. <tr>
  219. <td class="headtext">$title</td>
  220. </tr>
  221. </table>
  222. </td>
  223. </tr>
  224. </table>
  225. HTML
  226. }
  227. sub _pageheader
  228. {
  229. my $self = shift;
  230. open(PAGEHEAD, $self->{cfg}->{pagehead}) or die("$0: Unable to open $self->{cfg}->{pagehead} for reading: $!\n");
  231. while (<PAGEHEAD>) {
  232. _html($_);
  233. }
  234. close(PAGEHEAD);
  235. }
  236. sub _pagefooter
  237. {
  238. my $self = shift;
  239. open(PAGEFOOT, $self->{cfg}->{pagefoot}) or die("$0: Unable to open $self->{cfg}->{pagefoot} for reading: $!\n");
  240. while (<PAGEFOOT>) {
  241. _html($_);
  242. }
  243. close(PAGEFOOT);
  244. }
  245. sub _activetimes
  246. {
  247. # The most actives times on the channel
  248. my $self = shift;
  249. my (%output, $class);
  250. $self->_headline($self->_template_text('activetimestopic'));
  251. my @toptime = sort { $self->{stats}->{times}{$b} <=> $self->{stats}->{times}{$a} } keys %{ $self->{stats}->{times} };
  252. my $highest_value = $self->{stats}->{times}{$toptime[0]};
  253. my @now = localtime($self->{cfg}->{timestamp});
  254. my $image;
  255. for my $hour (sort keys %{ $self->{stats}->{times} }) {
  256. my $size = ($self->{stats}->{times}{$hour} / $highest_value) * 100;
  257. my $percent = ($self->{stats}->{times}{$hour} / $self->{stats}->{totallines}) * 100;
  258. $percent =~ s/(\.\d)\d+/$1/;
  259. if ($size < 1 && $size != 0) {
  260. # Opera doesn't understand '0.xxxx' in the height="xx" attr,
  261. # so we simply round up to 1.0 here.
  262. $size = 1.0;
  263. }
  264. $image = "pic_v_".(int($hour/6)*6);
  265. $image = $self->{cfg}->{$image};
  266. $output{$hour} = "<td align=\"center\" valign=\"bottom\" class=\"asmall\">$percent%<br /><img src=\"$self->{cfg}->{piclocation}/$image\" width=\"15\" height=\"$size\" alt=\"$percent\" /></td>\n";
  267. }
  268. _html("<table border=\"0\"><tr>\n");
  269. for ($b = 0; $b < 24; $b++) {
  270. $a = sprintf("%02d", $b);
  271. if (!defined($output{$a}) || $output{$a} eq "") {
  272. _html("<td align=\"center\" valign=\"bottom\" class=\"asmall\">0%</td>");
  273. } else {
  274. _html($output{$a});
  275. }
  276. }
  277. _html("</tr><tr>");
  278. # Remove leading zero
  279. $toptime[0] =~ s/0(\d)/$1/;
  280. for ($b = 0; $b < 24; $b++) {
  281. if ($toptime[0] == $b) {
  282. # Highlight the top time
  283. $class = 'hirankc10center';
  284. } else {
  285. $class = 'rankc10center';
  286. }
  287. _html("<td class=\"$class\" align=\"center\">$b</td>");
  288. }
  289. _html("</tr></table>");
  290. if($self->{cfg}->{showlegend} == 1) {
  291. $self->_legend();
  292. }
  293. }
  294. sub _activenicks
  295. {
  296. # The most active nicks (those who wrote most lines)
  297. my $self = shift;
  298. $self->_headline($self->_template_text('activenickstopic'));
  299. _html("<table border=\"0\" width=\"$self->{cfg}->{tablewidth}\"><tr>");
  300. _html("<td>&nbsp;</td>"
  301. . "<td class=\"tdtop\"><b>" . $self->_template_text('nick') . "</b></td>"
  302. . "<td class=\"tdtop\"><b>" . $self->_template_text('numberlines') . "</b></td>"
  303. . ($self->{cfg}->{showtime} ? "<td class=\"tdtop\"><b>".$self->_template_text('show_time')."</b></td>" : "")
  304. . ($self->{cfg}->{showwords} ? "<td class=\"tdtop\"><b>".$self->_template_text('show_words')."</b></td>" : "")
  305. . ($self->{cfg}->{showwpl} ? "<td class=\"tdtop\"><b>".$self->_template_text('show_wpl')."</b></td>" : "")
  306. . ($self->{cfg}->{showcpl} ? "<td class=\"tdtop\"><b>".$self->_template_text('show_cpl')."</b></td>" : "")
  307. . ($self->{cfg}->{showlastseen} ? "<td class=\"tdtop\"><b>".$self->_template_text('show_lastseen')."</b></td>" : "")
  308. . ($self->{cfg}->{showrandquote} ? "<td class=\"tdtop\"><b>".$self->_template_text('randquote')."</b></td>" : "")
  309. );
  310. my @active;
  311. my $nicks;
  312. if ($self->{cfg}->{sortbywords}) {
  313. @active = sort { $self->{stats}->{words}{$b} <=> $self->{stats}->{words}{$a} } keys %{ $self->{stats}->{words} };
  314. $nicks = scalar keys %{ $self->{stats}->{words} };
  315. } else {
  316. @active = sort { $self->{stats}->{lines}{$b} <=> $self->{stats}->{lines}{$a} } keys %{ $self->{stats}->{lines} };
  317. $nicks = scalar keys %{ $self->{stats}->{lines} };
  318. }
  319. if ($self->{cfg}->{activenicks} > $nicks) { $self->{cfg}->{activenicks} = $nicks; }
  320. my $have_userpics;
  321. for (my $c = 0; $c < $self->{cfg}->{activenicks}; $c++) {
  322. my $nick = $active[$c];
  323. if ($self->{users}->{userpics}{$nick} && $self->{cfg}->{userpics} !~ /n/i) {
  324. $have_userpics = 1;
  325. _html("<td class=\"tdtop\"><b>" . $self->_template_text('userpic') ."</b></td>");
  326. last;
  327. }
  328. }
  329. _html("</tr>");
  330. for (my $i = 0; $i < $self->{cfg}->{activenicks}; $i++) {
  331. my $c = $i + 1;
  332. my $nick = $active[$i];
  333. my $visiblenick = $active[$i];
  334. my $randomline;
  335. if (not defined $self->{stats}->{sayings}{$nick}) {
  336. $randomline = "";
  337. } else {
  338. $randomline = htmlentities($self->{stats}->{sayings}{$nick});
  339. }
  340. # Convert URLs and e-mail addys to links
  341. $randomline = $self->_replace_links($randomline);
  342. # Add a link to the nick if there is any
  343. if ($self->{users}->{userlinks}{$nick}) {
  344. $visiblenick = $self->_replace_links($self->{users}->{userlinks}{$nick}, $nick);
  345. }
  346. my $color = $self->generate_colors($c);
  347. my $class = 'rankc';
  348. if ($c == 1) {
  349. $class = 'hirankc';
  350. }
  351. my $lastseen;
  352. if ($self->{cfg}->{showlastseen}) {
  353. $lastseen = $self->{stats}->{days} - $self->{stats}->{lastvisited}{$nick};
  354. if ($lastseen == 0) {
  355. $lastseen = $self->_template_text('today');
  356. } elsif ($lastseen == 1) {
  357. $lastseen = "$lastseen " .$self->_template_text('lastseen1');
  358. } else {
  359. $lastseen = "$lastseen " .$self->_template_text('lastseen2');
  360. }
  361. }
  362. _html("<tr><td class=\"$class\" align=\"left\">$c</td>");
  363. my $line = $self->{stats}->{lines}{$nick};
  364. my $w = $self->{stats}->{words}{$nick} ? $self->{stats}->{words}{$nick} : 0;
  365. my $ch = $self->{stats}->{lengths}{$nick};
  366. _html("<td style=\"background-color: $color\">$visiblenick</td>"
  367. . ($self->{cfg}->{showlinetime} ?
  368. "<td style=\"background-color: $color\" nowrap=\"nowrap\">".$self->_user_linetimes($nick,$active[0])."</td>"
  369. : "<td style=\"background-color: $color\">$line</td>")
  370. . ($self->{cfg}->{showtime} ?
  371. "<td style=\"background-color: $color\">".$self->_user_times($nick)."</td>"
  372. : "")
  373. . ($self->{cfg}->{showwords} ?
  374. ($self->{cfg}->{showwordtime} ?
  375. "<td style=\"background-color: $color\" nowrap=\"nowrap\">".$self->_user_wordtimes($nick,$active[0])."</td>"
  376. : "<td style=\"background-color: $color\">$w</td>")
  377. : "")
  378. . ($self->{cfg}->{showwpl} ?
  379. "<td style=\"background-color: $color\">".sprintf("%.1f",$w/$line)."</td>"
  380. : "")
  381. . ($self->{cfg}->{showcpl} ?
  382. "<td style=\"background-color: $color\">".sprintf("%.1f",$ch/$line)."</td>"
  383. : "")
  384. . ($self->{cfg}->{showlastseen} ?
  385. "<td style=\"background-color: $color\">$lastseen</td>"
  386. : "")
  387. . ($self->{cfg}->{showrandquote} ?
  388. "<td style=\"background-color: $color\">\"$randomline\"</td>"
  389. : "")
  390. );
  391. my $height = $self->{cfg}->{picheight};
  392. my $width = $self->{cfg}->{picwidth};
  393. if ($self->{users}->{userpics}{$nick} && $self->{cfg}->{userpics} !~ /n/i) {
  394. _html("<td style=\"background-color: $color\" align=\"center\">");
  395. if (defined $self->{users}->{biguserpics}{$nick}) {
  396. _html("<a href=\"$self->{cfg}->{imagepath}$self->{users}->{biguserpics}{$nick}\">");
  397. }
  398. if ($width ne '') {
  399. _html("<img valign=\"middle\" src=\"$self->{cfg}->{imagepath}$self->{users}->{userpics}{$nick}\" width=\"$width\" height=\"$height\" alt=\"$nick\" />");
  400. } else {
  401. _html("<img valign=\"middle\" src=\"$self->{cfg}->{imagepath}$self->{users}->{userpics}{$nick}\" alt=\"$nick\" />");
  402. }
  403. if (defined $self->{users}->{biguserpics}{$nick}) {
  404. _html("</a>");
  405. }
  406. _html("</td>");
  407. } elsif ($self->{cfg}->{defaultpic} ne '' && $self->{cfg}->{userpics} !~ /n/i) {
  408. _html("<td style=\"background-color: $color\" align=\"center\"><img valign=\"middle\" src=\"$self->{cfg}->{imagepath}$self->{cfg}->{defaultpic}\" alt=\"\" /></td>");
  409. }
  410. _html("</tr>");
  411. }
  412. _html("</table><br />");
  413. # Almost as active nicks ('These didn't make it to the top..')
  414. my $toshow = $self->{cfg}->{activenicks2} - $self->{cfg}->{activenicks};
  415. my $remain = $self->{cfg}->{activenicks} + $toshow;
  416. unless ($toshow > $nicks) {
  417. $remain = $self->{cfg}->{activenicks} + $self->{cfg}->{activenicks2};
  418. if ($remain > $nicks) {
  419. $remain = $nicks;
  420. }
  421. if ($self->{cfg}->{activenicks} < $remain) {
  422. _html("<br /><b><i>" . $self->_template_text('nottop') . "</i></b><table><tr>");
  423. for (my $i = $self->{cfg}->{activenicks}; $i < $remain; $i++) {
  424. unless ($i % 5) { if ($i != $self->{cfg}->{activenicks}) { _html("</tr><tr>"); } }
  425. my $items;
  426. if ($self->{cfg}->{sortbywords}) {
  427. $items = $self->{stats}->{words}{$active[$i]};
  428. } else {
  429. $items = $self->{stats}->{lines}{$active[$i]};
  430. }
  431. _html("<td class=\"rankc10\">$active[$i] ($items)</td>");
  432. }
  433. _html("</tr></table>");
  434. }
  435. }
  436. my %hash;
  437. $hash{totalnicks} = $nicks - $remain;
  438. if ($hash{totalnicks} > 0) {
  439. _html("<br /><b>" . $self->_template_text('totalnicks', %hash) . "</b><br />");
  440. }
  441. }
  442. sub generate_colors
  443. {
  444. my $self = shift;
  445. my $c = shift;
  446. my $h = $self->{cfg}->{hicell};
  447. $h =~ s/^#//;
  448. $h = hex $h;
  449. my $h2 = $self->{cfg}->{hicell2};
  450. $h2 =~ s/^#//;
  451. $h2 = hex $h2;
  452. my $f_b = $h & 0xff;
  453. my $f_g = ($h & 0xff00) >> 8;
  454. my $f_r = ($h & 0xff0000) >> 16;
  455. my $t_b = $h2 & 0xff;
  456. my $t_g = ($h2 & 0xff00) >> 8;
  457. my $t_r = ($h2 & 0xff0000) >> 16;
  458. my $blue = sprintf "%0.2x", abs int(((($t_b - $f_b) / $self->{cfg}->{activenicks}) * +$c) + $f_b);
  459. my $green = sprintf "%0.2x", abs int(((($t_g - $f_g) / $self->{cfg}->{activenicks}) * +$c) + $f_g);
  460. my $red = sprintf "%0.2x", abs int(((($t_r - $f_r) / $self->{cfg}->{activenicks}) * +$c) + $f_r);
  461. return "#$red$green$blue";
  462. }
  463. sub _html
  464. {
  465. my $html = shift;
  466. print OUTPUT "$html\n";
  467. }
  468. sub _questions
  469. {
  470. # Persons who asked the most questions
  471. my $self = shift;
  472. my %qpercent;
  473. foreach my $nick (sort keys %{ $self->{stats}->{questions} }) {
  474. if ($self->{stats}->{lines}{$nick} > 100) {
  475. $qpercent{$nick} = ($self->{stats}->{questions}{$nick} / $self->{stats}->{lines}{$nick}) * 100;
  476. $qpercent{$nick} =~ s/(\.\d)\d+/$1/;
  477. }
  478. }
  479. my @question = sort { $qpercent{$b} <=> $qpercent{$a} } keys %qpercent;
  480. if (@question) {
  481. my %hash = (
  482. nick => $question[0],
  483. per => $qpercent{$question[0]}
  484. );
  485. my $text = $self->_template_text('question1', %hash);
  486. _html("<tr><td class=\"hicell\">$text");
  487. if (@question >= 2) {
  488. my %hash = (
  489. nick => $question[1],
  490. per => $qpercent{$question[1]}
  491. );
  492. my $text = $self->_template_text('question2', %hash);
  493. _html("<br /><span class=\"small\">$text</span>");
  494. }
  495. _html("</td></tr>");
  496. } else {
  497. _html("<tr><td class=\"hicell\">" . $self->_template_text('question3') . "</td></tr>");
  498. }
  499. }
  500. sub _shoutpeople
  501. {
  502. # The ones who speak with exclamation marks!
  503. my $self = shift;
  504. my %spercent;
  505. foreach my $nick (sort keys %{ $self->{stats}->{shouts} }) {
  506. if ($self->{stats}->{lines}{$nick} > 100) {
  507. $spercent{$nick} = ($self->{stats}->{shouts}{$nick} / $self->{stats}->{lines}{$nick}) * 100;
  508. $spercent{$nick} =~ s/(\.\d)\d+/$1/;
  509. }
  510. }
  511. my @shout = sort { $spercent{$b} <=> $spercent{$a} } keys %spercent;
  512. if (@shout) {
  513. my %hash = (
  514. nick => $shout[0],
  515. per => $spercent{$shout[0]}
  516. );
  517. my $text = $self->_template_text('shout1', %hash);
  518. _html("<tr><td class=\"hicell\">$text");
  519. if (@shout >= 2) {
  520. my %hash = (
  521. nick => $shout[1],
  522. per => $spercent{$shout[1]}
  523. );
  524. my $text = $self->_template_text('shout2', %hash);
  525. _html("<br /><span class=\"small\">$text</span>");
  526. }
  527. _html("</td></tr>");
  528. } else {
  529. my $text = $self->_template_text('shout3');
  530. _html("<tr><td class=\"hicell\">$text</td></tr>");
  531. }
  532. }
  533. sub _capspeople
  534. {
  535. # The ones who speak ALL CAPS.
  536. my $self = shift;
  537. my %cpercent;
  538. foreach my $nick (sort keys %{ $self->{stats}->{allcaps} }) {
  539. if ($self->{stats}->{lines}{$nick} > 100) {
  540. $cpercent{$nick} = $self->{stats}->{allcaps}{$nick} / $self->{stats}->{lines}{$nick} * 100;
  541. $cpercent{$nick} =~ s/(\.\d)\d+/$1/;
  542. }
  543. }
  544. my @caps = sort { $cpercent{$b} <=> $cpercent{$a} } keys %cpercent;
  545. if (@caps) {
  546. my %hash = (
  547. nick => $caps[0],
  548. per => $cpercent{$caps[0]},
  549. line => htmlentities($self->{stats}->{allcaplines}{$caps[0]})
  550. );
  551. my $text = $self->_template_text('allcaps1', %hash);
  552. if($self->{cfg}->{showshoutline}) {
  553. my $exttext = $self->_template_text('allcapstext', %hash);
  554. _html("<tr><td class=\"hicell\">$text<br /><span class=\"small\">$exttext</span><br />");
  555. } else {
  556. _html("<tr><td class=\"hicell\">$text");
  557. }
  558. if (@caps >= 2) {
  559. my %hash = (
  560. nick => $caps[1],
  561. per => $cpercent{$caps[1]}
  562. );
  563. my $text = $self->_template_text('allcaps2', %hash);
  564. _html("<br /><span class=\"small\">$text</span>");
  565. }
  566. _html("</td></tr>");
  567. } else {
  568. my $text = $self->_template_text('allcaps3');
  569. _html("<tr><td class=\"hicell\">$text</td></tr>");
  570. }
  571. }
  572. sub _violent
  573. {
  574. # They attacked others (words defined by $self->{cfg}->{violent})
  575. my $self = shift;
  576. my @aggressors;
  577. @aggressors = sort { $self->{stats}->{violence}{$b} <=> $self->{stats}->{violence}{$a} }
  578. keys %{ $self->{stats}->{violence} };
  579. if(@aggressors) {
  580. my %hash = (
  581. nick => $aggressors[0],
  582. attacks => $self->{stats}->{violence}{$aggressors[0]},
  583. line => htmlentities($self->{stats}->{violencelines}{$aggressors[0]})
  584. );
  585. my $text = $self->_template_text('violent1', %hash);
  586. if($self->{cfg}->{showviolentlines}) {
  587. my $exttext = $self->_template_text('violenttext', %hash);
  588. _html("<tr><td class=\"hicell\">$text<br /><span class=\"small\">$exttext</span><br />");
  589. } else {
  590. _html("<tr><td class=\"hicell\">$text");
  591. }
  592. if (@aggressors >= 2) {
  593. my %hash = (
  594. nick => $aggressors[1],
  595. attacks => $self->{stats}->{violence}{$aggressors[1]}
  596. );
  597. my $text = $self->_template_text('violent2', %hash);
  598. _html("<br /><span class=\"small\">$text</span>");
  599. }
  600. _html("</td></tr>");
  601. } else {
  602. my $text = $self->_template_text('violent3');
  603. _html("<tr><td class=\"hicell\">$text</td></tr>");
  604. }
  605. # They got attacked
  606. my @victims;
  607. @victims = sort { $self->{stats}->{attacked}{$b} <=> $self->{stats}->{attacked}{$a} }
  608. keys %{ $self->{stats}->{attacked} };
  609. if(@victims) {
  610. my %hash = (
  611. nick => $victims[0],
  612. attacks => $self->{stats}->{attacked}{$victims[0]},
  613. line => htmlentities($self->{stats}->{attackedlines}{$victims[0]})
  614. );
  615. my $text = $self->_template_text('attacked1', %hash);
  616. if($self->{cfg}->{showviolentlines}) {
  617. my $exttext = $self->_template_text('attackedtext', %hash);
  618. _html("<tr><td class=\"hicell\">$text<br /><span class=\"small\">$exttext</span><br />");
  619. } else {
  620. _html("<tr><td class=\"hicell\">$text");
  621. }
  622. if (@victims >= 2) {
  623. my %hash = (
  624. nick => $victims[1],
  625. attacks => $self->{stats}->{attacked}{$victims[1]}
  626. );
  627. my $text = $self->_template_text('attacked2', %hash);
  628. _html("<br /><span class=\"small\">$text</span>");
  629. }
  630. _html("</td></tr>");
  631. }
  632. }
  633. sub _gotkicks
  634. {
  635. # The persons who got kicked the most
  636. my $self = shift;
  637. my @gotkick = sort { $self->{stats}->{gotkicked}{$b} <=> $self->{stats}->{gotkicked}{$a} }
  638. keys %{ $self->{stats}->{gotkicked} };
  639. if (@gotkick) {
  640. my %hash = (
  641. nick => $gotkick[0],
  642. kicks => $self->{stats}->{gotkicked}{$gotkick[0]},
  643. line => $self->{stats}->{kicklines}{$gotkick[0]}
  644. );
  645. my $text = $self->_template_text('gotkick1', %hash);
  646. if ($self->{cfg}->{showkickline}) {
  647. my $exttext = $self->_template_text('kicktext', %hash);
  648. _html("<tr><td class=\"hicell\">$text<br /><span class=\"small\">$exttext</span><br />");
  649. } else {
  650. _html("<tr><td class=\"hicell\">$text");
  651. }
  652. if (@gotkick >= 2) {
  653. my %hash = (
  654. nick => $gotkick[1],
  655. kicks => $self->{stats}->{gotkicked}{$gotkick[1]}
  656. );
  657. my $text = $self->_template_text('gotkick2', %hash);
  658. _html("<br /><span class=\"small\">$text</span>");
  659. }
  660. _html("</td></tr>");
  661. }
  662. }
  663. sub _mostjoins
  664. {
  665. my $self = shift;
  666. my @joins = sort { $self->{stats}->{joins}{$b} <=> $self->{stats}->{joins}{$a} }
  667. keys %{ $self->{stats}->{joins} };
  668. if (@joins) {
  669. my %hash = (
  670. nick => $joins[0],
  671. joins => $self->{stats}->{joins}{$joins[0]}
  672. );
  673. my $text = $self->_template_text('joins', %hash);
  674. _html("<tr><td class=\"hicell\">$text</td></tr>");
  675. }
  676. }
  677. sub _mostwords
  678. {
  679. # The person who got words the most
  680. my $self = shift;
  681. my @words = sort { $self->{stats}->{words}{$b} <=> $self->{stats}->{words}{$a} }
  682. keys %{ $self->{stats}->{words} };
  683. if (@words) {
  684. my %hash = (
  685. nick => $words[0],
  686. words => $self->{stats}->{words}{$words[0]}
  687. );
  688. my $text = $self->_template_text('words1', %hash);
  689. _html("<tr><td class=\"hicell\">$text");
  690. if (@words >= 2) {
  691. my %hash = (
  692. oldnick => $words[0],
  693. nick => $words[1],
  694. words => $self->{stats}->{words}{$words[1]}
  695. );
  696. my $text = $self->_template_text('words2', %hash);
  697. _html("<br /><span class=\"small\">$text</span>");
  698. }
  699. _html("</td></tr>");
  700. } else {
  701. my $text = $self->_template_text('kick3');
  702. _html("<tr><td class=\"hicell\">$text</td></tr>");
  703. }
  704. }
  705. sub _mostkicks
  706. {
  707. # The person who kicked the most
  708. my $self = shift;
  709. my @kicked = sort { $self->{stats}->{kicked}{$b} <=> $self->{stats}->{kicked}{$a} }
  710. keys %{ $self->{stats}->{kicked} };
  711. if (@kicked) {
  712. my %hash = (
  713. nick => $kicked[0],
  714. kicked => $self->{stats}->{kicked}{$kicked[0]}
  715. );
  716. my $text = $self->_template_text('kick1', %hash);
  717. _html("<tr><td class=\"hicell\">$text");
  718. if (@kicked >= 2) {
  719. my %hash = (
  720. oldnick => $kicked[0],
  721. nick => $kicked[1],
  722. kicked => $self->{stats}->{kicked}{$kicked[1]}
  723. );
  724. my $text = $self->_template_text('kick2', %hash);
  725. _html("<br /><span class=\"small\">$text</span>");
  726. }
  727. _html("</td></tr>");
  728. } else {
  729. my $text = $self->_template_text('kick3');
  730. _html("<tr><td class=\"hicell\">$text</td></tr>");
  731. }
  732. }
  733. sub _mostmonologues
  734. {
  735. # The person who had the most monologues (speaking to himself)
  736. my $self = shift;
  737. my @monologue = sort { $self->{stats}->{monologues}{$b} <=> $self->{stats}->{monologues}{$a} } keys %{ $self->{stats}->{monologues} };
  738. if (@monologue) {
  739. my %hash = (
  740. nick => $monologue[0],
  741. monos => $self->{stats}->{monologues}{$monologue[0]}
  742. );
  743. my $text = $self->_template_text('mono1', %hash);
  744. _html("<tr><td class=\"hicell\">$text");
  745. if (@monologue >= 2) {
  746. my %hash = (
  747. nick => $monologue[1],
  748. monos => $self->{stats}->{monologues}{$monologue[1]}
  749. );
  750. my $text = $self->_template_text('mono2', %hash);
  751. _html("<br /><span class=\"small\">$text</span>");
  752. }
  753. _html("</td></tr>");
  754. }
  755. }
  756. sub _linelengths
  757. {
  758. # The person(s) who wrote the longest lines
  759. my $self = shift;
  760. my %len;
  761. foreach my $nick (sort keys %{ $self->{stats}->{lengths} }) {
  762. if ($self->{stats}->{lines}{$nick} > 100) {
  763. $len{$nick} = $self->{stats}->{lengths}{$nick} / $self->{stats}->{lines}{$nick};
  764. $len{$nick} =~ s/(\.\d)\d+/$1/;
  765. }
  766. }
  767. my @len = sort { $len{$b} <=> $len{$a} } keys %len;
  768. my $all_lines = 0;
  769. my $totallength;
  770. foreach my $nick (keys %{ $self->{stats}->{lines} }) {
  771. $all_lines += $self->{stats}->{lines}{$nick};
  772. $totallength += $self->{stats}->{lengths}{$nick};
  773. }
  774. my $totalaverage;
  775. if ($all_lines > 0) {
  776. $totalaverage = $totallength / $all_lines;
  777. $totalaverage =~ s/(\.\d)\d+/$1/;
  778. }
  779. if (@len) {
  780. my %hash = (
  781. nick => $len[0],
  782. letters => $len{$len[0]}
  783. );
  784. my $text = $self->_template_text('long1', %hash);
  785. _html("<tr><td class=\"hicell\">$text<br />");
  786. if (@len >= 2) {
  787. %hash = (
  788. avg => $totalaverage
  789. );
  790. $text = $self->_template_text('long2', %hash);
  791. _html("<span class=\"small\">$text</span></td></tr>");
  792. }
  793. }
  794. # The person(s) who wrote the shortest lines
  795. if (@len) {
  796. my %hash = (
  797. nick => $len[$#len],
  798. letters => $len{$len[$#len]}
  799. );
  800. my $text = $self->_template_text('short1', %hash);
  801. _html("<tr><td class=\"hicell\">$text<br />");
  802. if (@len >= 2) {
  803. %hash = (
  804. nick => $len[$#len - 1],
  805. letters => $len{$len[$#len - 1]}
  806. );
  807. $text = $self->_template_text('short2', %hash);
  808. _html("<span class=\"small\">$text</span></td></tr>");
  809. }
  810. }
  811. }
  812. sub _mostfoul
  813. {
  814. my $self = shift;
  815. my %spercent;
  816. foreach my $nick (sort keys %{ $self->{stats}->{foul} }) {
  817. if ($self->{stats}->{lines}{$nick} > 15) {
  818. $spercent{$nick} = $self->{stats}->{foul}{$nick} / $self->{stats}->{words}{$nick} * 100;
  819. $spercent{$nick} =~ s/(\.\d)\d+/$1/;
  820. }
  821. }
  822. my @foul = sort { $spercent{$b} <=> $spercent{$a} } keys %spercent;
  823. if (@foul) {
  824. my %hash = (
  825. nick => $foul[0],
  826. per => $spercent{$foul[0]},
  827. line => htmlentities($self->{stats}{foullines}{$foul[0]}),
  828. );
  829. my $text = $self->_template_text('foul1', %hash);
  830. if($self->{cfg}->{showfoulline}) {
  831. my $exttext = $self->_template_text('foultext', %hash);
  832. _html("<tr><td class=\"hicell\">$text<br /><span class=\"small\">$exttext</span><br />");
  833. } else {
  834. _html("<tr><td class=\"hicell\">$text");
  835. }
  836. if (@foul >= 2) {
  837. my %hash = (
  838. nick => $foul[1],
  839. per => $spercent{$foul[1]}
  840. );
  841. my $text = $self->_template_text('foul2', %hash);
  842. _html("<br /><span class=\"small\">$text</span>");
  843. }
  844. _html("</td></tr>");
  845. } else {
  846. my $text = $self->_template_text('foul3');
  847. _html("<tr><td class=\"hicell\">$text</td></tr>");
  848. }
  849. }
  850. sub _mostsad
  851. {
  852. my $self = shift;
  853. my %spercent;
  854. foreach my $nick (sort keys %{ $self->{stats}->{frowns} }) {
  855. if ($self->{stats}->{lines}{$nick} > 100) {
  856. $spercent{$nick} = $self->{stats}->{frowns}{$nick} / $self->{stats}->{lines}{$nick} * 100;
  857. $spercent{$nick} =~ s/(\.\d)\d+/$1/;
  858. }
  859. }
  860. my @sadface = sort { $spercent{$b} <=> $spercent{$a} } keys %spercent;
  861. if (@sadface) {
  862. my %hash = (
  863. nick => $sadface[0],
  864. per => $spercent{$sadface[0]}
  865. );
  866. my $text = $self->_template_text('sad1', %hash);
  867. _html("<tr><td class=\"hicell\">$text");
  868. if (@sadface >= 2) {
  869. my %hash = (
  870. nick => $sadface[1],
  871. per => $spercent{$sadface[1]}
  872. );
  873. my $text = $self->_template_text('sad2', %hash);
  874. _html("<br /><span class=\"small\">$text</span>");
  875. }
  876. _html("</td></tr>");
  877. } else {
  878. my $text = $self->_template_text('sad3');
  879. _html("<tr><td class=\"hicell\">$text</td></tr>");
  880. }
  881. }
  882. sub _mostop
  883. {
  884. my $self = shift;
  885. my @ops = sort { $self->{stats}->{gaveops}{$b} <=> $self->{stats}->{gaveops}{$a} }
  886. keys %{ $self->{stats}->{gaveops} };
  887. my @deops = sort { $self->{stats}->{tookops}{$b} <=> $self->{stats}->{tookops}{$a} }
  888. keys %{ $self->{stats}->{tookops} };
  889. if (@ops) {
  890. my %hash = (
  891. nick => $ops[0],
  892. ops => $self->{stats}->{gaveops}{$ops[0]}
  893. );
  894. my $text = $self->_template_text('mostop1', %hash);
  895. _html("<tr><td class=\"hicell\">$text");
  896. if (@ops >= 2) {
  897. my %hash = (
  898. nick => $ops[1],
  899. ops => $self->{stats}->{gaveops}{$ops[1]}
  900. );
  901. my $text = $self->_template_text('mostop2', %hash);
  902. _html("<br /><span class=\"small\">$text</span>");
  903. }
  904. _html("</td></tr>");
  905. } else {
  906. my $text = $self->_template_text('mostop3');
  907. _html("<tr><td class=\"hicell\">$text</td></tr>");
  908. }
  909. if (@deops) {
  910. my %hash = (
  911. nick => $deops[0],
  912. deops => $self->{stats}->{tookops}{$deops[0]}
  913. );
  914. my $text = $self->_template_text('mostdeop1', %hash);
  915. _html("<tr><td class=\"hicell\">$text");
  916. if (@deops >= 2) {
  917. my %hash = (
  918. nick => $deops[1],
  919. deops => $self->{stats}->{tookops}{$deops[1]}
  920. );
  921. my $text = $self->_template_text('mostdeop2', %hash);
  922. _html("<br /><span class=\"small\">$text</span>");
  923. }
  924. _html("</td></tr>");
  925. } else {
  926. my $text = $self->_template_text('mostdeop3');
  927. _html("<tr><td class=\"hicell\">$text</td></tr>");
  928. }
  929. }
  930. sub _mostvoice
  931. {
  932. my $self = shift;
  933. my @voice = sort { $self->{stats}->{gavevoice}{$b} <=> $self->{stats}->{gavevoice}{$a} }
  934. keys %{ $self->{stats}->{gavevoice} };
  935. my @devoice = sort { $self->{stats}->{tookvoice}{$b} <=> $self->{stats}->{tookvoice}{$a} }
  936. keys %{ $self->{stats}->{tookvoice} };
  937. if (@voice) {
  938. my %hash = (
  939. nick => $voice[0],
  940. voices => $self->{stats}->{gavevoice}{$voice[0]}
  941. );
  942. my $text = $self->_template_text('mostvoice1', %hash);
  943. _html("<tr><td class=\"hicell\">$text");
  944. if (@voice >= 2) {
  945. my %hash = (
  946. nick => $voice[1],
  947. voices => $self->{stats}->{gavevoice}{$voice[1]}
  948. );
  949. my $text = $self->_template_text('mostvoice2', %hash);
  950. _html("<br /><span class=\"small\">$text</span>");
  951. }
  952. _html("</td></tr>");
  953. } else {
  954. my $text = $self->_template_text('mostvoice3');
  955. _html("<tr><td class=\"hicell\">$text</td></tr>");
  956. }
  957. if (@devoice) {
  958. my %hash = (
  959. nick => $devoice[0],
  960. devoices => $self->{stats}->{tookvoice}{$devoice[0]}
  961. );
  962. my $text = $self->_template_text('mostdevoice1', %hash);
  963. _html("<tr><td class=\"hicell\">$text");
  964. if (@devoice >= 2) {
  965. my %hash = (
  966. nick => $devoice[1],
  967. devoices => $self->{stats}->{tookvoice}{$devoice[1]}
  968. );
  969. my $text = $self->_template_text('mostdevoice2', %hash);
  970. _html("<br /><span class=\"small\">$text</span>");
  971. }
  972. _html("</td></tr>");
  973. } else {
  974. my $text = $self->_template_text('mostdevoice3');
  975. _html("<tr><td class=\"hicell\">$text</td></tr>");
  976. }
  977. }
  978. sub _mostactions
  979. {
  980. # The person who did the most /me's
  981. my $self = shift;
  982. my @actions = sort { $self->{stats}->{actions}{$b} <=> $self->{stats}->{actions}{$a} }
  983. keys %{ $self->{stats}->{actions} };
  984. if (@actions) {
  985. my %hash = (
  986. nick => $actions[0],
  987. actions => $self->{stats}->{actions}{$actions[0]},
  988. line => htmlentities($self->{stats}->{actionlines}{$actions[0]})
  989. );
  990. my $text = $self->_template_text('action1', %hash);
  991. if($self->{cfg}->{showactionline}) {
  992. my $exttext = $self->_template_text('actiontext', %hash);
  993. _html("<tr><td class=\"hicell\">$text<br /><span class=\"small\">$exttext</span><br />");
  994. } else {
  995. _html("<tr><td class=\"hicell\">$text");
  996. }
  997. if (@actions >= 2) {
  998. my %hash = (
  999. nick => $actions[1],
  1000. actions => $self->{stats}->{actions}{$actions[1]}
  1001. );
  1002. my $text = $self->_template_text('action2', %hash);
  1003. _html("<br /><span class=\"small\">$text</span>");
  1004. }
  1005. _html("</td></tr>");
  1006. } else {
  1007. my $text = $self->_template_text('action3');
  1008. _html("<tr><td class=\"hicell\">$text</td></tr>");
  1009. }
  1010. }
  1011. sub _mostsmiles
  1012. {
  1013. # The person(s) who smiled the most :-)
  1014. my $self = shift;
  1015. my %spercent;
  1016. foreach my $nick (sort keys %{ $self->{stats}->{smiles} }) {
  1017. if ($self->{stats}->{lines}{$nick} > 100) {
  1018. $spercent{$nick} = $self->{stats}->{smiles}{$nick} / $self->{stats}->{lines}{$nick} * 100;
  1019. $spercent{$nick} =~ s/(\.\d)\d+/$1/;
  1020. }
  1021. }
  1022. my @smiles = sort { $spercent{$b} <=> $spercent{$a} } keys %spercent;
  1023. if (@smiles) {
  1024. my %hash = (
  1025. nick => $smiles[0],
  1026. per => $spercent{$smiles[0]}
  1027. );
  1028. my $text = $self->_template_text('smiles1', %hash);
  1029. _html("<tr><td class=\"hicell\">$text");
  1030. if (@smiles >= 2) {
  1031. my %hash = (
  1032. nick => $smiles[1],
  1033. per => $spercent{$smiles[1]}
  1034. );
  1035. my $text = $self->_template_text('smiles2', %hash);
  1036. _html("<br /><span class=\"small\">$text</span>");
  1037. }
  1038. _html("</td></tr>");
  1039. } else {
  1040. my $text = $self->_template_text('smiles3');
  1041. _html("<tr><td class=\"hicell\">$text</td></tr>");
  1042. }
  1043. }
  1044. sub _lasttopics
  1045. {
  1046. my $self = shift;
  1047. if ($self->{stats}->{topics}) {
  1048. my %topic_seen;
  1049. my %hash = (
  1050. total => scalar @{ $self->{stats}->{topics} }
  1051. );
  1052. my $ltopic = $#{ $self->{stats}->{topics} };
  1053. my $tlimit = 0;
  1054. $self->{cfg}->{topichistory} -= 1;
  1055. if ($ltopic > $self->{cfg}->{topichistory}) {
  1056. $tlimit = $ltopic - $self->{cfg}->{topichistory};
  1057. }
  1058. for (my $i = $ltopic; $i >= $tlimit; $i--) {
  1059. my $topic = htmlentities($self->{stats}->{topics}[$i]{topic});
  1060. # This code makes sure that we don't see the same topic twice
  1061. next if ($topic_seen{$topic});
  1062. $topic_seen{$topic} = 1;
  1063. $topic = $self->_replace_links($topic);
  1064. # Strip off the quotes (')
  1065. $topic =~ s/^\'(.*)\'$/$1/;
  1066. my $nick = $self->{stats}->{topics}[$i]{nick};
  1067. my $hour = $self->{stats}->{topics}[$i]{hour};
  1068. my $min = $self->{stats}->{topics}[$i]{min};
  1069. $hash{nick} = $nick;
  1070. $hash{time} = "$hour:$min";
  1071. _html("<tr><td class=\"hicell\"><i>$topic</i></td>");
  1072. _html("<td class=\"hicell\"><b>" . $self->_template_text('bylinetopic', %hash) ."</b></td></tr>");
  1073. }
  1074. _html("<tr><td align=\"center\" colspan=\"2\" class=\"asmall\">" . $self->_template_text('totaltopic', %hash) . "</td></tr>");
  1075. } else {
  1076. _html("<tr><td class=\"hicell\">" . $self->_template_text('notopic') ."</td></tr>");
  1077. }
  1078. }
  1079. sub _template_text
  1080. {
  1081. # This function is for the homemade template system. It receives a name
  1082. # of a template and a hash with the fields in the template to update to
  1083. # its corresponding value
  1084. my $self = shift;
  1085. my $template = shift;
  1086. my %hash = @_;
  1087. my $text;
  1088. unless ($text = $self->{tmps}->{lc($self->{cfg}->{lang})}{$template}) {
  1089. # Fall back to English if the language template doesn't exist
  1090. if ($text = $self->{tmps}->{en}{$template}) {
  1091. print "Note: No translation in '$self->{cfg}->{lang}' for '$template' - falling back to English..\n"
  1092. unless ($self->{cfg}->{silent});
  1093. } else {
  1094. die("No such template '$template' in language file.\n");
  1095. }
  1096. }
  1097. $hash{channel} = $self->{cfg}->{channel};
  1098. foreach my $key (sort keys %hash) {
  1099. $text =~ s/\[:$key\]/$hash{$key}/;
  1100. $text =~ s/ü/&uuml;/go;
  1101. $text =~ s/ö/&ouml;/go;
  1102. $text =~ s/ä/&auml;/go;
  1103. $text =~ s/ß/&szlig;/go;
  1104. $text =~ s/å/&aring;/go;
  1105. $text =~ s/æ/&aelig;/go;
  1106. $text =~ s/ø/&oslash;/go;
  1107. $text =~ s/Å/&Aring;/go;
  1108. $text =~ s/Æ/&AElig;/go;
  1109. $text =~ s/Ø/&Oslash;/go;
  1110. }
  1111. if ($text =~ /\[:.*?:.*?:\]/o) {
  1112. $text =~ s/\[:(.*?):(.*?):\]/$self->_get_subst($1,$2,\%hash)/geo;
  1113. }
  1114. return $text;
  1115. }
  1116. sub _get_subst
  1117. {
  1118. # This function looks at the user definition and see if there is sex
  1119. # defined. If yes, return the appropriate value. If no, just return the
  1120. # default he/she value.
  1121. my $self = shift;
  1122. my ($m,$f,$hash) = @_;
  1123. if ($hash->{nick} && $self->{users}->{sex}{$hash->{nick}}) {
  1124. if ($self->{users}->{sex}{$hash->{nick}} eq 'm') {
  1125. return $m;
  1126. } elsif ($self->{users}->{sex}{$hash->{nick}} eq 'f') {
  1127. return $f;
  1128. }
  1129. }
  1130. return "$m/$f";
  1131. }
  1132. sub _mostusedword
  1133. {
  1134. # Word usage statistics
  1135. my $self = shift;
  1136. my %usages;
  1137. foreach my $word (keys %{ $self->{stats}->{wordcounts} }) {
  1138. # Skip people's nicks.
  1139. next if exists $self->{stats}->{lines}{$word};
  1140. next if (length($word) < $self->{cfg}->{wordlength});
  1141. $usages{$word} = $self->{stats}->{wordcounts}{$word};
  1142. }
  1143. my @popular = sort { $usages{$b} <=> $usages{$a} } keys %usages;
  1144. if (@popular) {
  1145. $self->_headline($self->_template_text('mostwordstopic'));
  1146. _html("<table border=\"0\" width=\"$self->{cfg}->{tablewidth}\"><tr>");
  1147. _html("<td>&nbsp;</td><td class=\"tdtop\"><b>" . $self->_template_text('word') . "</b></td>");
  1148. _html("<td class=\"tdtop\"><b>" . $self->_template_text('numberuses') . "</b></td>");
  1149. _html("<td class=\"tdtop\"><b>" . $self->_template_text('lastused') . "</b></td></tr>");
  1150. my $count = 0;
  1151. for(my $i = 0; $count < $self->{cfg}->{wordhistory}; $i++) {
  1152. last unless $i < $#popular;
  1153. # Skip nicks. It's far more efficient to do this here than when
  1154. # @popular is created.
  1155. next if is_ignored($popular[$i]);
  1156. next if exists $self->{stats}->{lines}{find_alias($popular[$i])};
  1157. my $a = $count + 1;
  1158. my $popular = htmlentities($popular[$i]);
  1159. my $wordcount = $self->{stats}->{wordcounts}{$popular[$i]};
  1160. my $lastused = htmlentities($self->{stats}->{wordnicks}{$popular[$i]});
  1161. my $class;
  1162. if ($a == 1) {
  1163. $class = 'hirankc';
  1164. } else {
  1165. $class = 'rankc';
  1166. }
  1167. _html("<tr><td class=\"$class\">$a</td>");
  1168. _html("<td class=\"hicell\">$popular</td>");
  1169. _html("<td class=\"hicell\">$wordcount</td>");
  1170. _html("<td class=\"hicell\">$lastused</td>");
  1171. _html("</tr>");
  1172. $count++;
  1173. }
  1174. _html("</table>");
  1175. }
  1176. }
  1177. sub _mostwordsperline
  1178. {
  1179. # The person who got the most words per line
  1180. my $self = shift;
  1181. my %wpl = ();
  1182. my $numlines = 0;
  1183. my ($avg, $numwords);
  1184. foreach my $n (keys %{ $self->{stats}->{words} }) {
  1185. $wpl{$n} = sprintf("%.2f", $self->{stats}->{words}{$n}/$self->{stats}->{lines}{$n});
  1186. $numlines += $self->{stats}->{lines}{$n};
  1187. $numwords += $self->{stats}->{words}{$n};
  1188. }
  1189. if ($numlines > 0) {
  1190. $avg = sprintf("%.2f", $numwords/$numlines);
  1191. }
  1192. my @wpl = sort { $wpl{$b} <=> $wpl{$a} } keys %wpl;
  1193. if (@wpl) {
  1194. my %hash = (
  1195. nick => $wpl[0],
  1196. wpl => $wpl{$wpl[0]}
  1197. );
  1198. my $text = $self->_template_text('wpl1', %hash);
  1199. _html("<tr><td class=\"hicell\">$text");
  1200. $hash{avg} = $avg;
  1201. $text = $self->_template_text('wpl2', %hash);
  1202. _html("<br /><span class=\"small\">$text</span>");
  1203. _html("</td></tr>");
  1204. }
  1205. }
  1206. sub _mostreferencednicks
  1207. {
  1208. # List showing the most referenced nicks
  1209. my $self = shift;
  1210. my %usages;
  1211. foreach my $word (sort keys %{ $self->{stats}->{wordcounts} }) {
  1212. next if !exists $self->{stats}->{lines}{$word};
  1213. next if is_ignored($word);
  1214. $usages{$word} = $self->{stats}->{wordcounts}{$word};
  1215. }
  1216. my @popular = sort { $usages{$b} <=> $usages{$a} } keys %usages;
  1217. if (@popular) {
  1218. $self->_headline($self->_template_text('referencetopic'));
  1219. _html("<table border=\"0\" width=\"$self->{cfg}->{tablewidth}\"><tr>");
  1220. _html("<td>&nbsp;</td><td class=\"tdtop\"><b>" . $self->_template_text('nick') . "</b></td>");
  1221. _html("<td class=\"tdtop\"><b>" . $self->_template_text('numberuses') . "</b></td>");
  1222. _html("<td class=\"tdtop\"><b>" . $self->_template_text('lastused') . "</b></td></tr>");
  1223. for(my $i = 0; $i < $self->{cfg}->{nickhistory}; $i++) {
  1224. last unless $i < $#popular;
  1225. my $a = $i + 1;
  1226. my $popular = $popular[$i];
  1227. my $wordcount = $self->{stats}->{wordcounts}{$popular[$i]};
  1228. my $lastused = $self->{stats}->{wordnicks}{$popular[$i]};
  1229. my $class;
  1230. if ($a == 1) {
  1231. $class = 'hirankc';
  1232. } else {
  1233. $class = 'rankc';
  1234. }
  1235. _html("<tr><td class=\"$class\">$a</td>");
  1236. _html("<td class=\"hicell\">$popular</td>");
  1237. _html("<td class=\"hicell\">$wordcount</td>");
  1238. _html("<td class=\"hicell\">$lastused</td>");
  1239. _html("</tr>");
  1240. }
  1241. _html("</table>");
  1242. }
  1243. }
  1244. sub _mosturls
  1245. {
  1246. # List showing the most referenced URLs
  1247. my $self = shift;
  1248. my @sorturls = sort { $self->{stats}->{urlcounts}{$b} <=> $self->{stats}->{urlcounts}{$a} }
  1249. keys %{ $self->{stats}->{urlcounts} };
  1250. if (@sorturls) {
  1251. $self->_headline($self->_template_text('urlstopic'));
  1252. _html("<table border=\"0\" width=\"$self->{cfg}->{tablewidth}\"><tr>");
  1253. _html("<td>&nbsp;</td><td class=\"tdtop\"><b>" . $self->_template_text('url') . "</b></td>");
  1254. _html("<td class=\"tdtop\"><b>" . $self->_template_text('numberuses') . "</b></td>");
  1255. _html("<td class=\"tdtop\"><b>" . $self->_template_text('lastused') . "</b></td></tr>");
  1256. for(my $i = 0; $i < $self->{cfg}->{urlhistory}; $i++) {
  1257. last unless $i < @sorturls;
  1258. my $a = $i + 1;
  1259. my $sorturl = $sorturls[$i];
  1260. my $urlcount = $self->{stats}->{urlcounts}{$sorturls[$i]};
  1261. my $lastused = $self->{stats}->{urlnicks}{$sorturls[$i]};
  1262. if (length($sorturl) > 60) {
  1263. $sorturl = substr($sorturl, 0, 60);
  1264. }
  1265. my $class;
  1266. if ($a == 1) {
  1267. $class = 'hirankc';
  1268. } else {
  1269. $class = 'rankc';
  1270. }
  1271. _html("<tr><td class=\"$class\">$a</td>");
  1272. _html("<td class=\"hicell\"><a href=\"$sorturls[$i]\">$sorturl</a></td>");
  1273. _html("<td class=\"hicell\">$urlcount</td>");
  1274. _html("<td class=\"hicell\">$lastused</td>");
  1275. _html("</tr>");
  1276. }
  1277. _html("</table>");
  1278. }
  1279. }
  1280. sub _legend
  1281. {
  1282. # A legend showing the timebars and their associated time.
  1283. my $self = shift;
  1284. _html("<table align=\"center\" border=\"0\" width=\"520\"><tr>");
  1285. _html("<td align=\"center\" class=\"asmall\"><img src=\"$self->{cfg}->{piclocation}/$self->{cfg}->{pic_h_0}\" width=\"40\" height=\"15\" align=\"middle\" alt=\"0-5\" /> = 0-5</td>");
  1286. _html("<td align=\"center\" class=\"asmall\"><img src=\"$self->{cfg}->{piclocation}/$self->{cfg}->{pic_h_6}\" width=\"40\" height=\"15\" align=\"middle\" alt=\"6-11\" /> = 6-11</td>");
  1287. _html("<td align=\"center\" class=\"asmall\"><img src=\"$self->{cfg}->{piclocation}/$self->{cfg}->{pic_h_12}\" width=\"40\" height=\"15\" align=\"middle\" alt=\"12-17\" /> = 12-17</td>");
  1288. _html("<td align=\"center\" class=\"asmall\"><img src=\"$self->{cfg}->{piclocation}/$self->{cfg}->{pic_h_18}\" width=\"40\" height=\"15\" align=\"middle\" alt=\"18-23\" /> = 18-23</td>");
  1289. _html("</tr></table>\n");
  1290. }
  1291. sub _replace_links
  1292. {
  1293. # Sub to replace urls and e-mail addys to links
  1294. my $self = shift;
  1295. my $str = shift;
  1296. my $nick = shift;
  1297. # Regular expressions are taken from match_urls() and match_email() in
  1298. # Common.pm
  1299. my $texturl = $self->_template_text("newwindow");
  1300. my $textmail = $self->_template_text("mailto");
  1301. if ($nick) {
  1302. $str =~ s/(http|https|ftp|telnet|news)(:\/\/[-a-zA-Z0-9_\/~]+\.[-a-zA-Z0-9.,_~=:&amp;@%?#\/+]+)/<a href="$1$2" target="_blank" title="$texturl $1$2">$nick<\/a>/g;
  1303. $str =~ s/([-a-zA-Z0-9._]+@[-a-zA-Z0-9_]+\.[-a-zA-Z0-9._]+)/<a href="mailto:$1" title="$textmail $nick">$nick<\/a>/g;
  1304. } else {
  1305. $str =~ s/(http|https|ftp|telnet|news)(:\/\/[-a-zA-Z0-9_\/~]+\.[-a-zA-Z0-9.,_~=:&amp;@%?#\/+]+)/<a href="$1$2" target="_blank" title="$texturl $1$2">$1$2<\/a>/g;
  1306. $str =~ s/([-a-zA-Z0-9._]+@[-a-zA-Z0-9_]+\.[-a-zA-Z0-9._]+)/<a href="mailto:$1" title="$textmail $1">$1<\/a>/g;
  1307. }
  1308. return $str;
  1309. }
  1310. sub _user_linetimes
  1311. {
  1312. my $self = shift;
  1313. my $nick = shift;
  1314. my $top = shift;
  1315. my $bar = "";
  1316. my $len = ($self->{stats}->{lines}{$nick} / $self->{stats}->{lines}{$top}) * 100;
  1317. for (my $i = 0; $i <= 3; $i++) {
  1318. next if not defined $self->{stats}->{line_times}{$nick}[$i];
  1319. my $w = int(($self->{stats}->{line_times}{$nick}[$i] / $self->{stats}->{lines}{$nick}) * $len);
  1320. if ($w) {
  1321. my $pic = 'pic_h_'.(6*$i);
  1322. $bar .= "<img src=\"$self->{cfg}->{piclocation}/$self->{cfg}->{$pic}\" border=\"0\" width=\"$w\" height=\"15\" align=\"middle\" alt=\"\" />";
  1323. }
  1324. }
  1325. return "$bar&nbsp;$self->{stats}->{lines}{$nick}";
  1326. }
  1327. sub _user_wordtimes
  1328. {
  1329. my $self = shift;
  1330. my $nick = shift;
  1331. my $top = shift;
  1332. my $bar = "";
  1333. my $len = ($self->{stats}->{words}{$nick} / $self->{stats}->{words}{$top}) * 100;
  1334. for (my $i = 0; $i <= 3; $i++) {
  1335. next if not defined $self->{stats}->{word_times}{$nick}[$i];
  1336. my $w = int(($self->{stats}->{word_times}{$nick}[$i] / $self->{stats}->{words}{$nick}) * $len);
  1337. if ($w) {
  1338. my $pic = 'pic_h_'.(6*$i);
  1339. $bar .= "<img src=\"$self->{cfg}->{piclocation}/$self->{cfg}->{$pic}\" border=\"0\" width=\"$w\" height=\"15\" align=\"middle\" alt=\"\" />";
  1340. }
  1341. }
  1342. return "$bar&nbsp;$self->{stats}->{words}{$nick}";
  1343. }
  1344. sub _user_times
  1345. {
  1346. my $self = shift;
  1347. my ($nick) = @_;
  1348. my $bar = "";
  1349. my $itemstat = ($self->{cfg}->{sortbywords} ? 'words' : 'lines');
  1350. my $timestat = ($self->{cfg}->{sortbywords} ? 'word_times' : 'line_times');
  1351. for (my $i = 0; $i <= 3; $i++) {
  1352. next if not defined $self->{stats}->{$timestat}{$nick}[$i];
  1353. my $w = int(($self->{stats}->{$timestat}{$nick}[$i] / $self->{stats}->{$itemstat}{$nick}) * 40);
  1354. if ($w) {
  1355. my $pic = 'pic_h_'.(6*$i);
  1356. $bar .= "<img src=\"$self->{cfg}->{piclocation}/$self->{cfg}->{$pic}\" border=\"0\" width=\"$w\" height=\"15\" alt=\"\" />";
  1357. }
  1358. }
  1359. return $bar;
  1360. }
  1361. sub _mostnicks
  1362. {
  1363. # List showing the user with most used nicks
  1364. my $self = shift;
  1365. my @sortnicks = sort { @{ $self->{stats}->{nicks}->{$b} } <=> @{ $self->{stats}->{nicks}->{$a} } }
  1366. keys %{ $self->{stats}->{nicks} };
  1367. if (@{ $self->{stats}->{nicks}->{$sortnicks[0]} } > 1) {
  1368. $self->_headline($self->_template_text('mostnickstopic'));
  1369. my $names1 = $self->_template_text('names1');
  1370. my $names2 = $self->_template_text('names2');
  1371. my $nick_txt = $self->_template_text('nick');
  1372. my $names_txt = $self->_template_text('names');
  1373. _html("<table border=\"0\" width=\"$self->{cfg}->{tablewidth}\"><tr>");
  1374. _html("<td>&nbsp;</td><td class=\"tdtop\"><b>$nick_txt</b></td>");
  1375. _html("<td class=\"tdtop\"><b>$names_txt</b></td></tr>");
  1376. for(my $i = 0; $i < $self->{cfg}->{mostnickshistory}; $i++) {
  1377. next if is_ignored($sortnicks[$i]);
  1378. last unless $i < @sortnicks;
  1379. my $nickcount = scalar(@{ $self->{stats}->{nicks}->{$sortnicks[$i]} });
  1380. my $nickused = join(", ", @{ $self->{stats}->{nicks}->{$sortnicks[$i]} });
  1381. next unless ($nickcount > 1);
  1382. my $a = $i + 1;
  1383. my $class = $a == 1 ? 'hirankc' : 'rankc';
  1384. my $n = $nickcount > 1 ? $names1 : $names2;
  1385. _html("<tr><td class=\"$class\">$a</td>");
  1386. _html("<td class=\"hicell10\">$sortnicks[$i]<br />($nickcount $n)</td>");
  1387. _html("<td class=\"hicell10\" valign='top'>$nickused</td>");
  1388. _html("</tr>");
  1389. }
  1390. _html("</table>");
  1391. }
  1392. }
  1393. sub _mostactivebyhour
  1394. {
  1395. # List showing the user with most used nicks
  1396. my $self = shift;
  1397. my $sortnicks;
  1398. my $lastline=-1;
  1399. my $maxlines=0;
  1400. foreach my $period (0,1,2,3) {
  1401. my @sortnicks =
  1402. sort
  1403. {
  1404. (defined $self->{stats}->{line_times}{$b}[$period]?$self->{stats}->{line_times}{$b}[$period]:0)
  1405. <=>
  1406. (defined $self->{stats}->{line_times}{$a}[$period]?$self->{stats}->{line_times}{$a}[$period]:0)
  1407. }
  1408. keys %{ $self->{stats}->{nicks} } ;
  1409. for(my $i = 0; $i < $self->{cfg}->{activenicksbyhour}; $i++) {
  1410. next if is_ignored($sortnicks[$i]);
  1411. last unless $i < @sortnicks;
  1412. my $nick=$sortnicks[$i];
  1413. my $count=$self->{stats}->{line_times}{$nick}[$period] || 0;
  1414. last unless $nick;
  1415. last unless $count;
  1416. $sortnicks->[$period][$i]=$nick;
  1417. if ($lastline<$i) {
  1418. $lastline=$i;
  1419. }
  1420. if ($maxlines<$count) {
  1421. $maxlines=$count;
  1422. }
  1423. }
  1424. }
  1425. if ($lastline>=0) {
  1426. $self->_headline($self->_template_text('activenickbyhourtopic'));
  1427. _html("<table border=\"0\" width=\"$self->{cfg}->{tablewidth}\"><tr>");
  1428. _html("<td>&nbsp;</td>");
  1429. _html("<td class=\"tdtop\"><b>0-5</b></td>");
  1430. _html("<td class=\"tdtop\"><b>6-11</b></td>");
  1431. _html("<td class=\"tdtop\"><b>12-17</b></td>");
  1432. _html("<td class=\"tdtop\"><b>18-23</b></td>");
  1433. _html("</tr>");
  1434. for(my $i = 0; $i <= $lastline; $i++) {
  1435. my $a = $i + 1;
  1436. my $class = $a == 1 ? 'hirankc' : 'rankc';
  1437. _html("<tr><td class=\"$class\">$a</td>");
  1438. foreach my $period (0,1,2,3) {
  1439. my $nick=$sortnicks->[$period][$i];
  1440. if ($nick) {
  1441. my $count=$self->{stats}->{line_times}{$nick}[$period];
  1442. if ($count) {
  1443. _html("<td class=\"hicell\">".$nick." - ".$count);
  1444. if ($self->{cfg}->{showmostactivebyhourgraph}) {
  1445. my $pic = 'pic_h_'.(6*$period);
  1446. my $w = int(($count / $maxlines) * 100);
  1447. _html("<br><img src=\"$self->{cfg}->{piclocation}/$self->{cfg}->{$pic}\" border=\"0\" width=\"$w\" height=\"15\" align=\"middle\" alt=\"\" />");
  1448. }
  1449. _html("</td>");
  1450. } else {
  1451. _html("<td class=\"hicell\">&nbsp;</td>");
  1452. }
  1453. } else {
  1454. _html("<td class=\"hicell\">&nbsp;</td>");
  1455. }
  1456. }
  1457. _html("</tr>");
  1458. }
  1459. _html("</table>");
  1460. }
  1461. }
  1462. 1;
  1463. __END__
  1464. =head1 NAME
  1465. Pisg::HTMLGenerator - class to create a static HTML page out of data parsed
  1466. =head1 DESCRIPTION
  1467. C<Pisg::HTMLGenerator> uses the hash returned by Pisg::Parser::Logfile and turns it into a static HTML page.
  1468. =head1 SYNOPSIS
  1469. use Pisg::HTMLGenerator;
  1470. $generator = new Pisg::HTMLGenerator(
  1471. cfg => $cfg,
  1472. stats => $stats,
  1473. users => $users,
  1474. tmps => $tmps
  1475. );
  1476. =head1 CONSTRUCTOR
  1477. =over 4
  1478. =item new ( [ OPTIONS ] )
  1479. This is the constructor for a new Pisg::HTMLGenerator object. C<OPTIONS> are passed in a hash like fashion using key and value pairs.
  1480. Possible options are:
  1481. B<cfg> - hashref containing configuration variables, created by the Pisg module.
  1482. B<stats> - reference to the hash returned by Pisg::Parser::Logfile containing all stats.
  1483. B<users> - reference to a hash containg user information
  1484. B<tmps> - reference to a hash containing the language templates.
  1485. =back
  1486. =head1 AUTHOR
  1487. Morten Brix Pedersen <morten@wtf.dk>
  1488. =head1 COPYRIGHT
  1489. Copyright (C) 2001-2002 Morten Brix Pedersen. All rights reserved.
  1490. This program is free software; you can redistribute it and/or modify it
  1491. under the terms of the GPL, license is included with the distribution of
  1492. this file.
  1493. =cut