diff options
| author | akpu1 <akpu1@inventati.org> | 2016-06-20 16:42:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-20 16:42:43 +0200 |
| commit | 7feb42edec849e7b70723e13292ac53674a8e453 (patch) | |
| tree | a656070dd8db923c50b7d8219b82ba26fa2efb29 | |
| parent | d289e42fa25eee1684d169788614a22a7e556d4b (diff) | |
Changed logic to use FILTER_MODE to determine whether whitelist/blacklist
| -rw-r--r-- | php/upload.php | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/php/upload.php b/php/upload.php index 9b58ba4..e82a7c4 100644 --- a/php/upload.php +++ b/php/upload.php @@ -74,7 +74,7 @@ function generateName($file) function uploadFile($file) { global $db; - global $WHITELIST_MIME; + global $FILTER_MODE; global $FILTER_MIME; // Handle file errors @@ -84,14 +84,15 @@ function uploadFile($file) // Check if mime type is blocked if (!empty($FILTER_MIME)) { - if (in_array($file->mime, $FILTER_MIME)) { - throw new UploadException(UPLOAD_ERR_EXTENSION); - } - } - if (!empty($WHITELIST_MIME)) { - if (!in_array($file->mime, $WHITELIST_MIME)) { - throw new UploadException(UPLOAD_ERR_EXTENSION); - } + if($FILTER_MODE == true) { //whitelist mode + if (!in_array($file->mime, $FILTER_MIME)) { + throw new UploadException(UPLOAD_ERR_EXTENSION); + } + else { //blacklist mode + if (in_array($file->mime, $FILTER_MIME)) { + throw new UploadException(UPLOAD_ERR_EXTENSION); + } + } } |
