]> jfr.im git - uguu.git/commitdiff
1.5.0 changes v1.5.0
authorGo Johansson <redacted>
Sun, 23 Jan 2022 11:33:37 +0000 (12:33 +0100)
committerGo Johansson <redacted>
Sun, 23 Jan 2022 11:33:37 +0000 (12:33 +0100)
dist.json
package.json
static/php/includes/Core.namespace.php
static/php/includes/Upload.class.php
static/php/upload.php

index 3b44d093483fc4dc0df07ef6389e40e380c05420..c9f1e8a6fe5f8adbc82e178207b297d5399241b0 100644 (file)
--- a/dist.json
+++ b/dist.json
@@ -3,7 +3,7 @@
     "allowErrors": false
   },
   "dest": "dist",
-  "pkgVersion": "1.4.0",
+  "pkgVersion": "1.5.0",
   "banners": [
     "banners/malware_scans.swig",
     "banners/donations.swig"
index e4a57d5f202029f818a1c00264f670a1f5186423..6aa703bbf0553af6b64acfc6e9fd17e34051e54a 100644 (file)
@@ -1,13 +1,13 @@
 {
   "name": "uguu",
-  "version": "1.4.0",
+  "version": "1.5.0",
   "description": "Kawaii file host",
   "homepage": "https://uguu.se/",
   "repository": {
     "type": "git",
-    "url": "https://github.com/nokonoko/pomf"
+    "url": "https://github.com/nokonoko/uguu"
   },
-  "author": "Eric Johansson <neku@pomf.se>",
+  "author": "Go Johansson <neku@pomf.se>",
   "contributors": [
     "Pomf Community <github.com/pomf/pomf>",
     "Uguu Community <github.com/nokonoko/uguu>"
index bbb216b3c8101ec46b914b9529dc0e0c62c38c49..b5665332402832dfa7b7b822dc35c23ac1b2cc78 100644 (file)
@@ -87,7 +87,7 @@ namespace Core {
             } catch (Exception) {
                 throw new Exception('Cant populate settings.', 500);
             }
-            (new Database())->assemblePDO();
+            Database::assemblePDO();
         }
     }
 
@@ -283,7 +283,7 @@ namespace Core {
         /**
          * @throws Exception
          */
-        public function dbCheckNameExists()
+        public static function dbCheckNameExists()
         {
             try {
                 $q = Settings::$DB->prepare('SELECT COUNT(filename) FROM files WHERE filename = (:name)');
@@ -298,7 +298,7 @@ namespace Core {
         /**
          * @throws Exception
          */
-        public function checkFileBlacklist()
+        public static function checkFileBlacklist()
         {
             try {
                 $q = Settings::$DB->prepare('SELECT hash, COUNT(*) AS count FROM blacklist WHERE hash = (:hash)');
@@ -316,7 +316,7 @@ namespace Core {
         /**
          * @throws Exception
          */
-        public function antiDupe()
+        public static function antiDupe()
         {
             try {
                 $q = Settings::$DB->prepare(
@@ -327,7 +327,9 @@ namespace Core {
                 $q->execute();
                 $result = $q->fetch();
                 if ($result['count'] > 0) {
-                    return $result['filename'];
+                    Upload::$NEW_NAME_FULL = $result['filename'];
+                } else {
+                    Upload::generateName();
                 }
             } catch (Exception) {
                 throw new Exception('Cant check for dupes in DB.', 500);
@@ -337,7 +339,7 @@ namespace Core {
         /**
          * @throws Exception
          */
-        public function newIntoDB()
+        public static function newIntoDB()
         {
             try {
                 $q = Settings::$DB->prepare(
index edf9b7cc798cbffb933b07c2a2b01de8112c678f..31bb2d1ab628f581900006111735d6cdb990d6a5 100644 (file)
@@ -39,7 +39,7 @@ class Upload
     public static string $TEMP_FILE;
 
 
-    public function reFiles($files): array
+    public static function reFiles($files): array
     {
         $result = [];
         $files = self::diverseArray($files);
@@ -54,7 +54,7 @@ class Upload
         return $result;
     }
 
-    public function diverseArray($files): array
+    public static function diverseArray($files): array
     {
         $result = [];
 
@@ -69,13 +69,13 @@ class Upload
     /**
      * @throws Exception
      */
-    public function uploadFile(): array
+    public static function uploadFile(): array
     {
-        (new Settings())->loadConfig();
-        (new Upload())->fileInfo();
+        Settings::loadConfig();
+        self::fileInfo();
 
         if (Settings::$BLACKLIST_DB) {
-            (new Database())->checkFileBlacklist();
+            Database::checkFileBlacklist();
         }
 
         if (Settings::$FILTER_MODE) {
@@ -84,16 +84,11 @@ class Upload
         }
 
         if (Settings::$ANTI_DUPE) {
-            $result = (new Database())->antiDupe();
-            if (isset($result)) {
-                self::$NEW_NAME_FULL = $result;
-            } else {
-                (new Upload())->generateName();
-            }
+            Database::antiDupe();
         }
 
         if (!Settings::$ANTI_DUPE) {
-            (new Upload())->generateName();
+            self::generateName();
         }
 
         if (!is_dir(Settings::$FILES_ROOT)) {
@@ -108,7 +103,7 @@ class Upload
             throw new Exception('Failed to change file permissions', 500);
         }
 
-        (new Database())->newIntoDB();
+        Database::newIntoDB();
 
         if (Settings::$SSL) {
             $preURL = 'https://';
@@ -124,7 +119,7 @@ class Upload
         ];
     }
 
-    public function fileInfo()
+    public static function fileInfo()
     {
         if (isset($_FILES['files'])) {
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
@@ -144,7 +139,7 @@ class Upload
     /**
      * @throws Exception
      */
-    public function checkMimeBlacklist()
+    public static function checkMimeBlacklist()
     {
         if (in_array(self::$FILE_MIME, Settings::$BLOCKED_MIME)) {
             throw new Exception('Filetype not allowed.', 415);
@@ -157,7 +152,7 @@ class Upload
      *
      * @throws Exception
      */
-    public function checkExtensionBlacklist()
+    public static function checkExtensionBlacklist()
     {
         if (in_array(self::$FILE_EXTENSION, Settings::$BLOCKED_EXTENSIONS)) {
             throw new Exception('Filetype not allowed.', 415);
@@ -167,7 +162,7 @@ class Upload
     /**
      * @throws Exception
      */
-    public function generateName(): string
+    public static function generateName()
     {
         do {
             if (Settings::$FILES_RETRIES === 0) {
@@ -183,7 +178,6 @@ class Upload
                 self::$NEW_NAME_FULL = self::$NEW_NAME;
                 self::$NEW_NAME_FULL .= '.' . self::$FILE_EXTENSION;
             }
-        } while ((new Database())->dbCheckNameExists() > 0);
-        return self::$NEW_NAME_FULL;
+        } while (Database::dbCheckNameExists() > 0);
     }
 }
\ No newline at end of file
index 27ff3e37f2c39e956959c6b3739d55e6dec13273..37458a98e85477b862a409b2f4a6c41d6f54cf0a 100644 (file)
@@ -24,11 +24,11 @@ $type = $_GET['output'] ?? 'json';
 $response = (new Core\Response($type));
 
 if (isset($_FILES['files'])) {
-    $uploads = (new Upload())->reFiles($_FILES['files']);
+    $uploads = Upload::reFiles($_FILES['files']);
 
     try {
         foreach ($uploads as $upload) {
-            $res[] = (new Upload())->uploadFile();
+            $res[] = Upload::uploadFile();
         }
         if (isset($res)) {
             $response->send($res);