### Finds the words from your query that matched and presents an output string
###
sub search_keyword_result_line {
my ($text, $o) = @_;
my @r = search_prepare_query($o, 1);
my @q = @{ $r[0] };
push @q, @{ $r[2] };
my $str = join("|", @q);
$str = join("", "(", $str, ")");
$str = join($str, '(^|\b)', '(\b|$)') if $o->{search_opt}->{whole};
my $k = $o->{search_opt}->{sensitive} ? "" : "(?i)";
my $u = ""; my $c = 0;
while ($text =~ /$k(^|\b)(.{0,20})($str)(.{0,20})(\b|$)/) {
$text = $'; $u .= join("", $&, " ... ");
$c++; last if $c >= 2;
}
$u =~ s/$k$str/\%open$&\%close/g;
$u =~ s/\s+\.\.\.\s+$//;
return $u;
}
###
### search_log_create_cache
###
### Creates a cache file for a new message search or other search whose
### results are displayed in a message tree
###
sub search_log_create_cache {
my ($s, $tt, $uid) = @_;
return undef if ref $s ne "ARRAY";
return undef if ref $tt ne "ARRAY";
return undef if scalar(@{ $tt }) <= 0;
return undef if scalar(@{ $s }) <= 0;
if (! -d "$DCONF->{admin_dir}/msg_index/searches") {
unlink "$DCONF->{admin_dir}/msg_index/searches" if -f "$DCONF->{admin_dir}/msg_index/searches";
mkdir "$DCONF->{admin_dir}/msg_index/searches", oct($DCONF->{perms0777}) || error_message("Directory Error", "Could not create 'searches' subdirectory. This is probably a permissions problem. Make sure that the 'msg_index' subdirectory is world writable.");
if (! -d "$DCONF->{admin_dir}/msg_index/searches") {
unlink "$DCONF->{admin_dir}/msg_index/searches" if -f "$DCONF->{admin_dir}/msg_index/searches";
mkdir "$DCONF->{admin_dir}/msg_index/searches", oct($DCONF->{perms0777}) || error_message("Directory Error", "Could not create 'searches' subdirectory. This is probably a permissions problem. Make sure that the 'msg_index' subdirectory is world writable.");