SetServer( "localhost", 9312 );
$cl->SetMatchMode( SPH_MATCH_EXTENDED2 );
# $cl->SetSortMode( SPH_SORT_RELEVANCE );
//$cl->SetGroupBy ( "ID_TOPIC", SPH_GROUPBY_ATTR, '@weight DESC');
// $cl->SetFieldWeights(array('subject'=>10, 'body'=>1));
# $cl->SetSelect( 'id AS ID_MSG');
$cl->SetLimits(0, 20);
# $cl->SetFilter( 'model', array( 3 ) );
$cl->SetArrayResult( true );
$q = $cl->EscapeString ($_GET['s']);
$result = $cl->Query( "\"$q\"", 'rt_posts' );
$msgs = array();
$subjects = array();
$bodies = array();
if ( $result === false ) {
echo "Query failed: " . $cl->GetLastError() . ".\n";
}
else {
if ( $cl->GetLastWarning() ) {
echo "WARNING: " . $cl->GetLastWarning() . "
";
}
if ( ! empty($result["matches"]) ) {
foreach ( $result["matches"] as $doc => $docinfo ) {
$msgs[] = $docinfo['id'];
}
mysql_connect("localhost","root","Id0nTkN0w");
mysql_select_db("rock");
$res = mysql_query("SELECT ID_TOPIC, subject, body, ID_MSG from smf_messages WHERE ID_MSG IN (".implode(',',$msgs).");");
$msgs = array();
while ($msg = mysql_fetch_object($res)) {
if (! $msg) continue;
$subjects[] = $msg->subject;
parsecode($msg->body);
$bodies[] = $msg->body;
$topics[] = $msg->ID_TOPIC;
$msgs[] = $msg->ID_MSG;
}
$res2 = $cl->BuildExcerpts($subjects,'topics',$q);
$res3 = $cl->BuildExcerpts($bodies,'topics',$q, array("html_strip_mode" => "strip"));
foreach($topics as $key=>$topic) {
echo '',
$res2[$key],"
\n";
echo '', $res3[$key],"\n
\n
\n";
}
}
}
}
?>