]> jfr.im git - uguu.git/commitdiff
Changed hash from SHA1 to xxh3
authorJacob439 <redacted>
Mon, 31 Jul 2023 22:02:14 +0000 (18:02 -0400)
committerJacob <redacted>
Tue, 1 Aug 2023 16:31:27 +0000 (12:31 -0400)
src/Classes/Database.php
src/Classes/Upload.php

index da295ded4146216f987654253354e52fc3537735..fdf9dbabc779f98c1881427d7a33e1708cc89dea 100644 (file)
@@ -90,7 +90,7 @@
                'INSERT INTO files (hash, originalname, filename, size, date, ip)' .
                'VALUES (:hash, :orig, :name, :size, :date, :ip)',
             );
-            $q->bindValue(':hash', $FILE_INFO['SHA1']);
+            $q->bindValue(':hash', $FILE_INFO['XXH']);
             $q->bindValue(':orig', $FILE_INFO['NAME']);
             $q->bindValue(':name', $FILE_INFO['FILENAME']);
             $q->bindValue(':size', $FILE_INFO['SIZE'], PDO::PARAM_INT);
index ac4943c8fb9d3b88cd7837df8496bc6398ec922d..e59e902b17432924062d339eab53686bc3b81daf 100644 (file)
@@ -44,7 +44,7 @@
                    'TEMP_NAME' => $file['tmp_name'],
                    'NAME'      => strip_tags($this->checkNameLength($file['name'])),
                    'SIZE'      => $file['size'],
-                   'SHA1'      => sha1_file($file['tmp_name']),
+                   'XXH'      => hash('xxh3', $file['tmp_name']),
                    'EXTENSION' => $this->fileExtension($file),
                    'MIME'      => $this->fileMIME($file),
                    'DUPE'      => false,
@@ -53,7 +53,7 @@
                 // Check if anti dupe is enabled
                 if ($this->Connector->CONFIG['ANTI_DUPE']) {
                     // Check if hash exists in DB, if it does return the name of the file
-                    $dupeResult = $this->Connector->antiDupe($this->FILE_INFO['SHA1']);
+                    $dupeResult = $this->Connector->antiDupe($this->FILE_INFO['XXH']);
                     if ($dupeResult['result']) {
                         $this->FILE_INFO['FILENAME'] = $dupeResult['name'];
                         $this->FILE_INFO['DUPE'] = true;
@@ -67,7 +67,7 @@
                    $this->FILE_INFO['TEMP_NAME'],
                    $this->FILE_INFO['NAME'],
                    $this->FILE_INFO['SIZE'],
-                   $this->FILE_INFO['SHA1'],
+                   $this->FILE_INFO['XXH'],
                    $this->FILE_INFO['EXTENSION'],
                    $this->FILE_INFO['MIME'],
                    $this->FILE_INFO['DUPE'],
@@ -88,7 +88,7 @@
          *     'TEMP_NAME' => 'example'
          *     'NAME' => 'example'
          *     'SIZE' => 'example'
-         *     'SHA1' => 'example'
+         *     'XXH' => 'example'
          *     'EXTENSION' => 'example'
          *     'MIME' => 'example'
          *
@@ -97,7 +97,7 @@
          *     'TEMP_NAME' => 'example'
          *     'NAME' => 'example'
          *     'SIZE' => 'example'
-         *     'SHA1' => 'example'
+         *     'XXH' => 'example'
          *     'EXTENSION' => 'example'
          *     'MIME' => 'example'
          *   ]
                     }
                 // Continue
                 case $this->Connector->CONFIG['BLACKLIST_DB']:
-                    $this->Connector->checkFileBlacklist($this->FILE_INFO['SHA1']);
+                    $this->Connector->checkFileBlacklist($this->FILE_INFO['XXH']);
                 // Continue
                 case $this->Connector->CONFIG['FILTER_MODE'] && empty($this->FILE_INFO['EXTENSION']):
                     $this->checkMimeBlacklist();
                 $this->Connector->newIntoDB($this->FILE_INFO, $this->fingerPrintInfo);
             }
             return [
-               'hash'     => $this->FILE_INFO['SHA1'],
+               'hash'     => $this->FILE_INFO['XXH'],
                'name'     => $this->FILE_INFO['NAME'],
                'filename' => $this->FILE_INFO['FILENAME'],
                'url'      => 'https://' . $this->Connector->CONFIG['FILE_DOMAIN'] . '/' . $this->FILE_INFO['FILENAME'],