From 1cee6fcf41b10765323e3af7356ae23acb7bd8d4 Mon Sep 17 00:00:00 2001 From: Graham Eames Date: Sat, 20 May 2006 14:01:48 +0000 Subject: [PATCH] Some changes to the way we filter short search terms since it seemed to not completely work on some configurations I've moved the minimum number of characters to a config variable as well to save hard-coding it several times and allow configuration for those who want it There will not be an option to change this via the ACP, you can always do so via the database if you want to git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@5942 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/docs/CHANGELOG.html | 2 ++ phpBB/install/schemas/mssql_basic.sql | 1 + phpBB/install/schemas/mysql_basic.sql | 1 + phpBB/install/schemas/postgres_basic.sql | 1 + phpBB/install/update_to_latest.php | 8 +++++++- phpBB/search.php | 6 +++--- 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index e82930b3a5..77050d360f 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -75,6 +75,8 @@ p,ul,td {font-size:10pt;}
  • [Fix] Redirect to list if cancelling deletion of ranks, smilies or word censors
  • [Fix] Missing error message if an inactive user tried to login (Bug #1598)
  • [Fix] Do not alter post counts when just removing a poll (Bug #1602)
  • +
  • [Fix] Correct error in removal of old session keys
  • +
  • [Fix] Changed filtering of short search terms
  • [Sec] Improved filtering on language selection (also addresses a number of bug reports related to missing languages)
  • [Change] Backported more efficient highlighting code from Olympus
  • diff --git a/phpBB/install/schemas/mssql_basic.sql b/phpBB/install/schemas/mssql_basic.sql index b08ed10a52..c4bc82a6e4 100644 --- a/phpBB/install/schemas/mssql_basic.sql +++ b/phpBB/install/schemas/mssql_basic.sql @@ -52,6 +52,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('sendmail_fix','0') INSERT INTO phpbb_config (config_name, config_value) VALUES ('require_activation','0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('flood_interval','15'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_flood_interval','15'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_min_chars','3'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_login_attempts', '5'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('login_reset_time', '30'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email_form','0'); diff --git a/phpBB/install/schemas/mysql_basic.sql b/phpBB/install/schemas/mysql_basic.sql index 71dc16244f..64dee0f4bc 100644 --- a/phpBB/install/schemas/mysql_basic.sql +++ b/phpBB/install/schemas/mysql_basic.sql @@ -45,6 +45,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('sendmail_fix','0') INSERT INTO phpbb_config (config_name, config_value) VALUES ('require_activation','0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('flood_interval','15'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_flood_interval','15'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_min_chars','3'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_login_attempts', '5'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('login_reset_time', '30'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email_form','0'); diff --git a/phpBB/install/schemas/postgres_basic.sql b/phpBB/install/schemas/postgres_basic.sql index 7ccc88ca0b..2954bf8d22 100644 --- a/phpBB/install/schemas/postgres_basic.sql +++ b/phpBB/install/schemas/postgres_basic.sql @@ -46,6 +46,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('sendmail_fix','0') INSERT INTO phpbb_config (config_name, config_value) VALUES ('require_activation','0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('flood_interval','15'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_flood_interval','15'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_min_chars','3'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_login_attempts', '5'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('login_reset_time', '30'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email_form','0'); diff --git a/phpBB/install/update_to_latest.php b/phpBB/install/update_to_latest.php index 7c9ca9a4d0..5e20600d7e 100644 --- a/phpBB/install/update_to_latest.php +++ b/phpBB/install/update_to_latest.php @@ -1092,6 +1092,12 @@ switch ($row['config_value']) VALUES ('rand_seed', '0')"; _sql($sql, $errored, $error_ary); + case '.0.20': + + $sql = 'INSERT INTO ' . CONFIG_TABLE . " (config_name, config_value) + VALUES ('search_min_chars', '3')"; + _sql($sql, $errored, $error_ary); + // We reset those having autologin enabled and forcing the re-assignment of a session id // since there have been changes to the way these are handled from previous versions $sql = 'DELETE FROM ' . SESSIONS_TABLE; @@ -1103,7 +1109,7 @@ switch ($row['config_value']) break; default: - echo " No updates where required

    \n"; + echo " No updates were required

    \n"; break; } diff --git a/phpBB/search.php b/phpBB/search.php index 306ba5bea9..7a14f1028e 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -218,7 +218,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id ) { $search_author = str_replace('*', '%', trim($search_author)); - if( ( strpos($search_author, '%') !== false ) && ( strlen(str_replace('%', '', $search_author)) < 3 ) ) + if( ( strpos($search_author, '%') !== false ) && ( strlen(str_replace('%', '', $search_author)) < $board_config['search_min_chars'] ) ) { $search_author = ''; } @@ -290,7 +290,7 @@ 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])))) + if ( strlen(str_replace(array('*', '%'), '', trim($split_search[$i]))) < $board_config['search_min_chars'] ) { $split_search[$i] = ''; continue; @@ -441,7 +441,7 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id ) { $search_author = str_replace('*', '%', trim($search_author)); - if( ( strpos($search_author, '%') !== false ) && ( strlen(str_replace('%', '', $search_author)) < 3 ) ) + if( ( strpos($search_author, '%') !== false ) && ( strlen(str_replace('%', '', $search_author)) < $board_config['search_min_chars'] ) ) { $search_author = ''; }