pisg.pl 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068
  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";
  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/å/&aring;/g;
  589. $text =~ s/æ/&aelig;/g;
  590. $text =~ s/ø/&oslash;/g;
  591. }
  592. return $text;
  593. }
  594. sub replace_links
  595. {
  596. # Sub to replace urls and e-mail addys to links
  597. my $str = shift;
  598. my $nick = shift;
  599. if ($nick) {
  600. $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;
  601. $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;
  602. } else {
  603. $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;
  604. $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;
  605. }
  606. return $str;
  607. }
  608. sub debug
  609. {
  610. if ($debug) {
  611. my $debugline = $_[0] . "\n";
  612. print DEBUG $debugline;
  613. }
  614. }
  615. sub find_alias
  616. {
  617. my $nick = shift;
  618. foreach (keys %alias) {
  619. return $_ if (grep /^\Q$nick\E$/i, @{$alias{$_}});
  620. }
  621. return $nick;
  622. }
  623. sub create_html
  624. {
  625. # This is where all subroutines get executed, you can actually design
  626. # your own layout here, the lines should be self-explainable
  627. print "Now generating HTML($outputfile)...\n";
  628. open (OUTPUT, "> $outputfile") or die("$0: Unable to open outputfile($outputfile): $!\n");
  629. htmlheader();
  630. pageheader();
  631. activetimes();
  632. activenicks();
  633. headline(template_text('bignumtopic'));
  634. html("<table width=\"614\">\n"); # Needed for sections
  635. questions();
  636. loudpeople();
  637. mostsmiles();
  638. mostsad();
  639. longlines();
  640. shortlines();
  641. html("</table>"); # Needed for sections
  642. mostusedword();
  643. mostreferenced();
  644. headline(template_text('othernumtopic'));
  645. html("<table width=\"614\">\n"); # Needed for sections
  646. gotkicks();
  647. mostkicks();
  648. mostop();
  649. mostmonologues();
  650. mostjoins();
  651. mostfoul();
  652. html("</table>"); # Needed for sections
  653. headline(template_text('latesttopic'));
  654. html("<table width=\"614\">\n"); # Needed for sections
  655. lasttopics();
  656. html("</table>"); # Needed for sections
  657. my %hash = ( lines => $lines );
  658. html(template_text('totallines', %hash) . "<br><br>");
  659. htmlfooter();
  660. close(OUTPUT);
  661. }
  662. sub activetimes
  663. {
  664. # The most actives times on the channel
  665. my (%output, $tbgcolor);
  666. &headline(template_text('activetimestopic'));
  667. my @toptime = sort { $times{$b} <=> $times{$a} } keys %times;
  668. my $highest_value = $times{$toptime[0]};
  669. my @now = localtime($timestamp);
  670. my $image;
  671. for my $hour (sort keys %times) {
  672. debug("Time: $hour => ". $times{$hour});
  673. if ($toptime[0] == $hour) {
  674. $image = $pic2;
  675. } else {
  676. $image = $pic1;
  677. }
  678. my $size = ($times{$hour} / $highest_value) * 100;
  679. my $percent = ($times{$hour} / $lines) * 100;
  680. $percent =~ s/(\.\d)\d+/$1/;
  681. if ($timeoffset =~ /\+(\d+)/) {
  682. # We must plus some hours to the time
  683. $hour += $1;
  684. $hour = $hour % 24;
  685. if ($hour < 10) { $hour = "0" . $hour; }
  686. } elsif ($timeoffset =~ /-(\d+)/) {
  687. # We must remove some hours from the time
  688. $hour -= $1;
  689. $hour = $hour % 24;
  690. if ($hour < 10) { $hour = "0" . $hour; }
  691. }
  692. $output{$hour} = "<td align=\"center\" valign=\"bottom\" class=\"asmall\">$percent%<br><img src=\"$image\" width=\"15\" height=\"$size\" alt=\"$percent\"></td>\n";
  693. }
  694. html("<table border=\"0\" width=\"614\"><tr>\n");
  695. for ($b = 0; $b < 24; $b++) {
  696. if ($b < 10) { $a = "0" . $b; } else { $a = $b; }
  697. if (!defined($output{$a}) || $output{$a} eq "") {
  698. html("<td align=\"center\" valign=\"bottom\" class=\"asmall\">0%</td>");
  699. } else {
  700. html($output{$a});
  701. }
  702. }
  703. html("</tr><tr>");
  704. for ($b = 0; $b < 24; $b++) {
  705. if ($now[2] == $b) { $tbgcolor = "\#AAAAAA"; } else { $tbgcolor = "\#CCCCCC"; }
  706. html("<td bgcolor=\"$tbgcolor\" align=\"center\" class=\"small\">$b</td>");
  707. }
  708. html("</tr></table>");
  709. }
  710. sub activenicks
  711. {
  712. # The most active nicks (those who wrote most lines)
  713. my $randomline;
  714. &headline(template_text('activenickstopic'));
  715. html("<table border=\"0\" width=\"614\"><tr>");
  716. 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>");
  717. if (%userpics) {
  718. html("<td bgcolor=\"$tdtop\"><b>" . template_text('userpic') ."</b></td>");
  719. }
  720. html("</tr>");
  721. my @active = sort { $line{$b} <=> $line{$a} } keys %line;
  722. if ($activenicks > $nicks) {
  723. $activenicks = $nicks;
  724. print "Note: There was less nicks in the logfile than your specificied there to be in most active nicks...\n";
  725. }
  726. my ($nick, $visiblenick);
  727. my $i = 1;
  728. for (my $c = 0; $c < $activenicks; $c++) {
  729. $nick = $active[$c];
  730. $visiblenick = $active[$c];
  731. if (!$longlines{$nick}) {
  732. $randomline = "";
  733. } else {
  734. my $rand = rand($longlines{$nick});
  735. $randomline = $sayings{$nick}[$rand];
  736. }
  737. # Convert URLs and e-mail addys to links
  738. $randomline = replace_links($randomline);
  739. # Add a link to the nick if there is any
  740. if ($userlinks{$nick}) {
  741. $visiblenick = replace_links($userlinks{$nick}, $nick);
  742. }
  743. my $h = $hicell;
  744. $h =~ s/^#//;
  745. $h = hex $h;
  746. my $h2 = $hicell2;
  747. $h2 =~ s/^#//;
  748. $h2 = hex $h2;
  749. my $f_b = $h & 0xff;
  750. my $f_g = ($h & 0xff00) >> 8;
  751. my $f_r = ($h & 0xff0000) >> 16;
  752. my $t_b = $h2 & 0xff;
  753. my $t_g = ($h2 & 0xff00) >> 8;
  754. my $t_r = ($h2 & 0xff0000) >> 16;
  755. my $col_b = sprintf "%0.2x", abs int(((($t_b - $f_b) / $activenicks) * +$c) + $f_b);
  756. my $col_g = sprintf "%0.2x", abs int(((($t_g - $f_g) / $activenicks) * +$c) + $f_g);
  757. my $col_r = sprintf "%0.2x", abs int(((($t_r - $f_r) / $activenicks) * +$c) + $f_r);
  758. html("<tr><td bgcolor=\"$rankc\" align=\"left\">");
  759. my $line = $line{$nick};
  760. 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\">");
  761. html("\"$randomline\"</td>");
  762. if ($userpics{$nick}) {
  763. html("<td bgcolor=\"#$col_r$col_g$col_b\" align=\"center\"><img valign=\"middle\" src=\"$imagepath$userpics{$nick}\"></td>");
  764. }
  765. html("</tr>");
  766. $i++;
  767. }
  768. html("</table><br>");
  769. # ALMOST AS ACTIVE NICKS
  770. @active = sort { $line{$b} <=> $line{$a} } keys %line;
  771. my $nickstoshow = $activenicks + $activenicks2;
  772. unless ($nickstoshow > $nicks) {
  773. html("<br><b><i>" . template_text('nottop') . "</i></b><table><tr>");
  774. for (my $c = $activenicks; $c < $nickstoshow; $c++) {
  775. unless ($c % 5) { unless ($c == $activenicks) { html("</tr><tr>"); } }
  776. html("<td bgcolor=\"$rankc\" class=\"small\">");
  777. my $nick = $active[$c];
  778. my $lines = $line{$nick};
  779. html("$nick ($lines)</td>");
  780. }
  781. html("</table>");
  782. }
  783. }
  784. sub mostusedword
  785. {
  786. # Lao the infamous word usage statistics
  787. my %usages;
  788. foreach my $word (sort keys %wordcount) {
  789. next if exists $line{$word};
  790. $usages{$word} = $wordcount{$word};
  791. }
  792. my @popular = sort { $usages{$b} <=> $usages{$a} } keys %usages;
  793. if (@popular) {
  794. &headline(template_text('mostwordstopic'));
  795. html("<table border=\"0\" width=\"614\"><tr>");
  796. html("<td>&nbsp;</td><td bgcolor=\"$tdtop\"><b>" . template_text('word') . "</b></td>");
  797. html("<td bgcolor=\"$tdtop\"><b>" . template_text('numberuses') . "</b></td>");
  798. html("<td bgcolor=\"$tdtop\"><b>" . template_text('lastused') . "</b></td>");
  799. for(my $i = 0; $i < 10; $i++) {
  800. last unless $i < $#popular;
  801. my $a = $i + 1;
  802. my $popular = $popular[$i];
  803. my $wordcount = $wordcount{$popular[$i]};
  804. my $lastused = $lastused{$popular[$i]};
  805. html("<tr><td bgcolor=\"$rankc\"><b>$a</b>");
  806. html("<td bgcolor=\"$hicell\">$popular</td>");
  807. html("<td bgcolor=\"$hicell\">$wordcount</td>");
  808. html("<td bgcolor=\"$hicell\">$lastused</td>");
  809. html("</tr>");
  810. }
  811. html("</table>");
  812. }
  813. }
  814. sub mostreferenced
  815. {
  816. my %usages;
  817. foreach my $word (sort keys %wordcount) {
  818. next unless exists $line{$word};
  819. $usages{$word} = $wordcount{$word};
  820. }
  821. my @popular = sort { $usages{$b} <=> $usages{$a} } keys %usages;
  822. if (@popular) {
  823. &headline(template_text('referencetopic'));
  824. html("<table border=\"0\" width=\"614\"><tr>");
  825. html("<td>&nbsp;</td><td bgcolor=\"$tdtop\"><b>" . template_text('nick') . "</b></td>");
  826. html("<td bgcolor=\"$tdtop\"><b>" . template_text('numberuses') . "</b></td>");
  827. html("<td bgcolor=\"$tdtop\"><b>" . template_text('lastused') . "</b></td>");
  828. for(my $i = 0; $i < 5; $i++) {
  829. last unless $i < $#popular;
  830. my $a = $i + 1;
  831. my $popular = $popular[$i];
  832. my $wordcount = $wordcount{$popular[$i]};
  833. my $lastused = $lastused{$popular[$i]};
  834. html("<tr><td bgcolor=\"$rankc\"><b>$a</b>");
  835. html("<td bgcolor=\"$hicell\">$popular</td>");
  836. html("<td bgcolor=\"$hicell\">$wordcount</td>");
  837. html("<td bgcolor=\"$hicell\">$lastused</td>");
  838. html("</tr>");
  839. }
  840. html("</table>");
  841. }
  842. }
  843. sub questions
  844. {
  845. # Persons who asked the most questions
  846. foreach my $nick (sort keys %question) {
  847. if ($line{$nick} > 100) {
  848. $qpercent{$nick} = ($question{$nick} / $line{$nick}) * 100;
  849. $qpercent{$nick} =~ s/(\.\d)\d+/$1/;
  850. }
  851. }
  852. my @question = sort { $qpercent{$b} <=> $qpercent{$a} } keys %qpercent;
  853. if (@question) {
  854. my %hash = (
  855. nick => $question[0],
  856. per => $qpercent{$question[0]}
  857. );
  858. my $text = template_text('question1', %hash);
  859. html("<tr><td bgcolor=\"$hicell\">$text");
  860. if (@question >= 2) {
  861. my %hash = (
  862. nick => $question[1],
  863. per => $qpercent{$question[1]}
  864. );
  865. my $text = template_text('question2', %hash);
  866. html("<br><span class=\"small\">$text</span>");
  867. }
  868. html("</td></tr>");
  869. } else {
  870. html("<tr><td bgcolor=\"$hicell\">" . template_text('question3') . "</td></tr>");
  871. }
  872. }
  873. sub loudpeople
  874. {
  875. # The ones who speak LOUDLY!
  876. foreach my $nick (sort keys %loud) {
  877. if ($line{$nick} > 100) {
  878. $lpercent{$nick} = ($loud{$nick} / $line{$nick}) * 100;
  879. $lpercent{$nick} =~ s/(\.\d)\d+/$1/;
  880. }
  881. }
  882. my @loud = sort { $lpercent{$b} <=> $lpercent{$a} } keys %lpercent;
  883. if (@loud) {
  884. my %hash = (
  885. nick => $loud[0],
  886. per => $lpercent{$loud[0]}
  887. );
  888. my $text = template_text('loud1', %hash);
  889. html("<tr><td bgcolor=\"$hicell\">$text");
  890. if (@loud >= 2) {
  891. my %hash = (
  892. nick => $loud[1],
  893. per => $lpercent{$loud[1]}
  894. );
  895. my $text = template_text('loud2', %hash);
  896. html("<br><span class=\"small\">$text</span>");
  897. }
  898. html("</td></tr>");
  899. } else {
  900. my $text = template_text('loud3');
  901. html("<tr><td bgcolor=\"$hicell\">$text</td></tr>");
  902. }
  903. }
  904. sub gotkicks
  905. {
  906. # The persons who got kicked the most
  907. my @gotkick = sort { $gotkick{$b} <=> $gotkick{$a} } keys %gotkick;
  908. if (@gotkick) {
  909. my %hash = (
  910. nick => $gotkick[0],
  911. kicks => $gotkick{$gotkick[0]}
  912. );
  913. my $text = template_text('gotkick1', %hash);
  914. html("<tr><td bgcolor=\"$hicell\">$text");
  915. if (@gotkick >= 2) {
  916. my %hash = (
  917. nick => $gotkick[1],
  918. kicks => $gotkick{$gotkick[1]}
  919. );
  920. my $text = template_text('gotkick2', %hash);
  921. html("<br><span class=\"small\">$text</span>");
  922. }
  923. html("</td></tr>");
  924. }
  925. }
  926. sub mostjoins
  927. {
  928. my @joins = sort { $joins{$b} <=> $joins{$a} } keys %joins;
  929. if (@joins) {
  930. my %hash = (
  931. nick => $joins[0],
  932. joins => $joins{$joins[0]}
  933. );
  934. my $text = template_text('joins', %hash);
  935. html("<tr><td bgcolor=\"$hicell\">$text</td></tr>");
  936. }
  937. }
  938. sub mostkicks
  939. {
  940. # The person who got kicked the most
  941. my @kicked = sort { $kicked{$b} <=> $kicked{$a} } keys %kicked;
  942. if (@kicked) {
  943. my %hash = (
  944. nick => $kicked[0],
  945. kicked => $kicked{$kicked[0]}
  946. );
  947. my $text = template_text('kick1', %hash);
  948. html("<tr><td bgcolor=\"$hicell\">$text");
  949. if (@kicked >= 2) {
  950. my %hash = (
  951. oldnick => $kicked[0],
  952. nick => $kicked[1],
  953. kicked => $kicked{$kicked[1]}
  954. );
  955. my $text = template_text('kick2', %hash);
  956. html("<br><span class=\"small\">$text</span>");
  957. }
  958. html("</td></tr>");
  959. } else {
  960. my $text = template_text('kick3');
  961. html("<tr><td bgcolor=\"$hicell\">$text</td></tr>");
  962. }
  963. }
  964. sub mostmonologues
  965. {
  966. # The person who had the most monologues (speaking to himself)
  967. my @monologue = sort { $monologue{$b} <=> $monologue{$a} } keys %monologue;
  968. if (@monologue) {
  969. my %hash = (
  970. nick => $monologue[0],
  971. monos => $monologue{$monologue[0]}
  972. );
  973. my $text = template_text('mono1', %hash);
  974. html("<tr><td bgcolor=\"$hicell\">$text");
  975. if (@monologue >= 2) {
  976. my %hash = (
  977. nick => $monologue[1],
  978. monos => $monologue{$monologue[1]}
  979. );
  980. my $text = template_text('mono2', %hash);
  981. html("<br><span class=\"small\">$text</span>");
  982. }
  983. html("</td></tr>");
  984. }
  985. }
  986. sub longlines
  987. {
  988. my %len;
  989. # The person(s) who wrote the longest lines
  990. foreach my $nick (sort keys %length) {
  991. if ($line{$nick} > 100) {
  992. $len{$nick} = $length{$nick} / $line{$nick};
  993. $len{$nick} =~ s/(\.\d)\d+/$1/;
  994. }
  995. }
  996. my @len = sort { $len{$b} <=> $len{$a} } keys %len;
  997. my $all_lines = $normals + $actions;
  998. my $totalaverage;
  999. if ($all_lines > 0) {
  1000. $totalaverage = $totallength / $all_lines;
  1001. $totalaverage =~ s/(\.\d)\d+/$1/;
  1002. }
  1003. if (@len) {
  1004. my %hash = (
  1005. nick => $len[0],
  1006. letters => $len{$len[0]}
  1007. );
  1008. my $text = template_text('long1', %hash);
  1009. html("<tr><td bgcolor=\"$hicell\">$text<br>");
  1010. if (@len >= 2) {
  1011. %hash = (
  1012. channel => $channel,
  1013. avg => $totalaverage
  1014. );
  1015. $text = template_text('long2', %hash);
  1016. html("<span class=\"small\">$text</span></td></tr>");
  1017. }
  1018. }
  1019. }
  1020. sub shortlines
  1021. {
  1022. # This sub should be combined with the longlines sub at some point.. it
  1023. # does basically the same thing.
  1024. my %len;
  1025. # The person(s) who wrote the shortest lines
  1026. foreach my $nick (sort keys %length) {
  1027. if ($line{$nick} > 5) {
  1028. $len{$nick} = $length{$nick} / $line{$nick};
  1029. $len{$nick} =~ s/(\.\d)\d+/$1/;
  1030. }
  1031. }
  1032. my @len = sort { $len{$a} <=> $len{$b} } keys %len;
  1033. if (@len) {
  1034. my %hash = (
  1035. nick => $len[0],
  1036. letters => $len{$len[0]}
  1037. );
  1038. my $text = template_text('short1', %hash);
  1039. html("<tr><td bgcolor=\"$hicell\">$text<br>");
  1040. if (@len >= 2) {
  1041. %hash = (
  1042. nick => $len[1],
  1043. letters => $len{$len[1]}
  1044. );
  1045. $text = template_text('short2', %hash);
  1046. html("<span class=\"small\">$text</span></td></tr>");
  1047. }
  1048. }
  1049. }
  1050. sub mostfoul
  1051. {
  1052. my %spercent;
  1053. foreach my $nick (sort keys %foul) {
  1054. if ($line{$nick} > 15) {
  1055. $spercent{$nick} = ($foul{$nick} / $line{$nick}) * 100;
  1056. $spercent{$nick} =~ s/(\.\d)\d+/$1/;
  1057. }
  1058. }
  1059. my @foul = sort { $spercent{$b} <=> $spercent{$a} } keys %spercent;
  1060. if (@foul) {
  1061. my %hash = (
  1062. nick => $foul[0],
  1063. per => $spercent{$foul[0]}
  1064. );
  1065. my $text = template_text('foul1', %hash);
  1066. html("<tr><td bgcolor=\"$hicell\">$text");
  1067. if (@foul >= 2) {
  1068. my %hash = (
  1069. nick => $foul[1],
  1070. per => $spercent{$foul[1]}
  1071. );
  1072. my $text = template_text('foul2', %hash);
  1073. html("<br><span class=\"small\">$text</span>");
  1074. }
  1075. html("</td></tr>");
  1076. } else {
  1077. my %hash = (
  1078. channel => $channel
  1079. );
  1080. my $text = template_text('foul3', %hash);
  1081. html("<tr><td bgcolor=\"$hicell\">$text</td></tr>");
  1082. }
  1083. }
  1084. sub mostsad
  1085. {
  1086. my %spercent;
  1087. foreach my $nick (sort keys %sadface) {
  1088. if ($line{$nick} > 100) {
  1089. $spercent{$nick} = ($sadface{$nick} / $line{$nick}) * 100;
  1090. $spercent{$nick} =~ s/(\.\d)\d+/$1/;
  1091. }
  1092. }
  1093. my @sadface = sort { $spercent{$b} <=> $spercent{$a} } keys %spercent;
  1094. if (@sadface) {
  1095. my %hash = (
  1096. nick => $sadface[0],
  1097. per => $spercent{$sadface[0]}
  1098. );
  1099. my $text = template_text('sad1', %hash);
  1100. html("<tr><td bgcolor=\"$hicell\">$text");
  1101. if (@sadface >= 2) {
  1102. my %hash = (
  1103. nick => $sadface[1],
  1104. per => $spercent{$sadface[1]}
  1105. );
  1106. my $text = template_text('sad2', %hash);
  1107. html("<br><span class=\"small\">$text</span>");
  1108. }
  1109. html("</td></tr>");
  1110. } else {
  1111. my %hash = (
  1112. channel => $channel
  1113. );
  1114. my $text = template_text('sad3', %hash);
  1115. html("<tr><td bgcolor=\"$hicell\">$text</td></tr>");
  1116. }
  1117. }
  1118. sub mostop
  1119. {
  1120. my @ops = sort { $gaveop{$b} <=> $gaveop{$a} } keys %gaveop;
  1121. my @deops = sort { $tookop{$b} <=> $tookop{$a} } keys %tookop;
  1122. if (@ops) {
  1123. my %hash = (
  1124. nick => $ops[0],
  1125. ops => $gaveop{$ops[0]}
  1126. );
  1127. my $text = template_text('mostop1', %hash);
  1128. html("<tr><td bgcolor=\"$hicell\">$text");
  1129. if (@ops >= 2) {
  1130. my %hash = (
  1131. nick => $ops[1],
  1132. ops => $gaveop{$ops[1]}
  1133. );
  1134. my $text = template_text('mostop2', %hash);
  1135. html("<br><span class=\"small\">$text</span>");
  1136. }
  1137. html("</td></tr>");
  1138. } else {
  1139. my %hash = ( channel => $channel );
  1140. my $text = template_text('mostop3', %hash);
  1141. html("<tr><td bgcolor=\"$hicell\">$text</td></tr>");
  1142. }
  1143. if (@deops) {
  1144. my %hash = (
  1145. channel => $channel,
  1146. nick => $deops[0],
  1147. deops => $tookop{$deops[0]}
  1148. );
  1149. my $text = template_text('mostdeop1', %hash);
  1150. html("<tr><td bgcolor=\"$hicell\">$text");
  1151. if (@deops >= 2) {
  1152. my %hash = (
  1153. nick => $deops[1],
  1154. deops => $tookop{$deops[1]}
  1155. );
  1156. my $text = template_text('mostdeop2', %hash);
  1157. html("<br><span class=\"small\">$text</span>");
  1158. }
  1159. html("</td></tr>");
  1160. } else {
  1161. my %hash = ( channel => $channel );
  1162. my $text = template_text('mostdeop3', %hash);
  1163. html("<tr><td bgcolor=\"$hicell\">$text");
  1164. }
  1165. }
  1166. sub mostsmiles
  1167. {
  1168. # The person(s) who smiled the most :-)
  1169. my %spercent;
  1170. foreach my $nick (sort keys %smile) {
  1171. if ($line{$nick} > 100) {
  1172. $spercent{$nick} = ($smile{$nick} / $line{$nick}) * 100;
  1173. $spercent{$nick} =~ s/(\.\d)\d+/$1/;
  1174. }
  1175. }
  1176. my @smiles = sort { $spercent{$b} <=> $spercent{$a} } keys %spercent;
  1177. if (@smiles) {
  1178. my %hash = (
  1179. nick => $smiles[0],
  1180. per => $spercent{$smiles[0]}
  1181. );
  1182. my $text = template_text('smiles1', %hash);
  1183. html("<tr><td bgcolor=\"$hicell\">$text");
  1184. if (@smiles >= 2) {
  1185. my %hash = (
  1186. nick => $smiles[1],
  1187. per => $spercent{$smiles[1]}
  1188. );
  1189. my $text = template_text('smiles2', %hash);
  1190. html("<br><span class=\"small\">$text</span>");
  1191. }
  1192. html("</td></tr>");
  1193. } else {
  1194. my %hash = (
  1195. channel => $channel
  1196. );
  1197. my $text = template_text('smiles3', %hash);
  1198. html("<tr><td bgcolor=\"$hicell\">$text</td></tr>");
  1199. }
  1200. }
  1201. sub lasttopics
  1202. {
  1203. debug("Total number of topics: ". scalar @topics);
  1204. if (@topics) {
  1205. my $ltopic = @topics - 1;
  1206. my $tlimit = 0;
  1207. $topichistory -= 1;
  1208. if ($ltopic > $topichistory) { $tlimit = $ltopic - $topichistory; }
  1209. for (my $i = $ltopic; $i >= $tlimit; $i--) {
  1210. $topics[$i]{"topic"} = replace_links($topics[$i]{"topic"});
  1211. my $topic = $topics[$i]{topic};
  1212. my $nick = $topics[$i]{nick};
  1213. my $hour = $topics[$i]{hour};
  1214. my $min = $topics[$i]{min};
  1215. html("<tr><td bgcolor=\"$hicell\"><i>$topic</i></td>");
  1216. html("<td bgcolor=\"$hicell\">By <b>$nick</b> at <b>$hour:$min</b></td></tr>");
  1217. }
  1218. } else {
  1219. html("<tr><td bgcolor=\"$hicell\">" . template_text('notopic') ."</td></tr>");
  1220. }
  1221. }
  1222. # Some HTML subs
  1223. sub htmlheader
  1224. {
  1225. print OUTPUT <<HTML;
  1226. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  1227. <html>
  1228. <head>
  1229. <title>$channel @ $network channel statistics</title>
  1230. <style type="text/css">
  1231. a { text-decoration: none }
  1232. a:link { color: $link; }
  1233. a:visited { color: $vlink; }
  1234. a:hover { text-decoration: underline; color: $hlink }
  1235. body {
  1236. background-color: $bgcolor;
  1237. font-family: verdana, arial, sans-serif;
  1238. font-size: 13px;
  1239. color: $text;
  1240. }
  1241. td {
  1242. font-family: verdana, arial, sans-serif;
  1243. font-size: 13px;
  1244. color: $tdcolor;
  1245. }
  1246. .title {
  1247. font-family: tahoma, arial, sans-serif;
  1248. font-size: 16px;
  1249. font-weight: bold;
  1250. }
  1251. .headline { color: $hcolor; }
  1252. .small { font-family: verdana, arial, sans-serif; font-size: 10px; }
  1253. .asmall { font-family: arial narrow, sans-serif; font-size: 10px }
  1254. </style></head>
  1255. <body>
  1256. <div align="center">
  1257. HTML
  1258. my %hash = (
  1259. channel => $channel,
  1260. network => $network,
  1261. maintainer => $maintainer,
  1262. time => $time,
  1263. days => $days,
  1264. nicks => $nicks,
  1265. channel => $channel
  1266. );
  1267. print OUTPUT "<span class=\"title\">" . template_text('pagetitle1', %hash) . "</span><br>";
  1268. print OUTPUT "<br>" . template_text('pagetitle2', %hash) . "<br>";
  1269. print OUTPUT template_text('pagetitle3', %hash) . "<br><br>";
  1270. }
  1271. sub htmlfooter
  1272. {
  1273. print OUTPUT <<HTML;
  1274. <span class="small">
  1275. Stats generated by <a href="http://www.wtf.dk/hp/index.php?page=pisg" title="Go to the pisg homepage">pisg</a> $version<br>
  1276. pisg by <a href="http://www.wtf.dk/hp/" title="Go to the authors homepage">Morten "LostStar" Brix Pedersen</a> and others<br>
  1277. Stats generated in $processtime
  1278. </span>
  1279. </div>
  1280. </body>
  1281. </html>
  1282. HTML
  1283. }
  1284. sub headline
  1285. {
  1286. my ($title) = @_;
  1287. print OUTPUT <<HTML;
  1288. <br>
  1289. <table width="610" cellpadding="1" cellspacing="0" border="0">
  1290. <tr>
  1291. <td bgcolor="$headline">
  1292. <table width="100%" cellpadding="2" cellspacing="0" border="0" align="center">
  1293. <tr>
  1294. <td bgcolor="$hbgcolor" class="text10">
  1295. <div align="center" class="headline"><b>$title</b></div>
  1296. </td>
  1297. </tr>
  1298. </table>
  1299. </td>
  1300. </tr>
  1301. </table>
  1302. HTML
  1303. }
  1304. sub pageheader
  1305. {
  1306. if ($pagehead ne 'none') {
  1307. open(PAGEHEAD, $pagehead) or die("$0: Unable to open $pagehead for reading: $!\n");
  1308. while (<PAGEHEAD>) {
  1309. html($_);
  1310. }
  1311. }
  1312. }
  1313. sub close_debug
  1314. {
  1315. if ($debug) {
  1316. close(DEBUG) or print STDERR "$0: Cannot close debugfile($debugfile): $!\n";
  1317. }
  1318. }
  1319. sub get_cmdlineoptions
  1320. {
  1321. my $tmp;
  1322. # Commandline options
  1323. my $help;
  1324. my $usage = <<END_USAGE;
  1325. Usage: pisg.pl [-c channel] [-l logfile] [-o outputfile] [-m
  1326. maintainer] [-f format] [-n network] [-d logdir] [-a aliasfile]
  1327. [-i ignorefile] [-h]
  1328. -c --channel=xxx : Set channel name
  1329. -l --logfile=xxx : Log file to parse
  1330. -o --outfile=xxx : Name of html file to create
  1331. -m --maintainer=xxx : Channel/statistics maintainer
  1332. -f --format=xxx : Logfile format [see FORMATS file]
  1333. -n --network=xxx : IRC Network this channel is on.
  1334. -d --dir=xxx : Analyze all files in this dir. Ignores logfile.
  1335. -u --usersfile=xxx : Users config file
  1336. -h --help : Output this message and exit (-? also works).
  1337. Example:
  1338. \$ pisg.pl -n IRCnet -f xchat -o suid.html -c \\#channel -l logfile.log
  1339. As always, all options may also be defined by editing the source and calling
  1340. pisg without arguments.
  1341. END_USAGE
  1342. if (GetOptions('channel=s' => \$channel,
  1343. 'logfile=s' => \$logfile,
  1344. 'format=s' => \$format,
  1345. 'network=s' => \$network,
  1346. 'maintainer=s' => \$maintainer,
  1347. 'outfile=s' => \$outputfile,
  1348. 'dir=s' => \$logdir,
  1349. 'ignorefile=s' => \$tmp,
  1350. 'aliasfile=s' => \$tmp,
  1351. 'usersfile=s' => \$usersfile,
  1352. 'help|?' => \$help
  1353. ) == 0 or $help) {
  1354. die($usage);
  1355. }
  1356. if (@ARGV) {
  1357. if ($ARGV[0]) { $channel = $ARGV[0]; }
  1358. if ($ARGV[1]) { $logfile = $ARGV[1]; }
  1359. if ($ARGV[2]) { $outputfile = $ARGV[2]; }
  1360. if ($ARGV[3]) { $maintainer = $ARGV[3]; }
  1361. }
  1362. if ($tmp) {
  1363. die("The aliasfile and ignorefile has been obsoleted by the new
  1364. userscfg, please use that instead [look in users.cfg]\n");
  1365. }
  1366. }
  1367. ### English
  1368. $T{EN}{mostop1} = "<b>[:nick]</b> donated [:ops] ops in the channel...";
  1369. $T{EN}{mostop2} = "<b>[:nick]</b> was also very polite: [:ops] from her/him";
  1370. $T{EN}{mostop3} = "Strange, no op was given on [:channel]!";
  1371. $T{EN}{mostdeop1} = "<b>[:nick]</b> is the channel sheriff with [:deops] deops...";
  1372. $T{EN}{mostdeop2} = "<b>[:nick]</b> deoped [:deops] users";
  1373. $T{EN}{mostdeop3} = "Wow, no op was taken on [:channel]!";
  1374. $T{EN}{question1} = "<b>[:nick]</b> is either stupid or just making many questions... [:per]% lines contained a question!";
  1375. $T{EN}{question2} = "<b>[:nick]</b> didn't know that much either, [:per]% of his lines were questions";
  1376. $T{EN}{question3} = "Nobody asked questions here, just geniuses at this channel?";
  1377. $T{EN}{loud1} = "Loudest one was <b>[:nick]</b> who yelled [:per]% of the time!";
  1378. $T{EN}{loud2} = "Another <i>old yeller</i> was <b>[:nick]</b> who shouted [:per]% of the time!";
  1379. $T{EN}{loud3} = "Nobody raised an exclamation mark, wow.";
  1380. $T{EN}{gotkick1} = "<b>[:nick]</b> wasn't very popular, got kicked [:kicks] times!";
  1381. $T{EN}{gotkick2} = "<b>[:nick]</b> seemed to be hated too, [:kicks] kicks were received";
  1382. $T{EN}{joins} = "<b>[:nick]</b> couldn't decide to stay or to go, [:joins] joins during this reporting period!";
  1383. $T{EN}{kick1} = "<b>[:nick]</b> is insane or just a fair op, kicked a total of [:kicked] people!";
  1384. $T{EN}{kick2} = "[:oldnick]'s faithfull follower, <b>[:nick]</b>, kicked about [:kicked] people";
  1385. $T{EN}{kick3} = "Nice oppers here, no one got kicked!";
  1386. $T{EN}{mono1} = "<b>[:nick]</b> is talking to himself a lot, wrote over 5 lines in a row [:monos] times!";
  1387. $T{EN}{mono2} = "Another lonely one was <b>[:nick]</b>, who managed to hit [:monos] times";
  1388. $T{EN}{long1} = "<b>[:nick]</b> wrote longest lines, average of [:letters] per line...";
  1389. $T{EN}{long2} = "Channel average on [:channel] was [:avg] letters per line";
  1390. $T{EN}{short1} = "<b>[:nick]</b> wrote shortest lines, average of [:letters] per line...";
  1391. $T{EN}{short2} = "[:nick] was tight-lipped, too, averaging [:letters]";
  1392. $T{EN}{foul1} = "<b>[:nick]</b> has quite a potty mouth, [:per]% lines contained foul language";
  1393. $T{EN}{foul2} = "<b>[:nick]</b> also makes sailors blush, [:per]% of the time";
  1394. $T{EN}{foul3} = "Nobody is foul-mouthed at [:channel]! Get out much?";
  1395. $T{EN}{smiles1} = "<b>[:nick]</b> brings happiness to the world, [:per]% lines contained smiling faces :)";
  1396. $T{EN}{smiles2} = "<b>[:nick]</b> isn't a sad person either, who smiled [:per]% of the time";
  1397. $T{EN}{smiles3} = "Nobody smiles at [:channel]! Cheer up guys and girls.";
  1398. $T{EN}{sad1} = "<b>[:nick]</b> seems to be sad at the moment, [:per]% lines contained sad faces :(";
  1399. $T{EN}{sad2} = "<b>[:nick]</b> is also a sad person, who cried [:per]% of the time";
  1400. $T{EN}{sad3} = "Nobody is sad at [:channel]! What a happy channel :-)";
  1401. $T{EN}{notopic} = "A topic was never set on this channel";
  1402. ## Topics
  1403. $T{EN}{bignumtopic} = "Big numbers";
  1404. $T{EN}{othernumtopic} = "Other interesting numbers";
  1405. $T{EN}{latesttopic} = "Latest Topics";
  1406. $T{EN}{activetimestopic} = "Most active times";
  1407. $T{EN}{activenickstopic} = "Most active nicks";
  1408. $T{EN}{mostwordstopic} = "Most used words";
  1409. $T{EN}{referencetopic} = "Most referenced nick";
  1410. ## Other text
  1411. $T{EN}{totallines} = "Total number of lines: [:lines]";
  1412. $T{EN}{nick} = "Nick";
  1413. $T{EN}{numberlines} = "Number of lines";
  1414. $T{EN}{randquote} = "Random quote";
  1415. $T{EN}{userpic} = "Userpic";
  1416. $T{EN}{nottop} = "These didn't make it to the top:";
  1417. $T{EN}{word} = "Word";
  1418. $T{EN}{numberuses} = "Number of Uses";
  1419. $T{EN}{lastused} = "Last Used by";
  1420. $T{EN}{pagetitle1} = "[:channel] @ [:network] stats by [:maintainer]";
  1421. $T{EN}{pagetitle2} = "Statistics generated on [:time]";
  1422. $T{EN}{pagetitle3} = "During this [:days]\-days reporting period, a total number of <b>[:nicks]</b> different nicks were represented on [:channel].";
  1423. ### German
  1424. $T{DE}{mostop1} = "<b>[:nick]</b> vergab [:ops] ops im Channel...";
  1425. $T{DE}{mostop2} = "<b>[:nick]</b> war auch sehr zuvorkommend: [:ops] von ihm/ihr";
  1426. $T{DE}{mostop3} = "Komisch, kein op wurde in [:channel] vergeben!";
  1427. $T{DE}{mostdeop1} = "<b>[:nick]</b> ist die Channel-Polizei. Er/Sie hat [:deops] Usern das @ wieder weggenommen...";
  1428. $T{DE}{mostdeop2} = "<b>[:nick]</b> nahm [:deops] Usern das @ wieder weg.";
  1429. $T{DE}{mostdeop3} = "Wow, niemand wurde deopped in [:channel]!";
  1430. $T{DE}{question1} = "<b>[:nick]</b> hat wohl in der Schule nicht gut aufgepasst... [:per]% seiner Zeilen enthielten eine Frage!";
  1431. $T{DE}{question2} = "<b>[:nick]</b> weiss wohl auch nicht viel, [:per]% seiner Zeilen waren Fragen";
  1432. $T{DE}{question3} = "Niemand hat hier was gefragt, sollte das etwa ein Channel voller Genies sein? ;)";
  1433. $T{DE}{loud1} = "Am lautesten war <b>[:nick]</b> der [:per]% der Zeit geschrieen hat!";
  1434. $T{DE}{loud2} = "Ein anderer <i>Schreihals</i> war <b>[:nick]</b> der/die [:per]% der Zeit rumgeschrieen hat!";
  1435. $T{DE}{loud3} = "Niemand hat ein Ausrufungszeichen benutzt, wow... Zurückhaltende User im Channel ;)";
  1436. $T{DE}{gotkick1} = "<b>[:nick]</b> war wohl der Channelclown, er/sie wurde [:kicks] mal gekickt!";
  1437. $T{DE}{gotkick2} = "<b>[:nick]</b> konnte sich scheinbar auch nicht benehmen, [:kicks] kicks für ihn/sie";
  1438. $T{DE}{joins} = "<b>[:nick]</b> konnte sich nicht entscheiden im Channel zu bleiben oder zu gehen, [:joins] joins während des Statistik-Zeitraums!";
  1439. $T{DE}{kick1} = "Ist <b>[:nick]</b> jetzt einfach nur ein fairer Op oder macht ihm/ihr das Spass? Er/Sie kickte [:kicked] User!";
  1440. $T{DE}{kick2} = "[:oldnick]'s würdiger Nachfolger, <b>[:nick]</b>, er/sie kickte [:kicked] User";
  1441. $T{DE}{kick3} = "Nette Opper hier, niemand wurde gekickt!";
  1442. $T{DE}{mono1} = "<b>[:nick]</b> spricht viel mit sich selbst, er/sie schrieb über 5 Zeilen in einer Reihe und das [:monos] mal!";
  1443. $T{DE}{mono2} = "Ein anderes einsames Herz ist <b>[:nick]</b>, der/die [:monos] mal mit sich selbst redete";
  1444. $T{DE}{long1} = "<b>[:nick]</b> ist die Labertasche im Channel Er/Sie schrieb die längste Zeile mit durchschnittlich [:letters] Buchstaben pro Zeile...";
  1445. $T{DE}{long2} = "Channel-Durchschnitt in [:channel] war [:avg] Buchstaben pro Zeile";
  1446. $T{DE}{short1} = "<b>[:nick]</b> ist nicht sehr Mitteilungsbedürftig. Er/Sie schrieb die kürzeste Zeile mit durchschnittlich [:letters] Buchstaben pro Zeile...";
  1447. $T{DE}{short2} = "[:nick] war auch sehr kurzfassend, durchschnittlich [:letters] Buchstaben pro Zeile";
  1448. $T{DE}{foul1} = "<b>[:nick]</b> hat in seiner/ihrer Jugend keine Erziehung genossen, [:per]% seiner/ihrer S&auml;tze enthielten Schimpfworte!";
  1449. $T{DE}{foul2} = "<b>[:nick]</b> war [:per]% der Zeit unartig (Ob da der Weihnachtsman noch kommt?)";
  1450. $T{DE}{foul3} = "Alle gut erzogen in [:channel], niemand hat Schimpfworte benutzt!";
  1451. $T{DE}{smiles1} = "<b>[:nick]</b> ist ein fröhlicher Mensch, [:per]% seiner/ihrer Zeilen enthielt ein fröhliches Smily :)";
  1452. $T{DE}{smiles2} = "<b>[:nick]</b> scheint auch glücklich zu sein. Er/Sie \"smilte\" [:per]% der Zeit";
  1453. $T{DE}{smiles3} = "Niemand \"smilte\" in [:channel]! Los Leute legt mal wieder ein Lächeln auf :)";
  1454. $T{DE}{sad1} = "<b>[:nick]</b> scheint im Moment nicht gut drauf zu sein, [:per]% seiner/ihrer Zeilen enthielten ein trauriges Smily :(";
  1455. $T{DE}{sad2} = "<b>[:nick]</b> ist auch eine traurige Person, die [:per]% der Zeit geweint hat";
  1456. $T{DE}{sad3} = "Niemand ist traurig in [:channel]! Was für ein fröhlicher Channel :)";
  1457. $T{DE}{notopic} = "In diesem Channel wurde kein Topic gesetzt";
  1458. ## Topics
  1459. $T{DE}{bignumtopic} = "Die Zahlen sprechen für sich :)";
  1460. $T{DE}{othernumtopic} = "Andere interessante Zahlen";
  1461. $T{DE}{latesttopic} = "Letzte Topics";
  1462. $T{DE}{activetimestopic} = "Wann war am meisten los?";
  1463. $T{DE}{activenickstopic} = "Wer quatscht am meisten?";
  1464. $T{DE}{mostwordstopic} = "Am meisten benutzte Wörter";
  1465. $T{DE}{referencetopic} = "Begehrte Nicks :)";
  1466. ## Other text
  1467. $T{DE}{totallines} = "Gesamtanzahl der Zeilen: [:lines]";
  1468. $T{DE}{nick} = "Nick";
  1469. $T{DE}{numberlines} = "Anzahl der Zeilen";
  1470. $T{DE}{randquote} = "Zufalls quote";
  1471. $T{DE}{userpic} = "Userbild";
  1472. $T{DE}{nottop} = "Sie haben es nicht an die Spitze geschafft:";
  1473. $T{DE}{word} = "Wort";
  1474. $T{DE}{numberuses} = "Wie oft benutzt";
  1475. $T{DE}{lastused} = "Zuletzt benutzt von";
  1476. $T{DE}{pagetitle1} = "[:channel] @ [:network] stats erstellt von [:maintainer]";
  1477. $T{DE}{pagetitle2} = "Statistik erstellt am [:time]";
  1478. $T{DE}{pagetitle3} = "Während des Statistikzeitraums von [:days] Tage(n) wurden <b>[:nicks]</b> verschiedene Nicks in [:channel] gezählt.";
  1479. ### Danish
  1480. $T{DK}{mostop1} = "<b>[:nick]</b> gav [:ops] op status i kanalen...";
  1481. $T{DK}{mostop2} = "<b>[:nick]</b> var også venlig at gi': [:ops] fra sig";
  1482. $T{DK}{mostop3} = "Underligt, ingen har fået op på [:channel] endnu!";
  1483. $T{DK}{mostdeop1} = "<b>[:nick]</b> holder orden på [:channel] med [:deops] deops...";
  1484. $T{DK}{mostdeop2} = "<b>[:nick]</b> deoppede [:deops] brugere";
  1485. $T{DK}{mostdeop3} = "Hmm, der var ingen som fik op på [:channel]!";
  1486. $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!";
  1487. $T{DK}{question2} = "<b>[:nick]</b> var heller ingen Einstein, [:per]% af hans linjer var også spørgsmål";
  1488. $T{DK}{question3} = "Ingen spørgsmål på denne kanal. De må sørme være kloge!";
  1489. $T{DK}{loud1} = "Den mest larmende var <b>[:nick]</b>, som råbte [:per]% af tiden!";
  1490. $T{DK}{loud2} = "En anden skrigehals var <b>[:nick]</b>, som råbte [:per]% af tiden!";
  1491. $T{DK}{loud3} = "Der er ingen som råber. Leger de stilleleg?";
  1492. $T{DK}{gotkick1} = "<b>[:nick]</b> er ret upopulær, blev sparket ud [:kicks] gange!";
  1493. $T{DK}{gotkick2} = "<b>[:nick]</b> er heller ikke nogen Elvis, [:kicks] gange fik han sparket";
  1494. $T{DK}{joins} = "<b>[:nick]</b> er lidt forvirret. Han har været inde og ude af kanalen [:joins] gange!";
  1495. $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!";
  1496. $T{DK}{kick2} = "[:oldnick] har en efterfølger. <b>[:nick]</b> sparkede [:kicked] folk ud af kanalen";
  1497. $T{DK}{kick3} = "Venlige operatører må man sige. Ingen har fået sparket!";
  1498. $T{DK}{mono1} = "<b>[:nick]</b> snakker meget med sig selv. Han har skrevet over 5 linjer på en gang, [:monos] gange!";
  1499. $T{DK}{mono2} = "En anden ensom person var <b>[:nick]</b>, som snakkede til sig selv [:monos] gange";
  1500. $T{DK}{long1} = "<b>[:nick]</b> skriver meget lange sætninger. Gennemsnittet er [:letters] bogstaver pr. linje...";
  1501. $T{DK}{long2} = "Gennemsnittet på [:channel] er [:avg] bogstaver pr. linje";
  1502. $T{DK}{short1} = "<b>[:nick]</b> skrev de korteste linjer. Gennemsnittet er [:letters] bogstaver pr. linje...";
  1503. $T{DK}{short2} = "[:nick] skriver også korte linjer, med et gennesnit på [:letters]";
  1504. $T{DK}{foul1} = "<b>[:nick]</b> er lidt stor i munden, [:per]% af linjerne indholte uhøfligt sprog";
  1505. $T{DK}{foul2} = "<b>[:nick]</b> burde også vaske munden med sæbe med at det han fyrer af, [:per]% af tiden";
  1506. $T{DK}{foul3} = "Ingen rapkæftede på [:channel]!";
  1507. $T{DK}{smiles1} = "<b>[:nick]</b> er altid glad, [:per]% af linjerne havde glade ansigter :)";
  1508. $T{DK}{smiles2} = "<b>[:nick]</b> er heller ikke en trist person, som smilede [:per]% af tiden";
  1509. $T{DK}{smiles3} = "Ingen smiler på [:channel]! Op med humøret drenge og piger.";
  1510. $T{DK}{sad1} = "<b>[:nick]</b> er meget ked af det for tiden, [:per]% af linjerne havde sørgelige ansigter :(";
  1511. $T{DK}{sad2} = "<b>[:nick]</b> er også en trist person, som græd [:per]% af tiden";
  1512. $T{DK}{sad3} = "Ingen er kede af det på [:channel]! Sikke en glad kanal :-)";
  1513. $T{DK}{notopic} = "A topic was never set on this channel";
  1514. ## Topics
  1515. $T{DK}{bignumtopic} = "Store numre";
  1516. $T{DK}{othernumtopic} = "Andre interessante numre";
  1517. $T{DK}{latesttopic} = "Sidst nyeste topics";
  1518. $T{DK}{activetimestopic} = "Mest aktive tider";
  1519. $T{DK}{activenickstopic} = "Mest aktive nicks";
  1520. $T{DK}{mostwordstopic} = "Mest brugte ord";
  1521. $T{DK}{referencetopic} = "Mest tiltalte nicks";
  1522. ## Other text
  1523. $T{DK}{totallines} = "Hele antal linjer: [:lines]";
  1524. $T{DK}{nick} = "Nick";
  1525. $T{DK}{numberlines} = "Antal linjer";
  1526. $T{DK}{randquote} = "Tilfældig sætning";
  1527. $T{DK}{userpic} = "Brugerbillede";
  1528. $T{DK}{nottop} = "Disse nåede ikke til tops:";
  1529. $T{DK}{word} = "Ord";
  1530. $T{DK}{numberuses} = "Antal forbrug";
  1531. $T{DK}{lastused} = "Sidst brugt af";
  1532. $T{DK}{pagetitle1} = "[:channel] @ [:network] statistikker af [:maintainer]";
  1533. $T{DK}{pagetitle2} = "Statistikker lavet d. [:time]";
  1534. $T{DK}{pagetitle3} = "Igennem denne [:days]\-dages periode, har der været <b>[:nicks]</b> forskellige nicks på [:channel].";
  1535. ### French
  1536. # Not exactly the translation but something fun
  1537. # Time translation needs more update
  1538. $T{FR}{mostop1} = "<b>[:nick]</b> a donné [:ops] ops sur le channel...";
  1539. $T{FR}{mostop2} = "<b>[:nick]</b> est aussi très poli : [:ops] ops de sa part";
  1540. $T{FR}{mostop3} = "Etrange, aucun op n'a été donné sur [:channel]!";
  1541. $T{FR}{mostdeop1} = "<b>[:nick]</b> est le shérif avec [:deops] deops...";
  1542. $T{FR}{mostdeop2} = "<b>[:nick]</b> a deopé [:deops] utilisateurs";
  1543. $T{FR}{mostdeop3} = "Wow, aucun op n'a été retiré sur [:channel]!";
  1544. $T{FR}{question1} = "<b>[:nick]</b> est soit stupide soit trop curieux... [:per]% de ses lignes contiennent une question!";
  1545. $T{FR}{question2} = "<b>[:nick]</b> n'en connait pas davantage, [:per]% de ses lignes étaient des questions";
  1546. $T{FR}{question3} = "Personne ne pose de question ici, tous des génies sur ce channel?";
  1547. $T{FR}{loud1} = "Le plus bruyant est <b>[:nick]</b> qui gueule [:per]% du temps!";
  1548. $T{FR}{loud2} = "Un autre <i>vieux raleur</i> est <b>[:nick]</b> qui braille [:per]% du temps!";
  1549. $T{FR}{loud3} = "Personne ne s'exclame ici, wow.";
  1550. $T{FR}{gotkick1} = "<b>[:nick]</b> n'est pas trés populaire, kické [:kicks] fois!";
  1551. $T{FR}{gotkick2} = "<b>[:nick]</b> n'a pas d'ami non plus, [:kicks] kicks reçus";
  1552. $T{FR}{joins} = "<b>[:nick]</b> ne sait pas s'il doit rester ou partir, [:joins] visites durant cette période!";
  1553. $T{FR}{kick1} = "<b>[:nick]</b> est malade ou alors aime bien jouer, son kick a sévi [:kicked] fois!";
  1554. $T{FR}{kick2} = "Un disciple de [:oldnick], <b>[:nick]</b>, a kické [:kicked] personnes";
  1555. $T{FR}{kick3} = "Les ops sont sympas ici, personne n'a été kické!";
  1556. $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!";
  1557. $T{FR}{mono2} = "Un autre incompris est <b>[:nick]</b>, qui a tenté de le dépasser à [:monos] reprises";
  1558. $T{FR}{long1} = "<b>[:nick]</b> a écrit les lignes les plus longues, avec en moyenne [:letters] lettres par ligne...";
  1559. $T{FR}{long2} = "La moyenne sur [:channel] est de [:avg] lettres par ligne";
  1560. $T{FR}{short1} = "<b>[:nick]</b> a écrit les lignes les plus courtes, avec en moyenne [:letters] lettres par ligne...";
  1561. $T{FR}{short2} = "[:nick] n'a pas grand chose a dire non plus, en moyenne [:letters]";
  1562. $T{FR}{foul1} = "<b>[:nick]</b> a du mal a s'exprimer, [:per]% de ses lignes contiennent des mots incompréhensibles";
  1563. $T{FR}{foul2} = "<b>[:nick]</b> parle aussi comme un chartier, [:per]% du temps";
  1564. $T{FR}{foul3} = "Personne n'a de problème pour parler sur [:channel]! Pendant combien de temps encore?";
  1565. $T{FR}{smiles1} = "<b>[:nick]</b> apporte un peu de gaiété dans le monde, [:per]% de ses lignes contiennent un smiley :)";
  1566. $T{FR}{smiles2} = "<b>[:nick]</b> n'est pas triste non plus, il sourit [:per]% du temps";
  1567. $T{FR}{smiles3} = "Personne ne sourit sur [:channel]! Allez faites un effort quoi!";
  1568. $T{FR}{sad1} = "<b>[:nick]</b> semble un peu triste en ce moment, [:per]% de ses lignes contiennent un smiley :(";
  1569. $T{FR}{sad2} = "<b>[:nick]</b> est aussi bien triste, il pleure [:per]% du temps";
  1570. $T{FR}{sad3} = "Personne n'est triste sur [:channel]! Quel channel merveilleux :-)";
  1571. $T{FR}{notopic} = "Il n'y a jamais eu de topic sur ce channel";
  1572. ## Topics
  1573. $T{FR}{bignumtopic} = "Les gros chiffres";
  1574. $T{FR}{othernumtopic} = "D'autres chiffres intéressants";
  1575. $T{FR}{latesttopic} = "Les derniers topics";
  1576. $T{FR}{activetimestopic} = "Les périodes d'intense activité";
  1577. $T{FR}{activenickstopic} = "Les nicks les plus actifs";
  1578. $T{FR}{mostwordstopic} = "Les mots les plus utilisés";
  1579. $T{FR}{referencetopic} = "Les mots les plus utilisés dans la conversation";
  1580. ## Other text
  1581. $T{FR}{totallines} = "Nombre total de lignes: [:lines]";
  1582. $T{FR}{nick} = "Nick";
  1583. $T{FR}{numberlines} = "Nombre de lignes";
  1584. $T{FR}{randquote} = "Citation typique";
  1585. $T{FR}{userpic} = "Image";
  1586. $T{FR}{nottop} = "Ne sont pas dans le classement";
  1587. $T{FR}{word} = "Mot";
  1588. $T{FR}{numberuses} = "Nombre d'occurences";
  1589. $T{FR}{lastused} = "Dernière utilisation par";
  1590. $T{FR}{pagetitle1} = "[:channel] @ [:network] stats par [:maintainer]";
  1591. $T{FR}{pagetitle2} = "Statistiques générées le [:time]";
  1592. $T{FR}{pagetitle3} = "Durant cette periode de [:days] jours, <b>[:nicks]</b> nicks différents sont apparus sur [:channel].";
  1593. &main(); # Run the script