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