copy icon issue #1128

This commit is contained in:
jokob-sk
2025-08-02 07:56:57 +10:00
parent ffccca9424
commit f5f7031030
19 changed files with 82 additions and 34 deletions

View File

@@ -76,6 +76,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
switch ($action) {
case 'create': create($defaultValue, $expireMinutes, $dbtable, $columns, $values ); break;
case 'read' : read($rawSql); break;
case 'write' : write($rawSql); break;
case 'update': update($columnName, $id, $defaultValue, $expireMinutes, $dbtable, $columns, $values); break;
case 'delete': delete($columnName, $id, $dbtable); break;
case 'lockDatabase': lockDatabase($delay); break;
@@ -120,6 +121,31 @@ function read($rawSql) {
}
}
//------------------------------------------------------------------------------
// write
//------------------------------------------------------------------------------
function write($rawSql) {
global $db;
// Construct the SQL query to select values
$sql = $rawSql;
// Execute the SQL query
$result = $db->query($sql);
// Check if the query executed successfully
if (! $result == TRUE) {
// Output an error message if the query failed
echo "Error writing data\n\n " .$sql." \n\n". $db->lastErrorMsg();
return;
} else
{
// Output
echo "OK";
return;
}
}
//------------------------------------------------------------------------------
// update

View File

@@ -48,7 +48,6 @@
case 'getDevicesListCalendar': getDevicesListCalendar(); break; //todo: slowly deprecate this
case 'updateNetworkLeaf': updateNetworkLeaf(); break;
case 'overwriteIconType': overwriteIconType(); break;
case 'getIcons': getIcons(); break;
case 'getActions': getActions(); break;
case 'getDevices': getDevices(); break;
@@ -924,33 +923,6 @@ function updateNetworkLeaf()
}
// ----------------------------------------------------------------------------------------
function overwriteIconType()
{
$mac = $_REQUEST['mac'];
$icon = $_REQUEST['icon'];
if ((false === filter_var($mac , FILTER_VALIDATE_MAC) && $mac != "Internet" && $mac != "") ) {
throw new Exception('Invalid mac address');
}
else
{
global $db;
// sql
$sql = 'UPDATE Devices SET "devIcon" = "'. $icon .'" where devType in (select devType from Devices where devMac = "' . $mac.'")' ;
// update Data
$result = $db->query($sql);
// check result
if ($result == TRUE) {
echo 'OK';
} else {
echo lang('BackDevices_Device_UpdDevError');
}
}
}
//------------------------------------------------------------------------------
// Wake-on-LAN
// Inspired by @leiweibau: https://github.com/leiweibau/Pi.Alert/commit/30427c7fea180670c71a2b790699e5d9e9e88ffd