= $invite['max_uses']) $errors[] = 'This invite has already been used the maximum number of times.'; if ($invite['expires_at'] && strtotime($invite['expires_at']) < time()) $errors[] = 'This invite link has expired.'; } if (empty($errors) && $_SERVER['REQUEST_METHOD'] === 'POST') { verify_csrf(); $username = trim($_POST['username'] ?? ''); $email = trim($_POST['email'] ?? ''); $password = $_POST['password'] ?? ''; $confirm = $_POST['confirm'] ?? ''; if (strlen($username) < 3) $errors[] = 'Username must be at least 3 characters.'; if (!filter_var($email, FILTER_VALIDATE_EMAIL)) $errors[] = 'Invalid email address.'; if (!empty($invite['email']) && strtolower($invite['email']) !== strtolower($email)) { $errors[] = 'This invite was created for a specific email address that does not match.'; } if (strlen($password) < 8) $errors[] = 'Password must be at least 8 characters.'; if ($password !== $confirm) $errors[] = 'Passwords do not match.'; // Check username/email uniqueness if (empty($errors)) { $dup = db()->prepare("SELECT id FROM users WHERE username = ? OR email = ?"); $dup->execute([$username, $email]); if ($dup->fetch()) $errors[] = 'Username or email is already registered.'; } if (empty($errors)) { $userId = create_user($username, $email, $password, $invite['role'], (int)$invite['created_by']); use_invite($token, $userId); auth_login($username, $password); flash('success', 'Welcome to IndexGram! Your account has been created.'); header('Location: ' . base_url('admin/')); exit; } } $meta = build_meta(['title' => 'Register — ' . get_setting('site_title', SITE_NAME)]); include ROOT_PATH . '/includes/header.php'; ?>
= h($e) ?>
You've been invited to join as: = h(ucfirst($invite['role'])) ?> (by = h($invite['creator_name'] ?? 'an admin') ?>)