mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-10-31 22:47:05 +01:00
Removed authentication feature
This commit is contained in:
parent
63d8cb51c9
commit
31be64a084
@ -1,17 +1,12 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
function tellLock( $pAction, $pUser, $pPass, $pToken, $pIp ){
|
function tellLock( $pAction, $pUser, $pPass, $pToken, $pIp ){
|
||||||
|
|
||||||
$pAuthenticated = true;
|
|
||||||
|
|
||||||
$json = '{
|
$json = '{
|
||||||
"user":' . json_encode( $pUser ) . ',
|
"user":' . json_encode( $pUser ) . ',
|
||||||
"password":' . json_encode( $pPass ) . ',
|
"password":' . json_encode( $pPass ) . ',
|
||||||
"action":' . json_encode( $pAction ) . ',
|
"action":' . json_encode( $pAction ) . ',
|
||||||
"token":' . json_encode( $pToken ) . ',
|
"token":' . json_encode( $pToken ) . ',
|
||||||
"ip":' . json_encode( $pIp ) . ',
|
"ip":' . json_encode( $pIp ) . '
|
||||||
"authenticate":' . json_encode( $pAuthenticated ) . '
|
|
||||||
}'."\n";
|
}'."\n";
|
||||||
|
|
||||||
$address = "127.0.0.1";
|
$address = "127.0.0.1";
|
||||||
@ -80,37 +75,57 @@
|
|||||||
$showLoginForm = false;
|
$showLoginForm = false;
|
||||||
$showSuccess = false;
|
$showSuccess = false;
|
||||||
$showFailure = false;
|
$showFailure = false;
|
||||||
|
$isApi = false;
|
||||||
|
|
||||||
$pIp = $_SERVER[ 'REMOTE_ADDR' ];
|
$pIp = $_SERVER[ 'REMOTE_ADDR' ];
|
||||||
|
|
||||||
if( $_SERVER[ 'REQUEST_METHOD' ] == "POST" ) {
|
if( $_SERVER[ 'REQUEST_METHOD' ] == "POST" ) {
|
||||||
|
|
||||||
|
if (array_key_exists("user", $_POST)
|
||||||
|
&& array_key_exists('pass', $_POST)
|
||||||
|
&& array_key_exists('token', $_POST)
|
||||||
|
&& array_key_exists('action', $_POST)
|
||||||
|
&& array_key_exists('api', $_POST))
|
||||||
|
{
|
||||||
$pUser = $_POST[ 'user' ];
|
$pUser = $_POST[ 'user' ];
|
||||||
$pPass = $_POST[ 'pass' ];
|
$pPass = $_POST[ 'pass' ];
|
||||||
$pToken = $_POST[ 'token' ];
|
$pToken = $_POST[ 'token' ];
|
||||||
$pAction = $_POST[ 'action' ];
|
$pAction = $_POST[ 'action' ];
|
||||||
|
$pApi = $_POST[ 'api' ];
|
||||||
|
|
||||||
|
if ($pApi == "true")
|
||||||
|
{
|
||||||
|
$isApi = true;
|
||||||
|
}
|
||||||
|
|
||||||
$lSuccess = tellLock( $pAction, $pUser, $pPass, $pToken, $pIp );
|
$lSuccess = tellLock( $pAction, $pUser, $pPass, $pToken, $pIp );
|
||||||
|
|
||||||
if ($lSuccess == 0) {
|
if ($lSuccess == 0) {
|
||||||
$showSuccess = true;
|
$showSuccess = true;
|
||||||
} else {
|
} else {
|
||||||
http_response_code( 401 );
|
|
||||||
$failureMsg = err2str($lSuccess);
|
$failureMsg = err2str($lSuccess);
|
||||||
$showFailure = true;
|
$showFailure = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// This is done by apache mod_rewrite
|
$failureMsg = 'Invalid Request';
|
||||||
$pToken = $_GET[ 'token' ];
|
|
||||||
$lToken = preg_replace( '/[^0-9a-f]/i', "", $pToken );
|
|
||||||
if(strlen($lToken) != 16) {
|
|
||||||
http_response_code( 404 );
|
|
||||||
$showFailure = true;
|
$showFailure = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// This is done by apache mod_rewrite
|
||||||
|
$pToken = $_GET[ 'token' ];
|
||||||
|
$lToken = preg_replace( '/[^0-9a-fA-F]/i', "", $pToken );
|
||||||
|
|
||||||
|
if(strlen($lToken) != 16) {
|
||||||
|
$showFailure = true;
|
||||||
|
$failureMsg = "Please provide Token";
|
||||||
|
} else {
|
||||||
$showLoginForm = true;
|
$showLoginForm = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if ($isApi == false) {
|
||||||
?>
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
@ -161,6 +176,7 @@
|
|||||||
<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="token" value="<?php echo $lToken;?>">
|
||||||
|
<input type="hidden" name="api" value="false">
|
||||||
|
|
||||||
<button name="action" value="unlock">Open</button>
|
<button name="action" value="unlock">Open</button>
|
||||||
<hr/>
|
<hr/>
|
||||||
@ -180,3 +196,8 @@
|
|||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
<?php
|
||||||
|
} else {
|
||||||
|
echo $lSuccess;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user