Guard against intensive searches
This commit is contained in:
committed by
Chris Morgan
parent
504817d08f
commit
7be5d6bd34
@@ -427,7 +427,16 @@ function cleanupSearchWords($search_words)
|
|||||||
Search for the first word in the search query */
|
Search for the first word in the search query */
|
||||||
function searchForApplicationPartial($sSearchWords)
|
function searchForApplicationPartial($sSearchWords)
|
||||||
{
|
{
|
||||||
|
/* This would yield too many results and stress MySQL */
|
||||||
|
if(strlen($sSearchWords) < 4)
|
||||||
|
return null;
|
||||||
|
|
||||||
$sSearchWords = cleanupSearchWords($sSearchWords);
|
$sSearchWords = cleanupSearchWords($sSearchWords);
|
||||||
|
|
||||||
|
/* The search string may have gotten shorter; even empty */
|
||||||
|
if(strlen($sSearchWords) < 4)
|
||||||
|
return null;
|
||||||
|
|
||||||
$aWords = explode(' ', $sSearchWords);
|
$aWords = explode(' ', $sSearchWords);
|
||||||
$sSearchString = '';
|
$sSearchString = '';
|
||||||
$sEnsureExactWord = ''; // Used to ensure we don't match partial words when prepending
|
$sEnsureExactWord = ''; // Used to ensure we don't match partial words when prepending
|
||||||
@@ -455,9 +464,17 @@ function searchForApplicationPartial($sSearchWords)
|
|||||||
/* search the database and return a hResult from the query_appdb() */
|
/* search the database and return a hResult from the query_appdb() */
|
||||||
function searchForApplication($search_words)
|
function searchForApplication($search_words)
|
||||||
{
|
{
|
||||||
|
/* This would yield too many results and stress MySQL */
|
||||||
|
if(strlen($search_words) < 4)
|
||||||
|
return null;
|
||||||
|
|
||||||
/* cleanup search words */
|
/* cleanup search words */
|
||||||
$search_words = cleanupSearchWords($search_words);
|
$search_words = cleanupSearchWords($search_words);
|
||||||
|
|
||||||
|
/* The search string may have gotten shorter; even empty */
|
||||||
|
if(strlen($search_words) < 4)
|
||||||
|
return null;
|
||||||
|
|
||||||
/* remove any search words less than 4 letters */
|
/* remove any search words less than 4 letters */
|
||||||
$split_words = array();
|
$split_words = array();
|
||||||
$split_search_words = split(" ", $search_words);
|
$split_search_words = split(" ", $search_words);
|
||||||
|
|||||||
Reference in New Issue
Block a user