Enhances add to whitelist
parent
8d0518c7ff
commit
9b8f92f2eb
|
@ -89,7 +89,8 @@ class RateLimiter {
|
|||
}
|
||||
|
||||
// Add to whitelist
|
||||
public function addToWhitelist($ip, $isNetwork = false, $description = '', $createdBy = 'system') {
|
||||
public function addToWhitelist($ip, $isNetwork = false, $description = '', $createdBy = 'system', $userId = null) {
|
||||
try {
|
||||
$stmt = $this->db->prepare("INSERT INTO {$this->whitelistTable}
|
||||
(ip_address, is_network, description, created_by)
|
||||
VALUES (?, ?, ?, ?)
|
||||
|
@ -98,7 +99,27 @@ class RateLimiter {
|
|||
description = VALUES(description),
|
||||
created_by = VALUES(created_by)");
|
||||
|
||||
return $stmt->execute([$ip, $isNetwork, $description, $createdBy]);
|
||||
$result = $stmt->execute([$ip, $isNetwork, $description, $createdBy]);
|
||||
|
||||
if ($result) {
|
||||
$logMessage = sprintf(
|
||||
'IP Whitelist: Added %s "%s" by %s. Description: %s',
|
||||
$isNetwork ? 'network' : 'IP',
|
||||
$ip,
|
||||
$createdBy,
|
||||
$description
|
||||
);
|
||||
$this->log->insertLog($userId ?? 0, $logMessage, 'system');
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
} catch (Exception $e) {
|
||||
if ($userId) {
|
||||
$this->log->insertLog($userId, "IP Whitelist: Failed to add {$ip}: " . $e->getMessage(), 'system');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove from whitelist
|
||||
|
|
Loading…
Reference in New Issue