/[irc-logger]/trunk/bin/irc-logger.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/irc-logger.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 133 by dpavlin, Sat Apr 5 21:08:27 2008 UTC revision 141 by dpavlin, Fri Feb 6 14:12:00 2009 UTC
# Line 139  my $filter = { Line 139  my $filter = {
139                  # protect HTML from wiki modifications                  # protect HTML from wiki modifications
140                  sub e {                  sub e {
141                          my $t = shift;                          my $t = shift;
142                          return 'uri_unescape{' . uri_escape($t, '^a-zA-Z0-9') . '}';                          eval { $t = 'uri_unescape{' . uri_escape($t, '^a-zA-Z0-9') . '}'; };
143                            return $t;
144                  }                  }
145    
146                  $m =~ s/($escape_re)/$escape{$1}/gs;                  $m =~ s/($escape_re)/$escape{$1}/gs;
# Line 255  sub meta { Line 256  sub meta {
256    
257                  eval { $sth->execute( $value, $nick, $channel, $name ) };                  eval { $sth->execute( $value, $nick, $channel, $name ) };
258    
259                  # error or no result                  if ( $@ ) {
260                  if ( $@ || ! $sth->rows ) {                          # error
261                            _log("META ERROR: $@");
262                    } elsif ( ! $sth->rows ) {
263                            # no result -> add new
264                          $sth = $dbh->prepare(qq{ insert into meta (value,nick,channel,name,changed) values (?,?,?,?,now()) });                          $sth = $dbh->prepare(qq{ insert into meta (value,nick,channel,name,changed) values (?,?,?,?,now()) });
265                          $sth->execute( $value, $nick, $channel, $name );                          eval { $sth->execute( $value, $nick, $channel, $name ); };
266                          warn "## created $nick/$channel/$name = $value\n";                          if ( $@ ) {
267                                    _log "META ERROR: $@";
268                            } else {
269                                    _log "META: created $nick/$channel/$name = $value\n";
270                            }
271                  } else {                  } else {
272                          warn "## updated $nick/$channel/$name = $value\n";                          _log "META: updated $nick/$channel/$name = $value\n";
273                  }                  }
274    
275                  return $value;                  return $value;
# Line 556  sub save_message { Line 564  sub save_message {
564                  " " . $a->{message};                  " " . $a->{message};
565    
566          eval { $sth_insert_log->execute($a->{channel}, $a->{me}, $a->{nick}, $a->{message}, $a->{time}); };          eval { $sth_insert_log->execute($a->{channel}, $a->{me}, $a->{nick}, $a->{message}, $a->{time}); };
567          _log "ERROR: can't archive ", $a->{message} if $@;          if ( $@ ) {
568          $cloud->add_tag( id => $dbh->last_insert_id(undef,undef,"log",undef), %$a );                  _log "ERROR: can't archive ", $a->{message};
569            } else {
570                    $cloud->add_tag( id => $dbh->last_insert_id(undef,undef,"log",undef), %$a );
571            }
572  }  }
573    
574    
# Line 626  sub rss_parse_xml { Line 637  sub rss_parse_xml {
637    
638          warn "## RSS fetch first $send_rss_msgs items from", $args->{url} if $debug;          warn "## RSS fetch first $send_rss_msgs items from", $args->{url} if $debug;
639    
640          my $feed = XML::Feed->parse( \$args->{xml} );          my $feed;
641            eval { $feed = XML::Feed->parse( \$args->{xml} ) };
642          if ( ! $feed ) {          if ( ! $feed ) {
643                  _log "can't fetch RSS ", $args->{url}, XML::Feed->errstr;                  _log "can't fetch RSS ", $args->{url}, XML::Feed->errstr;
644                  return;                  return;
# Line 1283  sub root_handler { Line 1295  sub root_handler {
1295                          $rc = RC_DENY;                          $rc = RC_DENY;
1296                  }                  }
1297    
1298                  $response->content( $feed->as_xml );                  eval { $response->content( $feed->as_xml ); };
1299                    $rc = RC_INTERNAL_SERVER_ERROR if $@;
1300                  return $rc;                  return $rc;
1301          }          }
1302    
# Line 1350  sub root_handler { Line 1363  sub root_handler {
1363          } else {          } else {
1364                  $html .= join("</p><p>",                  $html .= join("</p><p>",
1365                          get_from_log(                          get_from_log(
1366                                  limit => ( $q->param('last') || $q->param('date') ) ? undef : 100,                                  limit => ( $q->param('date') ? undef : $q->param('last') || 100 ),
1367                                  search => $search || undef,                                  search => $search || undef,
1368                                  tag => $q->param('tag') || undef,                                  tag => $q->param('tag') || undef,
1369                                  date => $q->param('date') || undef,                                  date => $q->param('date') || undef,
# Line 1375  sub root_handler { Line 1388  sub root_handler {
1388          <p>See <a href="/history">history</a> of all messages.</p>          <p>See <a href="/history">history</a> of all messages.</p>
1389          </body></html>};          </body></html>};
1390    
1391          $response->content( decode('utf-8',$html) );          $response->content( $html );
1392          warn "<< ", $request->method, " ", $request->uri, " created ", length($html), " bytes\n";          warn "<< ", $request->method, " ", $request->uri, " created ", length($html), " bytes\n";
1393          return RC_OK;          return RC_OK;
1394  }  }
# Line 1415  sub html { Line 1428  sub html {
1428          }          }
1429    
1430    my $html = qq{<div id="htmltagcloud">};    my $html = qq{<div id="htmltagcloud">};
1431    foreach my $tag (@tags) {    foreach my $tag ( sort { lc($a->{name}) cmp lc($b->{name}) } @tags) {
1432      $html .=  sprintf(qq{<span class="tag tagcloud%d"><a href="%s" title="%s">%s</a></span>\n},      $html .=  sprintf(qq{<span class="tag tagcloud%d"><a href="%s" title="%s">%s</a></span>\n},
1433                  $tag->{level}, $tag->{url}, $tag->{count}, $tag->{name}                  $tag->{level}, $tag->{url}, $tag->{count}, $tag->{name}
1434          );          );

Legend:
Removed from v.133  
changed lines
  Added in v.141

  ViewVC Help
Powered by ViewVC 1.1.26