From dfd0fd39fdb825f073ef582fecdba157d769e303 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 15 Mar 2005 18:34:34 +0000 Subject: [PATCH] - try some matching against server intensive searches... git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@5102 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/search.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/phpBB/search.php b/phpBB/search.php index d06dbfd71f..bd9bb83cab 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -197,6 +197,11 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id ) } else { + if (preg_match('#^[\*%]+$#', trim($search_author)) || preg_match('#^[^\*]{1,2}$#', str_replace(array('*', '%'), '', trim($search_author)))) + { + $search_author = ''; + } + $search_author = str_replace('*', '%', trim($search_author)); $sql = "SELECT user_id @@ -264,6 +269,12 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id ) for($i = 0; $i < count($split_search); $i++) { + if (preg_match('#^[\*%]+$#', trim($split_search[$i])) || preg_match('#^[^\*]{1,2}$#', str_replace(array('*', '%'), '', trim($split_search[$i])))) + { + $split_search[$i] = ''; + continue; + } + switch ( $split_search[$i] ) { case 'and': @@ -407,6 +418,11 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id ) // if ( $search_author != '' ) { + if (preg_match('#^[\*%]+$#', trim($search_author)) || preg_match('#^[^\*]{1,2}$#', str_replace(array('*', '%'), '', trim($search_author)))) + { + $search_author = ''; + } + $search_author = str_replace('*', '%', trim(str_replace("\'", "''", $search_author))); }