\n\n";
}
#################################################################
sub commentSearch {
print <
EOT
my $prev = $I{F}{min} - $I{F}{max};
print linkSearch({
'link' => "$I{F}{min} previous matches...",
min => $prev
}), " " if $prev >= 0;
# select comment ID, comment Title, Author, Email, link to comment
# and SID, article title, type and a link to the article
my $sqlquery = "SELECT section, newstories.sid, aid, title, pid, subject, writestatus," .
getDateFormat("time","d") . "," .
getDateFormat("date","t") . ", uid, cid, ";
$sqlquery .= keysearch($I{F}{query}, 'subject', 'comment') if $I{F}{query};
$sqlquery .= " 1 as kw " unless $I{F}{query};
$sqlquery .= " FROM newstories, comments WHERE newstories.sid=comments.sid ";
$sqlquery .= " AND newstories.sid=" . $I{dbh}->quote($I{F}{sid}) if $I{F}{sid};
$sqlquery .= " AND points >= $I{F}{threshold} ";
$sqlquery .= " AND section=" . $I{dbh}->quote($I{F}{section}) if $I{F}{section};
$sqlquery .= " ORDER BY kw DESC, date DESC, time DESC LIMIT $I{F}{min},$I{F}{max} ";
if ($I{F}{sid}) {
my($t) = sqlSelect("title", "newstories",
"sid=" . $I{dbh}->quote($I{F}{sid})
) || "discussion";
printf "Return to %s ", linkComment({
sid => $I{F}{sid},
pid => 0,
subject => $t
});
print " ";
return unless $I{F}{query};
}
my $cursor = $I{dbh}->prepare($sqlquery);
$cursor->execute;
my $x = $I{F}{min};
while (my($section, $sid, $aid, $title, $pid, $subj, $ws, $sdate,
$cdate, $uid, $cid, $match) = $cursor->fetchrow) {
last if $I{F}{query} && !$match;
$x++;
my $href = $ws == 10
? "$I{rootdir}/$section/$sid.shtml#$cid"
: "$I{rootdir}/comments.pl?sid=$sid&pid=$pid#$cid";
my($cname, $cemail) = sqlSelect("nickname,fakeemail", "users", "uid=$uid");
printf < %s
$subj
by $cname on $cdate ", linkSearch({
# 'link' => "$remaining Matches Left",
'link' => "More matches...",
min => $x
}) unless !$x || $x < $I{F}{max};
}
#################################################################
sub userSearch {
my $prev = int($I{F}{min}) - $I{F}{max};
print linkSearch({
'link' => "$I{F}{min} previous matches...",
min => $prev
}), " " if $prev >=0;
# userSearch REALLY doesn't need to be ordered by keyword since you
# only care if the substring is found.
my $sqlquery = "SELECT fakeemail,nickname,uid ";
$sqlquery .= " FROM users WHERE uid > 0 ";
if ($I{F}{query}) {
my $kw = keysearch($I{F}{query}, 'nickname', 'ifnull(fakeemail,"")');
$kw =~ s/as kw$//;
$kw =~ s/\+/ OR /g;
$sqlquery .= "AND ($kw) ";
}
$sqlquery .= "ORDER BY uid LIMIT $I{F}{min}, $I{F}{max}";
my $c = $I{dbh}->prepare($sqlquery);
undef $c unless $c->execute;
# print " $sqlquery ";
print linkSearch({
# 'link' => "$remaining matches left",
'link' => "More matches...",
min => $I{F}{'last'},
# hitcount => $I{F}{hitcount}
}) unless !$x || $x < $I{F}{max};
}
#################################################################
sub storySearch {
my $prev = $I{F}{min} - $I{F}{max};
print linkSearch({
'link' => "$I{F}{min} previous matches...",
min => $prev
}), " " if $prev >= 0;
my $sqlquery = "SELECT aid,title,sid," . getDateFormat("time","t") .
", commentcount,section ";
$sqlquery .= "," . keysearch($I{F}{query}, "title", "introtext") . " "
if $I{F}{query};
$sqlquery .=" ,0 " unless $I{F}{query};
if ($I{F}{query} || $I{F}{topic}) {
$sqlquery .= " FROM stories ";
} else {
$sqlquery .= " FROM newstories ";
}
$sqlquery .= $I{F}{section} ? < $sqlquery ", linkSearch({
'link' => "More Articles...",
min => $I{F}{'last'}
}) unless !$x || $x < $I{F}{max};
}
main;
$I{dbh}->disconnect if $I{dbh};
1;
attached to $title
posted on $sdate by $aid
";
return unless $c;
my $total = $c->{rows};
my($x, $cnt) = 0;
while(my $N = $c->fetchrow_hashref) {
my $ln = $N->{nickname};
$ln =~ s/ /+/g;
my $fake = $N->{fakeemail} ? <
EOT
$x++;
}
$c->finish;
print "No Matches Found for your query" if $x < 1;
# Counting has been removed (see comment at top).
# my $remaining = $I{F}{hitcount} - $I{F}{'last'};
print "
!;
$x++;
}
$cursor->finish;
print "No Matches Found for your query." if $x < 1;
# Counting has been removed (see comment at top).
# my $remaining = $I{F}{hitcount} - $I{F}{'last'};
print "