HTMLGenerator.pm 58 KB

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