isAuthorized()) { http_response_code(403); } echo 'Some text otherwise PHP crashes. I wish this was a joke.'; } function toggle(Configuration $config) { if ($config->isAuthorized()) { $file = $config->stateFile(); if ($config->isOpen()) { unlink($file); } else { touch($file); } } header('location: ' . $_SERVER['REQUEST_URI']); } function display_state(bool $open) { header('X-Foobar-Open: ' . var_export($open, true)); if ($open) { require '../templates/open.html'; } else { require '../templates/closed.html'; } } if (isset($_POST['auth_check'])) { auth_check($config); } elseif (isset($_POST['toggle'])) { toggle($config); } else { display_state($config->isOpen()); }