Also, für das Forum klappt es nun.
Wer am Hack interessiert ist: Code: search.inc.php [newbb/include]
change: for ($i=1; $i<$count; $i++) { $sql .= " $andor "; $sql .= "(p.subject LIKE '%$queryarray[$i]%' OR p.post_text LIKE '%$queryarray[$i]%')"; }
into for ($i=1; $i<$count; $i++) { $sql .= " $andor "; $sql .= "(p.subject LIKE '%$queryarray[$i]%' OR p.post_text LIKE '%$queryarray[$i]%')"; $searchterm .= " "; $searchterm .= $queryarray[$i]; }
change: $ret[$i]['link'] = "viewtopic.php?topic_id=".$myrow['topic_id']."&forum=".$myrow['forum_id']."#".$myrow['post_id']."";
into: $ret[$i]['link'] = "viewtopic.php?query=".$searchterm."&topic_id=".$myrow['topic_id']."&forum=".$myrow['forum_id']."#".$myrow['post_id']."";
viewtopic.php:
insert before: $forum = intval($forum); $topic_id = intval($topic_id);
the following: // if GET/POST is set, set Query for Searchresult highlighting.. if ( isset($HTTP_POST_VARS['query']) ) { $query = $HTTP_POST_VARS['query']; } elseif ( isset($HTTP_GET_VARS['query']) ) { $query = $HTTP_GET_VARS['query']; }
change: $obj->showPost($viewmode, $order, $can_post, $forumdata['topic_status'], $forumdata['allow_sig'], $adminview, $row_color, $start);
into: $obj->showPost($viewmode, $order, $can_post, $forumdata['topic_status'], $forumdata['allow_sig'], $adminview, $row_color, $start, $query);
class.forumposts.php
change: function showPost($viewmode, $order, $can_post, $topic_status, $allow_sig, $adminview=0, $color_num=1, $start)
into: function showPost($viewmode, $order, $can_post, $topic_status, $allow_sig, $adminview=0, $color_num=1, $start, $searchterm)
after: $text = $this->text();
insert: if (!empty($searchterm)) { //if more than one term, put in array $searchterms = explode(" ", $searchterm); // count terms in array $numterms = count($searchterms); //Now, for every count start replace $x=0; for ($x=0;$x<$numterms;$x++){ $search = $searchterms[$x]; $replace = "<font color='FF0000'>".$search."</font>"; $text= str_replace($search, $replace, $text); //Because highlighting is case sensitive, iff all lower convert 1st to upper $search = ucfirst($searchterms[$x]); $replace = "<font color='FF0000'>".$search."</font>"; $text= str_replace($search, $replace, $text); } }
That's it.
Ist garantiert nicht ganz sauber, vor allem bin ich mir sicher dass str_replace eigentlich nicht zweimal aufgerufen werden muss, aber str_ireplace gibt's erst ab PHP5, und eine Funktion die ich dafür gefunden habe, wandelt einfach alles in lower case um.
Hauptsache für mich: Es funzt!
bye Frank |