";
$star_img = "
";
$alt_img = "
";
$bug_img = "
";
if ($words == ""){
print "You need to make an actual search, use ?query=keyword
";
print "
";
return;
}
if ($startingitem == "" || $startingitem < 0){
$startingitem=0;
}
$itemspan=20;
$cl = new SphinxClient ();
$cl->SetLimits($startingitem, $startingitem+$itemspan);
$cl->SetMatchMode(SPH_MATCH_EXTENDED2);
$cl->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
# consider other ranking e.g. pagerank, weighted with freshness and hybrid
$cl->SetSortMode(SPH_SORT_RELEVANCE);
$res = $cl->Query($words,$index);
#cf http://sphinxsearch.com/docs/manual-2.0.1.html#api-funcgroup-querying
#$res = $cl->BuildExcerpts ( $docs, $index, $words, $opts );
if ( !$res ) {
die ( "ERROR: " . $cl->GetLastError() . ".\n" );
} else {
// XXX should test for empty result before doing the assigment
// if (0 results) { $socialsearch = shell_exec("pmwiki_social_search "$keyword"); }
// ideally this would be done ascynhroneously as it does take some time (few seconds!)
// yet still always offer it as an option (since it's "costly")
#var_dump($res);
$IDs = array_keys($res["matches"]);
print "
";
print "\"$words\" found ".$res["words"]["$words"]["hits"]." time(s) in ".$res["total_found"]." document(s):
";
print "
";
foreach ($IDs as $i)
{
#BuildExcerpts()
#consider here adding snippet, would require few disk access, MySQL storage could be faster...
print "- ";
$file=$idx["$i"];
if (preg_match('|/home/fabien/irclogs/|',$file)){
$target = preg_replace('|/home/fabien/irclogs/(.*)|','$1',$file);
$url = urlencode($target);
print "IRClogs:$target";
}
elseif (preg_match('|/home/fabien/www/mirrors/|',$file)){
$page = preg_replace('|/home/fabien/www/mirrors/(.*)/wiki.d/(.*)\.(.*)|','$2/$3',$file);
$source = preg_replace('|/home/fabien/www/mirrors/(.*)/wiki.d/(.*)\.(.*)|','$1',$file);
switch ( $source ) {
case "saint-maur": $url="http://saint-maur.benetou.fr"; break;
case "fabien": $url="http://fabien.benetou.fr"; break;
case "pim": $url="http://www.ourp.im/"; break;
case "agiwiki": $url="http://www.agi-wiki.org/"; break;
case "wiki": $url="http://fabien.benetou.fr/innovativ.it/www/HistoricalArchives/Seedea"; break;
default: $url=$source;
}
print "$source:$page";
print preg_replace('|/home/fabien/www/mirrors/(.*)/wiki.d/(.*)\.(.*)|',''.$alt_img.'',$file);
print "$copy_img";
} elseif (preg_match('|/home/fabien/repository/|',$file)){
print preg_replace('|/home/fabien/repository/(.*)|','Repository:$1',$file);
} else {
print preg_replace('|/home/fabien/www/(.*)/wiki.d/(.*)\.(.*)|','$1:$2/$3',$file);
print preg_replace('|/home/fabien/www/(.*)/wiki.d/(.*)\.(.*)|',''.$alt_img.'',$file);
}
print "$star_img";
print "
";
}
$previousitems=$startingitem-$itemspan;
$nextitems=$startingitem+$itemspan;
print "
";
print "
";
if ($previousitems >= 0)
print "
previous items";
for ($p=1;$p<$res["total"]/$itemspan;$p++)
print "
$p/";
if ($nextitems < $res["total"])
print "
next items";
print "
";
$indexage = "unknown";
$targetindexfile = "/var/lib/sphinxsearch/data/pmwikis.spd";
$updatedindex = filemtime($targetindexfile);
$indexage = date("c",$updatedindex);
print "
$indexage index
(if bug check indexer errors).";
}
?>