From 30da6e162b7ffc4e07dd71a51eb57adbde60f5fb Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Mon, 14 Sep 2020 15:15:47 +0200 Subject: [PATCH] Few Fixes After infrastructure migration --- .htaccess | 6 +++--- app/Bootstrap.php | 20 +++++++++++--------- app/api/WidgetApi.php | 2 +- app/views/Device.php | 6 ++++++ app/views/templates/device.phtml | 2 ++ 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/.htaccess b/.htaccess index b0a8024..289a0f5 100644 --- a/.htaccess +++ b/.htaccess @@ -1,9 +1,9 @@ RewriteEngine On # require https -RewriteCond %{HTTPS} off -RewriteCond %{REQUEST_URI} !^/api/update -RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] +#RewriteCond %{HTTPS} off +#RewriteCond %{REQUEST_URI} !^/api/update +#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] #token to HTTP_AUTHORIZATION RewriteCond %{HTTP:Authorization} ^(.*) diff --git a/app/Bootstrap.php b/app/Bootstrap.php index 9faf5db..b45c175 100644 --- a/app/Bootstrap.php +++ b/app/Bootstrap.php @@ -1,4 +1,15 @@ write("[API] request body\n" . json_encode($obj, JSON_PRETTY_PRI $apiLogManager->write("[API] POST body\n" . json_encode($_POST, JSON_PRETTY_PRINT), LogRecordTypes::INFO); $apiLogManager->write("[API] GET body\n" . json_encode($_GET, JSON_PRETTY_PRINT), LogRecordTypes::INFO); -//Debug -error_reporting(E_ALL); -ini_set( 'display_errors','1'); -//setup -ini_set ('session.cookie_httponly', '1'); -ini_set('session.cookie_domain', $_SERVER['HTTP_HOST']); -ini_set('session.cookie_path', str_replace("login", "", str_replace('https://' . $_SERVER['HTTP_HOST'], "", $_SERVER['REQUEST_URI']))); -ini_set('session.cookie_secure', '1'); -mb_internal_encoding ("UTF-8"); Debugger::flag('dbconnect'); //D B Conector diff --git a/app/api/WidgetApi.php b/app/api/WidgetApi.php index 2734d9f..65e5950 100644 --- a/app/api/WidgetApi.php +++ b/app/api/WidgetApi.php @@ -12,7 +12,7 @@ class WidgetApi extends ApiController{ $subDeviceData = SubDeviceManager::getSubDevice($subDeviceId); if ($subDeviceData['type'] == 'on/off'){ $lastValue = RecordManager::getLastRecord($subDeviceData['subdevice_id'])['value']; - RecordManager::create($subDeviceData['device_id'], 'on/off', !$lastValue); + RecordManager::create($subDeviceData['device_id'], 'on/off', (int) !$lastValue); $response = !$lastValue; } else { throw new Exception("Bad Request", 403); diff --git a/app/views/Device.php b/app/views/Device.php index 203e7c7..0c5a6a8 100644 --- a/app/views/Device.php +++ b/app/views/Device.php @@ -30,6 +30,12 @@ class Device extends Template } else { $devices[$key]['firmware_hash'] = "false"; } + + $wifi = SubDeviceManager::getSubDeviceByMaster($device['device_id'], 'wifi'); + if ($wifi) { + $signalStrenght = RecordManager::getLastRecordNotNull($wifi['subdevice_id']); + $devices[$key]['signal'] = (!$signalStrenght ? 0 : $signalStrenght['value']); + } } $rooms = $roomManager->getAllRooms(); diff --git a/app/views/templates/device.phtml b/app/views/templates/device.phtml index 66ea919..910bc68 100644 --- a/app/views/templates/device.phtml +++ b/app/views/templates/device.phtml @@ -26,6 +26,7 @@ # Name + Signal Room Firmware IP Address
(Mac)
Token @@ -43,6 +44,7 @@ &#x +