Page/Search

* dropped support of wildcard characters
 * search for literal usage of underscore
This commit is contained in:
Sarjuuk
2018-12-07 21:35:30 +01:00
parent 09176d1ae9
commit db012cfa8c
17 changed files with 47 additions and 45 deletions

View File

@@ -1204,9 +1204,9 @@ abstract class Filter
foreach ($parts as $p) foreach ($parts as $p)
{ {
if ($p[0] == '-' && (mb_strlen($p) > 3 || $shortStr)) if ($p[0] == '-' && (mb_strlen($p) > 3 || $shortStr))
$sub[] = [$f, sprintf($exPH, mb_substr($p, 1)), '!']; $sub[] = [$f, sprintf($exPH, str_replace('_', '\\_', mb_substr($p, 1))), '!'];
else if ($p[0] != '-' && (mb_strlen($p) > 2 || $shortStr)) else if ($p[0] != '-' && (mb_strlen($p) > 2 || $shortStr))
$sub[] = [$f, sprintf($exPH, $p)]; $sub[] = [$f, sprintf($exPH, str_replace('_', '\\_', $p))];
} }
// single cnd? // single cnd?

View File

@@ -319,8 +319,8 @@ class AchievementListFilter extends Filter
protected $inputFields = array( protected $inputFields = array(
'cr' => [FILTER_V_RANGE, [2, 18], true ], // criteria ids 'cr' => [FILTER_V_RANGE, [2, 18], true ], // criteria ids
'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 99999]], true ], // criteria operators 'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 99999]], true ], // criteria operators
'crv' => [FILTER_V_REGEX, '/[\p{C};:]/ui', true ], // criteria values - only printable chars, no delimiters 'crv' => [FILTER_V_REGEX, '/[\p{C};:%\\\\]/ui', true ], // criteria values - only printable chars, no delimiters
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name / description - only printable chars, no delimiter 'na' => [FILTER_V_REGEX, '/[\p{C};%\\\\]/ui', false], // name / description - only printable chars, no delimiter
'ex' => [FILTER_V_EQUAL, 'on', false], // extended name search 'ex' => [FILTER_V_EQUAL, 'on', false], // extended name search
'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter 'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter
'si' => [FILTER_V_LIST, [1, 2, 3, -1, -2], false], // side 'si' => [FILTER_V_LIST, [1, 2, 3, -1, -2], false], // side

View File

@@ -73,7 +73,7 @@ class AreaTriggerListFilter extends Filter
'cr' => [FILTER_V_LIST, [2], true ], // criteria ids 'cr' => [FILTER_V_LIST, [2], true ], // criteria ids
'crs' => [FILTER_V_RANGE, [1, 6], true ], // criteria operators 'crs' => [FILTER_V_RANGE, [1, 6], true ], // criteria operators
'crv' => [FILTER_V_RANGE, [0, 99999], true ], // criteria values - all criteria are numeric here 'crv' => [FILTER_V_RANGE, [0, 99999], true ], // criteria values - all criteria are numeric here
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name - only printable chars, no delimiter 'na' => [FILTER_V_REGEX, '/[\p{C};\\\\]/ui', false], // name - only printable chars, no delimiter
'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter 'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter
'ty' => [FILTER_V_RANGE, [0, 5], true ] // types 'ty' => [FILTER_V_RANGE, [0, 5], true ] // types
); );

View File

@@ -47,7 +47,7 @@ class ArenaTeamListFilter extends Filter
// fieldId => [checkType, checkValue[, fieldIsArray]] // fieldId => [checkType, checkValue[, fieldIsArray]]
protected $inputFields = array( protected $inputFields = array(
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name - only printable chars, no delimiter 'na' => [FILTER_V_REGEX, '/[\p{C};%\\\\]/ui', false], // name - only printable chars, no delimiter
'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter 'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter
'ex' => [FILTER_V_EQUAL, 'on', false], // only match exact 'ex' => [FILTER_V_EQUAL, 'on', false], // only match exact
'si' => [FILTER_V_LIST, [1, 2], false], // side 'si' => [FILTER_V_LIST, [1, 2], false], // side

View File

@@ -335,8 +335,8 @@ class CreatureListFilter extends Filter
protected $inputFields = array( protected $inputFields = array(
'cr' => [FILTER_V_LIST, [[1, 3],[5, 12], 15, 16, [18, 25], [27, 29], [31, 35], 37, 38, [40, 44]], true ], // criteria ids 'cr' => [FILTER_V_LIST, [[1, 3],[5, 12], 15, 16, [18, 25], [27, 29], [31, 35], 37, 38, [40, 44]], true ], // criteria ids
'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 9999]], true ], // criteria operators 'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 9999]], true ], // criteria operators
'crv' => [FILTER_V_REGEX, '/[\p{C}:;]/ui', true ], // criteria values - only printable chars, no delimiter 'crv' => [FILTER_V_REGEX, '/[\p{C}:;%\\\\]/ui', true ], // criteria values - only printable chars, no delimiter
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name / subname - only printable chars, no delimiter 'na' => [FILTER_V_REGEX, '/[\p{C};%\\\\]/ui', false], // name / subname - only printable chars, no delimiter
'ex' => [FILTER_V_EQUAL, 'on', false], // also match subname 'ex' => [FILTER_V_EQUAL, 'on', false], // also match subname
'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter 'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter
'fa' => [FILTER_V_CALLBACK, 'cbPetFamily', true ], // pet family [list] - cat[0] == 1 'fa' => [FILTER_V_CALLBACK, 'cbPetFamily', true ], // pet family [list] - cat[0] == 1

View File

@@ -310,7 +310,7 @@ class EnchantmentListFilter extends Filter
'cr' => [FILTER_V_RANGE, [2, 123], true ], // criteria ids 'cr' => [FILTER_V_RANGE, [2, 123], true ], // criteria ids
'crs' => [FILTER_V_RANGE, [1, 15], true ], // criteria operators 'crs' => [FILTER_V_RANGE, [1, 15], true ], // criteria operators
'crv' => [FILTER_V_RANGE, [0, 99999], true ], // criteria values - only numerals 'crv' => [FILTER_V_RANGE, [0, 99999], true ], // criteria values - only numerals
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name - only printable chars, no delimiter 'na' => [FILTER_V_REGEX, '/[\p{C};%\\\\]/ui', false], // name - only printable chars, no delimiter
'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter 'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter
'ty' => [FILTER_V_RANGE, [1, 8], true ] // types 'ty' => [FILTER_V_RANGE, [1, 8], true ] // types
); );

View File

@@ -170,7 +170,7 @@ class GameObjectListFilter extends Filter
'cr' => [FILTER_V_LIST, [[1, 5], 7, 11, 13, 15, 16, 18, 50], true ], // criteria ids 'cr' => [FILTER_V_LIST, [[1, 5], 7, 11, 13, 15, 16, 18, 50], true ], // criteria ids
'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 5000]], true ], // criteria operators 'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 5000]], true ], // criteria operators
'crv' => [FILTER_V_RANGE, [0, 99999], true ], // criteria values - only numeric input values expected 'crv' => [FILTER_V_RANGE, [0, 99999], true ], // criteria values - only numeric input values expected
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name - only printable chars, no delimiter 'na' => [FILTER_V_REGEX, '/[\p{C};%\\\\]/ui', false], // name - only printable chars, no delimiter
'ma' => [FILTER_V_EQUAL, 1, false] // match any / all filter 'ma' => [FILTER_V_EQUAL, 1, false] // match any / all filter
); );

View File

@@ -90,7 +90,7 @@ class GuildListFilter extends Filter
// fieldId => [checkType, checkValue[, fieldIsArray]] // fieldId => [checkType, checkValue[, fieldIsArray]]
protected $inputFields = array( protected $inputFields = array(
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name - only printable chars, no delimiter 'na' => [FILTER_V_REGEX, '/[\p{C};%\\\\]/ui', false], // name - only printable chars, no delimiter
'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter 'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter
'ex' => [FILTER_V_EQUAL, 'on', false], // only match exact 'ex' => [FILTER_V_EQUAL, 'on', false], // only match exact
'si' => [FILTER_V_LIST, [1, 2], false], // side 'si' => [FILTER_V_LIST, [1, 2], false], // side

View File

@@ -135,7 +135,7 @@ class IconListFilter extends Filter
'cr' => [FILTER_V_LIST, [1, 2, 3, 6, 9, 11, 13], true ], // criteria ids 'cr' => [FILTER_V_LIST, [1, 2, 3, 6, 9, 11, 13], true ], // criteria ids
'crs' => [FILTER_V_RANGE, [1, 6], true ], // criteria operators 'crs' => [FILTER_V_RANGE, [1, 6], true ], // criteria operators
'crv' => [FILTER_V_RANGE, [0, 99999], true ], // criteria values - all criteria are numeric here 'crv' => [FILTER_V_RANGE, [0, 99999], true ], // criteria values - all criteria are numeric here
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name - only printable chars, no delimiter 'na' => [FILTER_V_REGEX, '/[\p{C};%\\\\]/ui', false], // name - only printable chars, no delimiter
'ma' => [FILTER_V_EQUAL, 1, false] // match any / all filter 'ma' => [FILTER_V_EQUAL, 1, false] // match any / all filter
); );

View File

@@ -1948,10 +1948,10 @@ class ItemListFilter extends Filter
'gm' => [FILTER_V_LIST, [2, 3, 4], false], // gem rarity for weight calculation 'gm' => [FILTER_V_LIST, [2, 3, 4], false], // gem rarity for weight calculation
'cr' => [FILTER_V_RANGE, [1, 177], true ], // criteria ids 'cr' => [FILTER_V_RANGE, [1, 177], true ], // criteria ids
'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 99999]], true ], // criteria operators 'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 99999]], true ], // criteria operators
'crv' => [FILTER_V_REGEX, '/[\p{C};:]/ui', true ], // criteria values - only printable chars, no delimiters 'crv' => [FILTER_V_REGEX, '/[\p{C};:%\\\\]/ui', true ], // criteria values - only printable chars, no delimiters
'upg' => [FILTER_V_RANGE, [1, 999999], true ], // upgrade item ids 'upg' => [FILTER_V_RANGE, [1, 999999], true ], // upgrade item ids
'gb' => [FILTER_V_LIST, [0, 1, 2, 3], false], // search result grouping 'gb' => [FILTER_V_LIST, [0, 1, 2, 3], false], // search result grouping
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name - only printable chars, no delimiter 'na' => [FILTER_V_REGEX, '/[\p{C};%\\\\]/ui', false], // name - only printable chars, no delimiter
'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter 'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter
'ub' => [FILTER_V_LIST, [[1, 9], 11], false], // usable by classId 'ub' => [FILTER_V_LIST, [[1, 9], 11], false], // usable by classId
'qu' => [FILTER_V_RANGE, [0, 7], true ], // quality ids 'qu' => [FILTER_V_RANGE, [0, 7], true ], // quality ids

View File

@@ -186,8 +186,8 @@ class ItemsetListFilter extends Filter
protected $inputFields = array( protected $inputFields = array(
'cr' => [FILTER_V_RANGE, [2, 12], true ], // criteria ids 'cr' => [FILTER_V_RANGE, [2, 12], true ], // criteria ids
'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 424]], true ], // criteria operators 'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 424]], true ], // criteria operators
'crv' => [FILTER_V_REGEX, '/[\p{C};:]/ui', true ], // criteria values - only printable chars, no delimiters 'crv' => [FILTER_V_REGEX, '/[\p{C};:%\\\\]/ui', true ], // criteria values - only printable chars, no delimiters
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name / description - only printable chars, no delimiter 'na' => [FILTER_V_REGEX, '/[\p{C};%\\\\]/ui', false], // name / description - only printable chars, no delimiter
'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter 'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter
'qu' => [FILTER_V_RANGE, [0, 7], true ], // quality 'qu' => [FILTER_V_RANGE, [0, 7], true ], // quality
'ty' => [FILTER_V_RANGE, [1, 12], true ], // set type 'ty' => [FILTER_V_RANGE, [1, 12], true ], // set type

View File

@@ -287,8 +287,8 @@ class ProfileListFilter extends Filter
protected $inputFields = array( protected $inputFields = array(
'cr' => [FILTER_V_RANGE, [1, 36], true ], // criteria ids 'cr' => [FILTER_V_RANGE, [1, 36], true ], // criteria ids
'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 5000]], true ], // criteria operators 'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 5000]], true ], // criteria operators
'crv' => [FILTER_V_REGEX, '/[\p{C};]/ui', true ], // criteria values 'crv' => [FILTER_V_REGEX, '/[\p{C}:;%\\\\]/ui', true ], // criteria values
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name - only printable chars, no delimiter 'na' => [FILTER_V_REGEX, '/[\p{C};%\\\\]/ui', false], // name - only printable chars, no delimiter
'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter 'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter
'ex' => [FILTER_V_EQUAL, 'on', false], // only match exact 'ex' => [FILTER_V_EQUAL, 'on', false], // only match exact
'si' => [FILTER_V_LIST, [1, 2], false], // side 'si' => [FILTER_V_LIST, [1, 2], false], // side

View File

@@ -469,7 +469,7 @@ class QuestListFilter extends Filter
'cr' => [FILTER_V_RANGE, [1, 45], true ], // criteria ids 'cr' => [FILTER_V_RANGE, [1, 45], true ], // criteria ids
'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 99999]], true ], // criteria operators 'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 99999]], true ], // criteria operators
'crv' => [FILTER_V_REGEX, '/\D/', true ], // criteria values - only numerals 'crv' => [FILTER_V_REGEX, '/\D/', true ], // criteria values - only numerals
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name / text - only printable chars, no delimiter 'na' => [FILTER_V_REGEX, '/[\p{C};%\\\\]/ui', false], // name / text - only printable chars, no delimiter
'ex' => [FILTER_V_EQUAL, 'on', false], // also match subname 'ex' => [FILTER_V_EQUAL, 'on', false], // also match subname
'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter 'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter
'minle' => [FILTER_V_RANGE, [1, 99], false], // min quest level 'minle' => [FILTER_V_RANGE, [1, 99], false], // min quest level

View File

@@ -105,7 +105,7 @@ class SoundListFilter extends Filter
{ {
// fieldId => [checkType, checkValue[, fieldIsArray]] // fieldId => [checkType, checkValue[, fieldIsArray]]
protected $inputFields = array( protected $inputFields = array(
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name - only printable chars, no delimiter 'na' => [FILTER_V_REGEX, '/[\p{C};%\\\\]/ui', false], // name - only printable chars, no delimiter
'ty' => [FILTER_V_LIST, [[1, 4], 6, 9, 10, 12, 13, 14, 16, 17, [19, 23], [25, 31], 50, 52, 53], true ] // type 'ty' => [FILTER_V_LIST, [[1, 4], 6, 9, 10, 12, 13, 14, 16, 17, [19, 23], [25, 31], 50, 52, 53], true ] // type
); );

View File

@@ -2504,8 +2504,8 @@ class SpellListFilter extends Filter
protected $inputFields = array( protected $inputFields = array(
'cr' => [FILTER_V_RANGE, [1, 116], true ], // criteria ids 'cr' => [FILTER_V_RANGE, [1, 116], true ], // criteria ids
'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 99999]], true ], // criteria operators 'crs' => [FILTER_V_LIST, [FILTER_ENUM_NONE, FILTER_ENUM_ANY, [0, 99999]], true ], // criteria operators
'crv' => [FILTER_V_REGEX, '/[\p{C};:]/ui', true ], // criteria values - only printable chars, no delimiters 'crv' => [FILTER_V_REGEX, '/[\p{C};:%\\\\]/ui', true ], // criteria values - only printable chars, no delimiters
'na' => [FILTER_V_REGEX, '/[\p{C};]/ui', false], // name / text - only printable chars, no delimiter 'na' => [FILTER_V_REGEX, '/[\p{C};%\\\\]/ui', false], // name / text - only printable chars, no delimiter
'ex' => [FILTER_V_EQUAL, 'on', false], // extended name search 'ex' => [FILTER_V_EQUAL, 'on', false], // extended name search
'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter 'ma' => [FILTER_V_EQUAL, 1, false], // match any / all filter
'minle' => [FILTER_V_RANGE, [1, 99], false], // spell level min 'minle' => [FILTER_V_RANGE, [1, 99], false], // spell level min

View File

@@ -53,8 +53,8 @@ class SearchPage extends GenericPage
public function __construct($pageCall, $pageParam) public function __construct($pageCall, $pageParam)
{ {
$this->search = trim(urlDecode($pageParam)); $this->search =
$this->query = strtr($this->search, '?*', '_%'); $this->query = trim(urlDecode($pageParam));
// restricted access // restricted access
if ($this->reqUGroup && !User::isInGroup($this->reqUGroup)) if ($this->reqUGroup && !User::isInGroup($this->reqUGroup))
@@ -124,23 +124,25 @@ class SearchPage extends GenericPage
if (!$this->query) if (!$this->query)
return; return;
foreach (explode(' ', $this->query) as $p) foreach (explode(' ', $this->query) as $raw)
{ {
if (!$p) // multiple spaces $clean = str_replace(['\\', '%'], '', $raw);
if (!$clean) // multiple spaces
continue; continue;
else if ($p[0] == '-') else if ($clean[0] == '-')
{ {
if (mb_strlen($p) < 4) if (mb_strlen($clean) < 4)
$this->invalid[] = mb_substr($p, 1); $this->invalid[] = mb_substr($raw, 1);
else else
$this->excluded[] = mb_substr($p, 1); $this->excluded[] = mb_substr(str_replace('_', '\\_', $clean), 1);
} }
else if ($p !== '') else if ($clean !== '')
{ {
if (mb_strlen($p) < 3) if (mb_strlen($clean) < 3)
$this->invalid[] = $p; $this->invalid[] = $raw;
else else
$this->included[] = $p; $this->included[] = str_replace('_', '\\_', $clean);
} }
} }
} }

View File

@@ -2593,7 +2593,7 @@ var LANG = {
user: "Benutzer", user: "Benutzer",
views: "Ansichten", views: "Ansichten",
userpage: "Benutzerseite", userpage: "Benutzerseite",
wins: "Siegt", wins: "Siege",
when: "Wann", when: "Wann",
today: "heute", today: "heute",
yes: "Ja", yes: "Ja",