2
0
Fork 0
forked from flashii/eeprom

Fixed another duplicate hash issue.

This commit is contained in:
flash 2023-11-07 22:40:26 +00:00
parent d669221869
commit 2f47bef354
4 changed files with 13 additions and 7 deletions

View file

@ -194,7 +194,7 @@ if($isApiDomain) {
$hash = hash_file('sha256', $localFile); $hash = hash_file('sha256', $localFile);
// this is stupid: dmca status is stored as a file record rather than in a separate table requiring this hack ass garbage // this is stupid: dmca status is stored as a file record rather than in a separate table requiring this hack ass garbage
$uploadInfo = Upload::byUserHash($db, $userInfo, $hash) ?? Upload::byHash($db, $hash); $uploadInfo = Upload::byAppUserHash($db, $appInfo, $userInfo, $hash) ?? Upload::byHash($db, $hash);
if($uploadInfo !== null) { if($uploadInfo !== null) {
if($uploadInfo->isDMCA()) if($uploadInfo->isDMCA())

View file

@ -1,7 +1,7 @@
<?php <?php
namespace EEPROM\Auth; namespace EEPROM\Auth;
use EEPROM\Config; use RuntimeException;
use Index\Serialisation\Serialiser; use Index\Serialisation\Serialiser;
class MisuzuAuth implements IAuth { class MisuzuAuth implements IAuth {
@ -47,10 +47,11 @@ class MisuzuAuth implements IAuth {
'X-SharpChat-Signature: ' . $signature, 'X-SharpChat-Signature: ' . $signature,
], ],
]); ]);
$userInfo = json_decode(curl_exec($login)); $rawUserInfo = curl_exec($login);
$userInfo = json_decode($rawUserInfo);
curl_close($login); curl_close($login);
return $userInfo->user_id; return empty($userInfo->success) ? 0 : $userInfo->user_id;
} }
return 0; return 0;

View file

@ -1,7 +1,6 @@
<?php <?php
namespace EEPROM\Auth; namespace EEPROM\Auth;
use EEPROM\Config;
use Index\Serialisation\UriBase64; use Index\Serialisation\UriBase64;
class NabuccoAuth implements IAuth { class NabuccoAuth implements IAuth {

View file

@ -283,7 +283,12 @@ final class Upload {
return self::constructDb($result); return self::constructDb($result);
} }
public static function byUserHash(IDbConnection $conn, User|string $userInfo, string $hash): ?self { public static function byAppUserHash(
IDbConnection $conn,
Application|string $appInfo,
User|string $userInfo,
string $hash
): ?self {
$get = $conn->prepare( $get = $conn->prepare(
'SELECT `upload_id`, `app_id`, `user_id`, `upload_name`, `upload_type`, `upload_size`, `upload_bump`,' 'SELECT `upload_id`, `app_id`, `user_id`, `upload_name`, `upload_type`, `upload_size`, `upload_bump`,'
. ' UNIX_TIMESTAMP(`upload_created`) AS `upload_created`,' . ' UNIX_TIMESTAMP(`upload_created`) AS `upload_created`,'
@ -293,10 +298,11 @@ final class Upload {
. ' UNIX_TIMESTAMP(`upload_dmca`) AS `upload_dmca`,' . ' UNIX_TIMESTAMP(`upload_dmca`) AS `upload_dmca`,'
. ' INET6_NTOA(`upload_ip`) AS `upload_ip`,' . ' INET6_NTOA(`upload_ip`) AS `upload_ip`,'
. ' LOWER(HEX(`upload_hash`)) AS `upload_hash`' . ' LOWER(HEX(`upload_hash`)) AS `upload_hash`'
. ' FROM `prm_uploads` WHERE `upload_hash` = UNHEX(?) AND `user_id` = ?' . ' FROM `prm_uploads` WHERE `upload_hash` = UNHEX(?) AND `user_id` = ? AND `app_id` = ?'
); );
$get->addParameter(1, $hash); $get->addParameter(1, $hash);
$get->addParameter(2, $userInfo instanceof User ? $userInfo->getId() : $userInfo); $get->addParameter(2, $userInfo instanceof User ? $userInfo->getId() : $userInfo);
$get->addParameter(3, $appInfo instanceof Application ? $appInfo->getId() : $appInfo);
$get->execute(); $get->execute();
$result = $get->getResult(); $result = $get->getResult();