API Clean UP
This commit is contained in:
		
							
								
								
									
										7
									
								
								api.php
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								api.php
									
									
									
									
									
								
							@@ -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
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user