| 1 | #!/usr/bin/perl |
| 2 | # |
| 3 | # usestats.pl |
| 4 | ############# |
| 5 | |
| 6 | # (c) 10/2003-10/2004 Thomas Hochstein <thh@inter.net> |
| 7 | # |
| 8 | # This program is free software; you can redistribute it and/or modify it under |
| 9 | # the terms of the GNU General Public License as published by the Free |
| 10 | # Software Foundation; either version 2 of the License, or (at your option) |
| 11 | # any later version. |
| 12 | # This program is distributed in the hope that it will be useful, but WITHOUT |
| 13 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 15 | # more details. |
| 16 | |
| 17 | # Modules ############################# |
| 18 | # use Data::Dumper; |
| 19 | use Date::Manip qw(Date_Init ParseDate Date_Cmp DateCalc UnixDate Delta_Format Date_DaysInMonth); |
| 20 | use File::Find; |
| 21 | use Getopt::Std; |
| 22 | use Locale::Recode; |
| 23 | use Mail::Address; |
| 24 | use MIME::Words qw(decode_mimewords); |
| 25 | |
| 26 | # Versionsnummer ###################### |
| 27 | $ver = '0.17 beta (20041003)'; |
| 28 | |
| 29 | # Konstanten ######################### |
| 30 | |
| 31 | $hex_nibb = '[0-9a-fA-F]'; |
| 32 | $gt_hex_nibb = '[0-9A-F]'; |
| 33 | $lt_hex_nibb = '[0-9a-f]'; |
| 34 | $alpha_num = '[0-9a-zA-Z]'; |
| 35 | $lt_alpha_num = '[0-9a-z]'; |
| 36 | $gt_alpha_num = '[0-9A-Z]'; |
| 37 | %reporttitel = ('newsgroups' => 'Newsgroupnutzung', |
| 38 | 'poster' => 'Poster (strukturiert)', |
| 39 | 'posterraw' => 'Poster (unstrukturiert)', |
| 40 | 'subject' => 'Subjects (strukturiert)', |
| 41 | 'newsreader' => 'Newsreader (strukturiert)', |
| 42 | 'nruser' => 'Nutzer pro Newsreader (strukturiert)'); |
| 43 | |
| 44 | # Variablen ########################### |
| 45 | |
| 46 | # Defaults |
| 47 | %config=(); |
| 48 | |
| 49 | # $config{'newsgroup'} = ''; |
| 50 | # $config{'start'} = ''; |
| 51 | # $config{'stop'} = ''; |
| 52 | $config{'recursive'} = 0; |
| 53 | $config{'pipeformat'} = 'mbox'; |
| 54 | $config{'charset'} = 'ISO-8859-1'; |
| 55 | $config{'tz'} = '+0200'; |
| 56 | $config{'graphchar'} = '#'; |
| 57 | |
| 58 | $config{'day'} = 1; |
| 59 | @reports = ('newsgroups','poster','posterraw','subject','newsreader','nruser'); |
| 60 | foreach $report (@reports) { |
| 61 | $config{$report} = 1; |
| 62 | $config{$report.'_width'} = 30; |
| 63 | $config{$report.'_indent'} = 2; |
| 64 | $config{$report.'_lines'} = 0; |
| 65 | $config{$report.'_cutoff'} = 0; |
| 66 | $config{$report.'_graph'} = 20; |
| 67 | }; |
| 68 | $config{'newsgroups'} = 0; |
| 69 | $config{'posterraw'} = 0; |
| 70 | $config{'unknownreader'} = 'show'; |
| 71 | |
| 72 | # Hauptprogramm ####################### |
| 73 | # Konfiguration einlesen |
| 74 | my %options; |
| 75 | getopts('hqc:r:w:', \%options); |
| 76 | if ($options{'h'}) { |
| 77 | print "$0 v $ver\nUsage: $0 [-hq] [-w|r <savefile>] [-c <configfile>]\n"; |
| 78 | exit(0); |
| 79 | }; |
| 80 | print STDERR "$0 v $ver [" . scalar(gmtime) . "]\n(c) 10/2003-10/2004 Thomas Hochstein * <thh\@inter.net>\n" if (!$options{'q'}); |
| 81 | if ($options{'c'}) { |
| 82 | &readconfig($options{'c'}); |
| 83 | }; |
| 84 | if (length($config{'graphchar'}) > 1 or $config{'graphchar'} eq '') { |
| 85 | $config{'graphchar'} = '#'; |
| 86 | }; |
| 87 |