diff --git a/includes/components/filter.class.php b/includes/components/filter.class.php index 9f7db3c6..8ea36189 100644 --- a/includes/components/filter.class.php +++ b/includes/components/filter.class.php @@ -452,20 +452,18 @@ abstract class Filter if (!Util::checkNumeric($val, NUM_CAST_INT)) return false; - foreach ($valid as $k => $v) + if (in_array($val, $valid)) + return true; + + foreach ($valid as $v) { if (gettype($v) != 'array') continue; if ($this->checkInput(self::V_RANGE, $v, $val, true)) return true; - - unset($valid[$k]); } - if (in_array($val, $valid)) - return true; - break; case self::V_RANGE: if (Util::checkNumeric($val, NUM_CAST_INT) && $val >= $valid[0] && $val <= $valid[1]) @@ -486,7 +484,7 @@ abstract class Filter if (!$recursive) { - trigger_error('Filter::checkInput - check failed [type: '.$type.' valid: '.((string)$valid).' val: '.((string)$val).']', E_USER_NOTICE); + trigger_error('Filter::checkInput - check failed [type: '.$type.' valid: '.Util::toString($valid).' val: '.((string)$val).']', E_USER_NOTICE); $this->error = true; } diff --git a/includes/dbtypes/creature.class.php b/includes/dbtypes/creature.class.php index f06d4910..5eb4edd8 100644 --- a/includes/dbtypes/creature.class.php +++ b/includes/dbtypes/creature.class.php @@ -332,8 +332,8 @@ class CreatureListFilter extends Filter 'ex' => [parent::V_EQUAL, 'on', false], // also match subname 'ma' => [parent::V_EQUAL, 1, false], // match any / all filter 'fa' => [parent::V_CALLBACK, 'cbPetFamily', true ], // pet family [list] - cat[0] == 1 - 'minle' => [parent::V_RANGE, [1, 99], false], // min level [int] - 'maxle' => [parent::V_RANGE, [1, 99], false], // max level [int] + 'minle' => [parent::V_RANGE, [0, 99], false], // min level [int] + 'maxle' => [parent::V_RANGE, [0, 99], false], // max level [int] 'cl' => [parent::V_RANGE, [0, 4], true ], // classification [list] 'ra' => [parent::V_LIST, [-1, 0, 1], false], // react alliance [int] 'rh' => [parent::V_LIST, [-1, 0, 1], false] // react horde [int] diff --git a/includes/dbtypes/item.class.php b/includes/dbtypes/item.class.php index d8e11659..595c468a 100644 --- a/includes/dbtypes/item.class.php +++ b/includes/dbtypes/item.class.php @@ -2021,10 +2021,10 @@ class ItemListFilter extends Filter 'ty' => [parent::V_CALLBACK, 'cbTypeCheck', true ], // item type - dynamic by current group 'sl' => [parent::V_CALLBACK, 'cbSlotCheck', true ], // item slot - dynamic by current group 'si' => [parent::V_LIST, [-SIDE_HORDE, -SIDE_ALLIANCE, SIDE_ALLIANCE, SIDE_HORDE, SIDE_BOTH], false], // side - 'minle' => [parent::V_RANGE, [1, 999], false], // item level min - 'maxle' => [parent::V_RANGE, [1, 999], false], // item level max - 'minrl' => [parent::V_RANGE, [1, MAX_LEVEL], false], // required level min - 'maxrl' => [parent::V_RANGE, [1, MAX_LEVEL], false] // required level max + 'minle' => [parent::V_RANGE, [0, 999], false], // item level min + 'maxle' => [parent::V_RANGE, [0, 999], false], // item level max + 'minrl' => [parent::V_RANGE, [0, MAX_LEVEL], false], // required level min + 'maxrl' => [parent::V_RANGE, [0, MAX_LEVEL], false] // required level max ); public array $extraOpts = []; // score for statWeights diff --git a/includes/dbtypes/itemset.class.php b/includes/dbtypes/itemset.class.php index 58988b63..0dfcb07c 100644 --- a/includes/dbtypes/itemset.class.php +++ b/includes/dbtypes/itemset.class.php @@ -187,10 +187,10 @@ class ItemsetListFilter extends Filter 'ma' => [parent::V_EQUAL, 1, false], // match any / all filter 'qu' => [parent::V_RANGE, [0, 7], true ], // quality 'ty' => [parent::V_RANGE, [1, 12], true ], // set type - 'minle' => [parent::V_RANGE, [1, 999], false], // min item level - 'maxle' => [parent::V_RANGE, [1, 999], false], // max itemlevel - 'minrl' => [parent::V_RANGE, [1, MAX_LEVEL], false], // min required level - 'maxrl' => [parent::V_RANGE, [1, MAX_LEVEL], false], // max required level + 'minle' => [parent::V_RANGE, [0, 999], false], // min item level + 'maxle' => [parent::V_RANGE, [0, 999], false], // max itemlevel + 'minrl' => [parent::V_RANGE, [0, MAX_LEVEL], false], // min required level + 'maxrl' => [parent::V_RANGE, [0, MAX_LEVEL], false], // max required level 'cl' => [parent::V_LIST, [[1, 9], 11], false], // class 'ta' => [parent::V_RANGE, [1, 30], false] // tag / content group ); diff --git a/includes/dbtypes/quest.class.php b/includes/dbtypes/quest.class.php index 5cd13bb7..f7798935 100644 --- a/includes/dbtypes/quest.class.php +++ b/includes/dbtypes/quest.class.php @@ -478,10 +478,10 @@ class QuestListFilter extends Filter 'na' => [parent::V_REGEX, parent::PATTERN_NAME, false], // name / text - only printable chars, no delimiter 'ex' => [parent::V_EQUAL, 'on', false], // also match subname 'ma' => [parent::V_EQUAL, 1, false], // match any / all filter - 'minle' => [parent::V_RANGE, [1, 99], false], // min quest level - 'maxle' => [parent::V_RANGE, [1, 99], false], // max quest level - 'minrl' => [parent::V_RANGE, [1, 99], false], // min required level - 'maxrl' => [parent::V_RANGE, [1, 99], false], // max required level + 'minle' => [parent::V_RANGE, [0, 99], false], // min quest level + 'maxle' => [parent::V_RANGE, [0, 99], false], // max quest level + 'minrl' => [parent::V_RANGE, [0, 99], false], // min required level + 'maxrl' => [parent::V_RANGE, [0, 99], false], // max required level 'si' => [parent::V_LIST, [-SIDE_HORDE, -SIDE_ALLIANCE, SIDE_ALLIANCE, SIDE_HORDE, SIDE_BOTH], false], // side 'ty' => [parent::V_LIST, [0, 1, 21, 41, 62, [81, 85], 88, 89], true ] // type ); diff --git a/includes/dbtypes/spell.class.php b/includes/dbtypes/spell.class.php index f41e8161..935f6fd4 100644 --- a/includes/dbtypes/spell.class.php +++ b/includes/dbtypes/spell.class.php @@ -2527,10 +2527,10 @@ class SpellListFilter extends Filter 'na' => [parent::V_REGEX, parent::PATTERN_NAME, false], // name / text - only printable chars, no delimiter 'ex' => [parent::V_EQUAL, 'on', false], // extended name search 'ma' => [parent::V_EQUAL, 1, false], // match any / all filter - 'minle' => [parent::V_RANGE, [1, 99], false], // spell level min - 'maxle' => [parent::V_RANGE, [1, 99], false], // spell level max - 'minrs' => [parent::V_RANGE, [1, 999], false], // required skill level min - 'maxrs' => [parent::V_RANGE, [1, 999], false], // required skill level max + 'minle' => [parent::V_RANGE, [0, 99], false], // spell level min + 'maxle' => [parent::V_RANGE, [0, 99], false], // spell level max + 'minrs' => [parent::V_RANGE, [0, 999], false], // required skill level min + 'maxrs' => [parent::V_RANGE, [0, 999], false], // required skill level max 'ra' => [parent::V_LIST, [[1, 8], 10, 11], false], // races 'cl' => [parent::V_CALLBACK, 'cbClasses', true ], // classes 'gl' => [parent::V_CALLBACK, 'cbGlyphs', true ], // glyph type diff --git a/includes/utilities.php b/includes/utilities.php index 61084146..2f3db816 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -1142,6 +1142,27 @@ abstract class Util return $bits; } + public static function toString(mixed $var) : string + { + if (is_array($var)) + return '[' . implode(', ', array_map(self::toString(...), $var)) . ']'; + + if (is_object($var)) + { + // hm, respect object stringability? + // if ($var instanceof Stringable) + // return (string)$var; + + $buff = []; + foreach ($var as $k => $v) + $buff[] = $k.':'.self::toString($v); + + return '{' . implode(', ', $buff) . '}'; + } + + return (string)$var; + } + public static function buildPosFixMenu(int $mapId, float $posX, float $posY, int $type, int $guid, int $parentArea = 0, int $parentFloor = 0) : array { $points = WorldPosition::toZonePos($mapId, $posX, $posY);