1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
$pattern = array();
$pattern[0] = '/e/';
$pattern[1] = '/a/';
$pattern[2] = '/i/';
$pattern[3] = '/o/';
$pattern[4] = '/u/';
$pattern[5] = '/c/';
$replace_html = array();
$replace_html[0] = "(e|é|É|è|È|ê|Ê|ë|Ë)";
$replace_html[1] = "(a|à|À|â|Â|ä|Ä)";
$replace_html[2] = "(i|î|Î|ï|Ï)";
$replace_html[3] = "(o|ô|Ô|ö|Ö)";
$replace_html[4] = "(u|ù|Ù|û|Û|ü|Ü)";
$replace_html[5] = "(c|ç|Ç)";
$motscles = $_GET["motscles"];
$motscles = mysql_real_escape_string(trim($motscles));
if(!empty($motscles)) {
$tab_mc = explode(" ",$motscles);
$cptmot = 0;
foreach($tab_mc as $k => $mot) {
if(strlen($mot) > 2) {
$mothtml = $mot;
$motreg = $mot;
$motreg = preg_replace($pattern,$replace_accent,$motreg);
$mothtml = preg_replace($pattern,$replace_html,$mothtml);
$mothtml = htmlentities($mothtml);
if($cptmot > 0) $param_txt .= " AND ";
$param_txt .= "T.contenu REGEXP '[[:<:]]".$mothtml."[[:>:]]'";
$cptmot++;
}
}
if($cptmot) {
$rcont = mysql_query("SELECT T.contenu, M.id, M.libelle FROM texte T
LEFT OUTER JOIN page_contenu P ON P.id = T.idcontenu
LEFT OUTER JOIN menu M ON P.idpage = M.id
WHERE ".$param_txt);
$nbcont = mysql_num_rows($rcont);
}
} |
Partager