Web: http://www.gammon.com.au/ Date: February 2001 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, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to The Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. The Free Software Foundation maintains a web page at: http://www.fsf.org See the file gpl.txt for the full GNU General Public License. */ require ("config.php"); require ($CONFIG_PATH . "general_config.php"); require ($INCLUDE_DIRECTORY . "common.php"); Init ("Forum search", "forum, search"); $forum_name = $control ['forum_name']; function ShowForm () { global $PHP_SELF, $searchfor, $bbtopic_id; ?>

Search for words

Enter one or more words in the box below to find messages that match.

Search for:   

Look in topic:  

Search the forum

" . htmlentities ($forum_name) . "

\n"; ShowForm (); if ($action == 'search') { // don't let them slip in semicolons, like ; drop database xxx; $searchfor = str_replace (";", " ", $searchfor); $searchfor = trim ($searchfor); // get rid of spaces // don't let them use % or _ in the string $searchforfixed = addcslashes ($searchfor, "%_"); $searcharray = explode (" ", $searchforfixed); $searchstring = ""; $not = ""; $and_or = "AND"; while (list ($key, $value) = each ($searcharray)) { $value = trim ($value); if (empty ($value)) continue; if (strtolower ($value) == "not") { $not = "NOT"; continue; } if (strtolower ($value) == "and") { $and_or = "AND"; continue; } if (strtolower ($value) == "or") { $and_or = "OR"; continue; } if (!empty ($searchstring)) $searchstring .= " $and_or "; $searchstring .= "$not (post_text LIKE '%$value%' OR " . "subject_name LIKE '%$value%')"; $not = ""; } if (strlen ($searchstring) == 0) ShowError ("You must specify something to search for"); else { // show search results $datetimeformat = $control ['datetimeformat']; $tz = $foruminfo ['time_zone']; if (!$tz) $tz = 0; // not logged in? Assume UTC $LIMIT = 50; if ($bbtopic_id > 0) $topic_where = "AND bbtopic.bbtopic_id = $bbtopic_id "; $query = "SELECT bbsubject.bbsubject_id, " . " CONCAT(section_name, ': ', topic_name, ': ', subject_name) AS fullname, " . "DATE_FORMAT(DATE_ADD(post_date, INTERVAL $tz HOUR), '$datetimeformat') AS excerpt " . "FROM bbpost, bbsubject, bbtopic, bbsection " . "WHERE ($searchstring) " . $topic_where . " AND bbsection.bbsection_id = bbtopic.bbsection_id " . " AND bbtopic.bbtopic_id = bbsubject.bbtopic_id " . " AND bbsubject.bbsubject_id = bbpost.bbsubject_id " . "GROUP BY bbsubject_id " . "ORDER BY section_name, topic_name, subject_name " . "LIMIT $LIMIT"; // echo $query . "
"; echo "

Search results

\n"; $count = ShowList ($query, "bbsubject_id", "", "fullname", true, "", "
  • ", "
  • ", "bbshowpost.php"); if ($count >= $LIMIT) echo "

    Search limited to $count items.

    "; } // end of something to search for } // end of search button pressed echo "
    \n"; ?>

    Search hints

    You can search for:

    Both the text of the post, and the subject line, are searched.