Suche einbinden

Begonnen von Schaum, 14 Februar 2004, 11:27:43

⏪ vorheriges - nächstes ⏩

0 Mitglieder und 1 Gast betrachten dieses Thema.

Schaum

Hallo,
was muß ich tun damit bzw. welchen Teil muß ich in die Search.php einbinden, damit das Forum bei einer suchanfrage mit eingebunen wird.

Hat jemand einen Tipp

Danke

tequila

Nimm die search.php und daraus den Quellcode, der für die Suche in "_table_threads" und "_table_posts" zuständig ist ... das muß dann eben auch bei Deiner Suchmaske mit rein

Schaum

Danke für die antwort!
Meinst du von der eboard-search diesen Teil:
 
Zitat

}

elseif($searchsubmit)
{
   
$array_1=array("AND","and","+"," ","%%");
$array_2=array("%","%","%","%","%");
for($x=0;$x<5;$x++)
{
$searchtext = str_replace($array_1[$x],$array_2[$x],$searchtext);
}

  if (empty($searchfrom)) { $searchfrom=0; }
  if (empty($searchin))   { $searchin='both'; }

$sql1 = "SELECT dateline, subject, fid, tid, author, icon FROM $table_threads";
$sql2 = "SELECT dateline, pid, fid, tid, author, icon FROM $table_posts";

if($searchfrom == "0") { $searchfrom = time(); }

$searchfrom = time() - $searchfrom;

if($searchtext)
{
  $sql1 .= " WHERE (message LIKE '%$searchtext%' OR subject LIKE '%$searchtext%')";
  $sql2 .= " WHERE message LIKE '%$searchtext%'";
}
elseif($searchtext == "" && $searchname == "" && $srchfid != "all" || $srchfid == "")
{
  $sql1 .= " WHERE fid='$srchfid'";
  $sql2 .= " WHERE fid='$srchfid'";
}  
elseif($searchtext == "" && $searchname != "")
{
  if($srchfid == "all")
  {
    $sql1 .= " WHERE author='$searchname'";
    $sql2 .= " WHERE author='$searchname'";
  }
  elseif($srchfid != "")
  {
    $sql1 .= " WHERE author='$searchname' AND fid='$srchfid'";
    $sql2 .= " WHERE author='$searchname' AND fid='$srchfid'";
  }
}
 

if($srchfid != "all" && $searchtext != "" && $searchname == "") {
$sql1 .= " AND fid='$srchfid'";
$sql2 .= " AND fid='$srchfid' AND dateline >= '$searchfrom'";
}
elseif($searchname != "" && $srchfid != "all" && $searchtext != "") {
$sql1 .= " AND fid='$srchfid'";
$sql2 .= " AND fid='$srchfid'";
}

if($searchtext != "" && $searchname != "") {
$sql1 .= " AND author='$searchname'";
$sql2 .= " AND author='$searchname'";
}

if (strstr( $sql1, "WHERE"))   { $sql1 .= " AND dateline >= '$searchfrom'"; }
else                     { $sql1 .= " WHERE dateline >= '$searchfrom'"; }

if (strstr( $sql2, "WHERE"))   { $sql2 .= " AND dateline >= '$searchfrom'"; }
else                     { $sql2 .= " WHERE dateline >= '$searchfrom'"; }


$query1 = $dbxf->sql_query($sql1);
$query2 = $dbxf->sql_query($sql2);

if($searchin == "both" || $searchin == "topic" || $searchin == "topicnoreply")
{
#  $threadcount = $dbxf->sql_num_rows($query1);

while($thread = $dbxf->sql_fetch_object($query1))
{
     # Query-Cache für Foren
     if(empty($forumcache[$thread->fid])){
        $forumquery = $dbxf->sql_query("SELECT type, name, moderator, private, userlist, fup FROM $table_forums WHERE fid='".$thread->fid."' AND status='on'");   
        $forum = $dbxf->sql_fetch_object($forumquery);
        $forumcache[$thread->fid] = $forum;
     }else{
        $forum = $forumcache[$thread->fid];
     }
     
     if(!empty($forum)){
     
     $howmany = 0;
     $date = date("$dateformat",$thread->dateline);
     $time = date("$timecode",$thread->dateline);
     $poston = "$date "._TEXTAT." $time";
     $thread->subject = stripslashes($thread->subject);
   
     // Autorisations
     $authToDisplay = FALSE;
     
     # Falls keine Zugangsbeschraenkung, alles ok
     if( empty($forum->private) && empty($forum->userlist) ){ $authToDisplay = TRUE; }
     # Falls Eintraege vorhanden, guck nach
     elseif( !empty($forum->private) || !empty($forum->userlist) ){
       if ( isTrusted($thisuser, $status, $forum->moderator, $forum->private, $forum->userlist) )   { $authToDisplay = TRUE; }
       else                                                   { $authToDisplay = FALSE; }        
     }
     
     # Falls Sub-Forum, guck ob Main-Forum Zugangsbeschraenkungen hat
     if( $authToDisplay && $forum->type == "sub" && !empty($forum->fup) ){
        $mainforumquery = $dbxf->sql_query("SELECT moderator, private, userlist FROM $table_forums WHERE fid='".$forum->fup."' AND status='on'");   
        $mainforum = $dbxf->sql_fetch_object($mainforumquery);
        if ( isTrusted($thisuser, $status, $mainforum->moderator, $mainforum->private, $mainforum->userlist) )   { $authToDisplay = TRUE; }
      else                                                   { $authToDisplay = FALSE; }
        
     }
     
     # Wenn nur nach Beiträgen ohne Antwort gesucht werden soll
     if($authToDisplay && $searchin == "topicnoreply"){
     $noreplyquery = $dbxf->sql_query("SELECT COUNT(pid) as nbsites FROM $table_posts WHERE tid='".$thread->tid."'");
     $howmany = $dbxf->sql_fetch_object($noreplyquery);
        if($howmany->nbsites != 0){
      $authToDisplay = false;
      }else{
      $authToDisplay = true;
      }
     }

   
     if( $authToDisplay )
     {    
       $tabtemp[]=array("dateline"=>$thread->dateline, "fid"=>$thread->fid, "icon"=>$thread->icon, "forumname"=>$forum->name, "subject"=>$thread->subject, "tid"=>$thread->tid, "author"=>$thread->author, "poston"=>$poston, "textpost"=>_TEXTTOPIC);   
     }
     
  } # Ende if $forum
  $forum = "";  
} # Ende while $thread

}

#if($searchin != "both" || $searchin != "reply")
if($searchin == "both" || $searchin == "reply")
{
#  $postcount = $dbxf->sql_num_rows($query2);

  while($post = $dbxf->sql_fetch_object($query2))
  {
     # Query-Cache für Foren
     if(empty($forumcache[$post->fid])){
        $forumquery = $dbxf->sql_query("SELECT type, name, moderator, private, userlist, fup FROM $table_forums WHERE fid='".$post->fid."' AND status='on'");   
        $forum = $dbxf->sql_fetch_object($forumquery);
        $forumcache[$post->fid] = $forum;
     }else{
        $forum = $forumcache[$post->fid];
     }
     
     if(!empty($forum)){

       $date = date("$dateformat",$post->dateline);
       $time = date("$timecode",$post->dateline);
       $poston = "$date "._TEXTAT." $time";
   
        // Autorisations
        $authToDisplay = FALSE;
        
        # Falls keine Zugangsbeschraenkung, alles ok
        if( empty($forum->private) && empty($forum->userlist) ){ $authToDisplay = TRUE; }
        # Falls Eintraege vorhanden, guck nach
        elseif( !empty($forum->private) || !empty($forum->userlist) ){
          if ( isTrusted($thisuser, $status, $forum->moderator, $forum->private, $forum->userlist) )   { $authToDisplay = TRUE; }
          else                                                   { $authToDisplay = FALSE; }        
        }
        # Falls Sub-Forum, guck ob Main-Forum Zugangsbeschraenkungen hat
        elseif( $authToDisplay && $forum->type == "sub" && !empty($forum->fup) ){
           $mainforumquery = $dbxf->sql_query("SELECT moderator, private, userlist FROM $table_forums WHERE fid='".$forum->fup."' AND status='on'");   
           $mainforum = $dbxf->sql_fetch_object($mainforumquery);
           if ( isTrusted($thisuser, $status, $mainforum->moderator, $mainforum->private, $mainforum->userlist) )   { $authToDisplay = TRUE; }
         else                                                   { $authToDisplay = FALSE; }
           
        }
/*
      # Alter Teil   
       if ( isPrivateForum( $post->fid ) )
       {
        if ( isInUserList( $thisuser, $post->fid ) || isOnStaff($status) )   { $authToDisplay = TRUE; }
        else                                                   { $authToDisplay = FALSE; }
       }
   
   #### oeffentliche Foren in Privaten oder staff-foren nicht anzeigen
       elseif ( isPrivateMainForum( $post->fid ) )
       {
       if ( isInUserList( $thisuser, $threadmainfid ) || isOnStaff($status) )   { $authToDisplay = TRUE; }
       else                                                   { $authToDisplay = FALSE; }
       }
     
   #### ende der mainforum-abfrage
   
       
      else { $authToDisplay = TRUE; }
*/   
       if( $authToDisplay )
       {
         # Query-Cache fuer Threads
        if(empty($threadcache[$post->tid])){
          $infoquery = $dbxf->sql_query("SELECT subject, tid FROM $table_threads WHERE tid='".$post->tid."'");
          $threadinfo = $dbxf->sql_fetch_object($infoquery);
          $threadinfo->subject = stripslashes($threadinfo->subject);
           $threadcache[$post->tid] = $threadinfo;
        }else{
           $threadinfo = $threadcache[$post->tid];
        }
        
          
          
#       $sqlname = $dbxf->sql_query("SELECT name FROM $table_forums WHERE fid= '".$post->fid."'");
#       $fidname = $dbxf->sql_fetch_object($sqlname);
     
      $tabtemp[]=array("dateline"=>$post->dateline, "fid"=>$post->fid, "icon"=>$post->icon, "forumname"=>$forum->name, "subject"=>$threadinfo->subject, "pid"=> $post->pid, "tid"=>$threadinfo->tid, "author"=>$post->author, "poston"=>$poston, "textpost"=>_TEXTREPLY);
   
   
   //     $tabtemp[]=array("dateline"=>$post->dateline, "subject"=>$threadinfo->subject, "pid"=> $post->pid, "tid"=>$threadinfo->tid, "author"=>$post->author, "poston"=>$poston, "textpost"=>_TEXTPOSTREPLYNOTE);
       } # Ende if $authToDisplay
     } # Ende if $forum
     $forum = "";
  } # Ende while $post
}

function cmp ($a, $b) {
    return ($a["dateline"] < $b["dateline"]);
}
usort($tabtemp, "cmp");

$resultnumber = count($tabtemp);

tequila

Na eigentlich interessiert Dich Doch die Suche nach einem Text, d.h. Datum, User, Forum usw kannst Du mal außern vor lassen.

Du mußt Dir eben nur die Resultate von den zwei folgenden Abfragen anzeigen lassen:

$searchtext = Dein SUchtext (keine Ahung, wie die Variable jetzt genau heißt)

$threads_query=mysql_query("SELECT tid, subject FROM mx_eboard_threads WHERE message LIKE '%$searchtext%' OR subject LIKE '%$searchtext%'");

$post_query=sql_query("SELECT t1.pid AS pid, t1.tid AS tid,  t2.subject AS subject FROM mx_eboard_posts AS t1, mx_eboard_posts AS t2  WHERE t1.message LIKE '%$searchtext%' AND t1.tid=t2.tid");


so, und dann holst Du Dir eben von diesen Threads/Posts die Daten und läßt sie anzeigen ... bedenkte das auch mehrere Resultate zurück kommen können, d.h. Du mußt eine dynamische Darstellung für jedes Resultat machen.

Sorry, war ein kleiner Typo in der letzten Abfrage ... stand t1.pid statt t1.tid

[Editiert am 15/2/2004 von tequila]