--- trunk/bin/irc-logger.pl 2008/04/12 10:41:22 134 +++ trunk/bin/irc-logger.pl 2011/10/08 18:33:36 149 @@ -18,6 +18,7 @@ use XML::Feed; use DateTime::Format::Flexible; use Encode; +#use Redis 2.0; =head1 NAME @@ -139,12 +140,13 @@ # protect HTML from wiki modifications sub e { my $t = shift; - return 'uri_unescape{' . uri_escape($t, '^a-zA-Z0-9') . '}'; + eval { $t = 'uri_unescape{' . uri_escape($t, '^a-zA-Z0-9') . '}'; }; + return $t; } $m =~ s/($escape_re)/$escape{$1}/gs; $m =~ s#($RE{URI}{HTTP})#e(qq{$1})#egs; - $m =~ s#\/(\w+)\/#$1#gs; +# $m =~ s#\/(\w+)\/#$1#gs; $m =~ s#$tag_regex#e(qq{$1})#egs; $m =~ s#\*(\w+)\*#$1#gs; $m =~ s#_(\w+)_#$1#gs; @@ -255,13 +257,20 @@ eval { $sth->execute( $value, $nick, $channel, $name ) }; - # error or no result - if ( $@ || ! $sth->rows ) { + if ( $@ ) { + # error + _log("META ERROR: $@"); + } elsif ( ! $sth->rows ) { + # no result -> add new $sth = $dbh->prepare(qq{ insert into meta (value,nick,channel,name,changed) values (?,?,?,?,now()) }); - $sth->execute( $value, $nick, $channel, $name ); - warn "## created $nick/$channel/$name = $value\n"; + eval { $sth->execute( $value, $nick, $channel, $name ); }; + if ( $@ ) { + _log "META ERROR: $@"; + } else { + _log "META: created $nick/$channel/$name = $value\n"; + } } else { - warn "## updated $nick/$channel/$name = $value\n"; + _log "META: updated $nick/$channel/$name = $value\n"; } return $value; @@ -556,8 +565,19 @@ " " . $a->{message}; eval { $sth_insert_log->execute($a->{channel}, $a->{me}, $a->{nick}, $a->{message}, $a->{time}); }; - _log "ERROR: can't archive ", $a->{message} if $@; - $cloud->add_tag( id => $dbh->last_insert_id(undef,undef,"log",undef), %$a ); + + eval { + my @channel = ( 'channel' , $a->{channel}, $a->{nick} ); + push @channel, 'me' if $a->{me}; +# my $redis = Redis->new( server => '192.168.1.61:6379' ); +# $redis->publish( join(' ',@channel), $a->{message} ); + }; + + if ( $@ ) { + _log "ERROR: can't archive ", $a->{message}; + } else { + $cloud->add_tag( id => $dbh->last_insert_id(undef,undef,"log",undef), %$a ); + } } @@ -626,7 +646,8 @@ warn "## RSS fetch first $send_rss_msgs items from", $args->{url} if $debug; - my $feed = XML::Feed->parse( \$args->{xml} ); + my $feed; + eval { $feed = XML::Feed->parse( \$args->{xml} ) }; if ( ! $feed ) { _log "can't fetch RSS ", $args->{url}, XML::Feed->errstr; return; @@ -1161,6 +1182,17 @@ return RC_OK if $request->uri =~ m/favicon.ico$/; + if ( $request->uri =~ m/robots.txt$/ ) { + $response->content_type( 'text/plain' ); + $response->content( qq{ + +User-Agent: * +Disallow: / + + }); + return RC_OK; + } + my $q; if ( $request->method eq 'POST' ) { @@ -1283,7 +1315,8 @@ $rc = RC_DENY; } - $response->content( $feed->as_xml ); + eval { $response->content( $feed->as_xml ); }; + $rc = RC_INTERNAL_SERVER_ERROR if $@; return $rc; } @@ -1296,7 +1329,9 @@ my $html = qq{$NICK} + . qq{ + + } . qq{