1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 10:24:26 +01:00

Improved Webfrontend

Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
This commit is contained in:
Ralf Ramsauer 2015-10-02 20:37:44 +02:00
parent 8f80d5b39c
commit 36ddfe4d5c

View File

@ -34,6 +34,7 @@
$showLoginForm = false;
$showSuccess = false;
$showFailure = false;
$showTokenForm = false;
$isApi = false;
$pIp = $_SERVER[ 'REMOTE_ADDR' ];
@ -75,11 +76,11 @@
} else {
// This is done by apache mod_rewrite
$pToken = $_GET['token'];
$lToken = preg_replace( '/[^0-9a-fA-F]/i', "", $pToken );
$lToken = $str= ltrim ($pToken, '/');
if(strlen($lToken) != 16) {
$showFailure = true;
$failureMsg = "Please provide Token";
if(strlen($lToken) == 0) {
$showLoginForm = true;
$showTokenForm = true;
} else {
$showLoginForm = true;
}
@ -130,15 +131,21 @@ if ($isApi == false) {
<?php if ($showLoginForm): ?>
<form name="login" method="post" action="/">
<?php if ($showTokenForm): ?>
<label for="token">Token</label>
<input type="text" name="token" value="">
<?php else: ?>
<input type="hidden" name="token" value="<?php echo $lToken;?>">
<?php endif; ?>
<input type="hidden" name="api" value="false">
<label for="user">User</label>
<input id="user" type="text" name="user">
<label for="pass">Pass</label>
<input id="pass" type="password" name="pass">
<input type="hidden" name="token" value="<?php echo $lToken;?>">
<input type="hidden" name="api" value="false">
<button name="command" value="unlock">Open</button>
<hr/>
<button name="command" value="lock">Lock</button>