[ Index ]
 

Code source de SPIP 1.8.3

Accédez au Source d'autres logiciels libres | Soutenez Angelica Josefina !

title

Body

[fermer]

/ecrire/ -> recherche.php3 (source)

   1  <?php
   2  
   3  /***************************************************************************\
   4   *  SPIP, Systeme de publication pour l'internet                           *
   5   *                                                                         *
   6   *  Copyright (c) 2001-2005                                                *
   7   *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
   8   *                                                                         *
   9   *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
  10   *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
  11  \***************************************************************************/
  12  
  13  
  14  include  ("inc.php3");
  15  include_ecrire  ("inc_mots.php3");
  16  include_ecrire  ("inc_sites.php3");
  17  
  18  $recherche = addslashes(entites_html($recherche));
  19  
  20  
  21  debut_page(_T('titre_page_recherche', array('recherche' => $recherche)));
  22  
  23  debut_gauche();
  24  
  25                  $recherche_aff = _T('info_rechercher');
  26                  $onfocus = "onfocus=this.value='';";
  27              echo "<form method='get' style='margin: 0px;' action='recherche.php3'>";
  28              echo '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="spip_recherche" accesskey="r" '.$onfocus.'>';
  29              echo "</form>";
  30  
  31  
  32  
  33  debut_droite();
  34  
  35  if (strlen($recherche) > 0) {
  36  
  37      echo "<FONT FACE='Verdana,Arial,Sans,sans-serif'><B>"._T('info_resultat_recherche')."</B><BR>";
  38      echo "<FONT SIZE=5 COLOR='$couleur_foncee'><B>$recherche</B></FONT><p>";
  39  
  40      $query_articles = "SELECT * FROM spip_articles WHERE";
  41      $query_breves = "SELECT * FROM spip_breves WHERE ";
  42      $query_rubriques = "SELECT * FROM spip_rubriques WHERE ";
  43      $query_sites = "SELECT * FROM spip_syndic WHERE ";
  44      
  45      if (ereg("^[0-9]+$", $recherche)) {
  46          $query_articles .= " (id_article = $recherche) OR ";
  47          $query_breves .= " (id_breve = $recherche) OR ";
  48          $query_rubriques .= " (id_rubrique = $recherche) OR ";
  49          $query_sites .= " (id_syndic = $recherche) OR ";
  50      }
  51      
  52      // Eviter les symboles '%', caracteres SQL speciaux
  53      $recherche = str_replace("%","\%",$recherche);
  54      $rech2 = split("[[:space:]]+", $recherche);
  55      if ($rech2)
  56          $where = " (titre LIKE '%".join("%' AND titre LIKE '%", $rech2)."%') ";
  57      else
  58          $where = " 1=2";
  59      
  60      $query_articles .= " $where ORDER BY date_modif DESC";
  61      $query_breves .= " $where ORDER BY maj DESC";
  62      $query_rubriques .= " $where ORDER BY maj DESC";
  63      
  64      $query_sites .= " $where ORDER BY maj DESC";
  65      $query_sites  = ereg_replace("titre LIKE", "nom_site LIKE", $query_sites);
  66      
  67      $activer_moteur = (lire_meta('activer_moteur') == 'oui');
  68      if ($activer_moteur) {    // texte integral
  69          include_ecrire  ('inc_index.php3');
  70          list($hash_recherche,) = requete_hash ($recherche);
  71          $query_articles_int = requete_txt_integral('article', $hash_recherche);
  72          $query_breves_int = requete_txt_integral('breve', $hash_recherche);
  73          $query_rubriques_int = requete_txt_integral('rubrique', $hash_recherche);
  74          $query_sites_int = requete_txt_integral('syndic', $hash_recherche);
  75          $query_auteurs_int = requete_txt_integral('auteur', $hash_recherche);
  76      }
  77      
  78      if ($query_articles)
  79          $nba = afficher_articles (_T('info_articles_trouves'), $query_articles);
  80      if ($activer_moteur) {
  81          if ($nba) {
  82              $doublons = join($nba, ",");
  83              $query_articles_int = ereg_replace ("WHERE", "WHERE objet.id_article NOT IN ($doublons) AND", $query_articles_int);
  84          }
  85          $nba1 = afficher_articles (_T('info_articles_trouves_dans_texte'), $query_articles_int);
  86      }
  87      
  88      if ($query_breves)
  89          $nbb = afficher_breves (_T('info_breves_touvees'), $query_breves, true);
  90      if ($activer_moteur) {
  91          if ($nbb) {
  92              $doublons = join($nbb, ",");
  93              $query_breves_int = ereg_replace ("WHERE", "WHERE objet.id_breve NOT IN ($doublons) AND", $query_breves_int);
  94          }
  95          $nbb1 = afficher_breves (_T('info_breves_touvees_dans_texte'), $query_breves_int, true);
  96      }
  97      
  98      if ($query_rubriques)
  99          $nbr = afficher_rubriques (_T('info_rubriques_trouvees'), $query_rubriques);
 100      if ($activer_moteur) {
 101          if ($nbr) {
 102              $doublons = join($nbr, ",");
 103              $query_rubriques_int = ereg_replace ("WHERE", "WHERE objet.id_rubrique NOT IN ($doublons) AND", $query_rubriques_int);
 104          }
 105          $nbr1 = afficher_rubriques (_T('info_rubriques_trouvees_dans_texte'), $query_rubriques_int);
 106      }
 107      
 108      if ($activer_moteur)
 109          $nbt = afficher_auteurs (_T('info_auteurs_trouves'), $query_auteurs_int);
 110      
 111      if ($query_sites)
 112          $nbs = afficher_sites (_T('info_sites_trouves'), $query_sites);
 113      if ($activer_moteur) {
 114          if ($nbs) {
 115              $doublons = join($nbs, ",");
 116              $query_sites_int = ereg_replace ("WHERE", "WHERE objet.id_syndic NOT IN ($doublons) AND", $query_sites_int);
 117          }
 118          $nbs1 = afficher_sites (_T('info_sites_trouves_dans_texte'), $query_sites_int);
 119      }
 120      
 121      if (!$nba AND !$nba1 AND !$nbb AND !$nbb1 AND !$nbr AND !$nbr1 AND !$nbt AND !$nbs AND !$nbs1) {
 122          echo "<FONT FACE='Verdana,Arial,Sans,sans-serif'>"._T('avis_aucun_resultat')."</FONT><P>";
 123      }
 124  }
 125  
 126  echo "<p>";
 127  
 128  fin_page();
 129  
 130  ?>


Généré le : Thu Feb 22 22:27:47 2007 par Balluche grâce à PHPXref 0.7