diff --git a/index.php b/index.php index 974fb0b..448b722 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,7 @@ 'Username ' . $username . ' already exists']); - exit(); - } if ($user['ip'] === $userIp) { - echo json_encode(['error' => 'IP address ' . $userIp . ' already exists']); - exit(); + $isDuplicateIp = true; + break; } } + if ($isDuplicateIp) { + continue; + } + // Ensure the IP range does not exceed the defined ranges if ($ipRangeFrom + $i > ip2long('10.255.255.254')) { echo json_encode(['error' => 'IP range exhausted. Please start a new range.']); @@ -138,6 +156,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { 'secret' => generateRandomPassword(), 'ip' => $userIp ]; + $addedUsers++; } $users = array_merge($users, $newUsers); @@ -148,6 +167,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } ?> +