public function board()
{
if ($this->isLoggedIn()) {
// You're already logged in!
\Airship\redirect($this->airship_cabin_prefix);
}
if (!$this->config('board.enabled')) {
\Airship\redirect($this->airship_cabin_prefix);
}
$this->storeLensVar('showmenu', false);
$post = $this->post(new BoardFilter());
if (!empty($post)) {
// Optional: CAPTCHA enforcement
if ($this->config('board.captcha')) {
if (isset($post['g-recaptcha-response'])) {
$rc = \Airship\getReCaptcha($this->config('recaptcha.secret-key'), $this->config('recaptcha.curl-opts') ?? []);
$resp = $rc->verify($post['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
if ($resp->isSuccess()) {
$this->processBoard($post);
return;
}
$this->storeLensVar('post_response', ['status' => 'ERROR', 'message' => 'Invalid CAPTCHA response']);
}
} else {
$this->processBoard($post);
return;
}
}
$this->lens('board', ['config' => $this->config(), 'title' => 'All Aboard!']);
}