Implement toggle in main controller.
This commit is contained in:
@@ -1,7 +1,22 @@
|
||||
<?php
|
||||
require_once '../vendor/autoload.php';
|
||||
|
||||
if (\FooBar\Configuration::loadConfig()->isOpen()) {
|
||||
$config = \FooBar\Configuration::loadConfig();
|
||||
|
||||
if (isset($_POST['auth_check'])) {
|
||||
if (!$config->isAuthorized()) {
|
||||
http_response_code(403);
|
||||
}
|
||||
} elseif (isset($_POST['toggle']) && $config->isAuthorized()) {
|
||||
$file = $config->stateFile();
|
||||
if ($config->isOpen()) {
|
||||
unlink($file);
|
||||
} else {
|
||||
touch($file);
|
||||
}
|
||||
}
|
||||
|
||||
if ($config->isOpen()) {
|
||||
require '../templates/open.html';
|
||||
} else {
|
||||
require '../templates/closed.html';
|
||||
|
||||
Reference in New Issue
Block a user