| ";
$cherche = array ("/[éèêëÈÉÊË]/", "/[ÌÍÎÏìíîï]/", "/[ÀÁÂÃÄÅàáâãäå]/", "/æ/", "/[Ññ]/", "/[ÒÓÔÕÖòóôõö]/", "/[ÙÚÛÜùúûü]/", "/[Ýýÿ]/", "/\\\\/", "/<\\/b.+$/i", "/ /");
$remplace = array ("e", "i", "a", "ae", "n", "o", "u", "y", "", "", "");
$dico = file($adr_dico);
$pauv = preg_replace ($cherche, $remplace, $rech); //mot dénué d'accents et de majuscules
$pauv = strtolower($pauv);
if ($opt[0]=='_') //$opt est définie négativement: on ne veut pas certains mots (souvent '_t')
{$pf=FALSE; //$opt n'est pas 'positif', mais 'négatif'
$opt=substr($opt, 1);
}
else //sinon, $opt est défini 'positivement'
{$pf=TRUE;
}
function inter($a, $b) //fonction qui renvoie TRUE si l'intersection de deux chaînes de caractères n'est pas vide, et FALSE si les deux chaînes n'ont aucune lettre en commun
{$a.='²²²';
$b.='°°°';
if ($a[0]==$b[0]) return TRUE;
if ($a[0]==$b[1]) return TRUE;
if ($a[0]==$b[2]) return TRUE;
if ($a[1]=='²') return FALSE;
if ($a[1]==$b[0]) return TRUE;
if ($a[1]==$b[1]) return TRUE;
if ($a[1]==$b[2]) return TRUE;
if ($a[2]==$b[0]) return TRUE;
if ($a[2]==$b[1]) return TRUE;
if ($a[2]==$b[2]) return TRUE;
return FALSE;
}
$ok=0;
if ($titre == 0) //on recherche des mots dans dico.txt
while (list ($key, $val) = each($dico))
{if (ereg("^$pauv", $val) || ($val != "\n" && $rech=='§'))
{$i=explode("¤", $val);
if ($opt=='' //si l'on respecte les options
|| ($pf && inter($i[4], $opt))
|| (!$pf && !inter($i[4], $opt)))
{if ($i[5] != '')
$i[5] = " ($i[5])";
if ($i[7] != '')
$i[7] = " Ex: $i[7]";
if ($i[8] != '')
$i[8] = " Syn: $i[8]";
if ($i[9] != '')
$i[9] = " Angl: $i[9]";
$aff = " $i[1] $i[3] $i[5] $i[6] $i[7] $i[8] $i[9] ";
$aff = ereg_replace("\\\'", "'", $aff);
$aff = ereg_replace('\\\"', '"', $aff);
print $aff;
$ok=1;
}
}
}
if ($titre == 1) //on recherche des abréviations
{$seulaff='éfg';
if (($rech=='§é') || ($rech=='§f') || ($rech=='§g'))
{$seulaff=$rech[1].$rech[1].$rech[1];
$rech='§';
}
$tabaff=array('éc'=>'', 'ér'=>'', 'ép'=>'', 'af'=>'', 'ag'=>'');
while (list ($key, $val) = each($dico))
{if (($val != "\n") && (($rech=='§') || preg_match("/^$pauv/", $val)))
{$i=explode("¤", $val);
if ($i[5] != '')
$i[5] = "($i[5]).";
if ($i[7] != '')
$i[7] = "Ex: $i[7].";
if ($i[8] != '')
$i[8] = "Syn: $i[8].";
if ($i[9] != '')
$i[9] = "Angl: $i[9].";
$aff = "$i[1] $i[3] $i[5] $i[6] $i[7] $i[8] $i[9] ";
$aff = preg_replace("/\\\'/", "'", $aff);
$aff = preg_replace('/\\\"/', '"', $aff);
$tabaff[$i[4]] .= $aff;
$ok=1;
}
}
if ($seulaff[0]=='é')
{if ($tabaff['éc'] != '')
print "Emoticons " . $tabaff['éc'];
if ($tabaff['ér'] != '')
print "Emoticons rares " . $tabaff['ér'];
if ($tabaff['ép'] != '')
print "Emoticons personnages " . $tabaff['ép'];
}
if (($seulaff[1]=='f') && ($tabaff['af'] != ''))
print "Abréviations françaises " . $tabaff['af'];
if (($seulaff[2]=='g') && ($tabaff['ag'] != ''))
print "Abréviations anglaises " . $tabaff['ag'];
}
if ($ok == 0) //s'il n'y a aucun mot
{print "Aucun mot ne correspond à votre requête !";
if ($titre==1) print "Pour effectuer votre recherche dans le Dictionnaire du net, cliquez ici";
$file = fopen("mots-absents.txt", "a"); //enregistrement d'une liste de mots absents
fwrite($file,"$rech\n");
fclose($file);
}
else
{$file = fopen("mots-trouves.txt", "a"); //pour statistique des mots recherchés
fwrite($file,"$rech\n");
fclose($file);
}
print " |