diff --git a/php/Database.php b/php/Database.php index 2fb32e6..8039434 100644 --- a/php/Database.php +++ b/php/Database.php @@ -36,26 +36,16 @@ public static function getUserIpAddress() : string { public static function userSentToManyRequests(string $action) : bool{ $timer = 0; - switch($action){ - case 'createAccount': - $timer = Settings::$limiter_createAccount; - break; - case 'getPasswords': - $timer = Settings::$limiter_getPasswords; - break; - case 'savePassword': - $timer = Settings::$limiter_savePassword; - break; - case 'editPassword': - $timer = Settings::$limiter_editPassword; - break; - case 'deletePassword': - $timer = Settings::$limiter_deletePassword; - break; - case 'deleteAccount': - $timer = Settings::$limiter_deleteAccount; - break; - } + $timerOptions = [ + 'createAccount' => Settings::$limiter_createAccount, + 'getPasswords' => Settings::$limiter_getPasswords, + 'savePassword' => Settings::$limiter_savePassword, + 'editPassword' => Settings::$limiter_editPassword, + 'deletePassword' => Settings::$limiter_deletePassword, + 'deleteAccount' => Settings::$limiter_deleteAccount + ]; + + $timer = $timerOptions[$action]; $ips_array = json_decode(file_get_contents('ips.json'), true); diff --git a/php/index.php b/php/index.php index ab4100c..23231c0 100644 --- a/php/index.php +++ b/php/index.php @@ -1,4 +1,17 @@