mirror of
https://github.com/nokonoko/Uguu.git
synced 2024-01-06 13:35:15 +00:00
Merge pull request #91 from Jacob439/update_hash_pr
Update hash algorithm from SHA1 to xxh3
This commit is contained in:
commit
9199822320
@ -90,7 +90,7 @@
|
|||||||
'INSERT INTO files (hash, originalname, filename, size, date, ip)' .
|
'INSERT INTO files (hash, originalname, filename, size, date, ip)' .
|
||||||
'VALUES (:hash, :orig, :name, :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(':orig', $FILE_INFO['NAME']);
|
||||||
$q->bindValue(':name', $FILE_INFO['FILENAME']);
|
$q->bindValue(':name', $FILE_INFO['FILENAME']);
|
||||||
$q->bindValue(':size', $FILE_INFO['SIZE'], PDO::PARAM_INT);
|
$q->bindValue(':size', $FILE_INFO['SIZE'], PDO::PARAM_INT);
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
'TEMP_NAME' => $file['tmp_name'],
|
'TEMP_NAME' => $file['tmp_name'],
|
||||||
'NAME' => strip_tags($this->checkNameLength($file['name'])),
|
'NAME' => strip_tags($this->checkNameLength($file['name'])),
|
||||||
'SIZE' => $file['size'],
|
'SIZE' => $file['size'],
|
||||||
'SHA1' => sha1_file($file['tmp_name']),
|
'XXH' => hash('xxh3', $file['tmp_name']),
|
||||||
'EXTENSION' => $this->fileExtension($file),
|
'EXTENSION' => $this->fileExtension($file),
|
||||||
'MIME' => $this->fileMIME($file),
|
'MIME' => $this->fileMIME($file),
|
||||||
'DUPE' => false,
|
'DUPE' => false,
|
||||||
@ -53,7 +53,7 @@
|
|||||||
// Check if anti dupe is enabled
|
// Check if anti dupe is enabled
|
||||||
if ($this->Connector->CONFIG['ANTI_DUPE']) {
|
if ($this->Connector->CONFIG['ANTI_DUPE']) {
|
||||||
// Check if hash exists in DB, if it does return the name of the file
|
// 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']) {
|
if ($dupeResult['result']) {
|
||||||
$this->FILE_INFO['FILENAME'] = $dupeResult['name'];
|
$this->FILE_INFO['FILENAME'] = $dupeResult['name'];
|
||||||
$this->FILE_INFO['DUPE'] = true;
|
$this->FILE_INFO['DUPE'] = true;
|
||||||
@ -67,7 +67,7 @@
|
|||||||
$this->FILE_INFO['TEMP_NAME'],
|
$this->FILE_INFO['TEMP_NAME'],
|
||||||
$this->FILE_INFO['NAME'],
|
$this->FILE_INFO['NAME'],
|
||||||
$this->FILE_INFO['SIZE'],
|
$this->FILE_INFO['SIZE'],
|
||||||
$this->FILE_INFO['SHA1'],
|
$this->FILE_INFO['XXH'],
|
||||||
$this->FILE_INFO['EXTENSION'],
|
$this->FILE_INFO['EXTENSION'],
|
||||||
$this->FILE_INFO['MIME'],
|
$this->FILE_INFO['MIME'],
|
||||||
$this->FILE_INFO['DUPE'],
|
$this->FILE_INFO['DUPE'],
|
||||||
@ -88,7 +88,7 @@
|
|||||||
* 'TEMP_NAME' => 'example'
|
* 'TEMP_NAME' => 'example'
|
||||||
* 'NAME' => 'example'
|
* 'NAME' => 'example'
|
||||||
* 'SIZE' => 'example'
|
* 'SIZE' => 'example'
|
||||||
* 'SHA1' => 'example'
|
* 'XXH' => 'example'
|
||||||
* 'EXTENSION' => 'example'
|
* 'EXTENSION' => 'example'
|
||||||
* 'MIME' => 'example'
|
* 'MIME' => 'example'
|
||||||
*
|
*
|
||||||
@ -97,7 +97,7 @@
|
|||||||
* 'TEMP_NAME' => 'example'
|
* 'TEMP_NAME' => 'example'
|
||||||
* 'NAME' => 'example'
|
* 'NAME' => 'example'
|
||||||
* 'SIZE' => 'example'
|
* 'SIZE' => 'example'
|
||||||
* 'SHA1' => 'example'
|
* 'XXH' => 'example'
|
||||||
* 'EXTENSION' => 'example'
|
* 'EXTENSION' => 'example'
|
||||||
* 'MIME' => 'example'
|
* 'MIME' => 'example'
|
||||||
* ]
|
* ]
|
||||||
@ -139,7 +139,7 @@
|
|||||||
}
|
}
|
||||||
// Continue
|
// Continue
|
||||||
case $this->Connector->CONFIG['BLACKLIST_DB']:
|
case $this->Connector->CONFIG['BLACKLIST_DB']:
|
||||||
$this->Connector->checkFileBlacklist($this->FILE_INFO['SHA1']);
|
$this->Connector->checkFileBlacklist($this->FILE_INFO['XXH']);
|
||||||
// Continue
|
// Continue
|
||||||
case $this->Connector->CONFIG['FILTER_MODE'] && empty($this->FILE_INFO['EXTENSION']):
|
case $this->Connector->CONFIG['FILTER_MODE'] && empty($this->FILE_INFO['EXTENSION']):
|
||||||
$this->checkMimeBlacklist();
|
$this->checkMimeBlacklist();
|
||||||
@ -170,7 +170,7 @@
|
|||||||
$this->Connector->newIntoDB($this->FILE_INFO, $this->fingerPrintInfo);
|
$this->Connector->newIntoDB($this->FILE_INFO, $this->fingerPrintInfo);
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
'hash' => $this->FILE_INFO['SHA1'],
|
'hash' => $this->FILE_INFO['XXH'],
|
||||||
'name' => $this->FILE_INFO['NAME'],
|
'name' => $this->FILE_INFO['NAME'],
|
||||||
'filename' => $this->FILE_INFO['FILENAME'],
|
'filename' => $this->FILE_INFO['FILENAME'],
|
||||||
'url' => 'https://' . $this->Connector->CONFIG['FILE_DOMAIN'] . '/' . $this->FILE_INFO['FILENAME'],
|
'url' => 'https://' . $this->Connector->CONFIG['FILE_DOMAIN'] . '/' . $this->FILE_INFO['FILENAME'],
|
||||||
|
Loading…
Reference in New Issue
Block a user