Forum Search

Search Text:

To exclude words from your search, put a '-' in front of that word. System defaults to AND logic between words.
You can search for exact text matches by putting the text string in quotes.
Posted by:
AID:
Name:
Forums to Search:
Include Messages with the following Flags:
Date Range:
Start: last day
last week
last 30 days
last 90 days
last year
End:
Format: yyyy-mm-dd
Search for text in:
checked> Subject checked> Message checked> URL
  
'' && $searchSubj == 0 && $searchMsg == 0 && $searchUrl == 0) { $searchSubj = "1"; $searchMsg = "1"; } if ($searchTxt<>'' || $AID<>'' || $Name<>'') { echo "Your Search Results

"; $sql1 = "select distinct m.mid,m.aid,m.name,m.flags,"; $sql1 .= "m.date,m.subject,m.message, f.name forumName, f.shortname "; $sql2 = ""; $searchText = ""; $intQuote = strpos($searchTxt, "\""); if ($intQuote === false) { $intQuote = 0; $searchText = $searchTxt; } $intEndQuote = strpos($searchTxt, "\"", $intQuote + 1); if ($intEndQuote === false & $intQuote > 0) $searchTxt = $searchTxt . "\""; $bConjunction = false; While ($intQuote > 0) { $intEndQuote = strpos($searchTxt, "\"", $intQuote + 1); if ($intEndQuote === false) { $searchTxt = $searchTxt . "\""; $intEndQuote = strpos($searchTxt, "\"", $intQuote + 1); } $strQuoteText = substr($searchTxt, $intQuote+1, $intEndQuote-($intQuote+2)); if ($intQuote > 0) $searchText = $searchText . substr($searchTxt, 0, $intQuote-1); $searchTxt = substr($searchTxt, $intEndQuote+2, strlen($searchTxt)-($intEndQuote+2)); $bNot = false; //If ($intQuote > 1) //{ // $strQualifier = substr($strNewSearch, strlen($strNewSearch) - 1, strlen($strNewSearch)); // if ($strQualifier == "-") // { // $bNot = true; // $strNewSearch = substr($strNewSearch, 0, strlen($strNewSearch)-1); // } //} if ($bConjunction) $sql2 .= " and "; $bConjunction = true; if ($bNot) { if ($searchSubj == "1" && $searchMsg == "1") { $searchArr[$i] = str_replace("-", "", $strQuoteText); $sql2 .= " (m.subject not like '%" . $strQuoteText . "%' "; $sql2 .= " and m.message not like '%" . $strQuoteText . "%') "; } else if ($searchSubj == "1") { $sql2 .= " m.subject not like '%" . $strQuoteText . "%' "; } else if ($searchMsg == "1") { $sql2 .= " m.message like '%" . $strQuoteText . "%' "; } } else { if ($searchSubj == "1" && $searchMsg == "1") { $sql2 .= " (m.subject like '%" . $strQuoteText . "%' "; $sql2 .= " or m.message like '%" . $strQuoteText . "%') "; } else if ($searchSubj == "1") $sql2 .= " m.subject like '%" . $strQuoteText . "%' "; else if ($searchMsg == "1") $sql2 .= " m.message like '%" . $strQuoteText . "%' "; } $intQuote = strpos($searchTxt, "\""); } //$searchTxt = $searchText; if (trim($searchTxt) != "") { $searchArr = split(" ",trim($searchTxt)); //check if any params are <=3 chars, if so, can't use indexed search //$useIndexedSearch = true; $useIndexedSearch = false; //for ($i=0; $i 0 && $sql2 != "") $sql2 = $sql2 . " and "; for ($i=0; $i0) $sql2 .= " and "; //$sql2 .= " ("; if ($useIndexedSearch) { if ($searchSubj == "1" && $searchMsg == "1") { $sql2 .= " match (m.subject,m.message) AGAINST ('" . $searchArr[$i] . "')"; } else if ($searchSubj == "1") { $sql2 .= " match (m.subject) AGAINST ('" . $searchArr[$i] . "')"; } else if ($searchMsg == "1") { $sql2 .= " match (m.message) AGAINST ('" . $searchArr[$i] . "')"; } if ($searchUrl == "1") { if ($searchSubj == "1" || $searchMsg == "1") $sql2 .= " or "; $sql2 .= " url like '%" . $searchTxt . "%' or urltext like '%" . $searchTxt . "%' "; } } else { $firstCharacter = $searchArr[$i]{0}; if ($searchSubj == "1" && $searchMsg == "1") { if ($firstCharacter == "-") { $searchArr[$i] = str_replace("-", "", $searchArr[$i]); $sql2 .= " (m.subject not like '%" . $searchArr[$i] . "%' "; $sql2 .= " and m.message not like '%" . $searchArr[$i] . "%') "; } else { $sql2 .= " (m.subject like '%" . $searchArr[$i] . "%' "; $sql2 .= " or m.message like '%" . $searchArr[$i] . "%') "; } } else if ($searchSubj == "1") { if ($firstCharacter == "-") $sql2 .= " m.subject not like '%" . $searchArr[$i] . "%' "; else $sql2 .= " m.subject like '%" . $searchArr[$i] . "%' "; } else if ($searchMsg == "1") { if ($firstCharacter == "-") $sql2 .= " m.message not like '%" . $searchArr[$i] . "%' "; else $sql2 .= " m.message like '%" . $searchArr[$i] . "%' "; } } //$sql2 .= ")"; } } if (strlen($sql2) > 0) $sql2 = " where (" . $sql2 . ") and "; else $sql2 = " where "; $sql2 .= " not (m.state = 'Deleted') "; if ($flagIncludeNT == "1") { if ($flagIncludeNonNT == "0") $sql2 .= " and m.flags like '%NoText%' "; } else if ($flagIncludeNonNT == "0") { $sql2 .= " and m.flags not like '%NoText%' "; } if ($flagIncludePIC == "1") { if ($flagIncludeNonPIC == "0") $sql2 .= " and m.flags like '%Picture%' "; } else if ($flagIncludeNonPIC == "0") { $sql2 .= " and m.flags not like '%Picture%' "; } if ($flagIncludeLINKS == "1") { if ($flagIncludeNonLINKS == "0") $sql2 .= " and m.flags like '%Link%' "; } else if ($flagIncludeNonLINKS == "0") { $sql2 .= " and m.flags not like '%Link%' "; } if ($startDate != "") $sql2 .= " and m.date >= '" . $startDate . "' "; if ($endDate != "") $sql2 .= " and m.date <= '" . $endDate . "' "; if ($AID != "") $sql2 .= " and m.aid=" . $AID; if ($Name != "") $sql2 .= " and m.name like '%" . $Name . "%' "; $sql = ""; if ($mySQLVersion >= 4) { for($i=0;$i < count($forumID);$i++) { if ($sql!="") { $sql .= " UNION "; $sql .= "(" . $sql1 . " from f_forums f, f_messages" . $forumID[$i] . " m "; $sql .= $sql2 . " and f.fid=" . $forumID[$i] . " ) "; } else { $sql .= "(" . $sql1 . " from f_forums f, f_messages" . $forumID[$i] . " m "; $sql .= $sql2 . " and f.fid=" . $forumID[$i] . ")"; } } } else { $sql .= $sql1 . " from f_forums f, f_messages" . $forumID[0] . " m "; $sql .= $sql2 . " and f.fid=" . $forumID[0]; } // Perform Query $rs = mysql_query($sql); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$rs) { //if (!$searchForum) //{ // $message = 'No forum selected. I do not know where to search.'; // $message = count($forumID) . ' ' . $sql; //} //else { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $sql; } die($message); } if (mysql_num_rows($rs)>0) { if (mysql_num_rows($rs) == 1) echo "1 match found
"; else echo mysql_num_rows($rs) . " matches found
"; ?>
# Forum
  ",$row['message']); //if ($row['url']) // $msg .= '' . $row['urltext'] . ''; ?>


= 10000) { echo 'more than 10,000 rows returned.'; break; } $maxRow = $i + $rowsPerPage - 1; if ($maxRow > mysql_num_rows($rs)) $maxRow = mysql_num_rows($rs); if ($startRow == $i-1) { ?> - -