<?
/* ----------------------------------------------------------------------------
M O T E U R D E R E C H E R C H E
> Traitement de la recherche <
PHPMyRing (4.0) dernière modification du fichier [06-12-02]
---------------------------------------------------------------------------- */
require('include/config.php');
require('include/fonctions.php');
$conf=config();
InsertLang('',$conf['lang']);
if ($mots=='')
{
header("Location: index.php?msgRech="._("Recherche vide!"));
exit;
}
require('tete.php');
require('haut2.php');
// Si nombre indéfinie
if (!$nombre) { $nombre=$conf['nbre_rech']; }
// Pareil pour limite
if (!$limite) { $limite=0; }
// Limite suivante et celle d'avant
$limitesuivante=$limite+$nombre;
$limiteprecedente=$limite-$nombre;
# # # # # # # #
# Modifications de la requète #
# # # # # # # #
$mots=trim($mots); // Suppression des espaces initiaux et finaux
$mots=strtolower($mots); // Passage en minuscules
$mots=str_replace('+',' ',$mots); // Remplacement par des espaces
$mots=str_replace("\'",' ',$mots);
$mots=str_replace('\"',' ',$mots);
$mots=str_replace('.',' ',$mots);
$mots=str_replace(',',' ',$mots);
$mots=htmlentities($mots); // En HTML
$tab=explode(' ',$mots); // hop dans un tableau (délimiteur : espace)
$nbre=count($tab); // Elements
// L'opérateur
if (!isset($operateur))
{
$operateur="OR";
}
//Endroit de la recherche
if (!isset($where))
{
$where="description";
}
// La chpetite requète SQL
$rqt="SELECT idsite, site_nom, url, description, date, visites FROM webring WHERE $where LIKE '%$tab[0]%' AND accept='1'";
// Une boucle pour tous les mots
for ($i=1;$i<$nbre;$i++)
{
$rqt.=" $operateur $where LIKE '%$tab[$i]%'";
}
// on va compter le nombre total
connecte();
$res=requete($rqt);
$total=mysql_num_rows($res);
$rqt.="LIMIT $limite,$nombre ";
$res = requete($rqt);
?>
<div class="titre-resultats-recherche">
<? echo _("Voici les résultats de la recherche :"); ?>
</div>
<table class="resultats-recherche">
<?
if ($res)
{
if (mysql_num_rows($res)==0)
{
?>
<tr>
<td>
<? echo _("La recherche n'a renvoyé aucun résultat"); ?>
</td>
</tr>
<?
// require('formsearch.php');
}
else
{
while ($row=mysql_fetch_array($res))
{
$url=$conf['adresse_site']."/".$conf['dossierwr']."/clik.php?idsite=$row[0]";
?>
<tr>
<td>
- <a href="<? echo $url; ?>"><? echo $row['site_nom']; ?></a><br />
<? echo substr($row['description'],0,80); ?>...<br />
<span class="infos_site"><? echo $row[2]." - "?>
<? printf(ngettext("visité une fois","visité %d fois",$row['visites']),$row['visites']);
?>
</span>
</td>
</tr>
<?
}
mysql_free_result($res);
}
}
?>
<tr>
<td>
<?
if ($limite != 0)
{
echo "[ <a href=\"$PHP_SELF?limite=$limiteprecedente&mots=$mots&where=$where\">"._("Précédents")."</a> ]";
}
?>
</td>
<td>
<?
if ($limitesuivante < $total)
{
echo "[ <a href=\"$PHP_SELF?limite=$limitesuivante&mots=$mots&where=$where\">"._("Suivants")."</a> ]";
}
?>
</td>
</tr>
</table>
<?
require('formsearch.php');
require('pied.php');
?>