Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace VDV\Alarm\Model; use VDV\Alarm\Model\AlarmAccess; use VDV\Database\Model..

Decoded Output download

<?php 
 namespace VDV\Alarm\Model; use VDV\Alarm\Model\AlarmAccess; use VDV\Database\Model\Db; use PDO; use DateTime; class BulkAlarmDb extends Db { public function getBulkAlarmById(int $groupId) { if ($this->hasAccessToBulkAlarm($groupId)) { $bulkAlarms = $this->getCustomAlarmsByGroupId($groupId); return $bulkAlarms; } return 0; } public function getBulkAlarmByAlarmId(int $alarmId) { return $this->getRow("\xd\xa            SELECT
\xa                t1.*,\xd\xa                t2.*,
\xa                t3.station_name,\xd\xa                t4.english_name,\xd
                t6.name as typeName,\xd\xa                CG.group_name,
\xa                variable_info.calculated_variable\xd
            FROM alarm_custom AS t1
            JOIN Alarm_Custom_Condition AS t2 ON
\xa                t1.alarm_id = t2.alarm_id\xd
            JOIN Station AS t3 ON
\xa                t1.station_id = t3.station_id          \xd
            JOIN variable_name AS t4 ON\xd\xa                t2.variable_id = t4.variable_id
            JOIn variable_info ON
                variable_info.variable_id = t2.variable_id
            JOIN alarm_types AS t6 ON
                t2.alarmTypeId = t6.id\xd\xa            JOIN contact_group AS CG ON\xd
                t1.contact_group_id = CG.group_id\xd
            WHERE\xd\xa                t1.active = 1 AND\xd\xa                groupId <> 0 AND
                multiCondition = 0 AND\xd\xa                t1.alarm_id = :alarmId", [":alarmId" => $alarmId]); } public function getAllBulkAlarms() { $query = "\xd\xa            SELECT\xd
                t1.*,\xd
                t2.*,\xd
                t3.station_name,
                t4.english_name,
                t6.name as typeName,
                CG.group_name,
\xa                variable_info.calculated_variable
            FROM alarm_custom as t1
            JOIN Alarm_Custom_Condition as t2 ON
\xa                t1.alarm_id = t2.alarm_id\xd\xa            JOIN Station as t3 ON\xd\xa                t1.station_id = t3.station_id          
\xa            JOIN variable_name as t4 ON
                t2.variable_id = t4.variable_id
            JOIn variable_info ON\xd
                variable_info.variable_id = t2.variable_id\xd
            JOIN alarm_types t6 ON\xd
                t2.alarmTypeId = t6.id
            JOIN contact_group as CG ON\xd\xa                t1.contact_group_id = CG.group_id
\xa            WHERE\xd\xa                t1.active = 1 AND\xd\xa                groupId <> 0 AND
\xa                multiCondition = 0
\xa            ORDER BY t1.groupId, t2.variable_id;"; $alarmParam = ["query" => $query, "db" => $this->db, "db_type" => $this->db_type]; $alarmStmt = vdv_prepare_query($alarmParam); $alarmStmt->execute(); $alarmResult = $alarmStmt->fetchAll(PDO::FETCH_ASSOC); return $alarmResult; } public function getAllBulkAlarmsForList() { $query = "SELECT t1.*, t2.*, t3.station_name, t4.english_name, t6.name as typeName, CG.group_name\xd
            FROM alarm_custom as t1
\xa            JOIN Alarm_Custom_Condition as t2 on t1.alarm_id = t2.alarm_id
            JOIN Station as t3 on t1.station_id = t3.station_id          \xd\xa            JOIN variable_name as t4 on t2.variable_id = t4.variable_id
\xa            JOIN alarm_types t6 on t2.alarmTypeId = t6.id
\xa            JOIN contact_group as CG ON t1.contact_group_id = CG.group_id\xd\xa            WHERE groupId <> 0 AND multiCondition = 0 
\xa            ORDER BY t1.groupId, t2.variable_id;"; $alarmParam = ["query" => $query, "db" => $this->db, "db_type" => $this->db_type]; $alarmStmt = vdv_prepare_query($alarmParam); $alarmStmt->execute(); $alarmResult = $alarmStmt->fetchAll(PDO::FETCH_ASSOC); return $alarmResult; } public function getCustomAlarms() { $query = "
\xa            SELECT\xd\xa                t1.*,
                t2.*,
                t3.station_name,
                t5.station_name as station_name_2,
\xa                t4.english_name,
                t6.name as typeName,
                variable_info.calculated_variable,
\xa                (SELECT c.id from alarm_csi_command as c where c.alarm_variable_id = t1.alarm_id limit 1) as alarm_command_id
\xa            FROM alarm_custom as t1\xd\xa            JOIN Alarm_Custom_Condition as t2 on t1.alarm_id = t2.alarm_id\xd
            JOIN Station as t3 on t1.station_id = t3.station_id
\xa            JOIN Station as t5 on t1.station_id = t5.station_id\xd\xa            JOIN variable_name as t4 on t2.variable_id = t4.variable_id
            JOIN variable_info ON variable_info.variable_id = t2.variable_id\xd\xa            LEFT JOIN alarm_types t6 on t2.alarmTypeId = t6.id\xd\xa            WHERE t1.active = 1 AND t1.groupId = 0 AND multiCondition = 0"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute([]); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; } private function getCustomAlarmsByGroupId(int $groupId) { $query = "\xd
            SELECT AC.*, ACC.alarm_condition_id, ACC.limit_value, ACC.limit_type, ACC.alarmTypeId, ACC.delay, 
\xa                    S.station_name, VM.english_name, ACC.variable_id, AC.timeAlarm, ACC.startTime, ACC.stopTime, 
\xa                    ACC.days, ACC.latest, ACC.period_hours, ACC.process, ACC.absolute_value, ACC.last_timestamp_check\xd\xa            FROM alarm_custom AS AC 
            JOIN alarm_custom_condition AS ACC ON AC.alarm_id = ACC.alarm_id\xd
            JOIN station AS S ON S.station_id = AC.station_id
\xa            JOIN variable_name AS VM ON VM.variable_id = ACC.variable_id
            WHERE AC.groupId = :groupId\xd
            ORDER BY ACC.limit_type, ACC.limit_value"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute([":groupId" => $groupId]); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; } public function getAllBulkAlarmsByUser() { $user = $_SESSION["user"]; $allUniqueGroupIds = []; if ($user["all_sites"] == 0) { $groups = $this->getAllGroupsByUserNotAdmin(); } else { if ($user["owner_group"] == 0 || $user["admin"] == 1) { $groups = $this->getAllAlarmGroups(); } else { $groups = $this->getAllGroupsByUserNotAdmin(); } } return $groups; } public function getAllGroupsByUserNotAdmin() { $user = $_SESSION["user"]; $groups = $this->getAllBulkAlarmsForList(); $userStationIds = array_column($user["sites"], "station_id"); $allUniqueGroupIds = array_unique(array_column($groups, "groupId")); foreach ($allUniqueGroupIds as $groupId) { $allBulkByGroupId = array_filter($groups, function ($val) use($groupId) { return $val["groupId"] == $groupId; }); $hasAccess = true; foreach ($allBulkByGroupId as $key => $bulk) { $stationId = $bulk["station_id"]; if (!in_array($stationId, $userStationIds)) { $hasAccess = false; break; } } if ($hasAccess == false) { $groups = array_filter($groups, function ($val) use($groupId) { return $val["groupId"] != $groupId; }); } } $allGroupsUserHasAccessTo = array_unique(array_column($groups, "groupId")); return $this->getAlarmGroupsByGroupIds($allGroupsUserHasAccessTo); } public function getActiveAlarm(int $alarmId) { $query = "SELECT * FROM Alarm_Custom_Active WHERE alarm_id = :alarmId;"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["alarmId" => $alarmId]); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result; } public function saveNewActiveAlarm($alarm, $value, $timestamp) { $query = "\xd
        INSERT INTO alarm_custom_active (alarm_id, alarm_timestamp, alarm_value,
\xa                      repeat_index, last_repeat_timestamp, alarm_on, confirmed)
        values (:alarm_id, :alarm_timestamp, :alarm_value, :repeat_index, :last_repeat_timestamp, :alarm_on, :confirmed)"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute([":alarm_id" => $alarm["alarm_id"], ":alarm_timestamp" => $timestamp, ":alarm_value" => $value, ":repeat_index" => 0, ":last_repeat_timestamp" => $alarm["alarm_timestamp"], ":alarm_on" => 1, ":confirmed" => 0]); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); } public function updateLastRepeatTimestamp(int $activeAlarmId) { $query = "
        UPDATE alarm_custom_active SET \xd\xa            last_repeat_timestamp = now(), \xd
            repeat_index = repeat_index + 1  \xd\xa        WHERE active_alarm_id = :active_alarm_id"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute([":active_alarm_id" => $activeAlarmId]); } public function updateLastTimestampCheck($alarmConditionId, $timestamp) { $query = "\xd\xa        UPDATE Alarm_Custom_Condition
        SET last_timestamp_check = :lastTimestamp
\xa        WHERE alarm_condition_id = :alarmConditionId;"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute([":lastTimestamp" => $timestamp, ":alarmConditionId" => $alarmConditionId]); } public function updateAlarmConditionDelayTimestamp($alarmConditionId, $timestamp) { $query = "\xd\xa        UPDATE alarm_custom_condition SET delayTimestamp = :timestamp \xd\xa        WHERE alarm_condition_id = :id"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute([":timestamp" => $timestamp, ":id" => $alarmConditionId]); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); } public function updateActiveAlarm($activeAlarmId, $alarmValue, $status, $timestamp) { $query = "
\xa        UPDATE alarm_custom_active \xd\xa          SET alarm_on = :alarmOn, \xd
          alarm_value = :alarmValue, 
          alarm_timestamp = :alarmTimestamp 
        WHERE active_alarm_id = :id;"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute([":alarmOn" => $status, ":alarmValue" => $alarmValue, ":id" => $activeAlarmId, ":alarmTimestamp" => $timestamp]); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); } public function getActiveAlarmByIdAndOnOffString($alarmId) { $query = "\xd\xa        SELECT t1.*, t2.*, t3.*, t4.*, t5.warning_on_string, t5.warning_off_string, t6.name AS typeName, t7.station_name,\xd
        (SELECT c.id from alarm_csi_command as c where c.alarm_variable_id = t1.alarm_id limit 1) as alarm_command_id
        FROM alarm_custom_active as t1\xd
        JOIN alarm_custom as t2 ON t1.alarm_id = t2.alarm_id
        JOIN alarm_custom_condition as t3 ON t1.alarm_id = t3.alarm_id
\xa        JOIN Variable_Name AS t4 ON t3.variable_id = t4.variable_id
        JOIN system_info as t5
\xa        JOIN station AS t7 ON t2.station_id = t7.station_id\xd\xa        LEFT JOIN alarm_types t6 on t6.id = t3.alarmTypeId
\xa        WHERE t1.alarm_id = :alarmId"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute([":alarmId" => $alarmId]); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result; } public function getActiveAlarmsAndOnOffString() { $query = "\xd
            SELECT t1.*, t2.*, t3.*, t4.*, t5.warning_on_string, t5.warning_off_string, t6.name AS typeName, t7.station_name\xd\xa            FROM alarm_custom_active as t1\xd\xa            JOIN alarm_custom as t2 ON t1.alarm_id = t2.alarm_id
            JOIN alarm_custom_condition as t3 ON t1.alarm_id = t3.alarm_id\xd\xa            JOIN Variable_Name AS t4 ON t3.variable_id = t4.variable_id\xd
            JOIN system_info as t5
\xa            JOIN station AS t7 ON t2.station_id = t7.station_id
            LEFT JOIN alarm_types t6 on t6.id = t3.alarmTypeId"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; } public function getRepeatAlarmsAndOnOffString() { $query = "\xd
            SELECT t1.*, t2.*, t3.*, t4.*, t5.warning_on_string, t5.warning_off_string, t6.name AS typeName, t7.station_name\xd
            FROM alarm_custom_active as t1\xd\xa            JOIN alarm_custom as t2 ON t1.alarm_id = t2.alarm_id\xd\xa            JOIN alarm_custom_condition as t3 ON t1.alarm_id = t3.alarm_id\xd\xa            JOIN Variable_Name AS t4 ON t3.variable_id = t4.variable_id\xd
            JOIN system_info as t5\xd
            JOIN station AS t7 ON t2.station_id = t7.station_id
\xa            LEFT JOIN alarm_types t6 on t6.id = t3.alarmTypeId\xd\xa            WHERE t2.repeat_minutes > 0 
              AND t1.alarm_on = 1
              AND t1.confirmed = 0\xd\xa              AND t2.multiCondition = 0
              AND (t1.last_repeat_timestamp < DATE_SUB(now(), INTERVAL t2.repeat_minutes MINUTE));"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; } public function getAlarmMessageHeaderAndFooter() { $query = "SELECT warning_email_header, warning_email_footer FROM system_info"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute([]); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result; } private function getAllAlarmGroups() { $query = "\xd
            select t1.*, count(distinct t4.variable_id) as variableCount, FLOOR(count(t2.alarm_id) / count(distinct t4.variable_id)) as limitCount, \xd\xa                   t3.group_name as contactGroupName, t2.active as active\xd\xa        from alarm_custom_group t1
        join alarm_custom t2 on t2.groupId = t1.id
\xa        join contact_group t3 on t3.group_id = t2.contact_group_id
\xa        join alarm_custom_condition t4 on t4.alarm_id = t2.alarm_id\xd
        group by t1.id"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; } private function getAlarmGroupsByGroupIds(array $groupIds) { if (count($groupIds) == 0) { return []; } $boundParameters = createBoundParameters($groupIds); $query = "select t1.*, count(distinct t4.variable_id) as variableCount, FLOOR(count(t2.alarm_id) / count(distinct t4.variable_id)) as limitCount, t3.group_name as contactGroupName, t2.active
        from alarm_custom_group t1
        join alarm_custom t2 on t2.groupId = t1.id
\xa        join contact_group t3 on t3.group_id = t2.contact_group_id\xd\xa        join alarm_custom_condition t4 on t4.alarm_id = t2.alarm_id
\xa        WHERE t2.groupId IN ({$boundParameters})
        group by t1.id"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); bindArrayParameters($stmt, $groupIds); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; } public function saveBulkAlarm(array $bulkAlarm) { $access = new AlarmAccess(); $contactCheck = $access->checkContactGroupId($bulkAlarm["contactGroupId"]); if ($contactCheck) { if ($bulkAlarm["groupId"] !== null) { if ($this->hasAccessToBulkAlarm($bulkAlarm["groupId"])) { return $this->updateBulkAlarm($bulkAlarm); } } else { return $this->saveNewBulkAlarm($bulkAlarm); } } } public function hasAccessToBulkAlarm($groupId) { if ($_SESSION["user"]["owner_group"] == 0 || $_SESSION["user"]["admin"] == 1) { return true; } $userAccessBulk = $this->getAllGroupsByUserNotAdmin(); $bulkIds = array_column($userAccessBulk, "id"); if (in_array($groupId, $bulkIds)) { return true; } return false; } public function deleteBulkGroup(int $groupId) { $hasAccess = $this->hasAccessToBulkAlarm($groupId); if ($hasAccess) { $alarms = $this->getCustomAlarmsByGroupId($groupId); $alarmIds = array(); foreach ($alarms as $alarm) { array_push($alarmIds, $alarm["alarm_id"]); } $alarmIds = implode(",", $alarmIds); $this->deleteCustomConditions($alarmIds); $this->deleteCustomActive($alarmIds); $this->deleteAlarmCustom($groupId); $this->deleteBulkAlarm($groupId); } } private function deleteCustomConditions(String $alarmIds) { $boundParameters = createBoundParameters($alarmIds); $query = "delete from alarm_custom_condition where alarm_id in ({$boundParameters});"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); bindArrayParameters($stmt, $alarmIds); $stmt->execute(); } private function deleteCustomActive(String $alarmIds) { $boundParameters = createBoundParameters($alarmIds); $query = "delete from alarm_custom_active where alarm_id in ({$boundParameters});"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); bindArrayParameters($stmt, $alarmIds); $stmt->execute(); } private function deleteAlarmCustom(int $groupId) { $query = "delete from alarm_custom where groupId = :groupId"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(array(":groupId" => $groupId)); } private function deleteBulkAlarm(int $groupId) { $query = "delete from alarm_custom_group where id = :groupId"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(array(":groupId" => $groupId)); } private function updateBulkAlarm(array $bulkAlarm) { $name = $bulkAlarm["name"]; $this->updateBulkAlarmGroup($name, $bulkAlarm["groupId"]); $this->updateBulkAlarms($bulkAlarm); $this->checkIfNewLimitWasAdded($bulkAlarm); $this->deleteAlarmsThatWereRemoved($bulkAlarm["variablesToDelete"]); } private function saveNewBulkAlarm(array $bulkAlarm) { $name = $bulkAlarm["name"]; $variables = $bulkAlarm["variableList"]; $limitsList = $bulkAlarm["limitsList"]; $newGroupId = $this->saveBulkAlarmGroup($name); $this->saveBulkAlarms($bulkAlarm, $newGroupId, $variables, $limitsList); return $newGroupId; } private function saveBulkAlarmGroup(string $name) { $query = "INSERT INTO alarm_custom_group (name) VALUES(:name)"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute([":name" => $name]); $newGroupId = $this->db->lastInsertId(); return $newGroupId; } private function updateBulkAlarmGroup(string $name, $id) { $query = "UPDATE alarm_custom_group SET name = :name WHERE id = :id"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute([":name" => $name, ":id" => $id]); } public function saveBulkAlarms(array $bulkAlarm, $groupId, $variables, $limitsList) { foreach ($variables as $variable) { $stationId = $variable["stationId"]; $stationLatestTimeStamp = $this->getLastTimestampCheckForAlarm($variable["stationId"]); foreach ($limitsList as $list) { $limits = $list["limits"]; foreach ($limits as $limit) { $newAlarmId = $this->saveCustomAlarm($bulkAlarm, $stationId, $groupId); $this->saveCustomAlarmCondition($newAlarmId, $variable, $limit, $stationLatestTimeStamp, $list, $bulkAlarm); } } } } private function updateBulkAlarms(array $bulkAlarms) { $variables = $bulkAlarms["variableList"]; foreach ($variables as $variable) { if ($variable["id"] === null) { $stationId = $variable["stationId"]; $stationLatestTimeStamp = $this->getLastTimestampCheckForAlarm($variable["stationId"]); foreach ($bulkAlarms["limitsList"] as $list) { foreach ($list["limits"] as $limit) { $newAlarmId = $this->saveCustomAlarm($bulkAlarms, $stationId, $bulkAlarms["groupId"]); $this->saveCustomAlarmCondition($newAlarmId, $variable, $limit, $stationLatestTimeStamp, $list, $bulkAlarms); } } } else { $this->updateCustomAlarm($bulkAlarms, $variable); if ($bulkAlarms["updateLastTimestampChange"] === true) { $lastTimestampCheck = $this->getLastTimestampCheckForAlarm($variable["stationId"]); $lastTimestampCheck = $lastTimestampCheck->format("Y-m-d H:i:s"); } else { $lastTimestampCheck = $variable["lastTimestampCheck"]; } $this->updateCustomAlarmCondition($variable, $bulkAlarms, $lastTimestampCheck); } } } private function checkIfNewLimitWasAdded($bulkAlarms) { $limitsList = $bulkAlarms["limitsList"]; $variables = $bulkAlarms["variableList"]; $uniqueIds = array_unique(array_column($variables, "variableId")); $uniqueVariables = array_intersect_key($variables, $uniqueIds); foreach ($limitsList as $list) { $limits = $list["limits"]; foreach ($limits as $limit) { if (!is_numeric($limit["id"])) { $tmpList = $list; $tmpList["limits"] = [$limit]; $this->saveBulkAlarms($bulkAlarms, $bulkAlarms["groupId"], $uniqueVariables, [$tmpList]); } } } } private function saveCustomAlarm($alarm, $stationId, $groupId) { $query = "
\xa        INSERT INTO Alarm_Custom (name, station_id, active, skip_off_alarm, contact_group_id, repeat_minutes, 
                                    subject, message, description, user_id, station_id_2, groupId, timeAlarm)\xd
        VALUES (:name, :station_id, :active, :skip_off_alarm, :contact_group_id, :repeat_minutes, 
\xa                 :subject, :message, :description, :user_id, :station_id_2, :groupId, :timeAlarm)"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type, "skipEscape" => [":subject", ":message", ":description"]); $stmt = vdv_prepare_query($param); $stmt->execute(array(":name" => $alarm["name"], ":station_id" => $stationId, ":active" => $alarm["monitor"] == true ? 1 : 0, ":skip_off_alarm" => $alarm["skipOffAlarm"] == true ? 1 : 0, ":contact_group_id" => $alarm["contactGroupId"], ":repeat_minutes" => $alarm["alarmRepeatMinutes"], ":subject" => $alarm["alarmSubject"], ":message" => nl2br($alarm["alarmMessage"]), ":description" => $alarm["alarmDescription"], ":user_id" => isset($_SESSION["user"]["user_id"]) ? $_SESSION["user"]["user_id"] : 0, ":station_id_2" => 0, ":groupId" => $groupId, ":timeAlarm" => $alarm["timeAlarm"] == true ? 1 : 0)); $newAlarmId = $this->db->lastInsertId(); return $newAlarmId; } private function updateCustomAlarm($alarm, $variable) { $query = "\xd
          UPDATE Alarm_Custom SET
\xa                name = :name,\xd\xa                station_id = :station_id,
                active = :active,\xd\xa                timeAlarm = :timeAlarm,
\xa                skip_off_alarm = :skip_off_alarm,
                contact_group_id = :contact_group_id,
\xa                repeat_minutes = :repeat_minutes,
\xa                subject = :subject,\xd\xa                message = :message,
\xa                description = :description,\xd
                user_id = :user_id                              \xd\xa        
                WHERE  alarm_id = :alarm_id;"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type, "skipEscape" => [":subject", ":message", ":description"]); $stmt = vdv_prepare_query($param); $stmt->execute(array(":name" => $alarm["name"], ":station_id" => $variable["stationId"], ":active" => $alarm["monitor"] == true ? 1 : 0, ":timeAlarm" => $alarm["timeAlarm"] == true ? 1 : 0, ":skip_off_alarm" => $alarm["skipOffAlarm"] == true ? 1 : 0, ":contact_group_id" => $alarm["contactGroupId"], ":repeat_minutes" => $alarm["alarmRepeatMinutes"], ":subject" => $alarm["alarmSubject"], ":message" => nl2br($alarm["alarmMessage"]), ":description" => $alarm["alarmDescription"], ":user_id" => $_SESSION["user"]["user_id"], ":alarm_id" => $variable["id"])); } private function deleteCustomAlarm($alarmId) { $query = "DELETE FROM alarm_custom WHERE alarm_id = :alarmId"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["alarmId" => $alarmId]); } private function saveCustomAlarmCondition($newAlarmId, $variable, $limit, $stationLatestTimeStamp, $limitList, $bulkAlarm) { $query = "
        INSERT INTO Alarm_Custom_Condition (alarm_id, variable_id, latest, limit_value, limit_type, process, \xd
            period_hours, absolute_value, last_timestamp_check, compare_type, variable_id_2, latest_2, 
            period_hours_2, process_2, absolute_value_2, offset_2, alarmTypeId, delay, startTime, stopTime, days)
            VALUES (:alarm_id, :variable_id, :latest, :limit_value, :limit_type, :process, \xd\xa            :period_hours, :absolute_value, :last_timestamp_check, :compare_type, :variable_id_2, \xd\xa            :latest_2, :period_hours_2, :process_2, :absolute_value_2, :offset_2, :alarmTypeId, :delay, \xd
            :startTime, :stopTime, :days)"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(array(":alarm_id" => $newAlarmId, ":variable_id" => $variable["variableId"], ":latest" => $bulkAlarm["latest"], ":limit_value" => $limit["value"], ":limit_type" => $limit["symbol"], ":process" => $bulkAlarm["process"], ":period_hours" => $bulkAlarm["periodHours"], ":absolute_value" => $bulkAlarm["absoluteValue"], ":last_timestamp_check" => $stationLatestTimeStamp->format("Y-m-d H:i:s"), ":compare_type" => 0, ":variable_id_2" => 0, ":latest_2" => 0, ":period_hours_2" => 0, ":process_2" => 0, ":absolute_value_2" => 0, ":offset_2" => 0, ":alarmTypeId" => $limit["alarmType"]["id"], ":delay" => $limit["delay"], ":startTime" => $limitList["startTime"], ":stopTime" => $limitList["stopTime"], ":days" => implode(",", $limitList["days"]))); } private function updateCustomAlarmCondition($variable, $bulkAlarm, $lastTimestampCheck) { $query = "\xd\xa            UPDATE Alarm_Custom_Condition SET
\xa            latest = :latest,
\xa            period_hours = :periodHours,
            process = :process,
            absolute_value = :absoluteValue,           
\xa            last_timestamp_check = :lastTimestampCheck,          \xd
            limit_value = :limitValue,\xd
            limit_type = :limitType,\xd
            alarmTypeId= :alarmTypeId,
\xa            delay = :delay,
\xa            startTime = :startTime,
            stopTime = :stopTime,
            days = :days          \xd
            WHERE alarm_condition_id = :alarmConditionId"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute([":latest" => $bulkAlarm["latest"], ":periodHours" => $bulkAlarm["periodHours"], ":process" => $bulkAlarm["process"], ":absoluteValue" => $bulkAlarm["absoluteValue"], ":lastTimestampCheck" => $lastTimestampCheck, "limitValue" => $variable["value"], ":limitType" => $variable["symbol"], ":alarmTypeId" => $variable["alarmTypeId"], ":delay" => $variable["delay"], ":startTime" => $variable["startTime"], ":stopTime" => $variable["stopTime"], ":days" => implode(",", $variable["days"]), ":alarmConditionId" => $variable["alarmConditionId"]]); } private function deleteCustomAlarmCondition($alarmId) { $query = "DELETE FROM alarm_custom_condition WHERE alarm_id = :alarmId"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["alarmId" => $alarmId]); } public function deleteCustomAlarmActive($alarmId) { $query = "DELETE FROM alarm_custom_active WHERE alarm_id = :alarmId"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["alarmId" => $alarmId]); } private function deleteAlarmsThatWereRemoved($variables) { foreach ($variables as $variable) { $alarmId = $variable["id"]; $this->deleteCustomAlarm($alarmId); $this->deleteCustomAlarmCondition($alarmId); $this->deleteCustomAlarmActive($alarmId); } } private function getLastTimestampCheckForAlarm($stationId) { $stationLatestTimeStamp = $this->getMaxTimestampFromStationId($stationId); $latestStationTimestamp = new DateTime($stationLatestTimeStamp); return $latestStationTimestamp; } public function getMaxTimestampFromStationId($stationId) { $query = "SELECT MAX(last_timestamp) as timestamp FROM File_Path WHERE station_id = :stationId"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["stationId" => $stationId]); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result["timestamp"]; } public function checkIfvariableHasAlarm($variable) { $query = "
        SELECT ac.*,at.color,at.rank,at.name\xd\xa        FROM alarm_custom_condition AS ac            \xd\xa        JOIN alarm_custom AS alarmCustom ON ac.alarm_id = alarmCustom.alarm_id
\xa        JOIN alarm_types AS at on ac.alarmTypeId = at.id 
\xa        JOIN alarm_custom_active AS aa on ac.alarm_id = aa.alarm_id\xd
        WHERE variable_id = :variableId and aa.alarm_on = 1 AND alarmCustom.active = 1\xd
        ORDER BY at.rank DESC;"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(array("variableId" => $variable["variable_id"])); return $stmt->fetchAll(PDO::FETCH_ASSOC); } public function checkIfvariableHasCustomAlarm($variable) { $query = "\xd\xa        SELECT ac.*,alarmCustom.active as alarmActive\xd\xa        FROM alarm_custom_condition AS ac \xd\xa        JOIN alarm_custom_active AS aa on ac.alarm_id = aa.alarm_id
\xa        JOIN alarm_custom AS alarmCustom on alarmCustom.alarm_id = aa.alarm_id\xd\xa        WHERE variable_id = :variableId and aa.alarm_on = 1
        ORDER BY alarmActive DESC;"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(array("variableId" => $variable["variable_id"])); return $stmt->fetchAll(PDO::FETCH_ASSOC); } public function variableHasAssignedAlarm($variableId) { $query = "
\xa            SELECT count(*) as variableCount\xd
            FROM alarm_custom_condition AS ac            \xd
            JOIN alarm_custom AS alarmCustom ON ac.alarm_id = alarmCustom.alarm_id
            WHERE variable_id = :variableId AND alarmCustom.active = 1"; $param = array("query" => $query, "db" => $this->db, "db_type" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(array("variableId" => $variableId)); $result = $stmt->fetch(PDO::FETCH_ASSOC); if ($result !== false && is_array($result) && $result["variableCount"] > 0) { return true; } return false; } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace VDV\Alarm\Model; use VDV\Alarm\Model\AlarmAccess; use VDV\Database\Model\Db; use PDO; use DateTime; class BulkAlarmDb extends Db { public function getBulkAlarmById(int $groupId) { if ($this->hasAccessToBulkAlarm($groupId)) { $bulkAlarms = $this->getCustomAlarmsByGroupId($groupId); return $bulkAlarms; } return 0; } public function getBulkAlarmByAlarmId(int $alarmId) { return $this->getRow("\xd\xa\x20\40\x20\x20\x20\x20\x20\x20\40\x20\40\40\123\x45\x4c\105\x43\x54\15\xa\40\40\x20\40\x20\40\40\x20\40\40\40\40\x20\x20\x20\40\164\61\56\x2a\54\xd\xa\x20\x20\40\x20\x20\40\x20\x20\40\40\40\40\40\40\40\x20\164\62\56\52\54\15\xa\40\40\x20\40\x20\40\40\40\40\40\40\40\40\x20\40\x20\164\63\x2e\163\x74\x61\x74\x69\157\x6e\x5f\x6e\141\155\145\x2c\xd\xa\x20\x20\40\40\40\40\x20\x20\40\x20\x20\40\40\x20\x20\40\x74\64\56\145\x6e\147\154\x69\x73\150\137\x6e\x61\x6d\x65\54\xd\12\40\x20\x20\40\40\40\x20\40\x20\x20\40\x20\40\x20\x20\x20\164\x36\56\156\x61\155\x65\x20\x61\163\40\x74\171\160\x65\x4e\141\x6d\145\54\xd\xa\40\x20\x20\40\40\40\40\x20\x20\40\x20\40\x20\x20\x20\x20\103\x47\x2e\x67\x72\x6f\165\160\x5f\x6e\141\x6d\x65\54\15\xa\x20\40\40\40\x20\40\x20\40\x20\x20\40\x20\40\x20\x20\40\x76\141\162\x69\x61\142\154\145\x5f\x69\156\146\x6f\x2e\143\x61\154\x63\165\x6c\141\x74\x65\144\137\166\141\x72\x69\141\x62\154\145\xd\12\x20\40\x20\40\40\40\40\x20\40\40\40\x20\x46\122\x4f\x4d\x20\x61\x6c\x61\162\155\137\x63\x75\x73\x74\157\155\40\101\123\40\164\61\15\12\40\x20\40\40\x20\x20\x20\40\40\x20\x20\40\112\117\111\116\x20\x41\154\x61\x72\155\x5f\x43\x75\x73\x74\x6f\x6d\x5f\103\157\x6e\x64\151\164\151\157\156\40\x41\123\40\x74\62\x20\x4f\x4e\15\xa\x20\x20\x20\x20\x20\40\x20\40\40\x20\x20\x20\x20\x20\x20\x20\164\x31\x2e\x61\154\x61\162\155\137\151\144\x20\x3d\40\x74\62\x2e\141\x6c\141\x72\155\137\151\x64\xd\12\x20\40\x20\x20\40\x20\x20\40\40\x20\x20\40\112\117\x49\116\x20\123\164\x61\164\151\x6f\156\x20\101\123\40\164\x33\40\x4f\x4e\15\xa\x20\x20\40\40\x20\40\x20\x20\x20\x20\40\40\40\40\40\40\164\x31\56\x73\x74\141\164\151\157\x6e\x5f\x69\x64\40\75\40\x74\x33\56\163\x74\141\164\x69\157\156\137\x69\144\x20\40\x20\40\40\40\40\x20\40\x20\xd\12\40\x20\40\40\40\x20\x20\x20\40\40\40\40\112\x4f\x49\116\x20\x76\141\x72\151\x61\142\x6c\x65\137\156\141\155\145\40\101\123\40\164\x34\x20\117\x4e\xd\xa\x20\40\40\40\x20\40\x20\40\x20\x20\x20\x20\40\40\40\40\x74\x32\x2e\166\141\162\151\x61\x62\154\x65\137\x69\x64\x20\75\x20\164\x34\x2e\x76\x61\162\x69\x61\x62\x6c\145\x5f\x69\144\15\12\40\x20\40\40\40\40\x20\40\40\x20\x20\40\x4a\x4f\x49\156\x20\166\141\x72\151\141\142\x6c\145\x5f\x69\156\x66\x6f\x20\x4f\116\15\12\40\40\x20\40\x20\40\40\40\x20\x20\x20\x20\40\40\40\x20\166\141\162\x69\141\142\x6c\x65\x5f\151\x6e\x66\x6f\56\166\141\x72\151\141\142\x6c\145\x5f\151\x64\x20\75\x20\164\62\x2e\166\141\x72\x69\x61\142\x6c\145\137\x69\144\15\12\40\x20\x20\x20\x20\40\40\x20\x20\x20\x20\x20\112\x4f\x49\116\x20\x61\154\x61\x72\x6d\x5f\x74\x79\160\145\x73\40\101\123\x20\164\x36\x20\x4f\116\15\12\x20\x20\x20\x20\40\x20\x20\40\40\x20\x20\40\40\40\x20\40\x74\x32\56\x61\x6c\141\x72\155\124\171\160\145\111\144\x20\75\x20\x74\66\56\x69\x64\xd\xa\x20\x20\x20\40\x20\x20\40\x20\40\x20\x20\x20\x4a\117\x49\116\x20\x63\x6f\156\x74\141\x63\x74\137\x67\x72\157\165\160\x20\x41\123\40\103\107\40\117\116\xd\12\40\x20\40\40\40\x20\x20\40\x20\40\x20\x20\40\40\40\x20\164\61\56\x63\x6f\156\x74\141\x63\164\x5f\147\162\157\165\160\137\151\144\40\x3d\40\x43\107\x2e\147\162\x6f\165\x70\x5f\x69\144\xd\12\x20\40\40\40\40\x20\x20\40\x20\x20\40\40\x57\x48\x45\122\x45\xd\xa\40\x20\x20\x20\40\40\x20\40\x20\40\x20\40\40\x20\40\40\164\x31\x2e\141\x63\x74\151\166\x65\x20\x3d\x20\61\40\x41\116\x44\xd\xa\40\40\40\40\40\x20\40\x20\40\x20\40\x20\x20\40\x20\x20\x67\x72\157\165\x70\x49\144\x20\74\x3e\x20\60\40\101\116\x44\15\12\40\40\40\40\40\x20\x20\x20\x20\x20\40\x20\x20\x20\40\40\x6d\165\x6c\x74\x69\x43\x6f\x6e\144\151\x74\151\157\156\40\x3d\40\x30\40\x41\116\104\xd\xa\x20\40\x20\x20\40\x20\x20\40\40\x20\x20\x20\40\x20\40\40\164\61\x2e\x61\154\141\x72\155\137\x69\x64\40\x3d\x20\x3a\x61\x6c\x61\x72\x6d\x49\144", ["\x3a\x61\154\x61\x72\x6d\x49\x64" => $alarmId]); } public function getAllBulkAlarms() { $query = "\xd\xa\40\40\40\40\x20\x20\x20\40\x20\x20\40\x20\123\x45\x4c\x45\103\x54\xd\12\40\40\x20\40\x20\40\40\x20\x20\x20\40\x20\x20\x20\x20\x20\x74\x31\x2e\52\x2c\xd\12\x20\40\40\40\x20\x20\40\x20\40\40\x20\40\x20\x20\40\x20\164\62\56\x2a\54\xd\12\x20\40\x20\40\40\40\x20\40\40\x20\40\40\x20\x20\x20\40\x74\63\56\163\x74\141\x74\151\x6f\x6e\x5f\x6e\141\155\x65\x2c\15\12\x20\40\40\x20\40\x20\x20\40\x20\40\40\x20\40\x20\40\x20\164\64\x2e\x65\x6e\147\154\151\163\150\x5f\x6e\141\x6d\x65\x2c\15\12\x20\x20\x20\x20\40\40\40\x20\x20\x20\x20\x20\x20\40\x20\40\164\66\x2e\x6e\141\x6d\145\40\x61\x73\40\x74\x79\160\x65\116\141\155\145\54\15\12\x20\x20\40\40\x20\x20\x20\40\x20\40\40\40\40\40\x20\40\x43\x47\56\x67\x72\x6f\165\160\x5f\x6e\141\x6d\x65\54\15\xa\x20\40\40\40\40\x20\x20\40\40\40\40\x20\40\40\40\40\x76\141\162\151\141\142\154\145\x5f\151\156\x66\x6f\x2e\x63\x61\x6c\x63\165\154\x61\164\145\144\137\x76\x61\162\x69\141\142\154\x65\15\12\40\40\x20\x20\x20\x20\x20\40\x20\x20\40\x20\106\122\x4f\115\x20\141\x6c\x61\162\155\137\x63\x75\x73\164\157\x6d\x20\x61\163\40\x74\x31\15\12\40\40\x20\40\x20\40\40\40\x20\x20\40\40\x4a\x4f\x49\x4e\40\x41\154\141\x72\155\x5f\103\165\x73\164\x6f\x6d\137\x43\157\156\144\151\x74\x69\x6f\x6e\40\141\163\x20\164\62\x20\117\x4e\15\xa\x20\40\40\40\x20\x20\40\40\x20\x20\x20\x20\40\40\40\40\164\x31\56\141\154\141\x72\x6d\x5f\151\144\40\75\x20\x74\x32\56\x61\x6c\x61\x72\155\x5f\x69\x64\xd\xa\x20\40\x20\x20\x20\x20\40\x20\x20\x20\x20\x20\x4a\x4f\x49\116\40\123\164\141\164\x69\x6f\156\40\141\163\40\x74\63\x20\117\x4e\xd\xa\x20\x20\x20\x20\40\x20\x20\x20\x20\x20\40\40\x20\x20\40\x20\164\x31\56\x73\x74\x61\164\151\157\x6e\137\151\144\x20\x3d\40\x74\63\x2e\163\164\141\164\x69\x6f\x6e\x5f\151\x64\40\40\40\40\x20\x20\x20\40\x20\x20\15\xa\x20\x20\x20\x20\40\40\40\x20\40\40\40\40\112\x4f\x49\x4e\x20\166\x61\162\x69\141\142\154\x65\x5f\x6e\141\x6d\145\40\x61\163\40\164\x34\x20\117\116\15\12\x20\40\40\40\40\40\40\x20\40\40\40\x20\40\x20\x20\40\x74\x32\56\x76\141\x72\x69\141\x62\154\145\x5f\151\x64\40\x3d\x20\x74\x34\x2e\166\141\162\151\141\x62\154\145\137\151\x64\15\12\x20\x20\x20\x20\x20\x20\x20\40\40\40\40\x20\112\117\111\x6e\40\x76\x61\162\x69\x61\142\154\145\137\151\x6e\x66\x6f\40\117\116\xd\12\x20\x20\x20\x20\x20\40\x20\40\x20\40\40\40\40\x20\x20\x20\x76\141\162\151\141\142\x6c\145\x5f\x69\156\146\157\56\x76\x61\162\x69\141\x62\154\145\137\x69\x64\x20\75\40\164\x32\x2e\166\x61\x72\151\141\x62\x6c\x65\x5f\x69\144\xd\12\40\40\x20\40\40\x20\40\40\x20\x20\40\40\112\x4f\x49\x4e\40\141\154\x61\162\155\x5f\164\x79\160\x65\x73\40\x74\x36\40\117\116\xd\12\x20\40\x20\x20\40\40\x20\40\x20\x20\x20\x20\x20\40\40\40\164\x32\x2e\x61\x6c\x61\x72\x6d\124\x79\x70\x65\111\x64\40\75\40\x74\66\56\151\x64\15\12\x20\x20\x20\x20\x20\40\x20\x20\x20\x20\40\40\x4a\x4f\111\116\x20\143\157\156\x74\141\143\x74\137\x67\x72\157\x75\x70\x20\141\163\x20\x43\x47\x20\x4f\x4e\xd\xa\40\40\40\x20\x20\40\x20\40\40\x20\40\x20\x20\x20\x20\x20\x74\61\56\x63\157\156\x74\141\x63\x74\137\147\x72\x6f\x75\160\x5f\x69\144\x20\x3d\x20\103\107\x2e\x67\x72\x6f\165\x70\137\151\x64\15\xa\40\40\40\40\40\x20\x20\40\x20\x20\x20\x20\x57\x48\105\x52\105\xd\xa\x20\x20\x20\x20\x20\40\x20\40\40\x20\x20\40\40\x20\40\40\x74\x31\56\141\x63\x74\x69\166\145\x20\75\40\61\40\x41\x4e\x44\xd\xa\40\x20\40\40\x20\40\40\x20\x20\40\x20\40\40\x20\x20\x20\x67\162\157\x75\x70\111\x64\40\x3c\x3e\x20\x30\40\101\116\x44\15\xa\40\x20\40\40\40\x20\40\40\x20\40\x20\x20\40\x20\40\x20\155\x75\x6c\x74\x69\103\x6f\156\x64\x69\164\151\157\156\40\x3d\40\60\15\xa\x20\x20\x20\40\40\x20\40\x20\x20\x20\40\x20\x4f\x52\x44\105\122\x20\x42\131\x20\x74\x31\56\x67\162\157\x75\160\111\x64\54\40\164\x32\x2e\166\x61\162\151\141\142\154\145\137\151\x64\73"; $alarmParam = ["\161\x75\145\x72\x79" => $query, "\144\142" => $this->db, "\144\142\137\164\x79\x70\x65" => $this->db_type]; $alarmStmt = vdv_prepare_query($alarmParam); $alarmStmt->execute(); $alarmResult = $alarmStmt->fetchAll(PDO::FETCH_ASSOC); return $alarmResult; } public function getAllBulkAlarmsForList() { $query = "\123\x45\x4c\x45\x43\124\40\164\x31\56\x2a\54\x20\164\x32\56\52\54\40\164\x33\x2e\163\164\x61\x74\x69\x6f\156\137\x6e\x61\155\x65\54\x20\x74\64\56\145\156\147\154\151\163\150\x5f\x6e\141\155\145\x2c\x20\x74\66\56\156\141\x6d\x65\40\141\163\x20\x74\171\160\x65\x4e\x61\x6d\145\x2c\40\103\107\56\x67\162\157\165\160\x5f\156\x61\155\145\xd\12\40\x20\40\x20\x20\x20\40\x20\x20\40\x20\x20\106\122\117\x4d\x20\141\x6c\141\162\x6d\137\143\x75\163\164\x6f\x6d\x20\141\163\x20\x74\61\15\xa\40\x20\x20\40\x20\x20\40\x20\40\x20\40\x20\112\117\111\116\40\x41\x6c\141\162\155\x5f\x43\x75\x73\x74\x6f\155\x5f\103\x6f\x6e\x64\x69\164\x69\x6f\156\40\x61\x73\40\x74\x32\x20\x6f\x6e\40\x74\x31\56\141\x6c\141\x72\155\x5f\x69\144\40\75\x20\164\x32\x2e\141\x6c\x61\x72\x6d\x5f\151\144\15\12\40\x20\x20\40\40\40\40\x20\x20\40\40\40\x4a\x4f\x49\x4e\x20\123\164\141\x74\x69\x6f\x6e\40\x61\x73\40\164\x33\40\x6f\x6e\40\x74\x31\56\163\164\x61\164\x69\157\156\x5f\151\x64\x20\75\40\164\63\x2e\x73\x74\141\x74\x69\x6f\156\137\151\144\x20\40\x20\x20\x20\x20\x20\40\x20\x20\xd\xa\x20\40\x20\40\x20\40\40\x20\x20\40\40\40\112\117\111\116\40\x76\141\x72\151\141\142\x6c\145\x5f\x6e\141\155\x65\40\x61\163\x20\164\64\x20\157\x6e\40\x74\62\56\166\x61\162\x69\141\x62\x6c\x65\x5f\x69\144\x20\x3d\x20\x74\x34\x2e\166\x61\x72\x69\x61\x62\x6c\145\x5f\151\x64\15\xa\x20\40\40\40\40\40\40\40\40\x20\40\x20\x4a\117\111\116\x20\x61\154\x61\162\155\137\x74\x79\160\x65\163\x20\164\66\x20\157\156\x20\164\x32\x2e\x61\x6c\141\x72\x6d\124\x79\160\145\x49\144\40\x3d\40\x74\x36\x2e\151\x64\15\xa\40\x20\40\x20\x20\x20\x20\40\x20\x20\x20\x20\112\117\x49\116\40\x63\x6f\x6e\164\141\x63\x74\x5f\147\x72\157\x75\160\40\141\x73\40\x43\107\x20\x4f\116\x20\x74\x31\56\x63\x6f\156\164\x61\x63\x74\137\x67\162\x6f\x75\x70\x5f\x69\x64\x20\75\x20\103\107\x2e\147\162\157\x75\x70\x5f\x69\144\xd\xa\x20\40\x20\40\x20\40\x20\40\x20\40\40\x20\x57\x48\105\122\105\40\147\162\x6f\x75\x70\x49\144\40\x3c\x3e\x20\60\40\101\x4e\x44\40\x6d\x75\x6c\x74\x69\103\157\x6e\x64\151\164\151\x6f\156\40\x3d\x20\x30\x20\15\xa\x20\40\40\40\40\40\x20\40\40\40\40\x20\x4f\122\104\105\x52\40\102\x59\x20\164\x31\56\147\x72\157\165\160\111\144\54\40\x74\62\x2e\x76\141\x72\x69\141\142\154\x65\137\151\x64\x3b"; $alarmParam = ["\161\x75\x65\162\x79" => $query, "\x64\142" => $this->db, "\x64\142\x5f\x74\171\x70\145" => $this->db_type]; $alarmStmt = vdv_prepare_query($alarmParam); $alarmStmt->execute(); $alarmResult = $alarmStmt->fetchAll(PDO::FETCH_ASSOC); return $alarmResult; } public function getCustomAlarms() { $query = "\15\xa\x20\40\40\x20\x20\x20\40\40\x20\40\x20\40\x53\x45\114\105\103\124\xd\xa\x20\x20\x20\x20\40\40\40\x20\40\x20\40\40\40\x20\x20\x20\164\61\x2e\x2a\54\15\12\40\40\x20\x20\40\x20\40\x20\x20\x20\40\x20\x20\40\x20\x20\164\62\x2e\x2a\x2c\15\12\40\40\40\x20\x20\x20\40\40\40\x20\x20\x20\40\x20\x20\40\x74\x33\x2e\163\164\141\x74\151\157\x6e\x5f\156\141\155\145\x2c\15\12\40\x20\40\x20\x20\40\40\40\x20\40\40\40\40\40\x20\x20\164\65\x2e\163\x74\141\x74\151\x6f\156\137\x6e\x61\155\145\40\x61\x73\40\163\164\141\164\x69\x6f\x6e\x5f\x6e\x61\155\145\137\x32\x2c\15\xa\x20\40\x20\40\x20\x20\40\40\x20\40\x20\40\x20\x20\40\x20\x74\64\56\x65\156\x67\154\151\x73\150\137\156\141\x6d\145\x2c\15\12\x20\x20\x20\x20\x20\x20\40\40\x20\x20\40\40\x20\x20\x20\x20\x74\x36\x2e\x6e\141\155\x65\40\141\x73\x20\x74\171\160\x65\x4e\x61\x6d\x65\54\15\12\x20\x20\x20\x20\40\40\x20\40\x20\40\x20\x20\40\40\40\40\166\141\162\151\x61\142\154\x65\x5f\151\156\x66\x6f\56\x63\x61\154\143\165\154\141\x74\x65\144\137\x76\141\x72\151\x61\x62\x6c\x65\x2c\15\xa\x20\40\x20\x20\x20\40\40\40\x20\x20\40\40\40\x20\40\x20\x28\x53\x45\x4c\x45\x43\x54\40\x63\56\x69\x64\40\x66\162\x6f\155\x20\141\x6c\x61\162\155\137\143\x73\151\x5f\x63\x6f\x6d\155\141\x6e\144\40\141\163\40\x63\x20\167\x68\x65\x72\145\x20\x63\56\141\154\141\x72\155\x5f\x76\x61\162\x69\x61\142\154\x65\x5f\x69\x64\x20\75\40\x74\x31\x2e\141\x6c\x61\x72\x6d\x5f\x69\144\x20\x6c\151\155\x69\164\40\61\51\x20\x61\163\40\141\154\141\x72\x6d\137\x63\x6f\x6d\155\x61\156\144\137\x69\144\15\xa\40\40\40\x20\40\x20\x20\40\40\40\40\x20\106\x52\x4f\x4d\40\141\154\141\x72\155\137\143\x75\163\x74\157\155\40\141\x73\40\164\61\xd\xa\x20\40\x20\x20\x20\x20\x20\40\x20\40\40\40\x4a\117\x49\x4e\40\x41\x6c\141\x72\155\137\x43\165\x73\x74\157\x6d\137\103\157\156\144\x69\x74\x69\157\x6e\40\x61\x73\40\x74\62\x20\157\x6e\x20\164\61\x2e\141\x6c\141\x72\155\x5f\151\144\40\x3d\x20\164\x32\56\141\x6c\x61\x72\155\x5f\151\144\xd\12\40\x20\40\40\x20\x20\x20\x20\x20\40\40\40\x4a\x4f\111\116\x20\x53\x74\x61\164\x69\157\156\x20\x61\x73\40\164\63\40\x6f\156\40\164\x31\x2e\163\x74\x61\164\151\157\156\137\x69\x64\x20\75\x20\x74\x33\x2e\x73\164\x61\x74\151\157\156\x5f\151\144\15\xa\x20\x20\x20\x20\40\x20\x20\x20\40\40\x20\40\112\117\111\x4e\40\x53\164\141\x74\151\157\156\x20\141\x73\x20\x74\x35\40\x6f\156\40\164\61\56\x73\x74\x61\164\x69\157\x6e\x5f\151\x64\40\x3d\x20\x74\65\x2e\163\x74\x61\164\x69\x6f\x6e\x5f\x69\x64\xd\xa\x20\x20\x20\40\40\x20\x20\40\40\40\x20\x20\112\117\111\x4e\40\x76\141\162\151\141\142\x6c\x65\x5f\156\141\155\x65\x20\141\163\40\164\64\40\x6f\x6e\x20\164\62\56\x76\141\162\x69\141\x62\x6c\x65\x5f\x69\x64\x20\x3d\40\x74\x34\x2e\166\x61\162\151\141\142\154\x65\137\151\144\15\12\x20\40\x20\40\40\40\x20\x20\x20\40\x20\x20\x4a\117\x49\x4e\40\166\141\x72\151\141\142\154\x65\x5f\151\x6e\x66\157\x20\x4f\116\x20\166\x61\x72\151\x61\142\x6c\145\137\x69\156\x66\157\56\166\x61\162\151\141\142\x6c\x65\137\x69\x64\x20\x3d\40\x74\x32\56\166\141\162\151\x61\x62\154\x65\x5f\x69\x64\xd\xa\40\40\40\40\x20\x20\x20\40\40\x20\x20\x20\114\x45\106\x54\x20\x4a\x4f\x49\x4e\x20\x61\154\141\162\x6d\137\x74\x79\x70\x65\163\x20\164\66\40\x6f\x6e\40\164\62\x2e\x61\154\141\162\x6d\x54\171\160\145\x49\x64\40\x3d\40\x74\66\56\x69\x64\xd\xa\x20\x20\x20\x20\x20\x20\40\x20\40\x20\x20\40\127\110\x45\122\x45\40\164\61\56\x61\x63\x74\151\x76\145\40\75\40\61\40\101\x4e\x44\x20\164\x31\56\147\162\157\165\160\111\144\40\x3d\40\x30\x20\x41\x4e\104\40\x6d\165\x6c\164\151\x43\x6f\156\144\x69\164\x69\x6f\x6e\40\75\x20\60"; $param = array("\161\165\145\162\171" => $query, "\144\x62" => $this->db, "\x64\x62\x5f\164\x79\160\145" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute([]); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; } private function getCustomAlarmsByGroupId(int $groupId) { $query = "\xd\12\40\x20\x20\40\x20\40\40\40\40\x20\40\40\123\105\x4c\x45\103\124\x20\x41\x43\x2e\x2a\x2c\x20\101\103\x43\56\141\154\141\162\155\x5f\143\x6f\156\144\151\x74\x69\x6f\x6e\137\151\144\x2c\40\101\103\103\x2e\154\x69\x6d\x69\164\x5f\166\x61\154\x75\x65\x2c\40\101\x43\103\56\x6c\151\x6d\x69\x74\137\164\171\x70\x65\54\40\101\103\x43\x2e\141\154\141\x72\155\x54\171\160\145\x49\x64\54\40\101\103\x43\x2e\144\145\154\x61\x79\54\40\15\xa\40\40\40\40\x20\x20\40\40\x20\40\x20\40\40\40\x20\40\x20\x20\40\40\x53\56\163\164\141\x74\x69\x6f\x6e\x5f\156\x61\155\x65\x2c\x20\126\x4d\56\x65\x6e\147\x6c\x69\x73\x68\137\x6e\x61\155\145\54\x20\x41\x43\x43\x2e\166\x61\x72\x69\x61\142\x6c\x65\137\151\x64\x2c\x20\x41\103\x2e\164\x69\x6d\x65\101\x6c\x61\x72\155\54\40\101\x43\x43\56\x73\x74\x61\162\164\124\x69\155\x65\x2c\40\101\103\x43\x2e\x73\164\x6f\x70\124\x69\155\145\54\x20\15\xa\40\40\x20\x20\40\x20\40\40\40\40\40\40\x20\40\x20\40\x20\x20\40\40\x41\103\x43\x2e\144\x61\x79\163\x2c\40\x41\x43\x43\x2e\154\141\x74\x65\x73\164\x2c\x20\x41\103\103\x2e\160\145\x72\151\157\144\x5f\150\x6f\165\162\163\x2c\x20\101\103\103\56\x70\162\x6f\x63\x65\x73\x73\54\40\101\103\103\x2e\141\x62\x73\157\154\x75\164\x65\137\166\141\x6c\165\145\54\x20\101\103\103\56\x6c\x61\163\x74\137\x74\x69\155\x65\x73\x74\x61\155\x70\x5f\x63\x68\x65\x63\153\xd\xa\40\x20\40\x20\40\x20\40\x20\x20\x20\40\40\106\122\117\115\x20\x61\x6c\141\162\155\x5f\x63\165\163\164\x6f\155\40\x41\123\40\x41\x43\40\15\12\40\40\x20\40\x20\40\40\40\x20\x20\x20\40\112\x4f\111\x4e\40\141\x6c\x61\x72\x6d\x5f\143\165\x73\x74\157\155\137\143\x6f\x6e\144\x69\x74\151\x6f\156\40\x41\123\x20\101\x43\x43\x20\x4f\x4e\40\101\x43\56\141\x6c\141\x72\155\x5f\151\144\x20\x3d\40\x41\103\x43\56\x61\154\141\162\155\137\151\x64\xd\12\40\x20\x20\x20\40\40\40\x20\x20\40\x20\x20\x4a\x4f\111\116\40\x73\164\x61\x74\x69\x6f\x6e\x20\101\x53\40\123\40\x4f\x4e\40\123\x2e\x73\164\141\x74\151\x6f\156\x5f\151\144\40\75\40\101\103\56\x73\x74\141\164\151\157\x6e\x5f\151\144\15\xa\x20\x20\40\40\x20\40\40\40\x20\x20\x20\40\x4a\x4f\x49\116\40\x76\141\162\x69\141\142\154\x65\x5f\156\141\x6d\x65\x20\101\123\40\x56\115\x20\x4f\116\x20\126\115\x2e\166\x61\x72\151\x61\142\154\145\x5f\x69\144\x20\75\x20\101\x43\103\56\166\x61\x72\151\x61\142\154\x65\137\151\x64\15\12\40\x20\x20\x20\x20\x20\x20\x20\40\40\40\x20\127\110\x45\122\105\x20\x41\103\x2e\147\162\x6f\x75\160\x49\144\x20\75\40\72\147\x72\x6f\x75\160\111\144\xd\12\x20\x20\x20\40\x20\x20\40\40\40\x20\x20\40\117\x52\104\x45\x52\40\102\131\x20\101\103\103\x2e\154\151\155\151\164\137\x74\171\x70\x65\x2c\x20\101\x43\103\56\x6c\x69\155\x69\164\137\x76\141\x6c\165\x65"; $param = array("\x71\x75\145\162\171" => $query, "\144\x62" => $this->db, "\144\x62\137\x74\171\x70\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\x3a\x67\162\x6f\x75\160\111\x64" => $groupId]); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; } public function getAllBulkAlarmsByUser() { $user = $_SESSION["\x75\x73\x65\x72"]; $allUniqueGroupIds = []; if ($user["\x61\154\x6c\x5f\x73\x69\x74\145\163"] == 0) { $groups = $this->getAllGroupsByUserNotAdmin(); } else { if ($user["\157\167\156\x65\x72\137\x67\x72\157\165\160"] == 0 || $user["\141\144\155\x69\x6e"] == 1) { $groups = $this->getAllAlarmGroups(); } else { $groups = $this->getAllGroupsByUserNotAdmin(); } } return $groups; } public function getAllGroupsByUserNotAdmin() { $user = $_SESSION["\x75\163\145\162"]; $groups = $this->getAllBulkAlarmsForList(); $userStationIds = array_column($user["\x73\151\164\x65\x73"], "\x73\164\x61\164\151\x6f\156\x5f\151\x64"); $allUniqueGroupIds = array_unique(array_column($groups, "\147\162\x6f\x75\x70\x49\x64")); foreach ($allUniqueGroupIds as $groupId) { $allBulkByGroupId = array_filter($groups, function ($val) use($groupId) { return $val["\147\162\x6f\x75\160\x49\x64"] == $groupId; }); $hasAccess = true; foreach ($allBulkByGroupId as $key => $bulk) { $stationId = $bulk["\x73\x74\141\164\151\157\156\x5f\151\x64"]; if (!in_array($stationId, $userStationIds)) { $hasAccess = false; break; } } if ($hasAccess == false) { $groups = array_filter($groups, function ($val) use($groupId) { return $val["\x67\x72\x6f\x75\160\111\x64"] != $groupId; }); } } $allGroupsUserHasAccessTo = array_unique(array_column($groups, "\147\x72\x6f\165\160\111\x64")); return $this->getAlarmGroupsByGroupIds($allGroupsUserHasAccessTo); } public function getActiveAlarm(int $alarmId) { $query = "\x53\x45\x4c\105\103\x54\x20\x2a\x20\x46\122\117\115\x20\x41\154\x61\162\x6d\x5f\x43\x75\x73\164\x6f\155\137\101\143\164\151\x76\145\40\x57\110\105\x52\105\x20\x61\154\141\162\x6d\137\151\x64\x20\75\x20\x3a\141\x6c\x61\x72\x6d\111\x64\x3b"; $param = array("\161\x75\x65\x72\171" => $query, "\144\x62" => $this->db, "\144\x62\137\x74\x79\160\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\x61\x6c\x61\162\x6d\x49\144" => $alarmId]); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result; } public function saveNewActiveAlarm($alarm, $value, $timestamp) { $query = "\xd\12\40\40\x20\x20\x20\40\40\x20\111\x4e\x53\x45\122\x54\x20\x49\116\124\x4f\x20\141\154\x61\x72\155\137\143\x75\x73\x74\x6f\155\137\x61\143\x74\x69\166\x65\40\x28\x61\154\141\162\155\x5f\151\144\x2c\40\141\x6c\x61\x72\155\x5f\x74\151\155\x65\163\x74\x61\155\160\54\x20\x61\154\x61\x72\x6d\137\x76\x61\x6c\x75\145\x2c\15\xa\x20\x20\40\x20\x20\40\x20\x20\40\40\x20\40\40\x20\x20\x20\40\x20\x20\x20\40\40\x72\145\x70\x65\x61\164\x5f\x69\x6e\144\145\x78\x2c\x20\154\x61\163\164\137\162\145\160\x65\141\x74\137\x74\151\155\145\x73\x74\141\155\160\54\x20\141\x6c\x61\x72\155\137\157\x6e\x2c\40\143\157\x6e\x66\x69\162\x6d\x65\x64\x29\15\12\40\40\40\x20\40\x20\x20\x20\166\141\154\165\145\163\x20\50\x3a\141\x6c\141\162\155\137\x69\x64\54\x20\72\x61\x6c\x61\162\x6d\137\164\151\155\x65\x73\164\141\155\160\54\x20\72\x61\154\141\162\155\137\x76\141\154\x75\145\x2c\x20\72\162\145\x70\x65\141\164\137\151\156\144\145\x78\54\x20\x3a\x6c\x61\163\164\137\162\145\x70\145\141\x74\137\164\151\x6d\145\163\164\x61\155\x70\x2c\40\72\141\154\141\x72\155\137\x6f\x6e\x2c\x20\72\143\x6f\156\146\151\162\x6d\x65\x64\51"; $param = array("\x71\165\145\162\x79" => $query, "\x64\x62" => $this->db, "\144\142\137\164\171\x70\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\72\141\x6c\x61\162\x6d\137\x69\144" => $alarm["\141\x6c\141\x72\155\x5f\151\144"], "\72\x61\154\141\x72\155\x5f\x74\151\155\145\x73\x74\x61\x6d\x70" => $timestamp, "\72\x61\x6c\141\162\155\137\166\x61\x6c\x75\145" => $value, "\72\162\145\x70\x65\x61\x74\x5f\x69\156\x64\x65\170" => 0, "\72\154\x61\x73\x74\137\162\145\160\x65\141\x74\137\164\x69\x6d\145\x73\x74\141\x6d\x70" => $alarm["\141\x6c\141\162\155\x5f\164\151\155\145\163\x74\x61\155\160"], "\72\x61\154\x61\x72\x6d\x5f\157\x6e" => 1, "\x3a\x63\x6f\x6e\x66\x69\162\155\x65\144" => 0]); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); } public function updateLastRepeatTimestamp(int $activeAlarmId) { $query = "\15\12\40\40\40\x20\40\40\x20\40\125\x50\104\101\x54\x45\40\141\x6c\141\x72\155\x5f\x63\x75\163\x74\157\155\x5f\x61\143\164\x69\x76\x65\40\x53\105\124\x20\xd\xa\x20\x20\x20\x20\40\40\40\40\40\x20\40\40\154\141\163\x74\x5f\162\x65\160\x65\141\164\x5f\164\x69\155\145\x73\164\141\155\160\x20\75\x20\x6e\x6f\167\x28\x29\54\40\xd\12\40\x20\x20\40\x20\x20\40\40\x20\40\40\x20\x72\x65\160\x65\x61\x74\x5f\151\x6e\144\x65\170\40\75\40\162\145\x70\x65\x61\164\137\151\156\144\145\170\40\53\x20\61\40\40\xd\xa\x20\x20\x20\x20\40\40\40\x20\x57\110\105\122\105\40\x61\143\x74\x69\x76\x65\137\x61\x6c\x61\162\155\137\151\144\x20\x3d\40\72\x61\143\164\151\x76\145\x5f\141\x6c\141\x72\x6d\x5f\x69\144"; $param = array("\x71\x75\x65\x72\171" => $query, "\144\x62" => $this->db, "\x64\142\x5f\x74\x79\x70\145" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\x3a\x61\x63\164\151\166\145\137\x61\x6c\x61\x72\x6d\137\151\144" => $activeAlarmId]); } public function updateLastTimestampCheck($alarmConditionId, $timestamp) { $query = "\xd\xa\x20\40\x20\x20\40\40\40\40\x55\120\x44\101\124\x45\x20\x41\154\141\x72\155\137\103\165\163\x74\x6f\155\137\x43\x6f\x6e\144\151\164\x69\x6f\x6e\15\12\40\x20\x20\40\40\x20\40\40\x53\105\x54\40\x6c\141\x73\164\137\x74\151\x6d\x65\163\x74\x61\x6d\160\x5f\143\150\145\143\x6b\40\x3d\x20\72\154\x61\x73\164\124\151\155\x65\163\x74\x61\155\160\15\xa\40\x20\40\40\40\40\40\x20\x57\110\105\x52\x45\40\141\154\x61\x72\155\x5f\x63\157\156\x64\x69\x74\x69\157\156\x5f\x69\144\x20\x3d\x20\72\141\x6c\141\x72\x6d\x43\x6f\156\144\x69\x74\x69\x6f\x6e\x49\144\73"; $param = array("\x71\165\145\x72\171" => $query, "\x64\142" => $this->db, "\144\x62\x5f\x74\171\x70\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\72\154\x61\163\164\x54\151\155\x65\163\164\141\155\x70" => $timestamp, "\x3a\141\154\141\x72\x6d\x43\157\x6e\x64\151\164\x69\157\x6e\x49\x64" => $alarmConditionId]); } public function updateAlarmConditionDelayTimestamp($alarmConditionId, $timestamp) { $query = "\xd\xa\x20\40\x20\x20\x20\x20\x20\x20\125\x50\104\x41\x54\x45\40\x61\x6c\x61\x72\x6d\137\143\165\163\x74\157\155\x5f\x63\157\156\x64\x69\164\151\157\156\40\x53\x45\x54\40\x64\x65\x6c\141\x79\x54\x69\155\x65\x73\164\141\x6d\x70\x20\x3d\x20\x3a\x74\x69\155\x65\x73\164\141\155\x70\x20\xd\xa\40\40\x20\40\x20\40\40\40\127\110\105\x52\x45\40\141\x6c\x61\162\155\x5f\143\157\x6e\144\x69\x74\x69\157\156\137\151\144\x20\75\x20\x3a\x69\x64"; $param = array("\161\x75\x65\162\x79" => $query, "\x64\x62" => $this->db, "\144\x62\x5f\x74\171\160\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\72\x74\x69\x6d\x65\x73\x74\x61\x6d\160" => $timestamp, "\72\151\144" => $alarmConditionId]); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); } public function updateActiveAlarm($activeAlarmId, $alarmValue, $status, $timestamp) { $query = "\15\xa\40\x20\40\x20\x20\40\40\40\x55\x50\104\101\x54\x45\40\141\154\141\162\155\137\x63\165\x73\x74\x6f\155\137\x61\143\x74\x69\x76\145\x20\xd\xa\40\x20\x20\40\40\40\40\40\40\40\x53\x45\x54\x20\x61\154\141\x72\x6d\137\x6f\x6e\40\x3d\x20\x3a\141\154\x61\162\x6d\x4f\156\54\x20\xd\12\x20\40\40\x20\40\x20\x20\40\40\x20\x61\154\141\162\155\x5f\166\141\x6c\x75\145\x20\75\x20\x3a\x61\154\141\x72\x6d\x56\141\154\165\145\54\x20\15\12\x20\40\x20\40\40\x20\x20\40\x20\x20\x61\x6c\x61\x72\x6d\x5f\164\x69\155\145\163\x74\x61\155\x70\40\x3d\x20\72\x61\154\x61\162\155\x54\151\x6d\145\x73\164\141\x6d\160\x20\15\12\x20\x20\x20\40\x20\x20\x20\x20\127\x48\105\122\x45\40\141\x63\164\x69\x76\x65\x5f\141\x6c\x61\x72\x6d\137\151\144\x20\x3d\40\x3a\x69\144\x3b"; $param = array("\x71\x75\x65\x72\171" => $query, "\144\142" => $this->db, "\x64\142\137\164\x79\160\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\x3a\141\154\x61\162\155\x4f\x6e" => $status, "\x3a\x61\x6c\x61\x72\155\126\x61\x6c\x75\145" => $alarmValue, "\x3a\151\x64" => $activeAlarmId, "\72\141\154\x61\162\155\124\x69\155\x65\x73\164\x61\x6d\160" => $timestamp]); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); } public function getActiveAlarmByIdAndOnOffString($alarmId) { $query = "\xd\xa\x20\40\x20\40\40\x20\40\x20\x53\105\114\x45\103\124\40\x74\x31\x2e\x2a\x2c\x20\164\62\x2e\x2a\x2c\x20\164\x33\56\x2a\54\x20\x74\x34\x2e\52\54\x20\x74\x35\56\167\141\162\156\151\156\147\137\x6f\156\137\x73\164\162\x69\156\147\54\40\164\x35\x2e\167\141\x72\x6e\x69\156\x67\x5f\157\146\x66\137\163\x74\x72\x69\156\x67\54\40\164\x36\56\x6e\x61\x6d\145\40\101\123\40\164\x79\x70\145\x4e\141\x6d\145\x2c\40\164\67\x2e\x73\x74\141\164\x69\x6f\156\x5f\x6e\x61\x6d\x65\x2c\xd\12\x20\40\x20\x20\40\40\40\40\x28\123\x45\114\x45\103\124\x20\x63\56\151\144\x20\146\x72\157\155\x20\x61\x6c\141\162\155\x5f\x63\163\x69\137\143\x6f\x6d\155\141\x6e\144\x20\141\x73\40\x63\x20\167\150\145\x72\x65\40\x63\56\x61\x6c\x61\162\155\137\166\x61\162\x69\x61\x62\x6c\145\x5f\x69\x64\x20\75\x20\x74\x31\56\x61\154\141\162\x6d\x5f\x69\x64\40\154\151\155\151\164\x20\x31\x29\x20\x61\x73\x20\x61\154\141\162\155\x5f\143\x6f\155\155\141\x6e\144\x5f\x69\144\15\12\x20\40\x20\x20\x20\x20\x20\40\x46\x52\117\x4d\x20\x61\x6c\x61\162\155\137\x63\x75\163\x74\157\155\137\x61\143\x74\151\166\x65\40\x61\x73\40\164\x31\xd\12\40\x20\40\x20\40\x20\40\x20\x4a\117\111\116\x20\x61\154\141\x72\x6d\x5f\x63\x75\x73\164\157\155\x20\141\x73\40\164\62\x20\117\x4e\x20\x74\61\x2e\141\154\141\x72\x6d\137\151\144\x20\75\x20\x74\x32\56\141\154\141\162\155\x5f\151\144\15\12\40\x20\x20\x20\x20\40\40\x20\112\117\111\116\x20\141\x6c\x61\162\155\137\143\165\x73\164\x6f\155\x5f\143\157\156\x64\x69\164\x69\x6f\x6e\40\141\x73\x20\x74\x33\x20\117\116\40\164\61\56\x61\x6c\141\x72\x6d\x5f\x69\x64\40\75\x20\164\63\x2e\141\x6c\141\162\155\137\151\144\15\xa\x20\40\x20\40\40\x20\40\x20\x4a\x4f\x49\116\x20\x56\141\x72\151\x61\x62\x6c\145\x5f\x4e\141\x6d\145\x20\x41\123\40\164\x34\40\117\116\x20\164\x33\x2e\x76\x61\x72\x69\141\142\154\145\x5f\x69\144\x20\75\40\164\x34\56\x76\141\162\151\x61\x62\154\145\x5f\151\144\15\12\40\40\x20\x20\x20\x20\x20\40\112\x4f\111\x4e\40\163\x79\x73\164\x65\x6d\137\x69\x6e\146\157\40\x61\x73\40\x74\65\15\xa\x20\40\x20\40\x20\x20\x20\40\112\117\x49\x4e\x20\x73\x74\141\164\151\157\x6e\40\x41\x53\40\164\67\x20\x4f\116\x20\164\62\56\163\164\x61\164\151\x6f\x6e\x5f\151\144\x20\75\x20\164\67\56\163\164\x61\x74\x69\x6f\x6e\x5f\x69\x64\xd\xa\x20\x20\x20\40\x20\x20\40\x20\x4c\105\x46\x54\x20\112\x4f\111\x4e\x20\x61\154\141\162\155\x5f\x74\171\x70\x65\x73\40\164\66\40\x6f\156\40\164\x36\x2e\151\144\x20\75\x20\164\63\56\x61\154\141\162\155\x54\171\160\145\111\144\15\xa\40\x20\x20\40\x20\40\x20\40\127\x48\105\x52\x45\x20\x74\61\56\x61\x6c\x61\162\x6d\137\151\x64\40\x3d\40\72\x61\154\x61\162\x6d\x49\x64"; $param = array("\161\165\x65\x72\x79" => $query, "\144\x62" => $this->db, "\144\142\137\x74\x79\160\145" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\x3a\141\154\141\162\x6d\111\144" => $alarmId]); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result; } public function getActiveAlarmsAndOnOffString() { $query = "\xd\12\x20\x20\40\x20\x20\x20\x20\40\x20\40\40\x20\123\x45\x4c\105\103\x54\40\164\x31\x2e\52\x2c\x20\x74\62\x2e\x2a\54\x20\x74\63\56\52\x2c\40\164\64\x2e\x2a\54\40\x74\x35\56\x77\x61\x72\x6e\151\156\x67\x5f\157\x6e\137\x73\164\x72\x69\x6e\x67\54\x20\164\65\56\167\141\162\156\151\156\147\x5f\x6f\x66\x66\x5f\x73\164\x72\151\156\x67\54\40\x74\66\x2e\156\x61\155\x65\x20\101\x53\40\x74\171\x70\x65\x4e\141\x6d\x65\54\40\x74\67\56\163\164\x61\x74\151\157\156\137\156\141\x6d\145\xd\xa\x20\x20\x20\x20\40\40\x20\40\x20\40\40\x20\x46\122\117\x4d\x20\x61\x6c\x61\162\155\x5f\x63\x75\x73\164\x6f\155\x5f\x61\x63\x74\x69\166\145\40\141\163\x20\x74\61\xd\xa\x20\40\40\40\40\40\40\x20\40\x20\40\40\112\x4f\x49\x4e\40\141\154\x61\x72\155\x5f\143\x75\x73\x74\x6f\155\40\x61\163\x20\164\x32\x20\117\116\x20\x74\61\x2e\x61\x6c\141\x72\x6d\x5f\x69\144\x20\x3d\40\164\62\x2e\141\x6c\141\x72\x6d\137\x69\144\15\12\40\x20\40\40\x20\x20\x20\40\40\x20\x20\x20\112\x4f\111\116\x20\x61\154\141\162\155\x5f\x63\165\163\164\157\x6d\137\143\157\156\x64\151\x74\151\x6f\x6e\40\141\x73\40\164\63\40\x4f\116\40\x74\61\56\x61\x6c\x61\162\155\x5f\151\144\40\75\x20\164\x33\x2e\x61\x6c\141\162\x6d\137\151\x64\xd\xa\x20\x20\40\x20\40\40\x20\40\x20\x20\40\40\112\x4f\111\116\x20\126\141\162\x69\141\x62\x6c\145\137\116\141\155\145\x20\101\x53\40\164\x34\40\117\x4e\x20\164\x33\x2e\x76\141\162\151\141\x62\x6c\x65\137\151\x64\x20\75\x20\x74\64\56\166\x61\162\151\141\142\x6c\x65\137\x69\x64\xd\12\x20\x20\40\40\40\x20\x20\40\40\x20\x20\x20\112\x4f\x49\116\x20\x73\171\163\164\x65\155\137\x69\156\146\157\x20\x61\163\x20\164\65\15\xa\x20\x20\x20\x20\x20\40\40\40\40\x20\40\40\x4a\x4f\111\116\40\x73\x74\141\x74\x69\157\156\x20\101\x53\40\164\67\40\x4f\x4e\x20\164\x32\56\x73\x74\141\x74\x69\x6f\x6e\x5f\151\x64\x20\75\x20\164\67\x2e\163\x74\141\x74\x69\157\x6e\x5f\151\144\15\12\40\x20\40\x20\x20\x20\x20\x20\40\x20\40\40\114\x45\106\124\x20\112\117\111\116\40\141\154\141\x72\155\x5f\164\171\160\x65\163\x20\164\x36\x20\x6f\x6e\x20\164\x36\56\x69\x64\40\75\40\164\x33\x2e\x61\154\x61\x72\x6d\124\171\160\145\111\x64"; $param = array("\161\x75\145\162\171" => $query, "\x64\142" => $this->db, "\144\x62\x5f\164\x79\160\145" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; } public function getRepeatAlarmsAndOnOffString() { $query = "\xd\12\x20\x20\x20\40\40\x20\40\40\40\40\40\40\x53\105\x4c\105\103\x54\40\x74\x31\56\x2a\x2c\40\x74\x32\x2e\52\54\40\164\63\56\52\x2c\x20\x74\x34\56\52\x2c\40\x74\x35\x2e\167\x61\x72\156\151\x6e\x67\x5f\x6f\x6e\x5f\163\164\162\151\x6e\147\x2c\40\164\x35\x2e\167\141\x72\156\x69\156\147\x5f\157\146\146\x5f\x73\x74\x72\151\x6e\x67\x2c\x20\x74\x36\x2e\156\141\155\x65\40\x41\123\x20\164\171\160\x65\x4e\x61\155\145\54\x20\164\x37\x2e\x73\x74\x61\164\151\x6f\156\x5f\x6e\141\155\x65\xd\12\x20\40\x20\40\40\x20\x20\40\x20\40\40\x20\106\x52\117\115\40\x61\x6c\141\x72\155\x5f\143\165\163\x74\x6f\155\x5f\x61\x63\x74\151\x76\145\40\x61\163\40\164\x31\xd\xa\x20\x20\x20\40\x20\x20\x20\x20\x20\40\x20\x20\112\117\111\x4e\x20\141\x6c\141\162\155\x5f\143\x75\x73\x74\157\x6d\x20\x61\163\x20\164\62\x20\117\116\40\x74\61\x2e\x61\154\141\162\155\137\151\144\40\x3d\40\164\62\56\141\x6c\141\x72\155\x5f\151\x64\xd\xa\x20\x20\40\40\40\40\x20\x20\40\x20\40\40\x4a\117\111\116\x20\141\154\x61\162\155\137\x63\x75\163\164\157\x6d\x5f\143\x6f\156\144\151\x74\151\157\x6e\40\x61\163\x20\164\x33\40\x4f\x4e\40\164\61\x2e\141\x6c\x61\162\x6d\x5f\151\x64\x20\x3d\40\164\63\x2e\x61\154\x61\x72\155\x5f\x69\144\xd\xa\40\40\x20\40\40\40\x20\x20\x20\40\40\x20\x4a\117\x49\x4e\40\126\141\162\x69\x61\142\x6c\145\137\x4e\x61\155\145\x20\101\x53\40\164\64\x20\117\x4e\40\x74\63\56\x76\x61\162\151\x61\142\154\145\137\151\144\x20\75\40\x74\x34\56\166\x61\162\151\x61\x62\x6c\x65\137\x69\144\xd\12\x20\x20\40\x20\40\40\40\40\40\40\x20\x20\x4a\117\x49\x4e\x20\163\171\163\164\145\155\x5f\151\x6e\146\157\x20\141\x73\40\x74\65\xd\12\x20\x20\x20\x20\40\40\x20\x20\40\40\x20\x20\x4a\x4f\111\x4e\x20\x73\164\141\164\151\x6f\156\x20\x41\x53\x20\x74\67\x20\x4f\x4e\40\164\62\56\163\x74\141\x74\x69\157\156\137\151\x64\40\x3d\x20\x74\67\56\x73\164\141\x74\x69\x6f\156\137\x69\144\15\xa\x20\40\x20\40\x20\40\x20\x20\40\x20\40\x20\x4c\105\106\x54\x20\112\117\x49\116\x20\141\154\141\162\x6d\137\x74\171\160\x65\163\40\164\66\x20\157\156\x20\164\x36\56\151\144\x20\75\40\x74\63\56\141\154\141\x72\155\124\171\160\x65\x49\x64\xd\xa\x20\40\40\x20\40\x20\40\40\40\40\40\40\x57\x48\105\122\105\x20\x74\62\56\162\x65\x70\x65\x61\164\137\155\x69\x6e\165\x74\x65\163\x20\x3e\x20\x30\40\15\12\40\40\x20\x20\40\40\40\x20\x20\40\x20\x20\40\x20\101\x4e\104\x20\x74\61\x2e\x61\154\141\162\x6d\137\157\156\40\75\40\61\15\12\40\x20\40\40\40\x20\40\40\40\x20\40\x20\40\x20\101\x4e\x44\40\x74\61\x2e\143\x6f\156\146\x69\x72\155\x65\x64\x20\75\40\60\xd\xa\40\x20\40\40\x20\40\x20\40\x20\40\x20\40\40\x20\101\116\104\40\164\62\56\155\165\x6c\164\x69\103\157\156\144\x69\x74\x69\x6f\x6e\40\75\40\60\15\12\x20\40\40\40\x20\40\40\40\x20\x20\40\40\40\40\101\116\x44\40\50\x74\x31\x2e\x6c\141\x73\x74\137\162\x65\160\x65\141\164\137\x74\x69\x6d\x65\x73\x74\x61\155\160\40\x3c\40\x44\x41\124\105\137\123\x55\x42\x28\156\157\x77\50\51\x2c\40\x49\116\124\x45\x52\x56\x41\114\x20\x74\62\x2e\x72\x65\160\x65\141\164\x5f\x6d\x69\x6e\x75\x74\145\163\x20\115\111\x4e\125\124\x45\51\x29\73"; $param = array("\161\165\145\162\171" => $query, "\144\142" => $this->db, "\144\142\x5f\164\x79\160\145" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; } public function getAlarmMessageHeaderAndFooter() { $query = "\123\105\x4c\105\x43\124\x20\167\x61\x72\x6e\x69\156\147\x5f\x65\x6d\x61\151\x6c\x5f\150\145\x61\144\x65\162\54\x20\167\x61\162\x6e\x69\156\147\x5f\x65\155\x61\x69\x6c\137\146\157\157\164\145\162\40\x46\122\117\x4d\40\x73\171\163\164\x65\x6d\x5f\x69\x6e\146\157"; $param = array("\161\x75\x65\x72\x79" => $query, "\144\x62" => $this->db, "\x64\x62\x5f\x74\171\160\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute([]); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result; } private function getAllAlarmGroups() { $query = "\xd\12\x20\40\40\x20\40\40\40\40\40\x20\40\x20\x73\145\154\x65\143\164\40\164\x31\x2e\x2a\54\x20\x63\x6f\165\x6e\164\x28\x64\x69\x73\x74\151\156\143\x74\40\164\x34\56\x76\141\x72\x69\x61\142\154\x65\137\x69\x64\51\40\x61\x73\40\166\141\x72\151\x61\142\x6c\145\x43\157\165\x6e\x74\54\x20\106\x4c\117\x4f\122\50\x63\x6f\x75\x6e\164\50\x74\62\56\x61\x6c\141\x72\x6d\x5f\151\x64\51\40\x2f\x20\x63\157\x75\x6e\164\50\x64\151\163\x74\151\x6e\143\164\40\164\64\56\x76\141\x72\151\141\142\154\145\137\151\144\51\51\x20\141\163\40\x6c\x69\x6d\151\x74\x43\x6f\x75\156\164\54\x20\xd\xa\x20\x20\x20\40\40\40\x20\40\40\40\x20\x20\x20\x20\x20\x20\40\40\x20\164\x33\x2e\x67\x72\x6f\x75\160\137\x6e\141\x6d\x65\x20\x61\163\x20\143\x6f\156\x74\x61\143\164\107\162\x6f\x75\160\116\141\155\145\x2c\x20\164\62\x2e\141\x63\164\x69\x76\x65\40\x61\x73\x20\141\143\164\x69\166\145\xd\xa\40\x20\x20\x20\x20\40\40\40\x66\162\x6f\155\x20\x61\x6c\141\x72\155\x5f\x63\x75\163\x74\157\155\x5f\x67\x72\x6f\165\160\40\164\61\15\12\x20\x20\x20\40\x20\40\x20\x20\x6a\x6f\151\156\x20\141\x6c\x61\162\x6d\x5f\x63\x75\x73\164\x6f\155\x20\x74\x32\x20\157\156\40\x74\62\56\147\x72\x6f\165\160\x49\144\x20\x3d\40\164\61\56\x69\144\15\xa\40\x20\x20\40\40\x20\x20\x20\x6a\x6f\151\156\x20\x63\157\156\x74\x61\143\x74\x5f\147\162\x6f\165\160\40\164\x33\x20\157\x6e\x20\164\x33\x2e\147\162\x6f\165\x70\137\x69\x64\40\x3d\x20\164\x32\56\143\x6f\x6e\164\x61\143\164\137\x67\x72\x6f\165\x70\137\151\x64\15\xa\x20\x20\x20\x20\40\40\x20\40\x6a\x6f\151\156\x20\x61\154\x61\162\155\x5f\x63\165\163\164\x6f\155\137\143\x6f\156\144\151\x74\x69\x6f\x6e\x20\x74\x34\40\157\x6e\40\164\64\x2e\x61\x6c\141\162\x6d\x5f\151\144\40\x3d\x20\x74\62\56\141\154\x61\162\155\x5f\151\x64\xd\12\x20\x20\x20\40\x20\40\40\40\x67\162\x6f\x75\160\x20\142\x79\x20\x74\x31\56\151\x64"; $param = array("\x71\165\145\162\x79" => $query, "\x64\x62" => $this->db, "\144\x62\137\x74\171\160\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; } private function getAlarmGroupsByGroupIds(array $groupIds) { if (count($groupIds) == 0) { return []; } $boundParameters = createBoundParameters($groupIds); $query = "\x73\145\154\x65\x63\164\x20\164\x31\x2e\x2a\54\x20\143\x6f\165\x6e\164\x28\144\151\x73\164\x69\156\143\164\x20\164\64\x2e\166\141\x72\151\x61\x62\x6c\x65\137\151\144\x29\x20\x61\x73\x20\166\141\x72\151\x61\x62\154\145\x43\x6f\x75\x6e\x74\54\40\106\x4c\117\x4f\x52\50\143\157\x75\x6e\164\x28\x74\62\x2e\x61\154\141\162\155\x5f\x69\144\51\x20\57\x20\143\x6f\x75\x6e\164\50\x64\x69\163\x74\151\x6e\x63\164\x20\x74\x34\x2e\166\x61\x72\x69\141\x62\154\x65\137\x69\144\51\51\x20\141\163\x20\154\x69\x6d\x69\164\x43\157\165\156\x74\54\40\164\63\56\147\162\157\x75\160\x5f\156\x61\155\145\x20\141\x73\40\143\157\x6e\x74\141\143\164\x47\x72\157\x75\x70\x4e\x61\155\x65\54\x20\164\x32\x2e\x61\143\x74\x69\x76\145\15\12\40\x20\40\x20\40\x20\40\x20\146\162\157\155\x20\141\x6c\x61\x72\x6d\137\143\165\x73\x74\x6f\x6d\x5f\x67\x72\x6f\x75\x70\x20\164\61\15\12\x20\40\x20\x20\x20\40\x20\40\x6a\x6f\151\x6e\40\x61\154\x61\162\155\137\143\165\x73\x74\157\155\x20\164\62\40\x6f\x6e\40\164\62\x2e\147\162\x6f\x75\x70\111\144\x20\75\x20\164\61\x2e\151\x64\15\xa\x20\40\x20\x20\40\40\40\40\152\x6f\x69\x6e\x20\143\x6f\x6e\x74\x61\143\x74\137\x67\x72\x6f\165\160\x20\164\63\x20\157\156\40\x74\x33\x2e\x67\x72\x6f\165\x70\x5f\151\x64\x20\75\40\164\62\56\x63\157\156\x74\x61\x63\164\137\x67\162\157\165\x70\x5f\x69\x64\xd\xa\40\x20\40\40\40\40\40\x20\152\157\151\x6e\x20\141\x6c\141\162\155\x5f\143\x75\163\164\157\x6d\137\x63\157\156\x64\151\x74\x69\157\156\40\164\x34\40\x6f\x6e\x20\164\x34\56\141\x6c\141\162\x6d\137\x69\144\40\x3d\x20\x74\62\56\x61\x6c\x61\x72\x6d\137\x69\144\15\xa\x20\x20\x20\40\40\40\40\x20\127\x48\105\122\x45\40\164\62\56\147\x72\157\165\160\x49\144\x20\111\116\x20\x28{$boundParameters}\51\15\12\40\x20\x20\x20\40\40\40\x20\x67\162\157\165\x70\x20\x62\171\x20\x74\61\x2e\151\x64"; $param = array("\x71\x75\x65\x72\171" => $query, "\x64\142" => $this->db, "\x64\x62\x5f\164\x79\x70\145" => $this->db_type); $stmt = vdv_prepare_query($param); bindArrayParameters($stmt, $groupIds); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); return $result; } public function saveBulkAlarm(array $bulkAlarm) { $access = new AlarmAccess(); $contactCheck = $access->checkContactGroupId($bulkAlarm["\143\x6f\156\164\x61\x63\x74\x47\162\x6f\165\160\x49\x64"]); if ($contactCheck) { if ($bulkAlarm["\x67\162\157\x75\160\111\144"] !== null) { if ($this->hasAccessToBulkAlarm($bulkAlarm["\147\x72\x6f\165\x70\111\144"])) { return $this->updateBulkAlarm($bulkAlarm); } } else { return $this->saveNewBulkAlarm($bulkAlarm); } } } public function hasAccessToBulkAlarm($groupId) { if ($_SESSION["\165\x73\145\162"]["\x6f\167\156\x65\162\137\147\x72\x6f\x75\x70"] == 0 || $_SESSION["\x75\x73\x65\162"]["\x61\x64\155\x69\156"] == 1) { return true; } $userAccessBulk = $this->getAllGroupsByUserNotAdmin(); $bulkIds = array_column($userAccessBulk, "\x69\144"); if (in_array($groupId, $bulkIds)) { return true; } return false; } public function deleteBulkGroup(int $groupId) { $hasAccess = $this->hasAccessToBulkAlarm($groupId); if ($hasAccess) { $alarms = $this->getCustomAlarmsByGroupId($groupId); $alarmIds = array(); foreach ($alarms as $alarm) { array_push($alarmIds, $alarm["\141\154\x61\162\x6d\137\151\x64"]); } $alarmIds = implode("\x2c", $alarmIds); $this->deleteCustomConditions($alarmIds); $this->deleteCustomActive($alarmIds); $this->deleteAlarmCustom($groupId); $this->deleteBulkAlarm($groupId); } } private function deleteCustomConditions(String $alarmIds) { $boundParameters = createBoundParameters($alarmIds); $query = "\144\145\x6c\x65\x74\145\40\x66\x72\157\155\x20\141\154\141\x72\x6d\137\x63\165\x73\x74\157\x6d\137\143\157\x6e\x64\151\x74\151\157\156\40\167\x68\x65\162\145\x20\x61\x6c\x61\162\x6d\x5f\x69\144\x20\x69\156\40\x28{$boundParameters}\x29\73"; $param = array("\x71\165\x65\162\171" => $query, "\x64\142" => $this->db, "\x64\x62\x5f\x74\171\x70\x65" => $this->db_type); $stmt = vdv_prepare_query($param); bindArrayParameters($stmt, $alarmIds); $stmt->execute(); } private function deleteCustomActive(String $alarmIds) { $boundParameters = createBoundParameters($alarmIds); $query = "\x64\145\154\x65\x74\x65\40\x66\x72\x6f\155\40\141\154\x61\162\x6d\137\x63\x75\163\164\x6f\x6d\x5f\x61\x63\x74\x69\166\x65\40\x77\x68\x65\162\x65\x20\141\x6c\x61\x72\x6d\137\151\144\40\x69\x6e\x20\50{$boundParameters}\51\x3b"; $param = array("\x71\x75\x65\x72\171" => $query, "\x64\x62" => $this->db, "\x64\142\x5f\x74\171\160\145" => $this->db_type); $stmt = vdv_prepare_query($param); bindArrayParameters($stmt, $alarmIds); $stmt->execute(); } private function deleteAlarmCustom(int $groupId) { $query = "\144\x65\154\145\x74\145\x20\146\162\157\155\40\x61\154\x61\162\155\x5f\143\x75\x73\164\x6f\155\40\x77\150\145\x72\145\x20\x67\162\157\165\x70\111\x64\40\75\40\x3a\147\x72\157\x75\x70\x49\x64"; $param = array("\x71\165\x65\x72\171" => $query, "\x64\x62" => $this->db, "\144\x62\x5f\x74\x79\x70\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(array("\x3a\147\x72\157\x75\x70\x49\x64" => $groupId)); } private function deleteBulkAlarm(int $groupId) { $query = "\x64\x65\154\145\x74\x65\40\x66\162\x6f\x6d\x20\x61\x6c\x61\162\155\137\x63\165\163\164\x6f\155\x5f\147\162\x6f\x75\160\x20\167\150\x65\162\145\40\x69\x64\40\75\40\72\x67\x72\x6f\165\160\111\144"; $param = array("\x71\x75\x65\162\171" => $query, "\144\142" => $this->db, "\144\x62\x5f\x74\171\x70\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(array("\72\x67\162\x6f\x75\160\x49\144" => $groupId)); } private function updateBulkAlarm(array $bulkAlarm) { $name = $bulkAlarm["\x6e\141\155\x65"]; $this->updateBulkAlarmGroup($name, $bulkAlarm["\147\x72\x6f\x75\160\111\144"]); $this->updateBulkAlarms($bulkAlarm); $this->checkIfNewLimitWasAdded($bulkAlarm); $this->deleteAlarmsThatWereRemoved($bulkAlarm["\x76\x61\x72\151\x61\x62\x6c\x65\x73\x54\157\x44\x65\154\x65\x74\145"]); } private function saveNewBulkAlarm(array $bulkAlarm) { $name = $bulkAlarm["\156\x61\x6d\145"]; $variables = $bulkAlarm["\x76\141\x72\x69\141\142\154\x65\x4c\151\163\164"]; $limitsList = $bulkAlarm["\x6c\151\155\151\x74\163\114\x69\x73\x74"]; $newGroupId = $this->saveBulkAlarmGroup($name); $this->saveBulkAlarms($bulkAlarm, $newGroupId, $variables, $limitsList); return $newGroupId; } private function saveBulkAlarmGroup(string $name) { $query = "\x49\116\123\x45\122\x54\x20\111\x4e\124\117\40\x61\154\141\162\x6d\x5f\143\x75\x73\164\157\x6d\137\x67\x72\x6f\165\x70\x20\x28\156\x61\155\x65\51\40\126\101\x4c\x55\x45\x53\50\x3a\x6e\x61\155\145\x29"; $param = array("\161\165\x65\x72\x79" => $query, "\144\x62" => $this->db, "\x64\x62\x5f\164\171\x70\145" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\x3a\x6e\141\x6d\x65" => $name]); $newGroupId = $this->db->lastInsertId(); return $newGroupId; } private function updateBulkAlarmGroup(string $name, $id) { $query = "\125\x50\104\x41\124\105\x20\141\x6c\141\162\155\x5f\143\x75\x73\x74\x6f\155\137\x67\162\157\x75\160\x20\123\105\124\40\x6e\141\x6d\145\40\75\x20\72\x6e\141\x6d\145\x20\127\110\x45\x52\105\x20\x69\144\40\75\x20\x3a\151\x64"; $param = array("\161\x75\x65\162\171" => $query, "\144\142" => $this->db, "\144\x62\x5f\164\x79\x70\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\72\x6e\x61\155\x65" => $name, "\72\x69\144" => $id]); } public function saveBulkAlarms(array $bulkAlarm, $groupId, $variables, $limitsList) { foreach ($variables as $variable) { $stationId = $variable["\163\164\141\x74\151\157\x6e\111\144"]; $stationLatestTimeStamp = $this->getLastTimestampCheckForAlarm($variable["\x73\x74\141\x74\151\x6f\156\x49\144"]); foreach ($limitsList as $list) { $limits = $list["\154\x69\x6d\151\164\163"]; foreach ($limits as $limit) { $newAlarmId = $this->saveCustomAlarm($bulkAlarm, $stationId, $groupId); $this->saveCustomAlarmCondition($newAlarmId, $variable, $limit, $stationLatestTimeStamp, $list, $bulkAlarm); } } } } private function updateBulkAlarms(array $bulkAlarms) { $variables = $bulkAlarms["\x76\141\162\x69\141\142\154\x65\114\151\x73\x74"]; foreach ($variables as $variable) { if ($variable["\x69\x64"] === null) { $stationId = $variable["\x73\x74\x61\x74\151\157\x6e\111\144"]; $stationLatestTimeStamp = $this->getLastTimestampCheckForAlarm($variable["\163\164\141\x74\x69\x6f\x6e\111\x64"]); foreach ($bulkAlarms["\154\151\155\151\x74\163\x4c\151\x73\164"] as $list) { foreach ($list["\154\151\x6d\x69\164\163"] as $limit) { $newAlarmId = $this->saveCustomAlarm($bulkAlarms, $stationId, $bulkAlarms["\147\162\x6f\165\x70\111\144"]); $this->saveCustomAlarmCondition($newAlarmId, $variable, $limit, $stationLatestTimeStamp, $list, $bulkAlarms); } } } else { $this->updateCustomAlarm($bulkAlarms, $variable); if ($bulkAlarms["\x75\160\x64\x61\164\145\x4c\141\163\x74\124\x69\x6d\145\163\164\141\155\x70\x43\x68\141\156\x67\x65"] === true) { $lastTimestampCheck = $this->getLastTimestampCheckForAlarm($variable["\163\164\141\x74\x69\x6f\x6e\x49\144"]); $lastTimestampCheck = $lastTimestampCheck->format("\x59\55\155\55\144\40\x48\x3a\151\72\x73"); } else { $lastTimestampCheck = $variable["\x6c\141\163\x74\x54\151\155\x65\163\x74\x61\x6d\x70\103\150\x65\143\x6b"]; } $this->updateCustomAlarmCondition($variable, $bulkAlarms, $lastTimestampCheck); } } } private function checkIfNewLimitWasAdded($bulkAlarms) { $limitsList = $bulkAlarms["\x6c\151\x6d\151\x74\163\114\x69\x73\164"]; $variables = $bulkAlarms["\166\x61\x72\151\x61\142\154\145\114\x69\x73\164"]; $uniqueIds = array_unique(array_column($variables, "\x76\141\162\x69\x61\142\x6c\x65\x49\x64")); $uniqueVariables = array_intersect_key($variables, $uniqueIds); foreach ($limitsList as $list) { $limits = $list["\x6c\151\x6d\x69\x74\163"]; foreach ($limits as $limit) { if (!is_numeric($limit["\151\x64"])) { $tmpList = $list; $tmpList["\154\x69\155\x69\164\x73"] = [$limit]; $this->saveBulkAlarms($bulkAlarms, $bulkAlarms["\x67\162\x6f\x75\160\111\x64"], $uniqueVariables, [$tmpList]); } } } } private function saveCustomAlarm($alarm, $stationId, $groupId) { $query = "\15\xa\x20\x20\40\x20\x20\40\40\x20\111\116\123\x45\x52\x54\40\111\x4e\x54\117\x20\x41\x6c\x61\x72\155\137\x43\x75\x73\x74\x6f\155\x20\50\156\141\x6d\145\x2c\40\163\164\141\x74\x69\157\156\137\151\x64\54\x20\x61\143\164\x69\166\x65\54\x20\x73\153\x69\160\137\157\146\x66\137\x61\154\x61\162\155\x2c\40\143\x6f\156\x74\141\143\164\x5f\x67\x72\x6f\165\x70\x5f\x69\x64\x2c\40\162\145\x70\145\x61\164\137\x6d\151\x6e\x75\x74\145\x73\54\40\15\12\x20\40\40\40\40\40\x20\x20\x20\40\x20\x20\40\40\x20\x20\40\x20\40\40\40\40\x20\x20\x20\40\x20\x20\40\40\x20\x20\40\x20\x20\40\x73\165\x62\152\x65\x63\x74\x2c\40\x6d\x65\163\163\141\147\x65\54\40\144\145\163\143\x72\x69\160\164\x69\157\x6e\x2c\x20\165\x73\x65\x72\137\x69\x64\54\40\163\x74\x61\164\151\157\156\137\151\x64\137\62\54\40\x67\x72\x6f\x75\160\111\x64\x2c\40\164\151\155\x65\x41\154\x61\x72\x6d\x29\xd\12\x20\x20\40\40\40\x20\40\40\126\x41\114\x55\x45\123\40\50\72\x6e\x61\155\x65\54\40\72\163\164\141\x74\151\x6f\156\137\x69\x64\x2c\40\72\x61\x63\164\x69\166\145\54\x20\72\x73\153\151\x70\137\x6f\x66\146\x5f\x61\154\x61\162\155\54\40\x3a\143\x6f\x6e\x74\x61\x63\164\137\147\x72\x6f\165\x70\137\x69\144\54\x20\72\x72\x65\x70\x65\x61\164\x5f\x6d\x69\x6e\x75\164\145\163\54\40\15\xa\40\40\40\40\x20\40\40\x20\x20\40\40\40\x20\x20\x20\x20\40\x3a\x73\x75\142\152\x65\x63\x74\54\40\72\x6d\145\163\163\x61\147\145\x2c\40\72\144\145\x73\143\x72\151\160\x74\x69\x6f\156\x2c\x20\72\165\163\145\162\x5f\151\x64\54\x20\x3a\x73\x74\x61\164\151\157\156\137\151\x64\137\x32\54\x20\x3a\147\x72\157\165\160\111\144\x2c\x20\x3a\x74\151\155\145\x41\154\141\x72\x6d\51"; $param = array("\161\x75\x65\x72\x79" => $query, "\x64\x62" => $this->db, "\144\142\137\x74\x79\160\x65" => $this->db_type, "\163\153\x69\x70\x45\163\x63\141\160\x65" => ["\x3a\163\165\142\x6a\145\143\164", "\x3a\x6d\145\x73\x73\141\x67\145", "\72\144\x65\163\x63\162\x69\160\x74\151\x6f\156"]); $stmt = vdv_prepare_query($param); $stmt->execute(array("\72\x6e\x61\x6d\x65" => $alarm["\x6e\x61\155\145"], "\x3a\x73\x74\141\x74\x69\x6f\156\137\x69\x64" => $stationId, "\x3a\141\143\x74\151\x76\145" => $alarm["\x6d\157\x6e\151\164\157\x72"] == true ? 1 : 0, "\72\x73\153\151\x70\137\157\146\x66\x5f\141\x6c\x61\x72\x6d" => $alarm["\x73\153\151\x70\117\146\146\101\154\141\162\x6d"] == true ? 1 : 0, "\72\143\x6f\x6e\164\x61\x63\164\x5f\147\x72\x6f\x75\160\137\x69\x64" => $alarm["\143\157\x6e\x74\x61\x63\164\x47\162\157\x75\160\111\x64"], "\72\162\145\160\145\141\164\x5f\155\x69\156\165\164\x65\x73" => $alarm["\x61\x6c\x61\x72\155\x52\145\x70\x65\x61\164\115\x69\x6e\x75\x74\x65\x73"], "\x3a\163\165\x62\x6a\x65\143\164" => $alarm["\x61\154\x61\162\155\123\165\x62\x6a\145\143\x74"], "\x3a\155\145\163\163\x61\147\x65" => nl2br($alarm["\x61\x6c\141\162\x6d\115\x65\163\163\x61\x67\145"]), "\72\144\145\163\143\162\x69\160\164\151\157\156" => $alarm["\x61\154\x61\x72\155\x44\x65\163\143\162\151\x70\164\151\157\x6e"], "\72\165\x73\x65\162\x5f\151\x64" => isset($_SESSION["\x75\x73\x65\162"]["\165\163\145\x72\137\151\144"]) ? $_SESSION["\165\x73\x65\162"]["\165\x73\145\162\x5f\x69\144"] : 0, "\72\163\x74\141\164\x69\157\x6e\x5f\x69\144\x5f\62" => 0, "\x3a\x67\162\x6f\165\x70\111\144" => $groupId, "\72\x74\151\155\145\x41\x6c\x61\x72\x6d" => $alarm["\164\151\155\x65\101\154\141\x72\x6d"] == true ? 1 : 0)); $newAlarmId = $this->db->lastInsertId(); return $newAlarmId; } private function updateCustomAlarm($alarm, $variable) { $query = "\xd\12\40\40\x20\x20\40\40\x20\40\40\40\x55\x50\104\x41\124\x45\x20\x41\x6c\141\x72\x6d\137\103\165\x73\x74\x6f\x6d\x20\x53\105\x54\15\xa\40\x20\x20\40\x20\x20\40\x20\x20\40\40\40\40\40\x20\x20\x6e\141\155\145\40\x3d\x20\x3a\x6e\141\155\145\x2c\xd\xa\x20\x20\40\40\40\40\40\x20\x20\x20\x20\x20\x20\x20\x20\40\x73\164\141\164\151\157\156\x5f\151\144\40\75\40\72\163\x74\x61\164\x69\x6f\156\x5f\151\144\54\15\12\x20\x20\x20\40\40\x20\40\40\40\40\x20\40\x20\x20\40\40\x61\x63\164\151\166\x65\x20\x3d\40\72\x61\143\x74\151\166\x65\54\xd\xa\x20\40\40\x20\x20\x20\x20\x20\40\x20\x20\40\x20\x20\40\40\x74\x69\155\145\x41\x6c\141\x72\155\x20\x3d\x20\x3a\164\151\155\x65\x41\x6c\x61\162\x6d\54\15\xa\40\x20\x20\40\40\x20\x20\40\x20\40\x20\40\x20\x20\40\x20\163\x6b\x69\160\137\157\146\146\x5f\x61\154\x61\162\x6d\40\75\x20\72\x73\x6b\x69\x70\x5f\x6f\146\146\x5f\141\154\141\x72\155\54\15\12\x20\x20\40\40\40\40\40\x20\40\x20\x20\x20\x20\40\x20\x20\x63\157\x6e\x74\141\x63\x74\x5f\x67\162\157\x75\160\137\151\144\40\75\40\72\143\157\x6e\164\141\143\164\x5f\147\x72\157\165\x70\x5f\x69\x64\54\15\xa\40\40\x20\x20\40\40\x20\x20\x20\x20\x20\x20\x20\40\40\40\162\x65\160\145\x61\164\137\155\x69\x6e\x75\164\x65\x73\x20\x3d\x20\72\x72\x65\160\145\x61\x74\x5f\x6d\x69\x6e\x75\x74\x65\x73\x2c\15\xa\x20\40\x20\40\40\x20\x20\x20\x20\x20\x20\x20\x20\x20\40\40\x73\x75\x62\x6a\x65\143\x74\x20\75\x20\72\163\165\142\x6a\x65\x63\164\54\xd\xa\x20\x20\40\40\x20\x20\x20\40\x20\x20\x20\x20\x20\40\40\40\x6d\145\163\x73\141\147\x65\40\75\x20\72\x6d\x65\x73\163\141\147\145\x2c\15\xa\40\x20\x20\x20\40\40\x20\x20\x20\x20\x20\x20\x20\40\x20\40\144\145\x73\x63\x72\151\160\x74\x69\157\156\40\75\x20\72\x64\x65\163\x63\162\151\160\x74\x69\157\x6e\x2c\xd\12\x20\40\x20\x20\x20\x20\40\x20\40\40\40\40\x20\40\40\40\165\163\145\162\137\151\144\40\75\x20\x3a\x75\163\x65\162\x5f\151\144\40\40\40\40\x20\40\40\40\40\40\40\x20\40\x20\40\x20\40\x20\40\x20\x20\40\x20\40\x20\x20\40\x20\40\x20\xd\xa\40\x20\40\x20\40\40\40\x20\15\12\40\x20\x20\x20\40\x20\40\40\40\40\x20\40\40\40\40\x20\x57\x48\x45\122\105\40\x20\x61\154\x61\x72\x6d\137\x69\x64\40\75\40\72\141\154\141\162\155\137\151\x64\x3b"; $param = array("\161\x75\145\x72\171" => $query, "\x64\142" => $this->db, "\144\142\x5f\x74\x79\x70\145" => $this->db_type, "\163\x6b\151\x70\105\x73\143\141\x70\x65" => ["\x3a\x73\x75\x62\152\x65\143\x74", "\72\x6d\145\163\x73\x61\x67\x65", "\72\x64\145\x73\143\162\151\x70\164\x69\x6f\x6e"]); $stmt = vdv_prepare_query($param); $stmt->execute(array("\x3a\156\x61\x6d\145" => $alarm["\156\141\x6d\145"], "\72\163\164\141\x74\x69\157\x6e\x5f\x69\144" => $variable["\x73\164\141\x74\151\x6f\156\111\144"], "\x3a\141\143\x74\x69\x76\145" => $alarm["\155\x6f\156\151\x74\157\162"] == true ? 1 : 0, "\72\x74\x69\155\145\x41\154\141\x72\155" => $alarm["\x74\x69\155\145\x41\x6c\x61\x72\155"] == true ? 1 : 0, "\72\163\x6b\x69\160\137\157\x66\x66\x5f\141\x6c\141\162\x6d" => $alarm["\x73\x6b\x69\160\117\146\x66\101\154\x61\162\155"] == true ? 1 : 0, "\x3a\x63\x6f\x6e\164\141\143\x74\x5f\x67\x72\x6f\x75\x70\x5f\151\144" => $alarm["\x63\x6f\x6e\164\x61\x63\x74\107\x72\x6f\165\x70\111\144"], "\72\162\145\x70\x65\x61\x74\x5f\x6d\x69\156\x75\x74\x65\163" => $alarm["\x61\x6c\x61\162\x6d\x52\145\x70\x65\141\164\x4d\x69\x6e\x75\x74\145\x73"], "\72\x73\165\x62\152\145\143\x74" => $alarm["\141\154\x61\162\x6d\x53\x75\x62\152\145\x63\164"], "\72\x6d\145\163\163\x61\x67\145" => nl2br($alarm["\x61\x6c\141\162\155\115\x65\x73\163\x61\x67\145"]), "\x3a\x64\145\163\x63\162\151\160\x74\x69\x6f\156" => $alarm["\x61\x6c\141\x72\155\x44\x65\163\143\162\151\160\164\151\157\x6e"], "\72\165\163\145\162\x5f\151\x64" => $_SESSION["\165\x73\x65\x72"]["\165\x73\x65\162\x5f\151\x64"], "\72\141\154\x61\x72\x6d\x5f\151\x64" => $variable["\151\144"])); } private function deleteCustomAlarm($alarmId) { $query = "\104\x45\x4c\x45\x54\x45\40\106\x52\117\115\40\141\154\141\x72\155\x5f\143\x75\163\x74\157\x6d\x20\127\110\x45\122\105\40\x61\154\x61\x72\155\x5f\151\144\x20\x3d\40\x3a\141\x6c\141\162\155\111\144"; $param = array("\161\x75\145\162\171" => $query, "\x64\x62" => $this->db, "\144\142\137\x74\171\160\145" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\141\154\141\x72\155\x49\144" => $alarmId]); } private function saveCustomAlarmCondition($newAlarmId, $variable, $limit, $stationLatestTimeStamp, $limitList, $bulkAlarm) { $query = "\15\12\x20\40\x20\40\x20\40\x20\x20\111\x4e\x53\x45\122\124\x20\111\116\x54\117\x20\101\154\141\162\x6d\137\x43\165\x73\x74\157\155\x5f\x43\x6f\x6e\x64\x69\x74\x69\x6f\156\40\x28\x61\x6c\x61\162\155\137\151\x64\54\x20\166\x61\x72\151\x61\x62\154\x65\137\x69\x64\x2c\40\x6c\141\164\x65\x73\x74\x2c\40\154\x69\155\x69\164\137\166\x61\x6c\x75\x65\x2c\40\154\151\155\x69\x74\x5f\x74\x79\x70\145\x2c\x20\160\162\157\143\x65\163\x73\x2c\40\xd\12\40\40\x20\x20\x20\40\x20\40\40\x20\x20\40\160\145\162\x69\157\144\137\x68\x6f\x75\x72\x73\x2c\x20\141\x62\x73\157\154\165\x74\145\137\x76\141\x6c\165\145\54\40\x6c\x61\163\164\x5f\164\x69\x6d\x65\x73\164\141\x6d\x70\137\143\150\145\143\x6b\54\x20\x63\157\155\160\x61\162\145\x5f\x74\171\x70\145\54\40\166\x61\162\151\141\142\154\145\137\x69\x64\137\62\54\x20\x6c\x61\x74\145\163\164\137\x32\54\40\15\12\40\x20\x20\x20\x20\40\x20\x20\x20\40\x20\x20\160\145\162\151\157\x64\137\x68\157\x75\x72\163\x5f\x32\x2c\40\160\x72\x6f\x63\145\x73\163\137\x32\54\x20\x61\x62\163\x6f\x6c\165\164\145\x5f\166\x61\x6c\165\x65\137\x32\54\x20\x6f\x66\x66\x73\145\x74\x5f\62\x2c\40\141\154\x61\x72\155\124\x79\160\x65\x49\x64\x2c\x20\x64\x65\154\141\171\54\x20\x73\x74\x61\x72\164\x54\x69\155\x65\x2c\x20\163\x74\x6f\160\x54\151\x6d\x65\x2c\40\x64\x61\171\163\x29\15\12\x20\x20\x20\40\40\40\x20\40\40\x20\x20\x20\x56\101\114\125\x45\x53\x20\50\x3a\x61\154\x61\162\x6d\x5f\151\144\54\x20\x3a\x76\x61\162\x69\141\x62\154\x65\137\x69\144\54\40\x3a\154\x61\164\145\163\x74\54\40\x3a\154\151\x6d\151\164\x5f\166\141\x6c\x75\145\x2c\40\x3a\154\151\155\x69\164\x5f\164\x79\160\145\x2c\x20\72\160\x72\x6f\143\x65\163\x73\54\x20\xd\xa\40\x20\40\x20\40\x20\40\40\x20\x20\x20\40\x3a\160\145\162\151\157\144\x5f\150\157\165\x72\163\54\40\72\x61\x62\x73\x6f\154\x75\x74\x65\x5f\x76\141\x6c\165\145\x2c\x20\72\x6c\x61\x73\x74\137\x74\151\x6d\145\163\x74\141\x6d\x70\137\x63\150\145\x63\153\x2c\x20\x3a\143\157\x6d\x70\x61\x72\x65\x5f\164\x79\160\x65\x2c\x20\x3a\x76\x61\x72\151\x61\142\x6c\x65\x5f\x69\144\x5f\62\54\40\xd\xa\x20\40\x20\40\x20\40\x20\40\40\x20\x20\x20\x3a\154\x61\x74\145\163\164\137\62\x2c\x20\x3a\160\x65\162\x69\157\144\x5f\x68\x6f\165\x72\163\137\62\54\x20\72\x70\162\x6f\x63\145\163\163\x5f\x32\54\40\72\x61\x62\163\x6f\x6c\165\x74\x65\137\166\x61\x6c\165\145\137\62\x2c\40\x3a\x6f\x66\x66\163\145\x74\137\x32\x2c\40\72\141\154\141\x72\x6d\124\x79\160\x65\111\144\x2c\40\x3a\x64\145\154\141\171\54\x20\xd\12\x20\40\40\x20\40\x20\x20\40\x20\40\40\40\x3a\163\164\x61\162\164\124\151\x6d\145\x2c\40\x3a\163\x74\157\x70\124\151\155\145\54\x20\72\144\x61\171\163\51"; $param = array("\x71\165\x65\162\x79" => $query, "\x64\142" => $this->db, "\x64\142\137\x74\x79\160\145" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(array("\72\x61\x6c\141\162\155\x5f\151\144" => $newAlarmId, "\x3a\x76\141\162\151\x61\x62\154\145\x5f\x69\144" => $variable["\166\141\x72\x69\141\x62\x6c\x65\x49\x64"], "\72\154\141\x74\x65\163\x74" => $bulkAlarm["\x6c\x61\x74\x65\163\164"], "\72\x6c\x69\155\x69\164\137\x76\x61\x6c\165\145" => $limit["\x76\141\154\x75\x65"], "\x3a\x6c\x69\x6d\x69\164\x5f\x74\x79\160\145" => $limit["\163\x79\155\x62\x6f\x6c"], "\x3a\x70\x72\x6f\143\145\x73\163" => $bulkAlarm["\160\162\157\x63\x65\163\x73"], "\x3a\160\x65\162\151\x6f\144\x5f\x68\157\165\162\163" => $bulkAlarm["\x70\145\x72\x69\157\144\x48\x6f\x75\162\163"], "\72\x61\142\163\157\x6c\165\164\145\x5f\x76\x61\154\165\x65" => $bulkAlarm["\141\x62\163\x6f\154\x75\164\145\126\141\x6c\x75\145"], "\72\154\x61\163\164\x5f\164\x69\x6d\145\x73\164\141\x6d\160\137\143\150\x65\x63\153" => $stationLatestTimeStamp->format("\x59\55\155\55\144\40\x48\72\x69\72\x73"), "\72\143\157\155\160\x61\162\145\137\x74\171\160\x65" => 0, "\x3a\166\141\x72\x69\x61\142\154\x65\x5f\x69\x64\137\62" => 0, "\x3a\154\x61\164\x65\163\x74\137\x32" => 0, "\72\160\145\162\151\157\144\137\x68\157\x75\x72\x73\x5f\62" => 0, "\72\160\162\157\143\x65\x73\163\x5f\x32" => 0, "\x3a\x61\x62\163\157\154\x75\164\145\137\x76\x61\154\x75\145\x5f\x32" => 0, "\72\157\146\x66\163\145\x74\x5f\x32" => 0, "\72\141\x6c\141\162\x6d\x54\171\160\145\x49\144" => $limit["\141\154\x61\x72\x6d\x54\171\160\x65"]["\151\144"], "\72\144\x65\154\x61\x79" => $limit["\x64\x65\x6c\x61\x79"], "\x3a\x73\x74\x61\x72\164\124\x69\155\x65" => $limitList["\x73\x74\x61\x72\x74\x54\x69\x6d\x65"], "\x3a\163\164\x6f\x70\124\151\x6d\145" => $limitList["\x73\x74\x6f\x70\124\x69\x6d\x65"], "\x3a\144\141\x79\163" => implode("\54", $limitList["\144\x61\x79\x73"]))); } private function updateCustomAlarmCondition($variable, $bulkAlarm, $lastTimestampCheck) { $query = "\xd\xa\x20\40\40\40\40\x20\x20\40\40\40\x20\40\125\x50\104\x41\124\x45\40\x41\154\141\x72\155\x5f\103\x75\x73\164\157\155\x5f\103\x6f\x6e\x64\151\x74\x69\x6f\x6e\40\123\105\124\15\xa\x20\x20\40\40\40\40\40\x20\x20\40\40\40\x6c\141\164\x65\163\x74\40\x3d\40\x3a\x6c\141\164\x65\x73\x74\54\15\xa\40\40\40\x20\40\40\40\x20\x20\x20\x20\40\160\145\162\x69\x6f\x64\x5f\x68\x6f\x75\x72\163\x20\x3d\40\x3a\160\145\x72\151\x6f\x64\110\x6f\x75\162\163\x2c\15\12\40\40\x20\40\x20\x20\40\x20\x20\40\x20\x20\160\x72\157\143\145\x73\x73\40\x3d\x20\72\x70\x72\157\143\145\163\x73\x2c\15\12\x20\x20\x20\40\40\x20\x20\x20\x20\x20\x20\40\x61\x62\x73\x6f\x6c\165\x74\x65\137\x76\x61\154\165\x65\x20\x3d\40\72\x61\x62\x73\x6f\154\x75\x74\145\x56\141\x6c\x75\x65\x2c\x20\40\40\x20\x20\x20\40\40\40\x20\40\15\xa\40\x20\40\40\x20\40\x20\40\40\x20\x20\40\x6c\x61\x73\x74\137\164\151\155\x65\x73\x74\x61\x6d\x70\x5f\143\150\145\143\x6b\40\75\40\x3a\x6c\141\x73\164\x54\151\155\145\163\x74\141\155\160\103\150\x65\x63\x6b\54\40\40\40\x20\40\40\40\x20\x20\40\xd\12\x20\x20\x20\x20\x20\x20\40\x20\x20\40\x20\x20\154\x69\155\x69\164\137\166\141\x6c\x75\145\x20\75\x20\72\x6c\151\155\151\x74\126\141\154\165\145\54\xd\12\40\40\x20\40\40\40\40\40\40\x20\40\x20\x6c\151\155\151\164\x5f\x74\171\160\145\40\75\40\72\x6c\151\x6d\151\164\124\171\x70\x65\x2c\xd\12\40\x20\x20\x20\x20\x20\x20\x20\x20\40\x20\x20\141\x6c\x61\x72\155\x54\171\160\x65\111\144\75\40\72\141\x6c\x61\162\155\x54\x79\160\145\x49\x64\x2c\15\xa\40\x20\40\40\x20\x20\x20\40\40\40\x20\40\144\145\154\x61\171\40\x3d\40\x3a\x64\145\x6c\x61\171\x2c\15\xa\x20\40\x20\x20\x20\x20\x20\40\x20\x20\40\x20\x73\x74\x61\x72\164\124\151\x6d\x65\x20\x3d\40\x3a\x73\164\141\x72\164\124\x69\x6d\x65\54\15\12\x20\x20\x20\40\40\40\x20\40\40\x20\x20\40\163\164\x6f\160\124\x69\155\x65\40\75\x20\x3a\163\164\x6f\x70\124\151\x6d\145\x2c\15\12\x20\40\40\40\40\x20\x20\40\40\40\40\x20\x64\x61\171\x73\40\75\40\x3a\x64\141\x79\x73\x20\40\x20\40\40\x20\40\40\x20\40\xd\12\40\x20\x20\40\x20\40\40\x20\40\x20\40\40\x57\x48\105\x52\105\40\141\x6c\141\x72\x6d\137\x63\157\x6e\144\151\x74\151\x6f\156\x5f\151\x64\40\75\x20\x3a\x61\154\x61\x72\x6d\103\x6f\x6e\144\x69\x74\151\x6f\156\x49\144"; $param = array("\x71\x75\x65\162\x79" => $query, "\x64\142" => $this->db, "\144\142\137\164\x79\x70\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\72\154\141\164\145\x73\x74" => $bulkAlarm["\154\x61\164\x65\163\x74"], "\72\160\145\162\151\157\x64\110\x6f\x75\x72\163" => $bulkAlarm["\x70\145\x72\151\157\x64\110\157\x75\x72\163"], "\x3a\160\162\x6f\x63\x65\163\163" => $bulkAlarm["\x70\x72\x6f\x63\145\163\163"], "\x3a\x61\142\163\157\154\x75\x74\145\x56\x61\154\165\145" => $bulkAlarm["\x61\x62\x73\x6f\x6c\x75\164\145\x56\141\x6c\165\x65"], "\72\154\x61\163\x74\124\x69\155\145\x73\x74\141\155\x70\103\150\x65\143\153" => $lastTimestampCheck, "\154\x69\x6d\151\x74\126\x61\x6c\x75\145" => $variable["\166\x61\x6c\x75\145"], "\72\154\x69\155\151\164\124\x79\160\x65" => $variable["\163\x79\x6d\142\x6f\154"], "\72\x61\154\141\162\155\x54\x79\x70\x65\x49\x64" => $variable["\141\x6c\141\162\155\x54\171\x70\x65\x49\144"], "\x3a\x64\x65\154\141\x79" => $variable["\144\145\154\x61\x79"], "\72\x73\164\x61\x72\x74\x54\151\x6d\145" => $variable["\x73\x74\141\x72\164\x54\x69\x6d\x65"], "\x3a\x73\x74\x6f\x70\x54\x69\155\145" => $variable["\163\164\x6f\x70\124\151\x6d\x65"], "\72\x64\141\x79\x73" => implode("\x2c", $variable["\144\141\171\x73"]), "\x3a\141\154\141\x72\x6d\103\x6f\x6e\x64\x69\x74\x69\157\x6e\111\144" => $variable["\141\x6c\x61\162\x6d\103\157\x6e\x64\151\164\151\157\x6e\111\144"]]); } private function deleteCustomAlarmCondition($alarmId) { $query = "\x44\x45\x4c\x45\x54\105\x20\x46\122\x4f\115\x20\141\154\141\x72\155\137\x63\x75\163\x74\157\155\137\143\x6f\156\144\x69\164\x69\157\x6e\40\127\x48\x45\122\x45\x20\x61\x6c\141\x72\x6d\137\x69\144\x20\75\x20\72\x61\154\141\x72\x6d\111\144"; $param = array("\x71\165\145\x72\171" => $query, "\x64\x62" => $this->db, "\144\142\137\x74\171\x70\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\141\x6c\x61\162\155\111\144" => $alarmId]); } public function deleteCustomAlarmActive($alarmId) { $query = "\104\x45\114\x45\124\x45\x20\106\122\117\x4d\40\141\154\141\x72\x6d\x5f\143\165\163\x74\157\155\137\x61\x63\x74\151\x76\145\x20\x57\110\105\x52\x45\x20\x61\x6c\141\162\155\x5f\x69\x64\x20\75\x20\72\141\x6c\x61\162\155\111\x64"; $param = array("\161\165\145\x72\x79" => $query, "\x64\142" => $this->db, "\144\142\x5f\164\171\x70\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\141\154\141\x72\155\x49\144" => $alarmId]); } private function deleteAlarmsThatWereRemoved($variables) { foreach ($variables as $variable) { $alarmId = $variable["\x69\144"]; $this->deleteCustomAlarm($alarmId); $this->deleteCustomAlarmCondition($alarmId); $this->deleteCustomAlarmActive($alarmId); } } private function getLastTimestampCheckForAlarm($stationId) { $stationLatestTimeStamp = $this->getMaxTimestampFromStationId($stationId); $latestStationTimestamp = new DateTime($stationLatestTimeStamp); return $latestStationTimestamp; } public function getMaxTimestampFromStationId($stationId) { $query = "\123\105\x4c\x45\x43\x54\x20\x4d\x41\x58\x28\x6c\141\163\164\137\164\x69\155\145\x73\164\141\x6d\x70\x29\x20\141\x73\x20\164\151\x6d\145\163\164\x61\155\160\x20\x46\x52\117\x4d\40\x46\x69\x6c\x65\x5f\120\x61\x74\150\x20\127\110\x45\122\105\x20\163\x74\141\164\x69\x6f\x6e\x5f\x69\x64\x20\x3d\x20\x3a\163\164\141\164\151\157\x6e\x49\x64"; $param = array("\x71\x75\145\162\171" => $query, "\144\142" => $this->db, "\144\x62\137\x74\171\x70\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(["\163\x74\x61\x74\151\157\156\x49\144" => $stationId]); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result["\164\x69\x6d\x65\x73\164\x61\155\x70"]; } public function checkIfvariableHasAlarm($variable) { $query = "\15\12\x20\40\40\x20\40\40\40\40\123\105\114\105\103\x54\x20\141\143\x2e\52\54\141\x74\x2e\143\x6f\154\157\162\x2c\141\x74\x2e\162\141\x6e\153\54\x61\x74\56\x6e\x61\155\x65\xd\xa\x20\x20\x20\40\x20\x20\x20\40\106\x52\117\115\x20\141\x6c\x61\x72\x6d\137\143\165\163\x74\x6f\155\x5f\x63\x6f\x6e\144\x69\164\151\157\156\x20\x41\x53\x20\x61\x63\40\40\40\40\40\40\x20\40\40\x20\40\40\xd\xa\x20\x20\x20\x20\40\x20\40\40\x4a\x4f\111\x4e\40\141\154\x61\162\155\x5f\143\165\x73\164\157\155\x20\101\x53\40\x61\x6c\141\162\x6d\x43\x75\163\x74\157\155\x20\117\116\x20\x61\x63\x2e\x61\x6c\x61\162\155\137\151\144\40\x3d\x20\x61\154\141\162\155\x43\165\x73\164\157\x6d\56\x61\154\x61\162\155\x5f\151\144\15\xa\40\x20\x20\40\40\x20\40\x20\x4a\117\x49\x4e\40\141\154\x61\x72\x6d\137\164\171\160\145\163\40\x41\x53\40\x61\x74\40\157\156\x20\x61\143\x2e\141\154\x61\x72\x6d\124\171\160\145\111\x64\40\x3d\40\x61\164\56\151\144\x20\15\xa\x20\40\40\x20\x20\x20\40\40\x4a\117\111\x4e\40\141\x6c\x61\162\x6d\137\143\x75\x73\x74\x6f\155\137\x61\x63\164\151\x76\x65\x20\101\x53\40\x61\141\x20\x6f\156\40\141\x63\x2e\x61\154\x61\x72\155\x5f\x69\x64\40\x3d\x20\141\141\x2e\141\x6c\141\x72\155\137\151\x64\xd\12\40\40\40\40\40\x20\x20\40\127\x48\x45\x52\105\40\166\141\162\x69\x61\142\154\145\137\151\144\x20\75\40\x3a\x76\141\162\x69\x61\x62\x6c\145\x49\x64\40\141\x6e\x64\40\x61\x61\x2e\x61\154\x61\x72\155\x5f\x6f\156\x20\75\x20\x31\x20\x41\116\104\40\x61\x6c\141\x72\155\x43\x75\163\164\157\155\56\141\143\x74\151\166\145\x20\75\40\x31\xd\12\x20\x20\x20\x20\40\40\40\x20\117\122\104\x45\x52\40\x42\x59\40\x61\164\56\162\x61\x6e\153\x20\x44\x45\x53\x43\x3b"; $param = array("\x71\x75\145\x72\x79" => $query, "\x64\x62" => $this->db, "\144\x62\x5f\x74\x79\x70\145" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(array("\166\141\162\x69\141\x62\x6c\145\111\144" => $variable["\166\x61\162\151\x61\x62\x6c\x65\137\x69\144"])); return $stmt->fetchAll(PDO::FETCH_ASSOC); } public function checkIfvariableHasCustomAlarm($variable) { $query = "\xd\xa\40\x20\x20\40\40\x20\x20\x20\x53\x45\x4c\x45\103\x54\x20\x61\143\56\52\54\x61\154\141\162\155\x43\x75\163\x74\x6f\x6d\x2e\x61\x63\164\x69\166\x65\x20\141\163\x20\x61\154\x61\x72\155\x41\143\x74\151\166\145\xd\xa\40\40\x20\40\x20\40\40\40\106\x52\x4f\115\40\x61\x6c\141\x72\x6d\137\x63\165\163\164\x6f\155\x5f\143\x6f\x6e\x64\151\164\151\x6f\156\x20\101\123\40\141\x63\x20\xd\xa\x20\x20\x20\40\40\40\x20\x20\x4a\117\x49\116\x20\141\154\x61\162\x6d\137\143\x75\x73\x74\x6f\x6d\137\141\143\164\x69\x76\145\x20\101\x53\x20\x61\x61\40\157\x6e\40\141\x63\56\141\x6c\141\x72\x6d\137\151\144\40\x3d\x20\141\141\56\141\154\141\162\x6d\x5f\151\x64\15\xa\40\x20\x20\40\x20\40\40\x20\x4a\x4f\111\x4e\x20\141\x6c\141\x72\155\137\x63\165\163\164\157\155\x20\101\123\40\x61\x6c\141\162\x6d\103\165\163\164\x6f\155\40\x6f\156\x20\141\x6c\x61\162\155\103\165\x73\x74\157\x6d\56\141\154\141\x72\x6d\137\x69\144\40\x3d\40\141\x61\56\141\154\x61\162\x6d\137\151\x64\xd\xa\x20\x20\40\40\x20\40\40\x20\127\x48\105\x52\x45\40\x76\141\162\x69\x61\x62\x6c\x65\137\151\x64\x20\x3d\40\72\x76\141\162\151\141\142\x6c\x65\x49\x64\x20\141\x6e\x64\x20\x61\141\x2e\x61\x6c\x61\x72\155\x5f\x6f\156\40\75\40\x31\15\12\x20\x20\x20\40\40\40\x20\x20\117\x52\x44\105\122\x20\x42\x59\x20\141\154\x61\x72\x6d\x41\143\164\151\166\x65\40\104\105\123\103\73"; $param = array("\x71\x75\x65\162\171" => $query, "\144\142" => $this->db, "\x64\142\x5f\164\x79\x70\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(array("\166\141\162\151\x61\x62\154\x65\x49\144" => $variable["\x76\x61\x72\x69\x61\142\154\145\x5f\151\144"])); return $stmt->fetchAll(PDO::FETCH_ASSOC); } public function variableHasAssignedAlarm($variableId) { $query = "\15\xa\40\x20\x20\40\x20\40\x20\x20\x20\x20\40\40\x53\x45\x4c\105\x43\124\x20\143\x6f\165\x6e\164\50\52\x29\40\141\163\40\166\141\162\x69\x61\142\154\x65\x43\157\165\x6e\x74\xd\12\x20\x20\40\40\x20\x20\x20\x20\x20\x20\x20\40\x46\x52\x4f\x4d\x20\x61\x6c\141\162\155\x5f\143\x75\x73\x74\x6f\x6d\137\x63\x6f\x6e\144\151\164\x69\x6f\x6e\x20\101\123\40\141\x63\x20\40\x20\40\x20\x20\40\40\x20\x20\40\40\xd\12\x20\x20\40\x20\x20\x20\40\x20\40\40\x20\40\x4a\117\x49\x4e\40\141\x6c\141\162\155\x5f\143\x75\x73\x74\x6f\x6d\x20\x41\x53\x20\x61\154\x61\162\155\103\x75\163\x74\x6f\x6d\40\x4f\x4e\40\141\x63\x2e\141\154\141\162\x6d\x5f\x69\x64\40\75\x20\141\154\141\162\x6d\103\x75\163\164\157\x6d\x2e\x61\154\141\x72\155\x5f\151\x64\15\12\40\x20\x20\40\x20\x20\x20\40\x20\x20\x20\x20\127\x48\105\122\105\40\x76\x61\162\151\141\142\x6c\x65\137\151\x64\x20\75\x20\72\x76\x61\x72\151\141\x62\x6c\145\111\144\40\x41\116\x44\x20\x61\154\x61\162\x6d\x43\x75\x73\x74\157\155\56\x61\x63\x74\151\166\x65\40\x3d\40\61"; $param = array("\161\x75\x65\162\171" => $query, "\x64\142" => $this->db, "\144\142\137\x74\x79\x70\x65" => $this->db_type); $stmt = vdv_prepare_query($param); $stmt->execute(array("\166\x61\x72\x69\141\x62\154\x65\x49\144" => $variableId)); $result = $stmt->fetch(PDO::FETCH_ASSOC); if ($result !== false && is_array($result) && $result["\x76\x61\x72\151\141\x62\x6c\x65\x43\157\x75\156\164"] > 0) { return true; } return false; } }

Function Calls

None

Variables

None

Stats

MD5 9556cf72076e5bc79b48ac6e67bfeee8
Eval Count 0
Decode Time 94 ms