Some minor changes of Automation system

This commit is contained in:
JonatanRek
2019-08-25 14:07:01 +02:00
parent aa8235c1bf
commit b1e19dd64d
12 changed files with 106 additions and 64 deletions

35
api.php
View File

@@ -14,20 +14,6 @@ foreach (["class", "views"] as $dir) {
//DB Conector
Db::connect (DBHOST, DBUSER, DBPASS, DBNAME);
//Filtrování IP adress
/*if (DEBUGMOD != 1) {
if (!in_array($_SERVER['REMOTE_ADDR'], HOMEIP)) {
echo json_encode(array(
'state' => 'unsuccess',
'errorMSG' => "Using API from your IP insn´t alowed!",
));
header("HTTP/1.1 401 Unauthorized");
exit();
}
}*/
//Read API data
$json = file_get_contents('php://input');
$obj = json_decode($json, true);
@@ -36,10 +22,24 @@ if (isset($obj['user']) && $obj['user'] != ''){
//user at home
$user = UserManager::getUser($obj['user']);
$userId = $user['user_id'];
UserManager::atHome($userId, $obj['location']);
$keyWords = ['entered', 'connected', 'connected to'];
UserManager::atHome($userId, $obj['atHome']);
echo 'ssaved';
die();
}
//Filtrování IP adress
/*if (DEBUGMOD != 1) {
if (!in_array($_SERVER['REMOTE_ADDR'], HOMEIP)) {
echo json_encode(array(
'state' => 'unsuccess',
'errorMSG' => "Using API from your IP insn´t alowed!",
));
header("HTTP/1.1 401 Unauthorized");
exit();
}
}*/
//automationExecution
AutomationManager::executeAll();
@@ -117,7 +117,6 @@ if ($values != null || $values != "") {
'state' => 'succes',
));
header("HTTP/1.1 200 OK");
die();
} else {
//Vypis
//TODO: doděla uložení výpisu jinými slovy zda li byl comman vykonán
@@ -145,5 +144,7 @@ if ($values != null || $values != "") {
'value' => $subDeviceLastReordValue
));
header("HTTP/1.1 200 OK");
die();
}
Db::disconect();
die();