From fa198e207f44c56a9ae48bbc432ea2303dd0deee Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 8 Aug 2014 21:35:00 +0200 Subject: [PATCH] enhance filters; make them work on multiimage --- inc/filters.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/inc/filters.php b/inc/filters.php index 5071353a..22843f10 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -97,19 +97,35 @@ class Filter { case 'filehash': return $match === $post['filehash']; case 'filename': - if (!$post['has_file']) + if (!$post['files']) return false; - return preg_match($match, $post['filename']); + + foreach ($post['files'] as $file) { + if (preg_match($match, $file['filename'])) { + return true; + } + } + return false; case 'extension': - if (!$post['has_file']) + if (!$post['files']) return false; - return preg_match($match, $post['body']); + + foreach ($post['files'] as $file) { + if (preg_match($match, $file['extension'])) { + return true; + } + } + return false; case 'ip': return preg_match($match, $_SERVER['REMOTE_ADDR']); case 'op': return $post['op'] == $match; case 'has_file': return $post['has_file'] == $match; + case 'board': + return $post['board'] == $match; + case 'password': + return $post['password'] == $match; default: error('Unknown filter condition: ' . $condition); }