API Clean UP

This commit is contained in:
JonatanRek 2019-10-11 17:49:31 +02:00
parent 23ae36dfc5
commit 875fbccd6e

View File

@ -3,9 +3,7 @@
include_once('./config.php'); include_once('./config.php');
//Autoloader //Autoloader
$files = scandir('./app/class/'); $files = scandir('./app/class/');
$files = array_diff($files, array( $files = array_diff($files, array(
'.', '.',
'..', '..',
@ -25,7 +23,6 @@ foreach($files as $file) {
include './app/class/'. $file; include './app/class/'. $file;
} }
//Allow acces only wia Curl, Ajax ETC //Allow acces only wia Curl, Ajax ETC
$restAcess = 'XMLHttpRequest' == ( $_SERVER['HTTP_X_REQUESTED_WITH'] ?? '' ); $restAcess = 'XMLHttpRequest' == ( $_SERVER['HTTP_X_REQUESTED_WITH'] ?? '' );
if (!$restAcess){ if (!$restAcess){
@ -154,12 +151,9 @@ if ($values != null || $values != "") {
RecordManager::create($deviceId, $key, round($value['value'],2)); RecordManager::create($deviceId, $key, round($value['value'],2));
$logManager->write("[API] Device_ID " . $deviceId . " writed value " . $key . ' ' . $value['value'], LogRecordType::INFO); $logManager->write("[API] Device_ID " . $deviceId . " writed value " . $key . ' ' . $value['value'], LogRecordType::INFO);
//notification //notification
if ($key == 'door' || $key == 'water') { if ($key == 'door' || $key == 'water') {
$notificationMng = new NotificationManager; $notificationMng = new NotificationManager;
$notificationData = []; $notificationData = [];
switch ($key) { switch ($key) {
@ -203,7 +197,6 @@ if ($values != null || $values != "") {
$jsonAnswer['sleepTime'] = $device['sleep_time']; $jsonAnswer['sleepTime'] = $device['sleep_time'];
} }
echo json_encode($jsonAnswer); echo json_encode($jsonAnswer);
header("HTTP/1.1 200 OK"); header("HTTP/1.1 200 OK");
} else { } else {
//Vypis //Vypis