Some minor changes of Automation system
This commit is contained in:
35
api.php
35
api.php
@@ -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();
|
||||
|
Reference in New Issue
Block a user