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; |
147 |
$m =~ s#($RE{URI}{HTTP})#e(qq{<a href="$1">$1</a>})#egs; |
$m =~ s#($RE{URI}{HTTP})#e(qq{<a href="$1">$1</a>})#egs; |
148 |
$m =~ s#\/(\w+)\/#<i>$1</i>#gs; |
# $m =~ s#\/(\w+)\/#<i>$1</i>#gs; |
149 |
$m =~ s#$tag_regex#e(qq{<a href="$url?tag=$1" class="tag">$1</a>})#egs; |
$m =~ s#$tag_regex#e(qq{<a href="$url?tag=$1" class="tag">$1</a>})#egs; |
150 |
$m =~ s#\*(\w+)\*#<b>$1</b>#gs; |
$m =~ s#\*(\w+)\*#<b>$1</b>#gs; |
151 |
$m =~ s#_(\w+)_#<u>$1</u>#gs; |
$m =~ s#_(\w+)_#<u>$1</u>#gs; |
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; |
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 |
|
|
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; |
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 |
|
|
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, |
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 |
} |
} |
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 |
); |
); |