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 ); |