1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-09-24 03:28:22 +02:00

enhance filters; make them work on multiimage

This commit is contained in:
czaks 2014-08-08 21:35:00 +02:00
parent 57e80951d9
commit fa198e207f

View File

@ -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);
}