Bonjour,
Pour un petit blog j'utilise le cms
PluXml et dans la
Wiki PluXml il y'a un code pour
ajouter un moteur de recherche à partir d'une page statique.
Code PHP :
<?php
# Page statique Pluxml : moteur de recherche
# revision 1.0 par Stephane :
# - compatibilité pluxml 4.2
# - paramètrage du format de la date
if(!defined('PLX_ROOT')) exit;
# Renseignez ici le format de la date
$format_date = '#num_day/#num_month/#num_year(4)';
global $plxShow;
if (!empty($_POST['searchfield'])) {
$plxGlob_arts = new plxGlob(PLX_ROOT.$plxShow->plxMotor->aConf['racine_articles']);
$aFiles = $plxGlob_arts->query('/[0-9]{4}.([0-9]{3}|home).[0-9]{12}.[a-z0-9-]+.xml$/','search','rsort');
if(is_array($aFiles)) { # On a des fichiers
$searchword = strtolower(addslashes($_POST['searchfield']));
ob_start();
while(list($k,$v) = each($aFiles)) { # On parcourt tous les fichiers
$art = $plxShow->plxMotor->parseArticle(PLX_ROOT.$plxShow->plxMotor->aConf['racine_articles'].$v);
$searchstring = strtolower(addslashes($art['title'].$art['chapo'].$art['content']));
if (strpos($searchstring,$searchword) !== false) {
$searchresults = true;
$art_num = intval($art['numero']);
$art_url = plxUtils::strCheck($art['url']);
$art_title = plxUtils::strCheck($art['title']);
$art_date = plxDate::dateIsoToHum($art['date'], $format_date);
echo '<li>'.$art_date.': <a href="'.$plxShow->plxMotor->aConf['racine'].'?article'.$art_num.'/'.$art_url.'">'.$art_title.'</a></li>';
}
}
$content = ob_get_clean();
if ($content!='')
echo '<p>Résultats de la recherche.<br /><ol class="search_results">'.$content.'</ol></p>';
else
echo '<p>Aucun résultat pour <strong>'.$searchword.'</strong></p>';
}
}
?>
<form method="post" id="searchform" action="<?php echo PLX_ROOT ?>?<?php $plxShow->get() ?>">
<p class="searchform">
<input type="hidden" name="search" value="search" />
<input type="text" class="searchfield" name="searchfield" value="Rechercher..." onblur="if(this.value=='') this.value='Rechercher...';" onfocus="if(this.value=='Rechercher...') this.value='';" />
<input type="submit" class="searchbutton" value="Go" />
</p>
</form>
Mon Problemme c'est que ce moteur de recherche présente
Faille XSS
Si c'est grave !
Comment résoudre ce problème ?
Merci