pisg.pl 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use Getopt::Long;
  4. # pisg - Perl IRC Statistics Generator
  5. #
  6. # Copyright (C) 2001 <Morten 'LostStar' Brix Pedersen> - morten@wtf.dk
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. my ($channel, $logfile, $format, $network, $outputfile, $maintainer,
  22. $pagehead, $usersfile, $imagepath, $logdir, $lang, $bgcolor, $text, $hbgcolor,
  23. $hcolor, $hicell, $hicell2, $tdcolor, $tdtop, $link, $vlink, $hlink, $headline,
  24. $rankc, $minquote, $maxquote, $activenicks, $activenicks2, $topichistory,
  25. $pic1, $pic2, $nicktracking, $timeoffset, $version, $debug, $debugfile);
  26. # Values that _MUST_ be set below (unless you pass them on commandline)
  27. $channel = "#channel"; # The name of your channel.
  28. $logfile = "channel.log"; # The exact filename of the logfile
  29. $format = "mIRC"; # logfile format. see FORMATS file
  30. $network = "SomeIRCNet"; # Network the channels is using.
  31. $outputfile = "index.html"; # The name of the html file to be generated
  32. $maintainer = "MAINTAINER"; # The maintainer or bot which makes the logfile
  33. $pagehead = "none"; # Some 'page header' file which you want to
  34. # include in top of the stats
  35. $usersfile = "/usr/local/apache/cgi-bin/users.cfg"; # Path to users config file (aliases, ignores,
  36. # pics and more, see users.cfg for examples)
  37. $imagepath = ""; # If your user pictures is located
  38. # some special directory, set the path here.
  39. $logdir = ""; # If you specify a path to a dir here, then
  40. # pisg will take that dir, and parse ALL
  41. # logfiles in it, and create 1 HTML file
  42. # from it
  43. $lang = 'EN'; # Language to use, EN | DE | DK | FR
  44. # Here you can set the colors for your stats page..
  45. $bgcolor = "#dedeee"; # Background color of the page
  46. $text = "black"; # Normal text color
  47. $hbgcolor = "#666699"; # Background color in headlines
  48. $hcolor = "white"; # Text color in headline
  49. $hicell = "#BABADD"; # Background color in highlighted cells
  50. $hicell2 = "#CCCCCC"; # Background color in highlighted cells
  51. $tdcolor = "black"; # Color of text in tables
  52. $tdtop = "#C8C8DD"; # Top color in some tables.
  53. $link = "#0b407a"; # Color of links
  54. $vlink = "#0b407a"; # Color of visited links
  55. $hlink = "#0b407a"; # Color of hovered links
  56. $headline = "#000000"; # Border color of headlines
  57. $rankc = "#CCCCCC"; # Colors of 'ranks' (1,2,3,4)
  58. $pic1 = "pipe-blue.png" # Bar-graphic-file for normal times
  59. $pic2 = "pipe-purple.png" # Bar-graphic-file for top-times
  60. # Other things that you might set, but not everyone cares about them
  61. $minquote = "25"; # Minimal value of letters for a random quote
  62. $maxquote = "65"; # Maximum value of letters for a random quote
  63. $activenicks = "25"; # Number of nicks to show in the 'top 25'
  64. $activenicks2 = "30"; # Nicks to show in 'these didnt make it...'
  65. $topichistory = "3"; # How many topics to show in 'latest topics'
  66. $nicktracking = 0; # Track nickchanges and create aliases (can
  67. # be slow, so it's disabled by default)
  68. $timeoffset = "+0"; # A time offset on the stats page - if your
  69. # country has a different timezone than the
  70. # machine where the stats are being
  71. # generated, then for example do +1
  72. # to add 1 hour to the time
  73. # You shouldn't care about anything below this point
  74. $debug = 0; # 0 = Debugging off, 1 = Debugging on
  75. $debugfile = "debug.log"; # Path to debug file(must be set if $debug == 1)
  76. $version = "v0.17-cvs-dh1";
  77. my ($lines, $kicked, $gotkicked, $smile, $longlines, $time, $timestamp, %alias,
  78. $normalline, $actionline, $thirdline, @ignore, $line, $processtime, @topics,
  79. %monologue, %kicked, %gotkick, %line, %length, %qpercent, %lpercent, %sadface,
  80. %smile, $nicks, %longlines, %mono, %times, %question, %loud, $totallength,
  81. %gaveop, %tookop, %joins, %actions, %sayings, %wordcount, %lastused,
  82. $colorcode, $boldcode, $underlinecode, %gotban, %setban, %foul, $days,
  83. $oldtime, $lastline, $actions, $normals, %userpics, %userlinks, %T,
  84. $repeated, $lastnormal);
  85. sub main
  86. {
  87. init_pisg(); # Init commandline arguments and other things
  88. init_lineformats(); # Attempt to set line formats in compliance with user specification (--format)
  89. init_users_config(); # Init users config. (Aliases, ignores etc.)
  90. init_debug(); # Init the debugging file
  91. if ($logdir) {
  92. parse_dir(); # Run through all logfiles in dir
  93. } else {
  94. parse_file($logfile); # Run through the whole logfile
  95. }
  96. create_html(); # Create the HTML
  97. # (look here if you want to remove some of the
  98. # stats which you don't care about)
  99. close_debug(); # Close the debugging file
  100. print "\nFile was parsed succesfully in $processtime on $time.\n";
  101. }
  102. sub init_pisg
  103. {
  104. print "pisg $version - Perl IRC Statistics Generator\n\n";
  105. get_cmdlineoptions();
  106. $timestamp = time;
  107. if ($timeoffset =~ /\+(\d+)/) {
  108. # We must plus some hours to the time
  109. $timestamp += 3600 * $1; # 3600 seconds per hour
  110. } elsif ($timeoffset =~ /-(\d+)/) {
  111. # We must remove some hours from the time
  112. $timestamp -= 3600 * $1; # 3600 seconds per hour
  113. }
  114. # Set useful values.
  115. $days = 1;
  116. $oldtime = "00";
  117. $lastline = "";
  118. $actions = "0";
  119. $normals = "0";
  120. $colorcode = chr(3);
  121. $boldcode = chr(2);
  122. $underlinecode = chr(31);
  123. $time = localtime($timestamp);
  124. $repeated = 0;
  125. $lastnormal = "";
  126. print "Statistics for channel $channel \@ $network by $maintainer\n\n";
  127. print "Using language template: $lang\n\n" if ($lang ne 'EN');
  128. }
  129. sub init_lineformats {
  130. # These are the regular expressions which matches the lines in the logfile,
  131. # and looks different if it's xchat, mIRC or whatever.
  132. # If you want to add support for a new format - you first have to add the
  133. # regex here, and then you also have to modify the parse subroutines called
  134. # 'parse_normalline()', 'parse_actionline()' and 'parse_thirdline()'
  135. if ($format eq 'xchat') {
  136. $normalline = '^(\d+):\d+:\d+ <([^>]+)>\s+(.*)';
  137. $actionline = '^(\d+):\d+:\d+ \*\s+(\S+) (.*)';
  138. $thirdline = '^(\d+):(\d+):\d+ .--\s+(\S+) (\S+) (\S+) (\S+) (\S+) (\S+) (.*)';
  139. } elsif ($format eq 'mIRC') {
  140. $normalline = '^\[(\d+):\d+\] <([^>]+)> (.*)';
  141. $actionline = '^\[(\d+):\d+\] \* (\S+) (.*)';
  142. $thirdline = '^\[(\d+):(\d+)\] \*\*\* (\S+) (\S+) (\S+) (\S+) (\S+)(.*)';
  143. } elsif ($format eq 'eggdrop') {
  144. $normalline = '^\[(\d+):\d+\] <([^>]+)> (.*)';
  145. $actionline = '^\[(\d+):\d+\] Action: (\S+) (.*)';
  146. $thirdline = '^\[(\d+):(\d+)\] (\S+) (\S+) (\S+) (\S+)(.*)';
  147. } elsif ($format eq 'bxlog') {
  148. $normalline = '^\[\d+ \w+\/(\d+):\d+\] <([^>]+)> (.*)';
  149. $actionline = '^\[\d+ \w+\/(\d+):\d+\] \* (\S+) (.*)';
  150. $thirdline = '^\[\d+ \w+\/(\d+):(\d+)\] \S (\S+) (\S+) (\S+) (\S+) (\S+) (\S+) (\S+) (.*)';
  151. } elsif ($format eq 'grufti') {
  152. $normalline = '^\[(\d+):\d+\] <([^>]+)> (.*)';
  153. $actionline = '^\[(\d+):\d+\] \* (\S+) (.*)';
  154. $thirdline = '^\[(\d+):(\d+)\] (\S+) (\S+) (\S+) (\S+) (\S+) (\S+)(.*)';
  155. } else {
  156. die("Logfile format not supported, check \$format setting.\n");
  157. }
  158. }
  159. sub init_users_config
  160. {
  161. if (open(USERS, $usersfile)) {
  162. my $lineno = 0;
  163. while (<USERS>)
  164. {
  165. $lineno++;
  166. my $line = $_;
  167. next if /^#/;
  168. if ($line =~ /<user.*>/) {
  169. my $nick;
  170. if ($line =~ /nick="([^"]+)"/) {
  171. $nick = $1;
  172. } else {
  173. print STDERR "Warning: no nick specified in $usersfile on line $lineno\n";
  174. next;
  175. }
  176. if ($line =~ /alias="([^"]+)"/) {
  177. my @thisalias = split(/\s+/, $1);
  178. push(@{ $alias{$nick} }, @thisalias);
  179. }
  180. if ($line =~ /pic="([^"]+)"/) {
  181. $userpics{$nick} = $1;
  182. }
  183. if ($line =~ /link="([^"]+)"/) {
  184. $userlinks{$nick} = $1;
  185. }
  186. if ($line =~ /ignore="Y"/i) {
  187. push(@ignore, $nick);
  188. }
  189. }
  190. }
  191. close(USERS);
  192. }
  193. }
  194. sub init_debug
  195. {
  196. if ($debug) {
  197. print "[ Debugging => $debugfile ]\n";
  198. open(DEBUG,"> $debugfile") or print STDERR "$0: Unable to open debug
  199. file($debugfile): $!\n";
  200. debug("*** pisg debug file for $logfile\n");
  201. }
  202. }
  203. sub parse_dir
  204. {
  205. print "Going into $logdir and parsing all files there...\n\n";
  206. my $files = `ls $logdir`;
  207. my @filesarray = split(/\n/, $files);
  208. # Add trailing slash when it's not there..
  209. if (substr($logdir, -1) ne '/') {
  210. $logdir =~ s/(.*)/$1\//;
  211. }
  212. foreach my $file (@filesarray) {
  213. $file = $logdir . $file;
  214. parse_file($file);
  215. }
  216. }
  217. sub parse_file
  218. {
  219. my $file = shift;
  220. # This parses the file..
  221. print "Analyzing log($file) in '$format' format...\n";
  222. open (LOGFILE, $file) or die("$0: Unable to open logfile($file): $!\n");
  223. while($line = <LOGFILE>) {
  224. $lines++; # Increment number of lines.
  225. # Strip mIRC color codes
  226. $line =~ s/$colorcode\d{1,2},\d{1,2}//g;
  227. $line =~ s/$colorcode\d{0,2}//g;
  228. # Strip mIRC bold and underline codes
  229. $line =~ s/[$boldcode$underlinecode]//g;
  230. my $hashref;
  231. # Match normal lines.
  232. if ($hashref = parse_normalline($line)) {
  233. my ($hour, $nick, $saying, $i);
  234. for ($i = 0; $i <= $repeated; $i++) {
  235. if ($i > 0) {
  236. $hashref = parse_normalline($lastnormal);
  237. $lines++; #Increment number of lines for repeated lines
  238. }
  239. $hour = $hashref->{hour};
  240. $nick = find_alias($hashref->{nick});
  241. $saying = $hashref->{saying};
  242. # Timestamp collecting
  243. $times{$hour}++;
  244. unless (grep /^\Q$nick\E$/i, @ignore) {
  245. $normals++;
  246. $line{$nick}++;
  247. # Count up monologues
  248. if ($lastline eq $nick) {
  249. $mono{$nick}++;
  250. if ($mono{$nick} == "5") {
  251. $monologue{$nick}++;
  252. $mono{$nick} = 0;
  253. }
  254. } else {
  255. $mono{$nick} = 0;
  256. }
  257. $lastline = $nick;
  258. my $l = length($saying);
  259. if ($l > $minquote && $l < $maxquote) {
  260. $saying = htmlentities($saying);
  261. # Creates $hash{nick}[n] - a hash of an array.
  262. push (@{ $sayings{$nick} }, $saying);
  263. $longlines{$nick}++;
  264. }
  265. $question{$nick}++
  266. if ($saying =~ /\?/);
  267. $loud{$nick}++
  268. if ($saying =~ /!/);
  269. $foul{$nick}++
  270. if ($saying =~ /ass|fuck|bitch|shit|scheisse|scheiße|kacke|arsch|ficker|ficken|schlampe/);
  271. # Who smiles the most?
  272. # A regex matching al lot of smilies
  273. $smile{$nick}++
  274. if ($saying =~ /[8;:=][ ^-o]?[)pPD}\]>]/);
  275. $sadface{$nick}++
  276. if ($saying =~ /[8;:=][ ^-]?[\(\[\\\/{]/);
  277. # Don't count http:// as a :/ face
  278. $sadface{$nick}--
  279. if ($saying =~ /\w+:\/\//);
  280. foreach my $word (split(/[\s,!?.:;)(]+/, $saying)) {
  281. # remove uninteresting words
  282. next unless (length($word) > 5);
  283. # ignore contractions
  284. next if ($word =~ m/'..?$/);
  285. $wordcount{$word}++ unless (grep /^\Q$word\E$/i, @ignore);
  286. $lastused{$word} = $nick;
  287. }
  288. $length{$nick} += $l;
  289. $totallength += $l;
  290. }
  291. }
  292. $lastnormal = $line;
  293. $repeated = 0;
  294. }
  295. # Match action lines.
  296. elsif ($hashref = parse_actionline($line)) {
  297. my ($hour, $nick, $saying);
  298. $hour = $hashref->{hour};
  299. $nick = find_alias($hashref->{nick});
  300. $saying = $hashref->{saying};
  301. # Timestamp collecting
  302. $times{$hour}++;
  303. unless (grep /^\Q$nick\E$/i, @ignore) {
  304. $actions++;
  305. $line{$nick}++;
  306. my $len = length($saying);
  307. $length{$nick} += $len;
  308. $totallength += $len;
  309. }
  310. }
  311. # Match *** lines.
  312. elsif ($hashref = parse_thirdline($line)) {
  313. my ($hour, $min, $nick, $kicker, $newtopic, $newmode, $newjoin, $newnick);
  314. $hour = $hashref->{hour};
  315. $min = $hashref->{min};
  316. $nick = find_alias($hashref->{nick});
  317. $kicker = $hashref->{kicker};
  318. $newtopic = $hashref->{newtopic};
  319. $newmode = $hashref->{newmode};
  320. $newjoin = $hashref->{newjoin};
  321. $newnick = $hashref->{newnick};
  322. # Timestamp collecting
  323. $times{$hour}++;
  324. unless (grep /^\Q$nick\E$/i, @ignore) {
  325. if (defined($kicker)) {
  326. unless (grep /^\Q$kicker\E$/i, @ignore) {
  327. $gotkick{$nick}++;
  328. $kicked{$kicker}++;
  329. }
  330. } elsif (defined($newtopic)) {
  331. my $tcount = @topics;
  332. $topics[$tcount]{topic} = htmlentities($newtopic);
  333. $topics[$tcount]{nick} = $nick;
  334. $topics[$tcount]{hour} = $hour;
  335. $topics[$tcount]{min} = $min;
  336. # Strip off the quotes (')
  337. $topics[$tcount]{topic} =~ s/^\'(.*)\'$/$1/;
  338. } elsif (defined($newmode)) {
  339. my @opchange = opchanges($newmode);
  340. unless (exists $gaveop{$nick}) { $gaveop{$nick} = 0 }
  341. $gaveop{$nick} += $opchange[0] if $opchange[0];
  342. $tookop{$nick} += $opchange[1] if $opchange[1];
  343. } elsif (defined($newjoin)) {
  344. $joins{$nick}++;
  345. } elsif (defined($newnick) && ($nicktracking == 1)) {
  346. if (find_alias($newnick) eq $newnick) {
  347. if (defined($alias{$nick}) && !defined($alias{$newnick})) {
  348. push (@{$alias{$nick}}, $newnick);
  349. } elsif (defined($alias{$newnick}) && !defined($alias{$nick})) {
  350. push (@{$alias{$newnick}}, $nick);
  351. } elsif ($nick =~ /Guest/) {
  352. push (@{$alias{$newnick}}, ($newnick, $nick));
  353. } else {
  354. push (@{$alias{$nick}}, ($nick, $newnick));
  355. }
  356. }
  357. }
  358. }
  359. if ($hour < $oldtime) { $days++ }
  360. $oldtime = $hour;
  361. }
  362. }
  363. close(LOGFILE);
  364. my ($sec,$min,$hour) = gmtime(time - $^T);
  365. $processtime = sprintf("%02d hours, %02d minutes and %02d seconds", $hour, $min, $sec);
  366. $nicks = scalar keys %line;
  367. print "Finished analyzing log, $days days total.\n";
  368. }
  369. # Here is the 3 parse sub routines, their function is to return a hash with
  370. # the elements in the line. This is where we add the format dependent stuff.
  371. sub parse_normalline
  372. {
  373. # Parse a normal line - returns a hash with 'hour', 'nick' and 'saying'
  374. my $line = shift;
  375. my %hash;
  376. if ($line =~ /$normalline/) {
  377. debug("[$lines] Normal: $1 $2 $3");
  378. if (($format eq 'mIRC') || ($format eq 'xchat') || ($format eq
  379. 'eggdrop') || ($format eq 'bxlog') || ($format eq 'grufti')) {
  380. $hash{hour} = $1;
  381. $hash{nick} = $2;
  382. $hash{saying} = $3;
  383. } else {
  384. die("Format not supported?!\n");
  385. }
  386. return \%hash;
  387. } else {
  388. return;
  389. }
  390. }
  391. sub parse_actionline
  392. {
  393. # Parse an action line - returns a hash with 'hour', 'nick' and 'saying'
  394. my $line = shift;
  395. my %hash;
  396. if ($line =~ /$actionline/) {
  397. debug("[$lines] Action: $1 $2 $3");
  398. if (($format eq 'mIRC') || ($format eq 'xchat') || ($format eq
  399. 'eggdrop') || $format eq 'bxlog' || ($format eq 'grufti')) {
  400. $hash{hour} = $1;
  401. $hash{nick} = $2;
  402. $hash{saying} = $3;
  403. } else {
  404. die("Format not supported?!\n");
  405. }
  406. return \%hash;
  407. } else {
  408. return;
  409. }
  410. }
  411. sub parse_thirdline
  412. {
  413. # Parses the 'third' line - (the third line is everything else, like
  414. # topic changes, mode changes, kicks, etc.)
  415. # parse_thirdline() have to return a hash with the following keys, for
  416. # every format:
  417. # hour - the hour we're in (for timestamp loggin)
  418. # min - the minute we're in (for timestamp loggin)
  419. # nick - the nick
  420. # kicker - the nick which were kicked (if any)
  421. # newtopic - the new topic (if any)
  422. # newmode - a deop or an op, must be '+o' or '-o'
  423. # newjoin - a new nick which has joined the channel
  424. # newnick - a person has changed nick and this is the new nick
  425. my $line = shift;
  426. my %hash;
  427. if ($line =~ /$thirdline/) {
  428. if ($7) {
  429. debug("[$lines] ***: $1 $2 $3 $4 $5 $6 $7");
  430. } else {
  431. debug("[$lines] ***: $1 $2 $3 $4 $5 $6");
  432. }
  433. if ($format eq 'mIRC') {
  434. $hash{hour} = $1;
  435. $hash{min} = $2;
  436. $hash{nick} = $3;
  437. if (($4.$5) eq 'waskicked') {
  438. $hash{kicker} = $7;
  439. } elsif (($4.$5) eq 'changestopic') {
  440. $hash{newtopic} = "$7 $8";
  441. } elsif (($4.$5) eq 'setsmode:') {
  442. $hash{newmode} = $6;
  443. } elsif (($4.$5) eq 'hasjoined') {
  444. $hash{newjoin} = $3;
  445. } elsif (($4.$5) eq 'nowknown') {
  446. $hash{newnick} = $8;
  447. }
  448. } elsif ($format eq 'xchat') {
  449. $hash{hour} = $1;
  450. $hash{min} = $2;
  451. $hash{nick} = $3;
  452. if (($4.$5) eq 'haskicked') {
  453. $hash{kicker} = $3;
  454. $hash{nick} = $6;
  455. } elsif (($4.$5) eq 'haschanged') {
  456. $hash{newtopic} = $9;
  457. } elsif (($4.$5) eq 'giveschannel') {
  458. $hash{newmode} = '+o';
  459. } elsif (($4.$5) eq 'removeschannel') {
  460. $hash{newmode} = '-o';
  461. } elsif (($5.$6) eq 'hasjoined') {
  462. $hash{newjoin} = $1;
  463. } elsif (($5.$6) eq 'nowknown') {
  464. $hash{newnick} = $8;
  465. }
  466. } elsif ($format eq 'eggdrop') {
  467. $hash{hour} = $1;
  468. $hash{min} = $2;
  469. $hash{nick} = $3;
  470. if (($4.$5) eq 'kickedfrom') {
  471. $7 =~ /^ by ([\S]+):.*/;
  472. $hash{kicker} = $1;
  473. } elsif ($3 eq 'Topic') {
  474. $7 =~ /^ by ([\S]+)![\S]+: (.*)/;
  475. $hash{nick} = $1;
  476. $hash{newtopic} = $2;
  477. } elsif (($4.$5) eq 'modechange') {
  478. $hash{newmode} = $6;
  479. $7 =~ /^ .+ by ([\S]+)!.*/;
  480. $hash{nick} = $1;
  481. $hash{newmode} =~ s/^\'//;
  482. } elsif ($5 eq 'joined') {
  483. $hash{newjoin} = $3;
  484. } elsif (($3.$4) eq 'Nickchange:') {
  485. $hash{nick} = $5;
  486. $7 =~ /([\S]+)/;
  487. $hash{newnick} = $1;
  488. } elsif (($3.$4.$5) eq 'Lastmessagerepeated') {
  489. $repeated = $6;
  490. }
  491. } elsif ($format eq 'bxlog') {
  492. $hash{hour} = $1;
  493. $hash{min} = $2;
  494. $hash{nick} = $3;
  495. if ($5 eq 'kicked') {
  496. $hash{kicker} = $9;
  497. $hash{kicker} =~ s/!.*$//;
  498. } elsif ($3 eq 'Topic') {
  499. $hash{nick} = substr($5, 0, -1);
  500. $hash{newtopic} = "$6 $7 $8 $9 $10";
  501. } elsif ($5 eq '[+o') {
  502. $hash{newmode} = '+o';
  503. $hash{newmode} = substr($6, 0, -1);
  504. } elsif ($5 eq '[-o') {
  505. $hash{newmode} = '-o';
  506. $hash{newmode} = substr($6, 0, -1);
  507. } elsif (($4.$5) eq 'hasjoined') {
  508. $hash{newjoin} = $1;
  509. } elsif (($4.$5) eq 'isknown') {
  510. $hash{newnick} = $6;
  511. }
  512. $hash{nick} =~ s/!.*$//;
  513. } elsif ($format eq 'grufti') {
  514. $hash{hour} = $1;
  515. $hash{min} = $2;
  516. $hash{nick} = $3;
  517. if ($5 eq 'kicked') {
  518. $hash{kicker} = $3;
  519. $hash{nick} = $6;
  520. } elsif (($4.$5) eq 'haschanged') {
  521. $hash{newtopic} = $9;
  522. } elsif (($4.$5) eq 'modechange') {
  523. $hash{newmode} = substr($6, 1);
  524. $hash{nick} = substr($9, 1);
  525. } elsif ($5 eq 'joined') {
  526. $hash{newjoin} = $1;
  527. } elsif (($3.$4) eq 'Nickchange') {
  528. $hash{nick} = $7;
  529. $hash{newnick} = $9;
  530. }
  531. } else {
  532. die("Format not supported?!\n");
  533. }
  534. return \%hash;
  535. } else {
  536. return;
  537. }
  538. }
  539. sub opchanges
  540. {
  541. my @modes = split(//, $_[0]);
  542. my ($mode,$plus) = ("",0);
  543. my ($gaveop,$tookop) = (0,0);
  544. foreach (@modes) {
  545. if (/^\+$/) { $plus = 1; next; }
  546. elsif (/^-$/) { $plus = 0; next; }
  547. else { next unless /^o$/ }
  548. if ($plus) { $gaveop++ } else { $tookop++ }
  549. }
  550. my @out = ($gaveop,$tookop);
  551. return @out;
  552. }
  553. sub htmlentities
  554. {
  555. my $str = shift;
  556. $str =~ s/\&/\&amp;/g;
  557. $str =~ s/\</\&lt;/g;
  558. $str =~ s/\>/\&gt;/g;
  559. return $str;
  560. }
  561. sub html
  562. {
  563. my $html = shift;
  564. print OUTPUT $html . "\n";
  565. }
  566. sub template_text
  567. {
  568. # This function is for the homemade template system. It receives a name
  569. # of a template and a hash with the fields in the template to update to
  570. # its corresponding value
  571. my $template = shift;
  572. my %hash = @_;
  573. my $text;
  574. if (!$T{$lang}{$template}) {
  575. # Fall back to English if the language template doesn't exist
  576. $text = $T{EN}{$template};
  577. }
  578. $text = $T{$lang}{$template};
  579. if (!$text) {
  580. die("No such template $template\n");
  581. }
  582. foreach my $key (sort keys %hash) {
  583. $text =~ s/\[:$key\]/$hash{$key}/;
  584. $text =~ s/ü/&uuml;/g;
  585. $text =~ s/ö/&ouml;/g;
  586. $text =~ s/ä/&auml;/g;
  587. $text =~ s/ß/&szlig/g;
  588. $text =~ s/&/&amp;/g;
  589. $text =~ s/å/&aring;/g;
  590. $text =~ s/æ/&aelig;/g;
  591. $text =~ s/ø/&oslash;/g;
  592. }
  593. return $text;
  594. }
  595. sub replace_links
  596. {
  597. # Sub to replace urls and e-mail addys to links
  598. my $str = shift;
  599. my $nick = shift;
  600. if ($nick) {
  601. $str =~ s/(http|https|ftp|telnet|news)(:\/\/[-a-zA-Z0-9_]+.[-a-zA-Z0-9.,_~=:;&@%?#\/+]+)/<a href="$1$2" target="_blank" title="Open in new window: $1$2">$nick<\/a>/g;
  602. $str =~ s/([-a-zA-Z0-9._]+@[-a-zA-Z0-9_]+.[-a-zA-Z0-9._]+)/<a href="mailto:$1" title="Mail to $nick">$nick<\/a>/g;
  603. } else {
  604. $str =~ s/(http|https|ftp|telnet|news)(:\/\/[-a-zA-Z0-9_]+.[-a-zA-Z0-9.,_~=:;&@%?#\/+]+)/<a href="$1$2" target="_blank" title="Open in new window: $1$2">$1$2<\/a>/g;
  605. $str =~ s/([-a-zA-Z0-9._]+@[-a-zA-Z0-9_]+.[-a-zA-Z0-9._]+)/<a href="mailto:$1" title="Mail to $1">$1<\/a>/g;
  606. }
  607. return $str;
  608. }
  609. sub debug
  610. {
  611. if ($debug) {
  612. my $debugline = $_[0] . "\n";
  613. print DEBUG $debugline;
  614. }
  615. }
  616. sub find_alias
  617. {
  618. my $nick = shift;
  619. foreach (keys %alias) {
  620. return $_ if (grep /^\Q$nick\E$/i, @{$alias{$_}});
  621. }
  622. return $nick;
  623. }
  624. sub create_html
  625. {
  626. # This is where all subroutines get executed, you can actually design
  627. # your own layout here, the lines should be self-explainable
  628. print "Now generating HTML($outputfile)...\n";
  629. open (OUTPUT, "> $outputfile") or die("$0: Unable to open outputfile($outputfile): $!\n");
  630. htmlheader();
  631. pageheader();
  632. activetimes();
  633. activenicks();
  634. headline(template_text('bignumtopic'));
  635. html("<table width=\"614\">\n"); # Needed for sections
  636. questions();
  637. loudpeople();
  638. mostsmiles();
  639. mostsad();
  640. longlines();
  641. shortlines();
  642. html("</table>"); # Needed for sections
  643. mostusedword();
  644. mostreferenced();
  645. headline(template_text('othernumtopic'));
  646. html("<table width=\"614\">\n"); # Needed for sections
  647. gotkicks();
  648. mostkicks();
  649. mostop();
  650. mostmonologues();
  651. mostjoins();
  652. mostfoul();
  653. html("</table>"); # Needed for sections
  654. headline(template_text('latesttopic'));
  655. html("<table width=\"614\">\n"); # Needed for sections
  656. lasttopics();
  657. html("</table>"); # Needed for sections
  658. my %hash = ( lines => $lines );
  659. html(template_text('totallines', %hash) . "<br><br>");
  660. htmlfooter();
  661. close(OUTPUT);
  662. }
  663. sub activetimes
  664. {
  665. # The most actives times on the channel
  666. my (%output, $tbgcolor);
  667. &headline(template_text('activetimestopic'));
  668. my @toptime = sort { $times{$b} <=> $times{$a} } keys %times;
  669. my $highest_value = $times{$toptime[0]};
  670. my @now = localtime($timestamp);
  671. my $image;
  672. for my $hour (sort keys %times) {
  673. debug("Time: $hour => ". $times{$hour});
  674. if ($toptime[0] == $hour) {
  675. $image = $pic2;
  676. } else {
  677. $image = $pic1;
  678. }
  679. my $size = ($times{$hour} / $highest_value) * 100;
  680. my $percent = ($times{$hour} / $lines) * 100;
  681. $percent =~ s/(\.\d)\d+/$1/;
  682. if ($timeoffset =~ /\+(\d+)/) {
  683. # We must plus some hours to the time
  684. $hour += $1;
  685. $hour = $hour % 24;
  686. if ($hour < 10) { $hour = "0" . $hour; }
  687. } elsif ($timeoffset =~ /-(\d+)/) {
  688. # We must remove some hours from the time
  689. $hour -= $1;
  690. $hour = $hour % 24;
  691. if ($hour < 10) { $hour = "0" . $hour; }
  692. }
  693. $output{$hour} = "<td align=\"center\" valign=\"bottom\" class=\"asmall\">$percent%<br><img src=\"$image\" width=\"15\" height=\"$size\" alt=\"$percent\"></td>\n";
  694. }
  695. html("<table border=\"0\" width=\"614\"><tr>\n");
  696. for ($b = 0; $b < 24; $b++) {
  697. if ($b < 10) { $a = "0" . $b; } else { $a = $b; }
  698. if (!defined($output{$a}) || $output{$a} eq "") {
  699. html("<td align=\"center\" valign=\"bottom\" class=\"asmall\">0%</td>");
  700. } else {
  701. html($output{$a});
  702. }
  703. }
  704. html("</tr><tr>");
  705. for ($b = 0; $b < 24; $b++) {
  706. if ($now[2] == $b) { $tbgcolor = "\#AAAAAA"; } else { $tbgcolor = "\#CCCCCC"; }
  707. html("<td bgcolor=\"$tbgcolor\" align=\"center\" class=\"small\">$b</td>");
  708. }
  709. html("</tr></table>");
  710. }
  711. sub activenicks
  712. {
  713. # The most active nicks (those who wrote most lines)
  714. my $randomline;
  715. &headline(template_text('activenickstopic'));
  716. html("<table border=\"0\" width=\"614\"><tr>");
  717. html("<td>&nbsp;</td><td bgcolor=\"$tdtop\"><b>" . template_text('nick') . "</b></td><td bgcolor=\"$tdtop\"><b>" . template_text('numberlines') ."</b></td><td bgcolor=\"$tdtop\"><b>". template_text('randquote') ."</b></td>");
  718. if (%userpics) {
  719. html("<td bgcolor=\"$tdtop\"><b>" . template_text('userpic') ."</b></td>");
  720. }
  721. html("</tr>");
  722. my @active = sort { $line{$b} <=> $line{$a} } keys %line;
  723. if ($activenicks > $nicks) {
  724. $activenicks = $nicks;
  725. print "Note: There was less nicks in the logfile than your specificied there to be in most active nicks...\n";
  726. }
  727. my ($nick, $visiblenick);
  728. my $i = 1;
  729. for (my $c = 0; $c < $activenicks; $c++) {
  730. $nick = $active[$c];
  731. $visiblenick = $active[$c];
  732. if (!$longlines{$nick}) {
  733. $randomline = "";
  734. } else {
  735. my $rand = rand($longlines{$nick});
  736. $randomline = $sayings{$nick}[$rand];
  737. }
  738. # Convert URLs and e-mail addys to links
  739. $randomline = replace_links($randomline);
  740. # Add a link to the nick if there is any
  741. if ($userlinks{$nick}) {
  742. $visiblenick = replace_links($userlinks{$nick}, $nick);
  743. }
  744. my $h = $hicell;
  745. $h =~ s/^#//;
  746. $h = hex $h;
  747. my $h2 = $hicell2;
  748. $h2 =~ s/^#//;
  749. $h2 = hex $h2;
  750. my $f_b = $h & 0xff;
  751. my $f_g = ($h & 0xff00) >> 8;
  752. my $f_r = ($h & 0xff0000) >> 16;
  753. my $t_b = $h2 & 0xff;
  754. my $t_g = ($h2 & 0xff00) >> 8;
  755. my $t_r = ($h2 & 0xff0000) >> 16;
  756. my $col_b = sprintf "%0.2x", abs int(((($t_b - $f_b) / $activenicks) * +$c) + $f_b);
  757. my $col_g = sprintf "%0.2x", abs int(((($t_g - $f_g) / $activenicks) * +$c) + $f_g);
  758. my $col_r = sprintf "%0.2x", abs int(((($t_r - $f_r) / $activenicks) * +$c) + $f_r);
  759. html("<tr><td bgcolor=\"$rankc\" align=\"left\">");
  760. my $line = $line{$nick};
  761. html("$i</td><td bgcolor=\"#$col_r$col_g$col_b\">$visiblenick</td><td bgcolor=\"#$col_r$col_g$col_b\">$line</td><td bgcolor=\"#$col_r$col_g$col_b\">");
  762. html("\"$randomline\"</td>");
  763. if ($userpics{$nick}) {
  764. html("<td bgcolor=\"#$col_r$col_g$col_b\" align=\"center\"><img valign=\"middle\" src=\"$imagepath$userpics{$nick}\"></td>");
  765. }
  766. html("</tr>");
  767. $i++;
  768. }
  769. html("</table><br>");
  770. # ALMOST AS ACTIVE NICKS
  771. @active = sort { $line{$b} <=> $line{$a} } keys %line;
  772. my $nickstoshow = $activenicks + $activenicks2;
  773. unless ($nickstoshow > $nicks) {
  774. html("<br><b><i>" . template_text('nottop') . "</i></b><table><tr>");
  775. for (my $c = $activenicks; $c < $nickstoshow; $c++) {
  776. unless ($c % 5) { unless ($c == $activenicks) { html("</tr><tr>"); } }
  777. html("<td bgcolor=\"$rankc\" class=\"small\">");
  778. my $nick = $active[$c];
  779. my $lines = $line{$nick};
  780. html("$nick ($lines)</td>");
  781. }
  782. html("</table>");
  783. }
  784. }
  785. sub mostusedword
  786. {
  787. # Lao the infamous word usage statistics
  788. my %usages;
  789. foreach my $word (sort keys %wordcount) {
  790. next if exists $line{$word};
  791. $usages{$word} = $wordcount{$word};
  792. }
  793. my @popular = sort { $usages{$b} <=> $usages{$a} } keys %usages;
  794. if (@popular) {
  795. &headline(template_text('mostwordstopic'));
  796. html("<table border=\"0\" width=\"614\"><tr>");
  797. html("<td>&nbsp;</td><td bgcolor=\"$tdtop\"><b>" . template_text('word') . "</b></td>");
  798. html("<td bgcolor=\"$tdtop\"><b>" . template_text('numberuses') . "</b></td>");
  799. html("<td bgcolor=\"$tdtop\"><b>" . template_text('lastused') . "</b></td>");
  800. for(my $i = 0; $i < 10; $i++) {
  801. last unless $i < $#popular;
  802. my $a = $i + 1;
  803. my $popular = $popular[$i];
  804. my $wordcount = $wordcount{$popular[$i]};
  805. my $lastused = $lastused{$popular[$i]};
  806. html("<tr><td bgcolor=\"$rankc\"><b>$a</b>");
  807. html("<td bgcolor=\"$hicell\">$popular</td>");
  808. html("<td bgcolor=\"$hicell\">$wordcount</td>");
  809. html("<td bgcolor=\"$hicell\">$lastused</td>");
  810. html("</tr>");
  811. }
  812. html("</table>");
  813. }
  814. }
  815. sub mostreferenced
  816. {
  817. my %usages;
  818. foreach my $word (sort keys %wordcount) {
  819. next unless exists $line{$word};
  820. $usages{$word} = $wordcount{$word};
  821. }
  822. my @popular = sort { $usages{$b} <=> $usages{$a} } keys %usages;
  823. if (@popular) {
  824. &headline(template_text('referencetopic'));
  825. html("<table border=\"0\" width=\"614\"><tr>");
  826. html("<td>&nbsp;</td><td bgcolor=\"$tdtop\"><b>" . template_text('nick') . "</b></td>");
  827. html("<td bgcolor=\"$tdtop\"><b>" . template_text('numberuses') . "</b></td>");
  828. html("<td bgcolor=\"$tdtop\"><b>" . template_text('lastused') . "</b></td>");
  829. for(my $i = 0; $i < 5; $i++) {
  830. last unless $i < $#popular;
  831. my $a = $i + 1;
  832. my $popular = $popular[$i];
  833. my $wordcount = $wordcount{$popular[$i]};
  834. my $lastused = $lastused{$popular[$i]};
  835. html("<tr><td bgcolor=\"$rankc\"><b>$a</b>");
  836. html("<td bgcolor=\"$hicell\">$popular</td>");
  837. html("<td bgcolor=\"$hicell\">$wordcount</td>");
  838. html("<td bgcolor=\"$hicell\">$lastused</td>");
  839. html("</tr>");
  840. }
  841. html("</table>");
  842. }
  843. }
  844. sub questions
  845. {
  846. # Persons who asked the most questions
  847. foreach my $nick (sort keys %question) {
  848. if ($line{$nick} > 100) {
  849. $qpercent{$nick} = ($question{$nick} / $line{$nick}) * 100;
  850. $qpercent{$nick} =~ s/(\.\d)\d+/$1/;
  851. }
  852. }
  853. my @question = sort { $qpercent{$b} <=> $qpercent{$a} } keys %qpercent;
  854. if (@question) {
  855. my %hash = (
  856. nick => $question[0],
  857. per => $qpercent{$question[0]}
  858. );
  859. my $text = template_text('question1', %hash);
  860. html("<tr><td bgcolor=\"$hicell\">$text");
  861. if (@question >= 2) {
  862. my %hash = (
  863. nick => $question[1],
  864. per => $qpercent{$question[1]}
  865. );
  866. my $text = template_text('question2', %hash);
  867. html("<br><span class=\"small\">$text</span>");
  868. }
  869. html("</td></tr>");
  870. } else {
  871. html("<tr><td bgcolor=\"$hicell\">" . template_text('question3') . "</td></tr>");
  872. }
  873. }
  874. sub loudpeople
  875. {
  876. # The ones who speak LOUDLY!
  877. foreach my $nick (sort keys %loud) {
  878. if ($line{$nick} > 100) {
  879. $lpercent{$nick} = ($loud{$nick} / $line{$nick}) * 100;
  880. $lpercent{$nick} =~ s/(\.\d)\d+/$1/;
  881. }
  882. }
  883. my @loud = sort { $lpercent{$b} <=> $lpercent{$a} } keys %lpercent;
  884. if (@loud) {
  885. my %hash = (
  886. nick => $loud[0],
  887. per => $lpercent{$loud[0]}
  888. );
  889. my $text = template_text('loud1', %hash);
  890. html("<tr><td bgcolor=\"$hicell\">$text");
  891. if (@loud >= 2) {
  892. my %hash = (
  893. nick => $loud[1],
  894. per => $lpercent{$loud[1]}
  895. );
  896. my $text = template_text('loud2', %hash);
  897. html("<br><span class=\"small\">$text</span>");
  898. }
  899. html("</td></tr>");
  900. } else {
  901. my $text = template_text('loud3');
  902. html("<tr><td bgcolor=\"$hicell\">$text</td></tr>");
  903. }
  904. }
  905. sub gotkicks
  906. {
  907. # The persons who got kicked the most
  908. my @gotkick = sort { $gotkick{$b} <=> $gotkick{$a} } keys %gotkick;
  909. if (@gotkick) {
  910. my %hash = (
  911. nick => $gotkick[0],
  912. kicks => $gotkick{$gotkick[0]}
  913. );
  914. my $text = template_text('gotkick1', %hash);
  915. html("<tr><td bgcolor=\"$hicell\">$text");
  916. if (@gotkick >= 2) {
  917. my %hash = (
  918. nick => $gotkick[1],
  919. kicks => $gotkick{$gotkick[1]}
  920. );
  921. my $text = template_text('gotkick2', %hash);
  922. html("<br><span class=\"small\">$text</span>");
  923. }
  924. html("</td></tr>");
  925. }
  926. }
  927. sub mostjoins
  928. {
  929. my @joins = sort { $joins{$b} <=> $joins{$a} } keys %joins;
  930. if (@joins) {
  931. my %hash = (
  932. nick => $joins[0],
  933. joins => $joins{$joins[0]}
  934. );
  935. my $text = template_text('joins', %hash);
  936. html("<tr><td bgcolor=\"$hicell\">$text</td></tr>");
  937. }
  938. }
  939. sub mostkicks
  940. {
  941. # The person who got kicked the most
  942. my @kicked = sort { $kicked{$b} <=> $kicked{$a} } keys %kicked;
  943. if (@kicked) {
  944. my %hash = (
  945. nick => $kicked[0],
  946. kicked => $kicked{$kicked[0]}
  947. );
  948. my $text = template_text('kick1', %hash);
  949. html("<tr><td bgcolor=\"$hicell\">$text");
  950. if (@kicked >= 2) {
  951. my %hash = (
  952. oldnick => $kicked[0],
  953. nick => $kicked[1],
  954. kicked => $kicked{$kicked[1]}
  955. );
  956. my $text = template_text('kick2', %hash);
  957. html("<br><span class=\"small\">$text</span>");
  958. }
  959. html("</td></tr>");
  960. } else {
  961. my $text = template_text('kick3');
  962. html("<tr><td bgcolor=\"$hicell\">$text</td></tr>");
  963. }
  964. }
  965. sub mostmonologues
  966. {
  967. # The person who had the most monologues (speaking to himself)
  968. my @monologue = sort { $monologue{$b} <=> $monologue{$a} } keys %monologue;
  969. if (@monologue) {
  970. my %hash = (
  971. nick => $monologue[0],
  972. monos => $monologue{$monologue[0]}
  973. );
  974. my $text = template_text('mono1', %hash);
  975. html("<tr><td bgcolor=\"$hicell\">$text");
  976. if (@monologue >= 2) {
  977. my %hash = (
  978. nick => $monologue[1],
  979. monos => $monologue{$monologue[1]}
  980. );
  981. my $text = template_text('mono2', %hash);
  982. html("<br><span class=\"small\">$text</span>");
  983. }
  984. html("</td></tr>");
  985. }
  986. }
  987. sub longlines
  988. {
  989. my %len;
  990. # The person(s) who wrote the longest lines
  991. foreach my $nick (sort keys %length) {
  992. if ($line{$nick} > 100) {
  993. $len{$nick} = $length{$nick} / $line{$nick};
  994. $len{$nick} =~ s/(\.\d)\d+/$1/;
  995. }
  996. }
  997. my @len = sort { $len{$b} <=> $len{$a} } keys %len;
  998. my $all_lines = $normals + $actions;
  999. my $totalaverage;
  1000. if ($all_lines > 0) {
  1001. $totalaverage = $totallength / $all_lines;
  1002. $totalaverage =~ s/(\.\d)\d+/$1/;
  1003. }
  1004. if (@len) {
  1005. my %hash = (
  1006. nick => $len[0],
  1007. letters => $len{$len[0]}
  1008. );
  1009. my $text = template_text('long1', %hash);
  1010. html("<tr><td bgcolor=\"$hicell\">$text<br>");
  1011. if (@len >= 2) {
  1012. %hash = (
  1013. channel => $channel,
  1014. avg => $totalaverage
  1015. );
  1016. $text = template_text('long2', %hash);
  1017. html("<span class=\"small\">$text</span></td></tr>");
  1018. }
  1019. }
  1020. }
  1021. sub shortlines
  1022. {
  1023. # This sub should be combined with the longlines sub at some point.. it
  1024. # does basically the same thing.
  1025. my %len;
  1026. # The person(s) who wrote the shortest lines
  1027. foreach my $nick (sort keys %length) {
  1028. if ($line{$nick} > 5) {
  1029. $len{$nick} = $length{$nick} / $line{$nick};
  1030. $len{$nick} =~ s/(\.\d)\d+/$1/;
  1031. }
  1032. }
  1033. my @len = sort { $len{$a} <=> $len{$b} } keys %len;
  1034. if (@len) {
  1035. my %hash = (
  1036. nick => $len[0],
  1037. letters => $len{$len[0]}
  1038. );
  1039. my $text = template_text('short1', %hash);
  1040. html("<tr><td bgcolor=\"$hicell\">$text<br>");
  1041. if (@len >= 2) {
  1042. %hash = (
  1043. nick => $len[1],
  1044. letters => $len{$len[1]}
  1045. );
  1046. $text = template_text('short2', %hash);
  1047. html("<span class=\"small\">$text</span></td></tr>");
  1048. }
  1049. }
  1050. }
  1051. sub mostfoul
  1052. {
  1053. my %spercent;
  1054. foreach my $nick (sort keys %foul) {
  1055. if ($line{$nick} > 15) {
  1056. $spercent{$nick} = ($foul{$nick} / $line{$nick}) * 100;
  1057. $spercent{$nick} =~ s/(\.\d)\d+/$1/;
  1058. }
  1059. }
  1060. my @foul = sort { $spercent{$b} <=> $spercent{$a} } keys %spercent;
  1061. if (@foul) {
  1062. my %hash = (
  1063. nick => $foul[0],
  1064. per => $spercent{$foul[0]}
  1065. );
  1066. my $text = template_text('foul1', %hash);
  1067. html("<tr><td bgcolor=\"$hicell\">$text");
  1068. if (@foul >= 2) {
  1069. my %hash = (
  1070. nick => $foul[1],
  1071. per => $spercent{$foul[1]}
  1072. );
  1073. my $text = template_text('foul2', %hash);
  1074. html("<br><span class=\"small\">$text</span>");
  1075. }
  1076. html("</td></tr>");
  1077. } else {
  1078. my %hash = (
  1079. channel => $channel
  1080. );
  1081. my $text = template_text('foul3', %hash);
  1082. html("<tr><td bgcolor=\"$hicell\">$text</td></tr>");
  1083. }
  1084. }
  1085. sub mostsad
  1086. {
  1087. my %spercent;
  1088. foreach my $nick (sort keys %sadface) {
  1089. if ($line{$nick} > 100) {
  1090. $spercent{$nick} = ($sadface{$nick} / $line{$nick}) * 100;
  1091. $spercent{$nick} =~ s/(\.\d)\d+/$1/;
  1092. }
  1093. }
  1094. my @sadface = sort { $spercent{$b} <=> $spercent{$a} } keys %spercent;
  1095. if (@sadface) {
  1096. my %hash = (
  1097. nick => $sadface[0],
  1098. per => $spercent{$sadface[0]}
  1099. );
  1100. my $text = template_text('sad1', %hash);
  1101. html("<tr><td bgcolor=\"$hicell\">$text");
  1102. if (@sadface >= 2) {
  1103. my %hash = (
  1104. nick => $sadface[1],
  1105. per => $spercent{$sadface[1]}
  1106. );
  1107. my $text = template_text('sad2', %hash);
  1108. html("<br><span class=\"small\">$text</span>");
  1109. }
  1110. html("</td></tr>");
  1111. } else {
  1112. my %hash = (
  1113. channel => $channel
  1114. );
  1115. my $text = template_text('sad3', %hash);
  1116. html("<tr><td bgcolor=\"$hicell\">$text</td></tr>");
  1117. }
  1118. }
  1119. sub mostop
  1120. {
  1121. my @ops = sort { $gaveop{$b} <=> $gaveop{$a} } keys %gaveop;
  1122. my @deops = sort { $tookop{$b} <=> $tookop{$a} } keys %tookop;
  1123. if (@ops) {
  1124. my %hash = (
  1125. nick => $ops[0],
  1126. ops => $gaveop{$ops[0]}
  1127. );
  1128. my $text = template_text('mostop1', %hash);
  1129. html("<tr><td bgcolor=\"$hicell\">$text");
  1130. if (@ops >= 2) {
  1131. my %hash = (
  1132. nick => $ops[1],
  1133. ops => $gaveop{$ops[1]}
  1134. );
  1135. my $text = template_text('mostop2', %hash);
  1136. html("<br><span class=\"small\">$text</span>");
  1137. }
  1138. html("</td></tr>");
  1139. } else {
  1140. my %hash = ( channel => $channel );
  1141. my $text = template_text('mostop3', %hash);
  1142. html("<tr><td bgcolor=\"$hicell\">$text</td></tr>");
  1143. }
  1144. if (@deops) {
  1145. my %hash = (
  1146. channel => $channel,
  1147. nick => $deops[0],
  1148. deops => $tookop{$deops[0]}
  1149. );
  1150. my $text = template_text('mostdeop1', %hash);
  1151. html("<tr><td bgcolor=\"$hicell\">$text");
  1152. if (@deops >= 2) {
  1153. my %hash = (
  1154. nick => $deops[1],
  1155. deops => $tookop{$deops[1]}
  1156. );
  1157. my $text = template_text('mostdeop2', %hash);
  1158. html("<br><span class=\"small\">$text</span>");
  1159. }
  1160. html("</td></tr>");
  1161. } else {
  1162. my %hash = ( channel => $channel );
  1163. my $text = template_text('mostdeop3', %hash);
  1164. html("<tr><td bgcolor=\"$hicell\">$text");
  1165. }
  1166. }
  1167. sub mostsmiles
  1168. {
  1169. # The person(s) who smiled the most :-)
  1170. my %spercent;
  1171. foreach my $nick (sort keys %smile) {
  1172. if ($line{$nick} > 100) {
  1173. $spercent{$nick} = ($smile{$nick} / $line{$nick}) * 100;
  1174. $spercent{$nick} =~ s/(\.\d)\d+/$1/;
  1175. }
  1176. }
  1177. my @smiles = sort { $spercent{$b} <=> $spercent{$a} } keys %spercent;
  1178. if (@smiles) {
  1179. my %hash = (
  1180. nick => $smiles[0],
  1181. per => $spercent{$smiles[0]}
  1182. );
  1183. my $text = template_text('smiles1', %hash);
  1184. html("<tr><td bgcolor=\"$hicell\">$text");
  1185. if (@smiles >= 2) {
  1186. my %hash = (
  1187. nick => $smiles[1],
  1188. per => $spercent{$smiles[1]}
  1189. );
  1190. my $text = template_text('smiles2', %hash);
  1191. html("<br><span class=\"small\">$text</span>");
  1192. }
  1193. html("</td></tr>");
  1194. } else {
  1195. my %hash = (
  1196. channel => $channel
  1197. );
  1198. my $text = template_text('smiles3', %hash);
  1199. html("<tr><td bgcolor=\"$hicell\">$text</td></tr>");
  1200. }
  1201. }
  1202. sub lasttopics
  1203. {
  1204. debug("Total number of topics: ". scalar @topics);
  1205. if (@topics) {
  1206. my $ltopic = @topics - 1;
  1207. my $tlimit = 0;
  1208. $topichistory -= 1;
  1209. if ($ltopic > $topichistory) { $tlimit = $ltopic - $topichistory; }
  1210. for (my $i = $ltopic; $i >= $tlimit; $i--) {
  1211. $topics[$i]{"topic"} = replace_links($topics[$i]{"topic"});
  1212. my $topic = $topics[$i]{topic};
  1213. my $nick = $topics[$i]{nick};
  1214. my $hour = $topics[$i]{hour};
  1215. my $min = $topics[$i]{min};
  1216. html("<tr><td bgcolor=\"$hicell\"><i>$topic</i></td>");
  1217. html("<td bgcolor=\"$hicell\">By <b>$nick</b> at <b>$hour:$min</b></td></tr>");
  1218. }
  1219. } else {
  1220. html("<tr><td bgcolor=\"$hicell\">" . template_text('notopic') ."</td></tr>");
  1221. }
  1222. }
  1223. # Some HTML subs
  1224. sub htmlheader
  1225. {
  1226. print OUTPUT <<HTML;
  1227. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  1228. <html>
  1229. <head>
  1230. <title>$channel @ $network channel statistics</title>
  1231. <style type="text/css">
  1232. a { text-decoration: none }
  1233. a:link { color: $link; }
  1234. a:visited { color: $vlink; }
  1235. a:hover { text-decoration: underline; color: $hlink }
  1236. body {
  1237. background-color: $bgcolor;
  1238. font-family: verdana, arial, sans-serif;
  1239. font-size: 13px;
  1240. color: $text;
  1241. }
  1242. td {
  1243. font-family: verdana, arial, sans-serif;
  1244. font-size: 13px;
  1245. color: $tdcolor;
  1246. }
  1247. .title {
  1248. font-family: tahoma, arial, sans-serif;
  1249. font-size: 16px;
  1250. font-weight: bold;
  1251. }
  1252. .headline { color: $hcolor; }
  1253. .small { font-family: verdana, arial, sans-serif; font-size: 10px; }
  1254. .asmall { font-family: arial narrow, sans-serif; font-size: 10px }
  1255. </style></head>
  1256. <body>
  1257. <div align="center">
  1258. HTML
  1259. my %hash = (
  1260. channel => $channel,
  1261. network => $network,
  1262. maintainer => $maintainer,
  1263. time => $time,
  1264. days => $days,
  1265. nicks => $nicks,
  1266. channel => $channel
  1267. );
  1268. print OUTPUT "<span class=\"title\">" . template_text('pagetitle1', %hash) . "</span><br>";
  1269. print OUTPUT "<br>" . template_text('pagetitle2', %hash) . "<br>";
  1270. print OUTPUT template_text('pagetitle3', %hash) . "<br><br>";
  1271. }
  1272. sub htmlfooter
  1273. {
  1274. print OUTPUT <<HTML;
  1275. <span class="small">
  1276. Stats generated by <a href="http://www.wtf.dk/hp/index.php?page=pisg" title="Go to the pisg homepage">pisg</a> $version<br>
  1277. pisg by <a href="http://www.wtf.dk/hp/" title="Go to the authors homepage">Morten "LostStar" Brix Pedersen</a> and others<br>
  1278. Stats generated in $processtime
  1279. </span>
  1280. </div>
  1281. </body>
  1282. </html>
  1283. HTML
  1284. }
  1285. sub headline
  1286. {
  1287. my ($title) = @_;
  1288. print OUTPUT <<HTML;
  1289. <br>
  1290. <table width="610" cellpadding="1" cellspacing="0" border="0">
  1291. <tr>
  1292. <td bgcolor="$headline">
  1293. <table width="100%" cellpadding="2" cellspacing="0" border="0" align="center">
  1294. <tr>
  1295. <td bgcolor="$hbgcolor" class="text10">
  1296. <div align="center" class="headline"><b>$title</b></div>
  1297. </td>
  1298. </tr>
  1299. </table>
  1300. </td>
  1301. </tr>
  1302. </table>
  1303. HTML
  1304. }
  1305. sub pageheader
  1306. {
  1307. if ($pagehead ne 'none') {
  1308. open(PAGEHEAD, $pagehead) or die("$0: Unable to open $pagehead for reading: $!\n");
  1309. while (<PAGEHEAD>) {
  1310. html($_);
  1311. }
  1312. }
  1313. }
  1314. sub close_debug
  1315. {
  1316. if ($debug) {
  1317. close(DEBUG) or print STDERR "$0: Cannot close debugfile($debugfile): $!\n";
  1318. }
  1319. }
  1320. sub get_cmdlineoptions
  1321. {
  1322. my $tmp;
  1323. # Commandline options
  1324. my $help;
  1325. my $usage = <<END_USAGE;
  1326. Usage: pisg.pl [-c channel] [-l logfile] [-o outputfile] [-m
  1327. maintainer] [-f format] [-n network] [-d logdir] [-a aliasfile]
  1328. [-i ignorefile] [-h]
  1329. -c --channel=xxx : Set channel name
  1330. -l --logfile=xxx : Log file to parse
  1331. -o --outfile=xxx : Name of html file to create
  1332. -m --maintainer=xxx : Channel/statistics maintainer
  1333. -f --format=xxx : Logfile format [see FORMATS file]
  1334. -n --network=xxx : IRC Network this channel is on.
  1335. -d --dir=xxx : Analyze all files in this dir. Ignores logfile.
  1336. -u --usersfile=xxx : Users config file
  1337. -h --help : Output this message and exit (-? also works).
  1338. Example:
  1339. \$ pisg.pl -n IRCnet -f xchat -o suid.html -c \\#channel -l logfile.log
  1340. As always, all options may also be defined by editing the source and calling
  1341. pisg without arguments.
  1342. END_USAGE
  1343. if (GetOptions('channel=s' => \$channel,
  1344. 'logfile=s' => \$logfile,
  1345. 'format=s' => \$format,
  1346. 'network=s' => \$network,
  1347. 'maintainer=s' => \$maintainer,
  1348. 'outfile=s' => \$outputfile,
  1349. 'dir=s' => \$logdir,
  1350. 'ignorefile=s' => \$tmp,
  1351. 'aliasfile=s' => \$tmp,
  1352. 'usersfile=s' => \$usersfile,
  1353. 'help|?' => \$help
  1354. ) == 0 or $help) {
  1355. die($usage);
  1356. }
  1357. if (@ARGV) {
  1358. if ($ARGV[0]) { $channel = $ARGV[0]; }
  1359. if ($ARGV[1]) { $logfile = $ARGV[1]; }
  1360. if ($ARGV[2]) { $outputfile = $ARGV[2]; }
  1361. if ($ARGV[3]) { $maintainer = $ARGV[3]; }
  1362. }
  1363. if ($tmp) {
  1364. die("The aliasfile and ignorefile has been obsoleted by the new
  1365. userscfg, please use that instead [look in users.cfg]\n");
  1366. }
  1367. }
  1368. ### English
  1369. $T{EN}{mostop1} = "<b>[:nick]</b> donated [:ops] ops in the channel...";
  1370. $T{EN}{mostop2} = "<b>[:nick]</b> was also very polite: [:ops] from her/him";
  1371. $T{EN}{mostop3} = "Strange, no op was given on [:channel]!";
  1372. $T{EN}{mostdeop1} = "<b>[:nick]</b> is the channel sheriff with [:deops] deops...";
  1373. $T{EN}{mostdeop2} = "<b>[:nick]</b> deoped [:deops] users";
  1374. $T{EN}{mostdeop3} = "Wow, no op was taken on [:channel]!";
  1375. $T{EN}{question1} = "<b>[:nick]</b> is either stupid or just making many questions... [:per]% lines contained a question!";
  1376. $T{EN}{question2} = "<b>[:nick]</b> didn't know that much either, [:per]% of his lines were questions";
  1377. $T{EN}{question3} = "Nobody asked questions here, just geniuses at this channel?";
  1378. $T{EN}{loud1} = "Loudest one was <b>[:nick]</b> who yelled [:per]% of the time!";
  1379. $T{EN}{loud2} = "Another <i>old yeller</i> was <b>[:nick]</b> who shouted [:per]% of the time!";
  1380. $T{EN}{loud3} = "Nobody raised an exclamation mark, wow.";
  1381. $T{EN}{gotkick1} = "<b>[:nick]</b> wasn't very popular, got kicked [:kicks] times!";
  1382. $T{EN}{gotkick2} = "<b>[:nick]</b> seemed to be hated too, [:kicks] kicks were received";
  1383. $T{EN}{joins} = "<b>[:nick]</b> couldn't decide to stay or to go, [:joins] joins during this reporting period!";
  1384. $T{EN}{kick1} = "<b>[:nick]</b> is insane or just a fair op, kicked a total of [:kicked] people!";
  1385. $T{EN}{kick2} = "[:oldnick]'s faithfull follower, <b>[:nick]</b>, kicked about [:kicked] people";
  1386. $T{EN}{kick3} = "Nice oppers here, no one got kicked!";
  1387. $T{EN}{mono1} = "<b>[:nick]</b> is talking to himself a lot, wrote over 5 lines in a row [:monos] times!";
  1388. $T{EN}{mono2} = "Another lonely one was <b>[:nick]</b>, who managed to hit [:monos] times";
  1389. $T{EN}{long1} = "<b>[:nick]</b> wrote longest lines, average of [:letters] per line...";
  1390. $T{EN}{long2} = "Channel average on [:channel] was [:avg] letters per line";
  1391. $T{EN}{short1} = "<b>[:nick]</b> wrote shortest lines, average of [:letters] per line...";
  1392. $T{EN}{short2} = "[:nick] was tight-lipped, too, averaging [:letters]";
  1393. $T{EN}{foul1} = "<b>[:nick]</b> has quite a potty mouth, [:per]% lines contained foul language";
  1394. $T{EN}{foul2} = "<b>[:nick]</b> also makes sailors blush, [:per]% of the time";
  1395. $T{EN}{foul3} = "Nobody is foul-mouthed at [:channel]! Get out much?";
  1396. $T{EN}{smiles1} = "<b>[:nick]</b> brings happiness to the world, [:per]% lines contained smiling faces :)";
  1397. $T{EN}{smiles2} = "<b>[:nick]</b> isn't a sad person either, who smiled [:per]% of the time";
  1398. $T{EN}{smiles3} = "Nobody smiles at [:channel]! Cheer up guys and girls.";
  1399. $T{EN}{sad1} = "<b>[:nick]</b> seems to be sad at the moment, [:per]% lines contained sad faces :(";
  1400. $T{EN}{sad2} = "<b>[:nick]</b> is also a sad person, who cried [:per]% of the time";
  1401. $T{EN}{sad3} = "Nobody is sad at [:channel]! What a happy channel :-)";
  1402. $T{EN}{notopic} = "A topic was never set on this channel";
  1403. ## Topics
  1404. $T{EN}{bignumtopic} = "Big numbers";
  1405. $T{EN}{othernumtopic} = "Other interesting numbers";
  1406. $T{EN}{latesttopic} = "Latest Topics";
  1407. $T{EN}{activetimestopic} = "Most active times";
  1408. $T{EN}{activenickstopic} = "Most active nicks";
  1409. $T{EN}{mostwordstopic} = "Most used words";
  1410. $T{EN}{referencetopic} = "Most referenced nick";
  1411. ## Other text
  1412. $T{EN}{totallines} = "Total number of lines: [:lines]";
  1413. $T{EN}{nick} = "Nick";
  1414. $T{EN}{numberlines} = "Number of lines";
  1415. $T{EN}{randquote} = "Random quote";
  1416. $T{EN}{userpic} = "Userpic";
  1417. $T{EN}{nottop} = "These didn't make it to the top:";
  1418. $T{EN}{word} = "Word";
  1419. $T{EN}{numberuses} = "Number of Uses";
  1420. $T{EN}{lastused} = "Last Used by";
  1421. $T{EN}{pagetitle1} = "[:channel] @ [:network] stats by [:maintainer]";
  1422. $T{EN}{pagetitle2} = "Statistics generated on [:time]";
  1423. $T{EN}{pagetitle3} = "During this [:days]\-days reporting period, a total number of <b>[:nicks]</b> different nicks were represented on [:channel].";
  1424. ### German
  1425. $T{DE}{mostop1} = "<b>[:nick]</b> vergab [:ops] ops im Channel...";
  1426. $T{DE}{mostop2} = "<b>[:nick]</b> war auch sehr zuvorkommend: [:ops] von ihm/ihr";
  1427. $T{DE}{mostop3} = "Komisch, kein op wurde in [:channel] vergeben!";
  1428. $T{DE}{mostdeop1} = "<b>[:nick]</b> ist die Channel-Polizei. Er/Sie hat [:deops] Usern das @ wieder weggenommen...";
  1429. $T{DE}{mostdeop2} = "<b>[:nick]</b> nahm [:deops] Usern das @ wieder weg.";
  1430. $T{DE}{mostdeop3} = "Wow, niemand wurde deopped in [:channel]!";
  1431. $T{DE}{question1} = "<b>[:nick]</b> hat wohl in der Schule nicht gut aufgepasst... [:per]% seiner Zeilen enthielten eine Frage!";
  1432. $T{DE}{question2} = "<b>[:nick]</b> weiss wohl auch nicht viel, [:per]% seiner Zeilen waren Fragen";
  1433. $T{DE}{question3} = "Niemand hat hier was gefragt, sollte das etwa ein Channel voller Genies sein? ;)";
  1434. $T{DE}{loud1} = "Am lautesten war <b>[:nick]</b> der [:per]% der Zeit geschrieen hat!";
  1435. $T{DE}{loud2} = "Ein anderer <i>Schreihals</i> war <b>[:nick]</b> der/die [:per]% der Zeit rumgeschrieen hat!";
  1436. $T{DE}{loud3} = "Niemand hat ein Ausrufungszeichen benutzt, wow... Zurückhaltende User im Channel ;)";
  1437. $T{DE}{gotkick1} = "<b>[:nick]</b> war wohl der Channelclown, er/sie wurde [:kicks] mal gekickt!";
  1438. $T{DE}{gotkick2} = "<b>[:nick]</b> konnte sich scheinbar auch nicht benehmen, [:kicks] kicks für ihn/sie";
  1439. $T{DE}{joins} = "<b>[:nick]</b> konnte sich nicht entscheiden im Channel zu bleiben oder zu gehen, [:joins] joins während des Statistik-Zeitraums!";
  1440. $T{DE}{kick1} = "Ist <b>[:nick]</b> jetzt einfach nur ein fairer Op oder macht ihm/ihr das Spass? Er/Sie kickte [:kicked] User!";
  1441. $T{DE}{kick2} = "[:oldnick]'s würdiger Nachfolger, <b>[:nick]</b>, er/sie kickte [:kicked] User";
  1442. $T{DE}{kick3} = "Nette Opper hier, niemand wurde gekickt!";
  1443. $T{DE}{mono1} = "<b>[:nick]</b> spricht viel mit sich selbst, er/sie schrieb über 5 Zeilen in einer Reihe und das [:monos] mal!";
  1444. $T{DE}{mono2} = "Ein anderes einsames Herz ist <b>[:nick]</b>, der/die [:monos] mal mit sich selbst redete";
  1445. $T{DE}{long1} = "<b>[:nick]</b> ist die Labertasche im Channel Er/Sie schrieb die längste Zeile mit durchschnittlich [:letters] Buchstaben pro Zeile...";
  1446. $T{DE}{long2} = "Channel-Durchschnitt in [:channel] war [:avg] Buchstaben pro Zeile";
  1447. $T{DE}{short1} = "<b>[:nick]</b> ist nicht sehr Mitteilungsbedürftig. Er/Sie schrieb die kürzeste Zeile mit durchschnittlich [:letters] Buchstaben pro Zeile...";
  1448. $T{DE}{short2} = "[:nick] war auch sehr kurzfassend, durchschnittlich [:letters] Buchstaben pro Zeile";
  1449. $T{DE}{foul1} = "<b>[:nick]</b> hat in seiner/ihrer Jugend keine Erziehung genossen, [:per]% seiner/ihrer S&auml;tze enthielten Schimpfworte!";
  1450. $T{DE}{foul2} = "<b>[:nick]</b> war [:per]% der Zeit unartig (Ob da der Weihnachtsman noch kommt?)";
  1451. $T{DE}{foul3} = "Alle gut erzogen in [:channel], niemand hat Schimpfworte benutzt!";
  1452. $T{DE}{smiles1} = "<b>[:nick]</b> ist ein fröhlicher Mensch, [:per]% seiner/ihrer Zeilen enthielt ein fröhliches Smily :)";
  1453. $T{DE}{smiles2} = "<b>[:nick]</b> scheint auch glücklich zu sein. Er/Sie \"smilte\" [:per]% der Zeit";
  1454. $T{DE}{smiles3} = "Niemand \"smilte\" in [:channel]! Los Leute legt mal wieder ein Lächeln auf :)";
  1455. $T{DE}{sad1} = "<b>[:nick]</b> scheint im Moment nicht gut drauf zu sein, [:per]% seiner/ihrer Zeilen enthielten ein trauriges Smily :(";
  1456. $T{DE}{sad2} = "<b>[:nick]</b> ist auch eine traurige Person, die [:per]% der Zeit geweint hat";
  1457. $T{DE}{sad3} = "Niemand ist traurig in [:channel]! Was für ein fröhlicher Channel :)";
  1458. $T{DE}{notopic} = "In diesem Channel wurde kein Topic gesetzt";
  1459. ## Topics
  1460. $T{DE}{bignumtopic} = "Die Zahlen sprechen für sich :)";
  1461. $T{DE}{othernumtopic} = "Andere interessante Zahlen";
  1462. $T{DE}{latesttopic} = "Letzte Topics";
  1463. $T{DE}{activetimestopic} = "Wann war am meisten los?";
  1464. $T{DE}{activenickstopic} = "Wer quatscht am meisten?";
  1465. $T{DE}{mostwordstopic} = "Am meisten benutzte Wörter";
  1466. $T{DE}{referencetopic} = "Begehrte Nicks :)";
  1467. ## Other text
  1468. $T{DE}{totallines} = "Gesamtanzahl der Zeilen: [:lines]";
  1469. $T{DE}{nick} = "Nick";
  1470. $T{DE}{numberlines} = "Anzahl der Zeilen";
  1471. $T{DE}{randquote} = "Zufalls quote";
  1472. $T{DE}{userpic} = "Userbild";
  1473. $T{DE}{nottop} = "Sie haben es nicht an die Spitze geschafft:";
  1474. $T{DE}{word} = "Wort";
  1475. $T{DE}{numberuses} = "Wie oft benutzt";
  1476. $T{DE}{lastused} = "Zuletzt benutzt von";
  1477. $T{DE}{pagetitle1} = "[:channel] @ [:network] stats erstellt von [:maintainer]";
  1478. $T{DE}{pagetitle2} = "Statistik erstellt am [:time]";
  1479. $T{DE}{pagetitle3} = "Während des Statistikzeitraums von [:days] Tage(n) wurden <b>[:nicks]</b> verschiedene Nicks in [:channel] gezählt.";
  1480. ### Danish
  1481. $T{DK}{mostop1} = "<b>[:nick]</b> gav [:ops] op status i kanalen...";
  1482. $T{DK}{mostop2} = "<b>[:nick]</b> var også venlig at gi': [:ops] fra sig";
  1483. $T{DK}{mostop3} = "Underligt, ingen har fået op på [:channel] endnu!";
  1484. $T{DK}{mostdeop1} = "<b>[:nick]</b> holder orden på [:channel] med [:deops] deops...";
  1485. $T{DK}{mostdeop2} = "<b>[:nick]</b> deoppede [:deops] brugere";
  1486. $T{DK}{mostdeop3} = "Hmm, der var ingen som fik op på [:channel]!";
  1487. $T{DK}{question1} = "<b>[:nick]</b> må være rimelig dum eller efterligner bare Spørge-Jørgen... [:per]% af hans linjer var spørgsmål!";
  1488. $T{DK}{question2} = "<b>[:nick]</b> var heller ingen Einstein, [:per]% af hans linjer var også spørgsmål";
  1489. $T{DK}{question3} = "Ingen spørgsmål på denne kanal. De må sørme være kloge!";
  1490. $T{DK}{loud1} = "Den mest larmende var <b>[:nick]</b>, som råbte [:per]% af tiden!";
  1491. $T{DK}{loud2} = "En anden skrigehals var <b>[:nick]</b>, som råbte [:per]% af tiden!";
  1492. $T{DK}{loud3} = "Der er ingen som råber. Leger de stilleleg?";
  1493. $T{DK}{gotkick1} = "<b>[:nick]</b> er ret upopulær, blev sparket ud [:kicks] gange!";
  1494. $T{DK}{gotkick2} = "<b>[:nick]</b> er heller ikke nogen Elvis, [:kicks] gange fik han sparket";
  1495. $T{DK}{joins} = "<b>[:nick]</b> er lidt forvirret. Han har været inde og ude af kanalen [:joins] gange!";
  1496. $T{DK}{kick1} = "<b>[:nick]</b> er magtsygt eller ved hvordan han/hun skal kontrollere sine fjender. Han har sparket [:kicked] folk ud af kanalen!";
  1497. $T{DK}{kick2} = "[:oldnick] har en efterfølger. <b>[:nick]</b> sparkede [:kicked] folk ud af kanalen";
  1498. $T{DK}{kick3} = "Venlige operatører må man sige. Ingen har fået sparket!";
  1499. $T{DK}{mono1} = "<b>[:nick]</b> snakker meget med sig selv. Han har skrevet over 5 linjer på en gang, [:monos] gange!";
  1500. $T{DK}{mono2} = "En anden ensom person var <b>[:nick]</b>, som snakkede til sig selv [:monos] gange";
  1501. $T{DK}{long1} = "<b>[:nick]</b> skriver meget lange sætninger. Gennemsnittet er [:letters] bogstaver pr. linje...";
  1502. $T{DK}{long2} = "Gennemsnittet på [:channel] er [:avg] bogstaver pr. linje";
  1503. $T{DK}{short1} = "<b>[:nick]</b> skrev de korteste linjer. Gennemsnittet er [:letters] bogstaver pr. linje...";
  1504. $T{DK}{short2} = "[:nick] skriver også korte linjer, med et gennesnit på [:letters]";
  1505. $T{DK}{foul1} = "<b>[:nick]</b> er lidt stor i munden, [:per]% af linjerne indholte uhøfligt sprog";
  1506. $T{DK}{foul2} = "<b>[:nick]</b> burde også vaske munden med sæbe med at det han fyrer af, [:per]% af tiden";
  1507. $T{DK}{foul3} = "Ingen rapkæftede på [:channel]!";
  1508. $T{DK}{smiles1} = "<b>[:nick]</b> er altid glad, [:per]% af linjerne havde glade ansigter :)";
  1509. $T{DK}{smiles2} = "<b>[:nick]</b> er heller ikke en trist person, som smilede [:per]% af tiden";
  1510. $T{DK}{smiles3} = "Ingen smiler på [:channel]! Op med humøret drenge og piger.";
  1511. $T{DK}{sad1} = "<b>[:nick]</b> er meget ked af det for tiden, [:per]% af linjerne havde sørgelige ansigter :(";
  1512. $T{DK}{sad2} = "<b>[:nick]</b> er også en trist person, som græd [:per]% af tiden";
  1513. $T{DK}{sad3} = "Ingen er kede af det på [:channel]! Sikke en glad kanal :-)";
  1514. $T{DK}{notopic} = "A topic was never set on this channel";
  1515. ## Topics
  1516. $T{DK}{bignumtopic} = "Store numre";
  1517. $T{DK}{othernumtopic} = "Andre interessante numre";
  1518. $T{DK}{latesttopic} = "Sidst nyeste topics";
  1519. $T{DK}{activetimestopic} = "Mest aktive tider";
  1520. $T{DK}{activenickstopic} = "Mest aktive nicks";
  1521. $T{DK}{mostwordstopic} = "Mest brugte ord";
  1522. $T{DK}{referencetopic} = "Mest tiltalte nicks";
  1523. ## Other text
  1524. $T{DK}{totallines} = "Hele antal linjer: [:lines]";
  1525. $T{DK}{nick} = "Nick";
  1526. $T{DK}{numberlines} = "Antal linjer";
  1527. $T{DK}{randquote} = "Tilfældig sætning";
  1528. $T{DK}{userpic} = "Brugerbillede";
  1529. $T{DK}{nottop} = "Disse nåede ikke til tops:";
  1530. $T{DK}{word} = "Ord";
  1531. $T{DK}{numberuses} = "Antal forbrug";
  1532. $T{DK}{lastused} = "Sidst brugt af";
  1533. $T{DK}{pagetitle1} = "[:channel] @ [:network] statistikker af [:maintainer]";
  1534. $T{DK}{pagetitle2} = "Statistikker lavet d. [:time]";
  1535. $T{DK}{pagetitle3} = "Igennem denne [:days]\-dages periode, har der været <b>[:nicks]</b> forskellige nicks på [:channel].";
  1536. ### French
  1537. # Not exactly the translation but something fun
  1538. # Time translation needs more update
  1539. $T{FR}{mostop1} = "<b>[:nick]</b> a donné [:ops] ops sur le channel...";
  1540. $T{FR}{mostop2} = "<b>[:nick]</b> est aussi très poli : [:ops] ops de sa part";
  1541. $T{FR}{mostop3} = "Etrange, aucun op n'a été donné sur [:channel]!";
  1542. $T{FR}{mostdeop1} = "<b>[:nick]</b> est le shérif avec [:deops] deops...";
  1543. $T{FR}{mostdeop2} = "<b>[:nick]</b> a deopé [:deops] utilisateurs";
  1544. $T{FR}{mostdeop3} = "Wow, aucun op n'a été retiré sur [:channel]!";
  1545. $T{FR}{question1} = "<b>[:nick]</b> est soit stupide soit trop curieux... [:per]% de ses lignes contiennent une question!";
  1546. $T{FR}{question2} = "<b>[:nick]</b> n'en connait pas davantage, [:per]% de ses lignes étaient des questions";
  1547. $T{FR}{question3} = "Personne ne pose de question ici, tous des génies sur ce channel?";
  1548. $T{FR}{loud1} = "Le plus bruyant est <b>[:nick]</b> qui gueule [:per]% du temps!";
  1549. $T{FR}{loud2} = "Un autre <i>vieux raleur</i> est <b>[:nick]</b> qui braille [:per]% du temps!";
  1550. $T{FR}{loud3} = "Personne ne s'exclame ici, wow.";
  1551. $T{FR}{gotkick1} = "<b>[:nick]</b> n'est pas trés populaire, kické [:kicks] fois!";
  1552. $T{FR}{gotkick2} = "<b>[:nick]</b> n'a pas d'ami non plus, [:kicks] kicks reçus";
  1553. $T{FR}{joins} = "<b>[:nick]</b> ne sait pas s'il doit rester ou partir, [:joins] visites durant cette période!";
  1554. $T{FR}{kick1} = "<b>[:nick]</b> est malade ou alors aime bien jouer, son kick a sévi [:kicked] fois!";
  1555. $T{FR}{kick2} = "Un disciple de [:oldnick], <b>[:nick]</b>, a kické [:kicked] personnes";
  1556. $T{FR}{kick3} = "Les ops sont sympas ici, personne n'a été kické!";
  1557. $T{FR}{mono1} = "<b>[:nick]</b> se parle à lui-meme trés souvent, il a écrit plus de 5 lignes d'un coup à [:monos] reprises!";
  1558. $T{FR}{mono2} = "Un autre incompris est <b>[:nick]</b>, qui a tenté de le dépasser à [:monos] reprises";
  1559. $T{FR}{long1} = "<b>[:nick]</b> a écrit les lignes les plus longues, avec en moyenne [:letters] lettres par ligne...";
  1560. $T{FR}{long2} = "La moyenne sur [:channel] est de [:avg] lettres par ligne";
  1561. $T{FR}{short1} = "<b>[:nick]</b> a écrit les lignes les plus courtes, avec en moyenne [:letters] lettres par ligne...";
  1562. $T{FR}{short2} = "[:nick] n'a pas grand chose a dire non plus, en moyenne [:letters]";
  1563. $T{FR}{foul1} = "<b>[:nick]</b> a du mal a s'exprimer, [:per]% de ses lignes contiennent des mots incompréhensibles";
  1564. $T{FR}{foul2} = "<b>[:nick]</b> parle aussi comme un chartier, [:per]% du temps";
  1565. $T{FR}{foul3} = "Personne n'a de problème pour parler sur [:channel]! Pendant combien de temps encore?";
  1566. $T{FR}{smiles1} = "<b>[:nick]</b> apporte un peu de gaiété dans le monde, [:per]% de ses lignes contiennent un smiley :)";
  1567. $T{FR}{smiles2} = "<b>[:nick]</b> n'est pas triste non plus, il sourit [:per]% du temps";
  1568. $T{FR}{smiles3} = "Personne ne sourit sur [:channel]! Allez faites un effort quoi!";
  1569. $T{FR}{sad1} = "<b>[:nick]</b> semble un peu triste en ce moment, [:per]% de ses lignes contiennent un smiley :(";
  1570. $T{FR}{sad2} = "<b>[:nick]</b> est aussi bien triste, il pleure [:per]% du temps";
  1571. $T{FR}{sad3} = "Personne n'est triste sur [:channel]! Quel channel merveilleux :-)";
  1572. $T{FR}{notopic} = "Il n'y a jamais eu de topic sur ce channel";
  1573. ## Topics
  1574. $T{FR}{bignumtopic} = "Les gros chiffres";
  1575. $T{FR}{othernumtopic} = "D'autres chiffres intéressants";
  1576. $T{FR}{latesttopic} = "Les derniers topics";
  1577. $T{FR}{activetimestopic} = "Les périodes d'intense activité";
  1578. $T{FR}{activenickstopic} = "Les nicks les plus actifs";
  1579. $T{FR}{mostwordstopic} = "Les mots les plus utilisés";
  1580. $T{FR}{referencetopic} = "Les mots les plus utilisés dans la conversation";
  1581. ## Other text
  1582. $T{FR}{totallines} = "Nombre total de lignes: [:lines]";
  1583. $T{FR}{nick} = "Nick";
  1584. $T{FR}{numberlines} = "Nombre de lignes";
  1585. $T{FR}{randquote} = "Citation typique";
  1586. $T{FR}{userpic} = "Image";
  1587. $T{FR}{nottop} = "Ne sont pas dans le classement";
  1588. $T{FR}{word} = "Mot";
  1589. $T{FR}{numberuses} = "Nombre d'occurences";
  1590. $T{FR}{lastused} = "Dernière utilisation par";
  1591. $T{FR}{pagetitle1} = "[:channel] @ [:network] stats par [:maintainer]";
  1592. $T{FR}{pagetitle2} = "Statistiques générées le [:time]";
  1593. $T{FR}{pagetitle3} = "Durant cette periode de [:days] jours, <b>[:nicks]</b> nicks différents sont apparus sur [:channel].";
  1594. &main(); # Run the script