User/Misc

* floating changes
 * codify user checks into functions
This commit is contained in:
Sarjuuk
2025-04-02 22:27:05 +02:00
parent 3078763ec3
commit 682b315e17
22 changed files with 78 additions and 71 deletions

View File

@@ -134,7 +134,7 @@ class Report
return;
}
if (!User::$id && !User::$ip)
if (!User::isLoggedIn() && !User::$ip)
{
trigger_error('Report - could not determine IP for anonymous user', E_USER_ERROR);
$this->errorCode = self::ERR_MISCELLANEOUS;
@@ -147,7 +147,7 @@ class Report
private function checkTargetContext() : int
{
// check already reported
$field = User::$id ? 'userId' : 'ip';
$field = User::isLoggedIn() ? 'userId' : 'ip';
if (DB::Aowow()->selectCell('SELECT 1 FROM ?_reports WHERE `mode` = ?d AND `reason`= ?d AND `subject` = ?d AND ?# = ?', $this->mode, $this->reason, $this->subject, $field, User::$id ?: User::$ip))
return self::ERR_ALREADY_REPORTED;