Refactor database interaction in MonitoringServer class to improve SQL execution conditions and enhance notification logic

This commit is contained in:
jhartworks
2026-03-19 13:59:59 +01:00
parent 192821320e
commit 6bbce403a6
+15 -6
View File
@@ -429,7 +429,9 @@ class MonitoringServer extends IPSModule {
$tdOld = $this->ReadAttributeString("AtAlarmtable"); $tdOld = $this->ReadAttributeString("AtAlarmtable");
$td = $tdOld; $td = $tdOld;
if ($idSql > 0 && $idSql != 12345){
MySQL_Open($idSql); MySQL_Open($idSql);
}
// === Helfer: Escaping für Strings === // === Helfer: Escaping für Strings ===
if (function_exists('MySQL_RealEscapeString')) { if (function_exists('MySQL_RealEscapeString')) {
@@ -449,12 +451,12 @@ class MonitoringServer extends IPSModule {
if (GetValue($trigid) == true && ($this->GetBuffer($smname) == "true")) { if (GetValue($trigid) == true && ($this->GetBuffer($smname) == "true")) {
$this->SetBuffer($smname, "false"); $this->SetBuffer($smname, "false");
if($webfrontid != 0){
if ($sendit == true){ if ($sendit == true){
VISU_PostNotification($webfrontid, $art, $smname, $ico, $targetid); VISU_PostNotification($webfrontid, $art, $smname, $ico, $targetid);
$push = 1; $push = 1;
}
} }
$whatsapp = 0; $whatsapp = 0;
$whatsapped = 0; $whatsapped = 0;
if ($sendwhatsapp == true){ if ($sendwhatsapp == true){
@@ -536,6 +538,8 @@ class MonitoringServer extends IPSModule {
)", )",
$esc($smname), $esc($phonenumber) $esc($smname), $esc($phonenumber)
); );
if ($idSql > 0 && $idSql != 12345){
// === Ausführen === // === Ausführen ===
$okcall = MySQL_ExecuteSimple($idSql, $sqlcall); $okcall = MySQL_ExecuteSimple($idSql, $sqlcall);
@@ -543,7 +547,11 @@ class MonitoringServer extends IPSModule {
echo "INSERT fehlgeschlagen.\n"; echo "INSERT fehlgeschlagen.\n";
} }
}
$phoned = 1; $phoned = 1;
} }
} }
} }
@@ -607,12 +615,13 @@ class MonitoringServer extends IPSModule {
(int)$mail, $esc($email_address), (int)$mailed, (int)$mail, $esc($email_address), (int)$mailed,
(int)$push (int)$push
); );
if ($idSql > 0 && $idSql != 12345){
// === Ausführen === // === Ausführen ===
$ok = MySQL_ExecuteSimple($idSql, $sql); $ok = MySQL_ExecuteSimple($idSql, $sql);
if (!$ok) { if (!$ok) {
echo "INSERT fehlgeschlagen.\n"; echo "INSERT fehlgeschlagen.\n";
} }
}
} }
elseif (GetValue($trigid) == false) { elseif (GetValue($trigid) == false) {
$this->SetBuffer($smname, "true"); $this->SetBuffer($smname, "true");