X-Git-Url: http://git.treefish.org/fex.git/blobdiff_plain/7fa382617fbaccc0ce522b2b3adbbee9db5ad227..c65ee6f7429eff9a7f58aad7c0aec858ad473092:/bin/logwatch?ds=sidebyside diff --git a/bin/logwatch b/bin/logwatch index 7ef1d4b..d5d2195 100755 --- a/bin/logwatch +++ b/bin/logwatch @@ -1,6 +1,5 @@ #!/usr/bin/perl -w -use Encode; use File::Basename; use Cwd 'abs_path'; use I18N::Langinfo qw'langinfo CODESET'; @@ -19,7 +18,7 @@ unless ($FEXLIB = $ENV{FEXLIB}) { die "$0: no $FEXLIB\n" unless -d $FEXLIB; # import from fex.pp -our ($logdir,$spooldir,$debug); +our (@logdir,$spooldir,$debug); # load common code, local config : $HOME/lib/fex.ph require "$FEXLIB/fex.pp" or die "$0: cannot load $FEXLIB/fex.pp - $!\n"; @@ -27,7 +26,7 @@ require "$FEXLIB/fex.pp" or die "$0: cannot load $FEXLIB/fex.pp - $!\n"; $CTYPE = langinfo(CODESET()); binmode(STDOUT,":encoding($CTYPE)"); -$log = shift || "$logdir/fexsrv.log"; +$log = shift || $logdir[0].'/fexsrv.log'; $ignore = join('|',qw( (CONNECT|CONTINUE).*(crawl|msnbot|obertux) @@ -40,11 +39,12 @@ $ignore = join('|',qw( GET./fup\?showstatus GET./FAQ/faq\.css GET./FAQ/jquery\.js - GET./10+.B GET.*Arrow\.gif GET./apple-touch + GET./browserconfig\.xml User-Agent:.*(Webnote|FeedFetcher|\w+bot|bot/|Website.Watcher|crawler|spider|searchme|Yandex|Slurp|ScoutJet|findlinks|urlmon|nagios) User-Agent:.fnb.*quak + User-Agent:.Google.favicon From:.*(msnbot|yandex|googlebot|webcrawler) Referer:.*sex.*stream Referer:.*stream.*sex @@ -65,16 +65,20 @@ $ignore = join('|',qw( DNT: Via: profile: + Upgrade-Insecure-Requests: if-modified-since Surrogate-Capability Proxy-Authorization http\. + Device-Stock NOKIA_ GPRS X-Proxy-ID X-Moz X.Wap X-FH + X-FB + X-WS X-Nokia X-UCBrowser X-NSN @@ -88,6 +92,10 @@ $ignore = join('|',qw( x-Mobile X-Country X-ClickOnceSupport + X-Newrelic + X-IMForwards + X-Clearswift + X-MDS .*:\s*$ ); @@ -132,7 +140,7 @@ for (;;) { printf " TO=\"%s\"\n",$to; $cgi = ''; if ($comment = slurp("$ddir/comment")) { - printf " COMMENT=\"%s\"\n",decode_utf8($comment,0)||''; + printf " COMMENT=\"%s\"\n",utf8decode($comment)||''; } if (not -f "$ddir/data" and $_ = slurp("$ddir/error")) { s/\n.*//s; @@ -146,12 +154,12 @@ for (;;) { read_skey($1); print "\n"; } + if ($debug and $pid and $cgi) { + &read_debug_log; + }; + $pid = $cgi = ''; } sleep 1; - if ($debug and $pid and $cgi) { - &read_debug_log; - $pid = $cgi = ''; - }; } @@ -164,9 +172,9 @@ sub read_debug_log { for (1..2) { sleep 1; - @log = `ls -rt $logdir/.debug/*_${pid}.$cgi 2>/dev/null`; + @log = `ls -rt $logdir[0]/.debug/*_${pid}.$cgi 2>/dev/null`; if ($log = $log[-1] and open $log,$log) { - # binmode($log,":encoding(UTF-8)"); + binmode($log,":encoding(UTF-8)"); while (<$log>) { s/\r//; if (/^Content-Disposition:.*name="FILE".*filename="(.+)"/i) { @@ -176,7 +184,7 @@ sub read_debug_log { $_ = <$log>; my $v = <$log>||''; $v =~ s/[\r\n]+//; - printf " %s=\"%s\"\n",$p,decode_utf8($v,0)||$v if $v; + printf " %s=\"%s\"\n",$p,utf8decode($v)||$v if $v; read_akey($v) if $p eq 'AKEY'; read_skey($v) if $p eq 'SKEY'; } elsif (/^(Param|Exp): (\w+=".+")/) { @@ -209,3 +217,10 @@ sub read_skey { close $skey; } } + + +sub utf8decode { + local $_ = shift; + s/([\xC0-\xDF])([\x80-\xBF])/chr(ord($1)<<6&0xC0|ord($2)&0x3F)/eg; + return $_; +}