diff --git a/functions.php b/functions.php index cc79a920..3fa706d7 100644 --- a/functions.php +++ b/functions.php @@ -2233,25 +2233,25 @@ function validateSAIDNumber($idNumber) { } // Optional: Validate checksum (Luhn algorithm) - $sum = 0; - for ($i = 0; $i < 13; $i++) { - $digit = (int)$idNumber[$i]; + // $sum = 0; + // for ($i = 0; $i < 13; $i++) { + // $digit = (int)$idNumber[$i]; - // Double every even-positioned digit (0-indexed) - if ($i % 2 == 0) { - $digit *= 2; - if ($digit > 9) { - $digit -= 9; - } - } + // // Double every even-positioned digit (0-indexed) + // if ($i % 2 == 0) { + // $digit *= 2; + // if ($digit > 9) { + // $digit -= 9; + // } + // } - $sum += $digit; - } + // $sum += $digit; + // } - // Last digit should make sum divisible by 10 - if ($sum % 10 != 0) { - return false; - } + // // Last digit should make sum divisible by 10 + // if ($sum % 10 != 0) { + // return false; + // } return $idNumber; } @@ -2534,18 +2534,18 @@ function countRecentFailedAttempts($email, $minutesBack = 15) { } $email = strtolower(trim($email)); - $ip = getClientIPAddress(); $cutoffTime = date('Y-m-d H:i:s', time() - ($minutesBack * 60)); + // Count failed attempts by email only (IP may vary due to proxies, mobile networks, etc) $sql = "SELECT COUNT(*) as count FROM login_attempts - WHERE email = ? AND ip_address = ? AND success = 0 + WHERE email = ? AND success = 0 AND attempted_at > ?"; $stmt = $conn->prepare($sql); if (!$stmt) { return 0; } - $stmt->bind_param('sss', $email, $ip, $cutoffTime); + $stmt->bind_param('ss', $email, $cutoffTime); $stmt->execute(); $stmt->bind_result($count); $stmt->fetch();