GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — DataExplorer/Query/LabelFilter.php at 6.x-dev · openmost/DataExplorer Expand file tree/ Copy pathLabelFilter.phpMore file actions 54 lines (45 loc) · 1.59 KB / Copy pathLabelFilter.phpFile metadata and controls54 lines (45 loc) · 1.59 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 <?php /** * Matomo - free/libre analytics platform * * @link https://matomo.org * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ declare(strict_types=1); namespace Piwik\Plugins\DataExplorer\Query; use Piwik\Common; /** * The filter operators applied in PHP to the labels of a stored value and to the value itself, case insensitive * like the default collation of the log tables. */ final class LabelFilter { public static function matches(string $operator, string $value, string ...$candidates): bool { $value = Common::unsanitizeInputValue($value); foreach (array_unique($candidates) as $candidate) { if (self::matchesOne($operator, $value, $candidate)) { return true; } } return false; } private static function matchesOne(string $operator, string $value, string $candidate): bool { $needle = mb_strtolower($value); $haystack = mb_strtolower($candidate); switch ($operator) { case 'equals': return $haystack === $needle; case 'contains': return $needle === '' || mb_strpos($haystack, $needle) !== false; case 'starts_with': return $needle === '' || mb_strpos($haystack, $needle) === 0; case 'ends_with': return $needle === '' || mb_substr($haystack, -mb_strlen($needle)) === $needle; case 'regex': return @preg_match('/' . str_replace('/', '\/', $value) . '/iu', $candidate) === 1; } return false; } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |