117 |
# protect HTML from wiki modifications |
# protect HTML from wiki modifications |
118 |
sub e { |
sub e { |
119 |
my $t = shift; |
my $t = shift; |
120 |
return 'uri_unescape{' . uri_escape($t) . '}'; |
return 'uri_unescape{' . uri_escape($t, '^a-zA-Z0-9') . '}'; |
121 |
} |
} |
122 |
|
|
123 |
$m =~ s/($escape_re)/$escape{$1}/gs; |
$m =~ s/($escape_re)/$escape{$1}/gs; |
124 |
$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; |
125 |
$m =~ s#\/(\w+)\/#<i>$1</i>#gs; |
$m =~ s#\/(\w+)\/#<i>$1</i>#gs; |
126 |
$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; |
127 |
$m =~ s#\*(\w+)\*#<b>$1</b>#gs; |
$m =~ s#\*(\w+)\*#<b>$1</b>#gs; |
339 |
|
|
340 |
my @where; |
my @where; |
341 |
my @args; |
my @args; |
342 |
|
my $msg; |
343 |
|
|
344 |
if (my $search = $args->{search}) { |
if (my $search = $args->{search}) { |
345 |
$search =~ s/^\s+//; |
$search =~ s/^\s+//; |
346 |
$search =~ s/\s+$//; |
$search =~ s/\s+$//; |
347 |
push @where, 'message ilike ? or nick ilike ?'; |
push @where, 'message ilike ? or nick ilike ?'; |
348 |
push @args, ( ( '%' . $search . '%' ) x 2 ); |
push @args, ( ( '%' . $search . '%' ) x 2 ); |
349 |
_log "search for '$search'"; |
$msg = "Search for '$search'"; |
350 |
} |
} |
351 |
|
|
352 |
if ($args->{tag} && $tags->{ $args->{tag} }) { |
if ($args->{tag} && $tags->{ $args->{tag} }) { |
353 |
push @where, 'id in (' . join(',', @{ $tags->{ $args->{tag} } }) . ')'; |
push @where, 'id in (' . join(',', @{ $tags->{ $args->{tag} } }) . ')'; |
354 |
_log "search for tags $args->{tag}"; |
$msg = "Search for tags $args->{tag}"; |
355 |
} |
} |
356 |
|
|
357 |
if (my $date = $args->{date} ) { |
if (my $date = $args->{date} ) { |
358 |
$date = check_date( $date ); |
$date = check_date( $date ); |
359 |
push @where, 'date(time) = ?'; |
push @where, 'date(time) = ?'; |
360 |
push @args, $date; |
push @args, $date; |
361 |
_log "search for date $date"; |
$msg = "search for date $date"; |
362 |
} |
} |
363 |
|
|
364 |
$sql .= " where " . join(" and ", @where) if @where; |
$sql .= " where " . join(" and ", @where) if @where; |
372 |
eval { $sth->execute( @args ) }; |
eval { $sth->execute( @args ) }; |
373 |
return if $@; |
return if $@; |
374 |
|
|
375 |
|
my $nr_results = $sth->rows; |
376 |
|
|
377 |
my $last_row = { |
my $last_row = { |
378 |
date => '', |
date => '', |
379 |
time => '', |
time => '', |
394 |
|
|
395 |
return @rows if ($args->{full_rows}); |
return @rows if ($args->{full_rows}); |
396 |
|
|
397 |
my @msgs = ( |
$msg .= ' produced ' . ( |
398 |
"Showing " . ($#rows + 1) . " messages..." |
$nr_results == 0 ? 'no results' : |
399 |
|
$nr_results == 0 ? 'one result' : |
400 |
|
$nr_results . ' results' |
401 |
); |
); |
402 |
|
|
403 |
|
my @msgs = ( $msg ); |
404 |
|
|
405 |
if ($context) { |
if ($context) { |
406 |
my @ids = @rows; |
my @ids = @rows; |
407 |
@rows = (); |
@rows = (); |
662 |
} elsif ( $link !~ m!^http! ) { |
} elsif ( $link !~ m!^http! ) { |
663 |
$link = $args->{url} . $link; |
$link = $args->{url} . $link; |
664 |
} |
} |
|
$link =~ s!//+!/!g; |
|
665 |
|
|
666 |
my $msg; |
my $msg; |
667 |
$msg .= prefix( 'From: ' , $args->{name} || $feed->title ); |
$msg .= prefix( 'From: ' , $args->{name} || $feed->title ); |
944 |
stop => qq{ update feeds set active = false where url = ? }, |
stop => qq{ update feeds set active = false where url = ? }, |
945 |
}; |
}; |
946 |
|
|
947 |
if (my $q = $sql->{$command} ) { |
if ( $command eq 'add' && ! $channel ) { |
948 |
|
$res = "ERROR: got '$msg' which doesn't have #channel in it, ignoring!"; |
949 |
|
} elsif (my $q = $sql->{$command} ) { |
950 |
my $sth = $dbh->prepare( $q ); |
my $sth = $dbh->prepare( $q ); |
951 |
my @data = ( $url ); |
my @data = ( $url ); |
952 |
if ( $command eq 'add' ) { |
if ( $command eq 'add' ) { |
962 |
} else { |
} else { |
963 |
$res = "ERROR: don't know what to do with: $msg"; |
$res = "ERROR: don't know what to do with: $msg"; |
964 |
} |
} |
|
|
|
965 |
} |
} |
966 |
|
|
967 |
if ($res) { |
if ($res) { |