121 lines
3 KiB
PHP
121 lines
3 KiB
PHP
|
<?
|
|||
|
#############################################
|
|||
|
# phpDirectory v1.0 #
|
|||
|
# #
|
|||
|
# Jean-Yves Fort - 21 avril 2001 #
|
|||
|
# jean-yves@lozere-online.com #
|
|||
|
# #
|
|||
|
# Consulter les documents du repertoire #
|
|||
|
# /doc pour plus d'informations sur #
|
|||
|
# l'installation, l'auteur, les conditions #
|
|||
|
# d'utilisation. #
|
|||
|
#############################################
|
|||
|
?>
|
|||
|
<?php
|
|||
|
|
|||
|
// variable indiquant le nombre de resultats par pages
|
|||
|
$nr=20;
|
|||
|
|
|||
|
|
|||
|
echo "<table width=450><tr><td>";
|
|||
|
$link = mysql_connect("$host","$user","$password");
|
|||
|
$z = strtr($z,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>","aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn");
|
|||
|
|
|||
|
$z = str_replace('+', ' ', trim($z));
|
|||
|
$z = str_replace('\\\'', ' ', $z);
|
|||
|
$z = str_replace(',', ' ', $z);
|
|||
|
$z = str_replace(':', ' ', $z);
|
|||
|
|
|||
|
$z=lire($z);
|
|||
|
|
|||
|
$mots = split( " ", $z );
|
|||
|
$phrase = '';
|
|||
|
$texte = '';
|
|||
|
for ($i = 0; $i < count( $mots ); $i ++)
|
|||
|
{
|
|||
|
if ( $i == 0 )
|
|||
|
{
|
|||
|
$texte = ' : ';
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
$phrase .= " and ";
|
|||
|
$texte .= " et ";
|
|||
|
}
|
|||
|
$phrase .= "(nomsite like '%$mots[$i]%' or description like '%$mots[$i]%' or mcles like '%$mots[$i]%')";
|
|||
|
$texte .= "<b><a href=\"index.php?m=l&s=1&z=".$mots[$i]."\">".$mots[$i]."</a></b>";
|
|||
|
}
|
|||
|
|
|||
|
$requete=mysql_db_query($base,"select nomsite, id, description, mcles, url, cat1 from ".$basesites." where ".$phrase." and valid=1 ",$link);
|
|||
|
$num=mysql_num_rows( $requete );
|
|||
|
|
|||
|
if ($z=="")
|
|||
|
{
|
|||
|
echo "Veuillez saisir un ou plusieurs mot-clés<br><br>";
|
|||
|
}
|
|||
|
elseif (eregi(".*%+.*", $z))
|
|||
|
{
|
|||
|
echo "Désolé, le caractère % est interdit<br><br>";
|
|||
|
}
|
|||
|
elseif (strlen($z)<2)
|
|||
|
{
|
|||
|
echo "Veuillez saisir au moins 2 caractères<br><br>";
|
|||
|
}
|
|||
|
elseif ($num==0)
|
|||
|
{
|
|||
|
echo "Aucun résultat à votre recherche".$texte."<br><br>";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
if ($num==1) {echo "<b>".$num."</b> site correspond à votre recherche".$texte."<br><br>";}
|
|||
|
|
|||
|
else {echo "<b>".$num."</b> sites correspondent à votre recherche".$texte."<br><br>";}
|
|||
|
|
|||
|
// nb de pages
|
|||
|
$nb_pages=(int)(($num-1)/$nr+1);
|
|||
|
|
|||
|
|
|||
|
// affichage des resultats
|
|||
|
|
|||
|
if (!isset($page)) {$page=1;}
|
|||
|
$n=($page-1)*$nr;
|
|||
|
$n_end=$n+$nr;
|
|||
|
|
|||
|
while(($n<$num)and($n<$n_end))
|
|||
|
{
|
|||
|
$id=mysql_result($requete,$n,"id");
|
|||
|
$sitenom=mysql_result($requete,$n,"nomsite");
|
|||
|
$description=mysql_result($requete,$n,"description");
|
|||
|
$url=mysql_result($requete,$n,"url");
|
|||
|
$cat=mysql_result($requete,$n,"cat1");
|
|||
|
$sitenom=enregistre($sitenom);
|
|||
|
$description=enregistre($description);
|
|||
|
|
|||
|
include("html/show.php");
|
|||
|
|
|||
|
$n++;
|
|||
|
}
|
|||
|
|
|||
|
// pages de resultats
|
|||
|
|
|||
|
if ($nb_pages>1)
|
|||
|
{
|
|||
|
$recherche=urlencode($z);
|
|||
|
$n=1;
|
|||
|
echo "pages de résultats:";
|
|||
|
while($n<=$nb_pages)
|
|||
|
{
|
|||
|
if ($n==$page){echo "<font color=\"red\"> $n</font>";}
|
|||
|
else
|
|||
|
{echo " <a href=index.php?m=l&s=1&z=$recherche&page=$n>$n</a>";}
|
|||
|
$n++;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
echo "</td></tr></table><br>";
|
|||
|
include("html/zbox.php");
|
|||
|
?>
|
|||
|
|