Index du Forum » » Questions

Auteur

Tous les messages postés par un membre...
gilbau
486      

  Posté : 06-11-2008 10:56

furax69 a peut etre oublié de poster le code, ce que je fais à sa place puisqu'il me l'a gentillement envoyé par email
Voici son fichier searchpost.php qu'il suffit d'appler via un menu dans un bloc ou ailleurs



<?PHP
/************************************************************** **********/
/* NPDS V : Net Portal Dynamic System .                           & nbsp;      */
/* ===========================        &nbs p;              ;                     */
/*            &nb sp;            &nbs p;              ;                           & nbsp;    */
/* Original Copyright (c) 2001 by Francisco Burzi (fburzi@ncc.org.ve)   */
/*            &nb sp;            &nbs p;              ;                           & nbsp;    */
/* This version name NPDS Copyright (c) 2002-2008 by Thierry Schmitt    */
/* Pour www.magic-oasis.net                        & nbsp;            &n bsp;        */
/*            &nb sp;            &nbs p;              ;                           & nbsp;    */
/* =========================                       & nbsp;            &n bsp;        */
/* Based on Parts of phpBB            &n bsp;            &nb sp;            &nbs p;       */
/*            &nb sp;            &nbs p;              ;                           & nbsp;    */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/*            &nb sp;            &nbs p;              ;                           & nbsp;    */
/* For limit the number off result : set the $Smax value - line 28      */
/*            &nb sp;            &nbs p;              ;                           & nbsp;    */
/************************************************************************/
if (!function_exists("Mysql_Connexion")) {!include! ("mainfile.php");}

!include!(
"functions.php");
if ($SuperCache) 
{
   $cache_obj = new cacheManager();
}
!include!(
"auth.php");
$Smax=
"5000";


function ancre($forum_id,$topic_id,$post_id,$posts_per_page) 
{
   $rowQ1=Q_Select (
"SELECT post_id FROM posts WHERE forum_ id='$forum_id' and topic_id='$topic_id' order by post_ id ASC", 600);
   if (!$rowQ1)
      forumerror('0015');
   while (list(,$row) = each($rowQ1)) 
{
      if ($row
[post_id]==$post_id)
         break;
      $i++;
   
}
   $start=$i-($i%$posts_per_page);
   return (
"&amp;ancre=1&amp;start=$start#".$forum_id.$topic_id.$post_id);
}


/*Formulaire spécial TS*/

!include!('header.php');
   opentable();
   //echo 
"<CENTER><IMG SRC='images/searchpost.jpg'><b r></CENTER>";
   echo 
"<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
   echo 
"</td></tr></table>\n";
   echo 
"<br />";
   echo 
"<form name=\"search\" action=\"$PHP_SELF\" method=\"post\">";
   echo 
"<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"100%\">";
   
/*Dans quel forums ont cherche ?*/
   echo 
"<tr>";
   echo 
"<td class=\"LIGNB\" width=\"20%\" align=\"right\">";
   echo 
"<b>Où chercher ?</b> :";
   echo 
"</td>";
   echo 
"<td width=\"20%\">";
   echo 
"<select class=\"TEXTBOX_STANDARD\" name=\"forum\">";
   echo 
"<option value=\"all\">".translate("Search All Forums")."</option>";
   $rowQ1=Q_Select (
"SELECT forum_name,forum_id FROM forums"
, 3600);
   if (!$rowQ1)
      forumerror('0015');
   while (list(,$row) = each($rowQ1)) 
{
      echo 
"<option value=\"$row[forum_id]\">$row[forum_name]</option>";
   
}
   echo 
"</select>";
   echo 
"</td>";
   echo 
"</tr>";
   
/*Nom du membre pour la recherche*/
   echo 
"<tr>";
   echo 
"<td class=\"LIGNB\" width=\"20%\" align=\"right\">";
   echo 
"<b>Pour quel membre ?</b> :";
   echo 
"</td>";
   echo 
"<td width=\"200\">";
   echo 
"<input class=\"TEXTBOX\" type=\"text\" name=\"username\">";
   echo 
"</td>";
   echo 
"</tr>";


/*Je cache le choix de recherche pour ne&n bsp;laisser que par auteur ! */
   echo 
"<tr>";
   echo 
"<td class=\"LIGNB\" width=\"20%\" align=\"right\">";
   echo 
"</td>";
   echo 
"<td width=\"80%\">";
   echo 
"<input type=\"hidden\" name=\"sortby\" value=\"u.uname\" checked>";
   echo 
"</td>";
      echo 
"<td>";
      echo 
"<hr>";
      echo 
"</td>";
   echo 
"</tr>";


/*Boutons annuler et valider puis début de  ;recherche */
   echo 
"<tr>";
   echo 
"<td colspan=\"2\" align=\"center\">";
   echo 
"<input class=\"BOUTON_STANDARD\" type=\"submit\" name=\"submit\" Value=".translate("Search").">&nbsp;&nbsp;<input class=\"BOUTON_STANDARD\" type=\"reset\" name=\"reset\" value=\"".translate("Clear")."\">";
   echo 
"</td></tr>";
   echo 
"</table>";
   echo 
"</form>";
   $query = 
"SELECT u.uid, f.forum_id, p.topic_id, p.pos t_id, u.uname, p.post_time, t.topic_title, f.forum_name,&nb sp;f.forum_type, f.forum_pass, f.arbre FROM posts p,&n bsp;users u, forums f, forumtopics t";
   if (isset($term)&&$term!=
""{
      $terms = split(
" ",stripslashes(removeHack(trim($term))));
      $addquery .= 
"( (p.post_text LIKE '%$terms[0]%' or strcmp(soundex(p.post_text), soundex('$ter ms[0]'))=0)";
      if ($addterms==
"any")
         $andor = "OR";
      else
         $andor = "AND";
      $size = sizeof($terms);
      for ($i=1;$i<$size;$i++)
          $addquery.=
" $andor (p.post_text LIKE '%$terms[
$i]%' or strcmp(soundex(p.post_text), soundex('$ter ms[$i]'))=0)";
      $addquery.=
")";
   
}

   if (isset($forum)&&$forum!=
"all"{
      if (isset($addquery))
         $addquery.=
" AND p.forum_id='$forum' AND f.forum_id='$f orum'";
      else
         $addquery.=
" p.forum_id='$forum' AND f.forum_id='$forum'";
   
}
   if (isset($username)&&$username!=
""{
      $username= removeHack($username);
      if (!$result = mysql_query (
"SELECT uid FROM users WHERE uname='$us ername'")) {
         forumerror(0001);
      
}
      list($userid) = mysql_fetch_row($result);
      if (isset($addquery))
         $addquery.=
" AND p.poster_id='$userid' AND u.uname='$us ername'";
      else
         $addquery.=
" p.poster_id='$userid' AND u.uname='$username'";
   
}

   if (!$user) 
{
      $addquery.=
" AND f.forum_type!='5' AND f.forum_type!='7 ' AND f.forum_type!='9'";
   
}

   if (isset($addquery))
      $query.=
" WHERE $addquery AND  ";
   else
      $query.=
" WHERE ";

   if ($only_solved) 
{
      $query.=
" p.topic_id = t.topic_id AND p.forum_i d = f.forum_id AND p.poster_id = u.uid AND&n bsp;t.topic_status='2' GROUP BY t.topic_title ORDER BY  $sortby DESC";
   
} else {
      $query.=
" p.topic_id = t.topic_id AND p.forum_i d = f.forum_id AND p.poster_id = u.uid AND&n bsp;t.topic_status!='2' ORDER BY $sortby DESC";
   
}
   $Smax++;
   settype($Smax,
"integer");
   $query.=
" limit 0,$Smax";
   $result = mysql_query($query);

   $affiche=true;
   if (!$row = @mysql_fetch_array($result)) 
{
      echo 
"<p align=\"center\">Indiquez seulement le pseudo d'un  membre unique et valide</p><br />";
      $affiche=false;
   
}
   if ($affiche) 
{
      $count=0;
      echo 
"<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">";
      do 
{
         $rowcolor = t ablos();
         if (($row
[
forum_type] == 5) or ($row[forum_type] == 7)) {
            $ok_a ffich=false;
            $tab_ groupe=valid_group($user);
            $ok_a ffich=groupe_forum($row
[forum_pass], $tab_groupe);
         
} else {
            $ok_a ffich=true;
         
}
         if ($ok_affich)&nb sp;
{
            if&nb sp;($count==0) 
{
              ;  echo 
"<tr>";
              ;  echo 
"<td class=\"ONGL\" align=\"left\">&nbsp;</td>";
              ;  echo 
"<td class=\"ONGL\" align=\"left\" nowrap=\"nowrap\">".translate("Forum")."</td>";
              ;  echo 
"<td class=\"ONGL\" align=\"left\">".translate("Topic")."</td>";
              ;  echo 
"<td class=\"ONGL\" align=\"left\" nowrap=\"nowrap\">".translate("Author")."</td>";
              ;  echo 
"<td class=\"ONGL\" align=\"left\" nowrap=\"nowrap\">".translate("Posted")."</td>";
              ;  echo 
"</tr>";
            }
            echo& nbsp;
"<tr $rowcolor>";
            echo& nbsp;
"<td align=\"left\">".($count+1)."</td><td align=\"left\"><a href=\"viewforum.php?forum=$row[forum_id]\" class=\"NOIR\">".stripslashes($row[forum_name])."</a></td>";
            if&nb sp;($row
[arbre]{$Hplus="H";} else {$Hplus="";}
            $ancr e=ancre($row
[forum_id],$row[topic_id],$row[post_id],$posts_per_page);
            echo& nbsp;
"<td align=\"left\"><a href=\"viewtopic$Hplus.php?topic=$row[topic_id]&amp;forum=$row[forum_id]$ancre\" class=\"NOIR\">".stripslashes($row[topic_title])."</a></td>";
            echo& nbsp;
"<td align=\"left\"><a href=\"user.php?op=userinfo&amp;uname=$row[uname]\" class=\"NOIR\">$row[uname]</a></td>";
            echo& nbsp;
"<td align=\"left\">".convertdate($row[post_time])."</td>";
            echo& nbsp;
"</tr>";
            $coun t++;
         
}
      
} while ($row=@mysql_fetch_array($result));
      echo 
"</table>";
   
}
   closetable();
   mysql_free_result;
   !include!('footer.php');
?>





Cet article provient de NPDS

http://www.npds.org/viewtopic.php?topic=23743&forum=9