Release Fixes
This commit is contained in:
parent
b2a8734ed3
commit
12212d6c56
@ -12,6 +12,7 @@ RewriteRule (.*) index.php?url=$1 [QSA,L]
|
|||||||
|
|
||||||
RewriteCond %{HTTPS} off
|
RewriteCond %{HTTPS} off
|
||||||
RewriteCond %{REQUEST_FILENAME} !api.php
|
RewriteCond %{REQUEST_FILENAME} !api.php
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !apiFront.php
|
||||||
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|
||||||
|
|
||||||
AddType application/x-httpd-php .php .phtml
|
AddType application/x-httpd-php .php .phtml
|
||||||
|
7
api.php
7
api.php
@ -180,6 +180,13 @@ if ($settings != null && $settings != ""){
|
|||||||
$data['firmware_hash'] = $settings["firmware_hash"];
|
$data['firmware_hash'] = $settings["firmware_hash"];
|
||||||
}
|
}
|
||||||
DeviceManager::editByToken($token, $data);
|
DeviceManager::editByToken($token, $data);
|
||||||
|
$jsonAnswer = [
|
||||||
|
'state' => 'succes',
|
||||||
|
'command' => $command,
|
||||||
|
];
|
||||||
|
echo json_encode($jsonAnswer, JSON_PRETTY_PRINT);
|
||||||
|
header($_SERVER["SERVER_PROTOCOL"]." 200 OK");
|
||||||
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issuing command
|
// Issuing command
|
||||||
|
43
apiFront.php
Normal file
43
apiFront.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
/** Includes **/
|
||||||
|
include_once('./config.php');
|
||||||
|
|
||||||
|
//Autoloader
|
||||||
|
$files = scandir('./app/class/');
|
||||||
|
$files = array_diff($files, array(
|
||||||
|
'.',
|
||||||
|
'..',
|
||||||
|
'app',
|
||||||
|
'ChartJS.php',
|
||||||
|
'ChartJS_Line.php',
|
||||||
|
'ChartManager.php',
|
||||||
|
'DashboardManager.php',
|
||||||
|
'Partial.php',
|
||||||
|
'Form.php',
|
||||||
|
'Route.php',
|
||||||
|
'Template.php',
|
||||||
|
'Ajax.php',
|
||||||
|
));
|
||||||
|
|
||||||
|
foreach($files as $file) {
|
||||||
|
include './app/class/'. $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Log
|
||||||
|
$apiLogManager = new LogManager('./app/logs/apiFront/'. date("Y-m-d").'.log');
|
||||||
|
|
||||||
|
//DB Conector
|
||||||
|
Db::connect (DBHOST, DBUSER, DBPASS, DBNAME);
|
||||||
|
|
||||||
|
//Read API data
|
||||||
|
$json = file_get_contents('php://input');
|
||||||
|
$obj = json_decode($json, true);
|
||||||
|
|
||||||
|
//Log RAW api request
|
||||||
|
if (API_DEBUGMOD == 1) {
|
||||||
|
$apiLogManager->write("[API] request body\n" . json_encode($obj, JSON_PRETTY_PRINT), LogRecordType::INFO);
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($logManager);
|
||||||
|
Db::disconect();
|
||||||
|
die();
|
@ -31,8 +31,11 @@ class UserManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAvatarUrl(){
|
public function getAvatarUrl($userId = null){
|
||||||
$email = self::getUserData('email');
|
$email = self::getUserData('email');
|
||||||
|
if ($userId != null){
|
||||||
|
$email = self::getUserData('email',$userId);
|
||||||
|
}
|
||||||
return 'https://secure.gravatar.com/avatar/' . md5( strtolower( trim( $email ) ) );
|
return 'https://secure.gravatar.com/avatar/' . md5( strtolower( trim( $email ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ return $lang = [
|
|||||||
'b_restart' => 'Restart',
|
'b_restart' => 'Restart',
|
||||||
'b_disable' => 'Deaktivovat',
|
'b_disable' => 'Deaktivovat',
|
||||||
'b_select' => 'Zvolit',
|
'b_select' => 'Zvolit',
|
||||||
|
'b_ota' => 'ota',
|
||||||
|
|
||||||
//labels
|
//labels
|
||||||
'l_choseDevice' => 'Zvolte zařízení:',
|
'l_choseDevice' => 'Zvolte zařízení:',
|
||||||
@ -57,6 +58,10 @@ return $lang = [
|
|||||||
'l_password' => 'Heslo',
|
'l_password' => 'Heslo',
|
||||||
'l_oldPassword' => 'Staré Heslo',
|
'l_oldPassword' => 'Staré Heslo',
|
||||||
'l_newPassword' => 'Nové Heslo',
|
'l_newPassword' => 'Nové Heslo',
|
||||||
|
'l_uploadFirmware' => 'Nahrát Firmware',
|
||||||
|
'l_userAvatar' => 'Avatar',
|
||||||
|
'l_userEmail' => 'Email',
|
||||||
|
'l_roomName' => 'Jméno Místnosti',
|
||||||
|
|
||||||
//Title
|
//Title
|
||||||
't_createScene' => 'Vytvořit scénu',
|
't_createScene' => 'Vytvořit scénu',
|
||||||
@ -70,6 +75,14 @@ return $lang = [
|
|||||||
't_experimental' => 'Experimental',
|
't_experimental' => 'Experimental',
|
||||||
't_createuser' => 'Vytvořit Uživatele',
|
't_createuser' => 'Vytvořit Uživatele',
|
||||||
't_changePassword' => 'Změnit Heslo',
|
't_changePassword' => 'Změnit Heslo',
|
||||||
|
't_networkSetting' => 'Nastavení Sítě',
|
||||||
|
't_deviceVersion' => 'Nastavení Verze',
|
||||||
|
't_ota' => 'OTA',
|
||||||
|
't_listUsers' => 'Seznam Uživatelů',
|
||||||
|
't_avatar' => 'Avatar',
|
||||||
|
't_listRooms' => 'Seznam Místností',
|
||||||
|
't_roomName' => 'Jméno Místnosti',
|
||||||
|
't_createRoom' => 'Vytvořit Místnost',
|
||||||
|
|
||||||
//constants
|
//constants
|
||||||
'temp' => 'Teplota',
|
'temp' => 'Teplota',
|
||||||
|
@ -28,6 +28,7 @@ return $lang = [
|
|||||||
'b_restart' => 'Restart',
|
'b_restart' => 'Restart',
|
||||||
'b_disable' => 'disabele',
|
'b_disable' => 'disabele',
|
||||||
'b_select' => 'Select',
|
'b_select' => 'Select',
|
||||||
|
'b_ota' => 'ota',
|
||||||
|
|
||||||
//labels
|
//labels
|
||||||
'l_choseDevice' => 'Chose device:',
|
'l_choseDevice' => 'Chose device:',
|
||||||
@ -57,6 +58,10 @@ return $lang = [
|
|||||||
'l_password' => 'Password',
|
'l_password' => 'Password',
|
||||||
'l_oldPassword' => 'Old Password',
|
'l_oldPassword' => 'Old Password',
|
||||||
'l_newPassword' => 'New Password',
|
'l_newPassword' => 'New Password',
|
||||||
|
'l_uploadFirmware' => 'Upload Firmware',
|
||||||
|
'l_userAvatar' => 'Avatar',
|
||||||
|
'l_userEmail' => 'Email',
|
||||||
|
'l_roomName' => 'Room Name',
|
||||||
|
|
||||||
//Title
|
//Title
|
||||||
't_createScene' => 'Create Scene',
|
't_createScene' => 'Create Scene',
|
||||||
@ -70,6 +75,14 @@ return $lang = [
|
|||||||
't_experimental' => 'Experimental',
|
't_experimental' => 'Experimental',
|
||||||
't_createuser' => 'Create User',
|
't_createuser' => 'Create User',
|
||||||
't_changePassword' => 'Change Password',
|
't_changePassword' => 'Change Password',
|
||||||
|
't_networkSetting' => 'Network Setting',
|
||||||
|
't_deviceVersion' => 'Version Setting',
|
||||||
|
't_ota' => 'OTA',
|
||||||
|
't_listUsers' => 'User List',
|
||||||
|
't_avatar' => 'Avatar',
|
||||||
|
't_listRooms' => 'Room List',
|
||||||
|
't_roomName' => 'Room Name',
|
||||||
|
't_createRoom' => 'Create Rom',
|
||||||
|
|
||||||
//constants
|
//constants
|
||||||
'humi' => 'Humidity',
|
'humi' => 'Humidity',
|
||||||
|
@ -17,6 +17,7 @@ if ('serviceWorker' in navigator) {
|
|||||||
navigator.serviceWorker.register('serviceWorker.js')
|
navigator.serviceWorker.register('serviceWorker.js')
|
||||||
.then(registration => {
|
.then(registration => {
|
||||||
console.log('Service Worker is registered', registration);
|
console.log('Service Worker is registered', registration);
|
||||||
|
|
||||||
messaging.useServiceWorker(registration);
|
messaging.useServiceWorker(registration);
|
||||||
messaging.usePublicVapidKey('BDYQ7X7J7PX0aOFNqB-CivQeqLq4-SqCxQJlDfJ6yNnQeYRoK8H2KOqxHRh47fLrbUhC8O3tve67MqJAIqox7Ng');
|
messaging.usePublicVapidKey('BDYQ7X7J7PX0aOFNqB-CivQeqLq4-SqCxQJlDfJ6yNnQeYRoK8H2KOqxHRh47fLrbUhC8O3tve67MqJAIqox7Ng');
|
||||||
messaging.requestPermission().then(function () {
|
messaging.requestPermission().then(function () {
|
||||||
@ -44,15 +45,6 @@ if ('serviceWorker' in navigator) {
|
|||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
console.log("Unable to get permission to notify.", err);
|
console.log("Unable to get permission to notify.", err);
|
||||||
});
|
});
|
||||||
messaging.onMessage(function(payload) {
|
|
||||||
console.log("Message received. ", payload);
|
|
||||||
var notification = new Notification('hello', {
|
|
||||||
body: "Hey there!",
|
|
||||||
});
|
|
||||||
notification.onclick = function () {
|
|
||||||
window.open("http://google.com");
|
|
||||||
};
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error('Registration failed:', err);
|
console.error('Registration failed:', err);
|
||||||
|
@ -84,12 +84,6 @@
|
|||||||
<input class="input" type="text" name="deviceGateway" value="<?php echo $DEVICE['gateway']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
|
<input class="input" type="text" name="deviceGateway" value="<?php echo $DEVICE['gateway']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php //TODO: ADD DNS TO DB MAKE ALL NETWORK SETTING EDITABLE ?>
|
|
||||||
<div class="field">
|
|
||||||
<div class="label">DNS:</div>
|
|
||||||
<input class="input" type="text" name="deviceDns" value="<?php echo $DEVICE['dns']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h4 class="mb-4"><?php $LANGMNG->echo('t_deviceVersion'); ?></h4>
|
<h4 class="mb-4"><?php $LANGMNG->echo('t_deviceVersion'); ?></h4>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="label"><?php $LANGMNG->echo('l_uploadFirmware'); ?></div>
|
<div class="label"><?php $LANGMNG->echo('l_uploadFirmware'); ?></div>
|
||||||
|
@ -115,6 +115,7 @@
|
|||||||
<table class="table is-fluid">
|
<table class="table is-fluid">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th><?php $LANGMNG->echo('t_avatar');?></th>
|
||||||
<th><?php $LANGMNG->echo('t_userName');?></th>
|
<th><?php $LANGMNG->echo('t_userName');?></th>
|
||||||
<th><?php $LANGMNG->echo('t_ota');?></th>
|
<th><?php $LANGMNG->echo('t_ota');?></th>
|
||||||
<th><?php $LANGMNG->echo('t_action');?></th>
|
<th><?php $LANGMNG->echo('t_action');?></th>
|
||||||
@ -123,6 +124,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($USERS as $key => $user) { ?>
|
<?php foreach ($USERS as $key => $user) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><img src="<?php echo $user['gavatar_url']; ?>" /></td>
|
||||||
<td><?php echo $user['username']; ?></td>
|
<td><?php echo $user['username']; ?></td>
|
||||||
<td><?php echo ($user['ota'] ? '<span class="fa"></span>' : ''); ?></td>
|
<td><?php echo ($user['ota'] ? '<span class="fa"></span>' : ''); ?></td>
|
||||||
<td><button name="deleteUser" type="button" class="button is-danger fa"></button></td>
|
<td><button name="deleteUser" type="button" class="button is-danger fa"></button></td>
|
||||||
|
@ -30,6 +30,9 @@ class Setting extends Template
|
|||||||
$template->prepare('automations', $automations);
|
$template->prepare('automations', $automations);
|
||||||
|
|
||||||
$users = $userManager->getUsers();
|
$users = $userManager->getUsers();
|
||||||
|
foreach ($users as $key => $value) {
|
||||||
|
$users[$key]['gavatar_url'] = $userManager->getAvatarUrl($value['user_id']);
|
||||||
|
}
|
||||||
$template->prepare('users', $users);
|
$template->prepare('users', $users);
|
||||||
|
|
||||||
$template->prepare('userName', $userManager->getUserData('username'));
|
$template->prepare('userName', $userManager->getUserData('username'));
|
||||||
|
@ -58,7 +58,7 @@ $localBinary = "./app/updater/" . str_replace(':', '', $macAddress) . ".bin";
|
|||||||
$logManager->write("[Updater] url: " . $localBinary, LogRecordType::INFO);
|
$logManager->write("[Updater] url: " . $localBinary, LogRecordType::INFO);
|
||||||
$logManager->write("[Updater] version: " . $_SERVER['HTTP_X_ESP8266_SKETCH_MD5'], LogRecordType::INFO);
|
$logManager->write("[Updater] version: " . $_SERVER['HTTP_X_ESP8266_SKETCH_MD5'], LogRecordType::INFO);
|
||||||
if (file_exists($localBinary)) {
|
if (file_exists($localBinary)) {
|
||||||
$logManager->write("[Updater] version PHP: " . md5_file($localBinary), LogRecordType::INFO);
|
$logManager->write("[Updater] version PHP: \n" . md5_file($localBinary), LogRecordType::INFO);
|
||||||
if ($_SERVER['HTTP_X_ESP8266_SKETCH_MD5'] != md5_file($localBinary)) {
|
if ($_SERVER['HTTP_X_ESP8266_SKETCH_MD5'] != md5_file($localBinary)) {
|
||||||
sendFile($localBinary);
|
sendFile($localBinary);
|
||||||
//get device data
|
//get device data
|
||||||
@ -67,7 +67,7 @@ if (file_exists($localBinary)) {
|
|||||||
$deviceId = $device['device_id'];
|
$deviceId = $device['device_id'];
|
||||||
//logfile write
|
//logfile write
|
||||||
$logManager->write("[Device] device_ID " . $deviceId . " was just updated to new version", LogRecordType::WARNING);
|
$logManager->write("[Device] device_ID " . $deviceId . " was just updated to new version", LogRecordType::WARNING);
|
||||||
$logManager->write("[Device] version hash:" . md5_file($localBinary), LogRecordType::INFO);
|
$logManager->write("[Device] version hash: \n" . md5_file($localBinary), LogRecordType::INFO);
|
||||||
//notification
|
//notification
|
||||||
$notificationMng = new NotificationManager;
|
$notificationMng = new NotificationManager;
|
||||||
$notificationData = [
|
$notificationData = [
|
||||||
|
Loading…
Reference in New Issue
Block a user