Some Fixes

This commit is contained in:
Václav Španinger 2020-09-07 11:05:47 +02:00
parent 960859087a
commit b0514c1f3a

View File

@ -17,6 +17,7 @@ class UpdatesApi {
return true; return true;
} }
return false; return false;
} }
public function default(){ public function default(){
@ -24,25 +25,25 @@ class UpdatesApi {
$logManager->setLevel(LOGLEVEL); $logManager->setLevel(LOGLEVEL);
$logManager->write("[Updater] Client Connected", LogRecordTypes::INFO); $logManager->write("[Updater] Client Connected", LogRecordTypes::INFO);
if($this->validateHeader($_SERVER)){ // if($this->validateHeader($_SERVER)){
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); // header($_SERVER["SERVER_PROTOCOL"]." 400 Bad Header");
die(); // die();
} // }
header('Content-type: text/plain; charset=utf8', true); header('Content-type: text/plain; charset=utf8', true);
//Filtrování IP adress // //Filtrování IP adress
if (DEBUGMOD != 1) { // if (DEBUGMOD != 1) {
if (!in_array($_SERVER['REMOTE_ADDR'], HOMEIP)) { // if (!in_array($_SERVER['REMOTE_ADDR'], HOMEIP)) {
echo json_encode(array( // echo json_encode(array(
'state' => 'unsuccess', // 'state' => 'unsuccess',
'errorMSG' => "Using API from your IP insnt alowed!", // 'errorMSG' => "Using API from your IP insnt alowed!",
)); // ));
header($_SERVER["SERVER_PROTOCOL"]." 401 Unauthorized"); // header($_SERVER["SERVER_PROTOCOL"]." 401 Unauthorized");
$logManager->write("[Updater] acces denied from " . $_SERVER['REMOTE_ADDR'], LogRecordTypes::INFO); // $logManager->write("[Updater] acces denied from " . $_SERVER['REMOTE_ADDR'], LogRecordTypes::INFO);
exit(); // exit();
} // }
} // }
$macAddress = $_SERVER['HTTP_X_ESP8266_STA_MAC']; $macAddress = $_SERVER['HTTP_X_ESP8266_STA_MAC'];
$localBinary = "../updater/" . str_replace(':', '', $macAddress) . ".bin"; $localBinary = "../updater/" . str_replace(':', '', $macAddress) . ".bin";