Port the old system to a more advanced setup.
This commit is contained in:
31
public/toggle.php
Normal file
31
public/toggle.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
require_once '../vendor/autoload.php';
|
||||
|
||||
$configuration = \FooBar\Configuration::loadConfig();
|
||||
|
||||
if (isset($_POST['toggle']) && $configuration->isAuthorized()) {
|
||||
$file = $configuration->stateFile();
|
||||
if ($configuration->isOpen()) {
|
||||
unlink($file);
|
||||
} else {
|
||||
touch($file);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Verander de status van de foobar</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>De foobar is nu
|
||||
<?php
|
||||
echo $configuration->isOpen() ? ' ' : ' niet ';
|
||||
?>
|
||||
open.</h1>
|
||||
<form method="post">
|
||||
<input type="submit" name="toggle" value="Verander dit">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user