Tfe

Ongi etorri tfe-ren webgunera...

Old stuff/old_sites/newepik/include/recherche.php

(Deskargatu)
<?

    $chemin[2] = preg_replace("[^a-zA-Z\_0-9]","",$chemin[2]);
    $recherche = $_POST['recherche'];
    $recherche = str_replace(" ","%",$recherche);

if (empty($recherche))
{

if (
    $chemin[2] == "breves"  or
    $chemin[2] == "edito"  or
    $chemin[2] == "articles"  or
    ($chemin[2] == "forum" and !empty($chemin[3]))
    )
{
    echo "
    <div class=\"article\">
    <h2>Recherche sur <?=$chemin[2]?></h2>
    <div class=\"element\">
    <div>
    <p>Recherche dans tout les elements de la table <?=$chemin[2]?> du site.</p>
    <form action=\"/site/recherche/";
    for($i=2;$i<=5;$i++) { if ($chemin[$i]) { echo "$chemin[$i]/"; }}
    echo "\" method=\"post\">
    <p><input type=\"text\" name=\"recherche\" value=\"Mot cle\"  onfocus=\"if (this.value == this.defaultValue) { this.value=''; }\"/>
    <input class=\"button\" type=\"submit\" value=\"Rechercher\" />
    </p>
    </form>
    </div>
    </div>
    ";

}
elseif ($chemin[2] !== "forum")
 {
    echo "
    <div class=\"article\">
    <div class=\"element\">
    <h2>Recherche sur le site</h2>
    <h3>Sections disponibles:</h3>
    <p>Vous pouvez effectuer des recherches sur diverses sections du site:</p>
    <ul>
    <li><a href=\"/site/recherche/breves\">Br&egrave;ves</a></li>
    <li><a href=\"/site/recherche/edito\">Edito</a></li>    
    <li><a href=\"/site/recherche/article\">Article</a></li>        
    <li><a href=\"/site/recherche/forum\">Forum</a></li>            
    </ul>
    </div>
    </div>
    ";
    }
else { 
    echo "
    <div class=\"article\">
    <div class=\"element\">
    <h2>Recherches sur les forums</h2>
    <h3>Sous sections disponibles:</h3>
    <p>Vous pouvez effectuer des recherches sur des sections du forum:</p>
    <ul>
    ";
    $query = "SELECT ref,nom FROM description";
    $result = mysql_query($query);
    while($row = mysql_fetch_assoc($result))
    {	
	$row["ref"] = preg_replace("/forum_(.*)/","$1",$row["ref"]);
        echo "<li><a href=\"/site/recherche/forum/".$row["ref"]."\">".$row["nom"]."</a></li>\n";
    }
    echo "
    </ul>
    </div>
    </div>
    ";

    
    }


}
else {
$chemin[3] = preg_replace("[^a-zA-Z]","",$chemin[3]);
if ($chemin[2] == "forum") { $art = "forum_$chemin[3]"; }
else { $art = $chemin[2]; }
if (ereg("^[0-9]{1,4}$",$chemin[4])) { $section = $chemin[4]; }


echo "<div class=\"article\">
<div class=\"element\">
<h2>Resultats de la recherche: $recherche dans $art</h2>
";
if ($chemin[2] !== "forum") { $query = "SELECT id,datetime,posteur,titre FROM $art WHERE 1 AND article LIKE '%$recherche%' or posteur LIKE '%$recherche%' or titre LIKE '%$recherche%' or arttyp LIKE '%$recherche%' LIMIT 50"; }
elseif ($section) {   $query = "SELECT id,date,pseudo,nom,topic_id FROM $art WHERE topic_id='$section' AND (pseudo LIKE '%$recherche%' or nom LIKE '%$recherche%' or contenu LIKE '%$recherche%') LIMIT 50"; }
else {  $query = "SELECT id,date,pseudo,nom,topic_id FROM $art WHERE 1 AND (pseudo LIKE '%$recherche%' or nom LIKE '%$recherche%' or contenu LIKE '%$recherche%') LIMIT 50"; }

$i=0;
$result =mysql_query($query) or die("Fatal: ".mysql_error());
echo "<h3>Recherche dans la table: $art</h3>
<ul>
";

$art = preg_replace("/^forum_(.*)$/","$1",$art);
while ($row = mysql_fetch_array($result))
    { $i=1; 
    if ($chemin[2] == "forum") {
    
    echo "    <li><a href=\"/site/$chemin[2]/$art/$row[4]-1\">$row[3]</a> (Poste le $row[1] par $row[2])</li>   " ;
    }
    else {
    echo "    <li><a href=\"/site/$chemin[2]/$row[0]\">$row[3]</a> (Poste le $row[1] par $row[2])</li>   " ;
    }
    
    
     }
echo "</ul>\n";
if ($i==0) { echo "<div class=\"element\"><h2>Aucun element trouve</h2>
<div><p>Vous pouvez <a href=\"/site/recherche\">effectuer une autre recherche</a> ou <a href=\"/site\">retourner a l'acceuil</a>.</p></div></div>"; }
echo "<p>fin de recherche</p>
</div>
</div>
";
}