pisg.pl 65 KB

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