$kind,'BTN_SUBMIT' => 'main.php', 'REGISTER_ACTION' => 'SignUp.createAccount']; if (($_SERVER['REQUEST_METHOD'] ?? 'GET') === 'POST') { $this->requireCsrf(); try { $auth = new AuthService(); if (!$auth->allowAttempt('signup-ip', $_SERVER['REMOTE_ADDR'] ?? '', 5, 3600)) { throw new InvalidArgumentException('Too many account requests. Please try again later.'); } if(!in_array($kind,['new_club','invited'],true))throw new InvalidArgumentException('Choose a valid signup option.'); $input=$_POST;$input['registration_kind']=$kind;$auth->register($input); try{(new EmailVerification())->request($_POST['user_email']);} catch(Throwable $e){error_log('Signup verification delivery failed: '.$e->getMessage());} $_SESSION['signup_success'] = $kind; header('Location: main.php?Xaction=signup', true, 303); exit; } catch (InvalidArgumentException $e) { $params['SIGNUP_ERROR'] = $e->getMessage(); foreach (['user_first_name', 'user_last_name', 'user_email', 'user_name', 'club_name'] as $field) { $params[strtoupper($field)] = $_POST[$field] ?? ''; } } } if (!empty($_SESSION['signup_success'])) { $params['REGISTRATION_KIND'] = $_SESSION['signup_success']; $params['SIGNUP_SUCCESSFUL'] = 'TRUE'; unset($_SESSION['signup_success']); } echo $this->applyXSL('', $this->getXSL('createAccount'), $params); exit; } }