]> jfr.im git - uguu.git/commitdiff
add whitelist mode and fix clipboard glyph v1.2.0
authornokonoko <redacted>
Sat, 3 Jul 2021 15:23:16 +0000 (17:23 +0200)
committernokonoko <redacted>
Sat, 3 Jul 2021 15:23:16 +0000 (17:23 +0200)
dist.json
package.json
static/css/uguu.css
static/php/includes/settings.inc.php
static/php/upload.php

index 92e510f690eee1a65c31606b1a73d4c62dd11c0b..d6e30dbee7854318358bbe0072c04c59d5e85545 100644 (file)
--- a/dist.json
+++ b/dist.json
@@ -3,7 +3,7 @@
           "allowErrors": false
         },
         "dest": "dist",
-        "pkgVersion": "1.1.2",
+        "pkgVersion": "1.2.0",
        "banners": [
                "banners/malware_scans.swig",
                "banners/donations.swig"
index d9f06eabdfbc3cd24724aba26b873a3935b9b922..48c287186abd7a240122dbc6eb6be6608d69cad7 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "uguu",
-  "version": "1.1.2",
+  "version": "1.2.0",
   "description": "Kawaii file host",
   "homepage": "https://uguu.se/",
   "repository": {
index 8faa7886005e0c180bd93d8e6f7c86c3f004a165..93c7fd32faeb3f2b4f66d1e9139f48b416776490 100644 (file)
@@ -232,7 +232,7 @@ nav > ul > li:last-child:after {
   color: #891A18;
 }
 button.upload-clipboard-btn {
-  height: 16px;
+  height: 32px;
 }
 .error#upload-filelist .progress-percent {
   color: #B94A48;
index e94f49bd4c0f9e65664416dffaa05e5b5987c68f..58e9738cbcba2e92be1d25c582b7e5794433c908 100644 (file)
@@ -25,10 +25,14 @@ define('UGUU_DB_USER', 'NULL');
 /* @param string UGUU_DB_PASS Database password */
 define('UGUU_DB_PASS', 'NULL');
 
-/** Log IP of uploads */
+/** 
+ * @param boolean Log IP of uploads 
+ */
 define('LOG_IP', false);
 
-/** Dont upload a file already in the DB */
+/** 
+ * @param boolean anti-dupe
+ */
 define('ANTI_DUPE', false);
 
 /*
@@ -78,11 +82,11 @@ define('CONFIG_BLOCKED_EXTENSIONS', serialize(['exe', 'scr', 'com', 'vbs', 'bat'
 define('CONFIG_BLOCKED_MIME', serialize(['application/msword', 'text/html', 'application/x-dosexec', 'application/java', 'application/java-archive', 'application/x-executable', 'application/x-mach-binary', 'image/svg+xml']));
 
 /**
- * Filter mode: whitelist (true) or blacklist (false).
- *
- * @param bool $FILTER_MODE mime type filter mode
+ * Whitelist or blacklist mode
+ * @param boolean blacklist (false) | whitelist (true)
  */
-$FILTER_MODE = false;
+define('CONFIG_FILTER_MODE', false);
+
 /**
  * Double dot file extensions.
  *
index acc4e82585d0e80f2186d85071ab6bebc12e341a..944815125190dd595802f3889e488856033e7016 100644 (file)
@@ -61,15 +61,34 @@ function generateName($file)
             $name .= '.'.$ext;
         }
 
-        //Check if MIME is blacklisted
-        if (in_array($type_mime, unserialize(CONFIG_BLOCKED_MIME))) {
-            http_response_code(415);
-            exit(0);
-        }
-        //Check if EXT is blacklisted
-        if (in_array($ext, unserialize(CONFIG_BLOCKED_EXTENSIONS))) {
-            http_response_code(415);
-            exit(0);
+        // Check if file is whitelisted or blacklisted
+        switch (CONFIG_FILTER_MODE) {
+
+            case false:
+                //check if MIME is blacklisted
+                if (in_array($type_mime, unserialize(CONFIG_BLOCKED_MIME))) {
+                    http_response_code(415);
+                    exit(0);
+                }
+                //Check if EXT is blacklisted
+                if (in_array($ext, unserialize(CONFIG_BLOCKED_EXTENSIONS))) {
+                    http_response_code(415);
+                    exit(0);
+                }
+            break;
+
+            case true:
+                //Check if MIME is whitelisted
+                if (!in_array($type_mime, unserialize(CONFIG_BLOCKED_MIME))) {
+                    http_response_code(415);
+                    exit(0);
+                }
+                //Check if EXT is whitelisted
+                if (!in_array($ext, unserialize(CONFIG_BLOCKED_EXTENSIONS))) {
+                    http_response_code(415);
+                    exit(0);
+                }
+            break;
         }
 
         // Check if a file with the same name does already exist in the database
@@ -93,8 +112,6 @@ function generateName($file)
 function uploadFile($file)
 {
     global $db;
-    global $FILTER_MODE;
-    global $FILTER_MIME;
 
     // Handle file errors
     if ($file->error) {