mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
▶ Ad-hoc event bug fix
This commit is contained in:
@@ -945,7 +945,8 @@ function updateApi()
|
|||||||
{
|
{
|
||||||
|
|
||||||
// value has to be in format event|param. e.g. run|ARPSCAN
|
// value has to be in format event|param. e.g. run|ARPSCAN
|
||||||
action = `update_api|devices,appevents`
|
action = `${getGuid()}|update_api|devices,appevents`
|
||||||
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ function getCellValue(row, index) {
|
|||||||
|
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
// Calls a backend function to add a front-end event (specified by the attributes 'data-myevent' and 'data-myparam-plugin' on the passed element) to an execution queue
|
// Calls a backend function to add a front-end event (specified by the attributes 'data-myevent' and 'data-myparam-plugin' on the passed element) to an execution queue
|
||||||
function addToExecutionQueue(element)
|
function addToExecutionQueue_settingEvent(element)
|
||||||
{
|
{
|
||||||
|
|
||||||
// value has to be in format event|param. e.g. run|ARPSCAN
|
// value has to be in format event|param. e.g. run|ARPSCAN
|
||||||
|
|||||||
@@ -624,7 +624,7 @@ function restartBackend() {
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "php/server/util.php",
|
url: "php/server/util.php",
|
||||||
data: { function: "addToExecutionQueue", action: 'cron_restart_backend' },
|
data: { function: "addToExecutionQueue", action: `${getGuid()}|cron_restart_backend` },
|
||||||
success: function(data, textStatus) {
|
success: function(data, textStatus) {
|
||||||
// showModalOk ('Result', data );
|
// showModalOk ('Result', data );
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,17 @@
|
|||||||
"filePath": "/app/front/log/app.php_errors.log",
|
"filePath": "/app/front/log/app.php_errors.log",
|
||||||
"textAreaCssClass": "logs logs-small"
|
"textAreaCssClass": "logs logs-small"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"buttons": [
|
||||||
|
{
|
||||||
|
"labelStringCode": "Maint_PurgeLog",
|
||||||
|
"event": "logManage('execution_queue.log', 'cleanLog')"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fileName": "execution_queue.log",
|
||||||
|
"filePath": "/app/front/log/execution_queue.log",
|
||||||
|
"textAreaCssClass": "logs logs-small"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"buttons": [
|
"buttons": [
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ function displayMessage($message, $logAlert = FALSE, $logConsole = TRUE, $logFil
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
// Adds an action to perform into the execution_queue.log file
|
// Adds an action to perform into the execution_queue.log file
|
||||||
function addToExecutionQueue($action)
|
function addToExecutionQueue($action)
|
||||||
@@ -253,7 +254,7 @@ function cleanLog($logFile)
|
|||||||
|
|
||||||
$path = "";
|
$path = "";
|
||||||
|
|
||||||
$allowedFiles = ['app.log', 'app_front.log', 'IP_changes.log', 'stdout.log', 'stderr.log', "pholus_lastrun.log", 'app.php_errors.log'];
|
$allowedFiles = ['app.log', 'app_front.log', 'IP_changes.log', 'stdout.log', 'stderr.log', "pholus_lastrun.log", 'app.php_errors.log', 'execution_queue.log'];
|
||||||
|
|
||||||
if(in_array($logFile, $allowedFiles))
|
if(in_array($logFile, $allowedFiles))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
require dirname(__FILE__).'/../templates/timezone.php';
|
require dirname(__FILE__).'/../templates/timezone.php';
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
// Check if the action parameter is set in the GET request
|
// Check if the action parameter is set in the GET request
|
||||||
if (isset($_GET['action'])) {
|
if (isset($_GET['action'])) {
|
||||||
// Collect GUID if provided
|
// Collect GUID if provided
|
||||||
@@ -46,6 +46,8 @@ if (isset($_GET['action'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
|
// Generates a random GUID
|
||||||
function generate_guid() {
|
function generate_guid() {
|
||||||
if (function_exists('com_create_guid') === true) {
|
if (function_exists('com_create_guid') === true) {
|
||||||
return trim(com_create_guid(), '{}');
|
return trim(com_create_guid(), '{}');
|
||||||
@@ -54,8 +56,10 @@ function generate_guid() {
|
|||||||
mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535),
|
mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535),
|
||||||
mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535),
|
mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535),
|
||||||
mt_rand(0, 65535), mt_rand(0, 65535));
|
mt_rand(0, 65535), mt_rand(0, 65535));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
|
// Logs a notification in in-app notification system
|
||||||
function write_notification($content, $level = "interrupt") {
|
function write_notification($content, $level = "interrupt") {
|
||||||
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
||||||
|
|
||||||
@@ -87,6 +91,8 @@ function write_notification($content, $level = "interrupt") {
|
|||||||
file_put_contents($NOTIFICATION_API_FILE, json_encode($notifications));
|
file_put_contents($NOTIFICATION_API_FILE, json_encode($notifications));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
|
// Removes a notification based on GUID
|
||||||
function remove_notification($guid) {
|
function remove_notification($guid) {
|
||||||
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
||||||
|
|
||||||
@@ -102,6 +108,8 @@ function remove_notification($guid) {
|
|||||||
file_put_contents($NOTIFICATION_API_FILE, json_encode(array_values($filtered_notifications)));
|
file_put_contents($NOTIFICATION_API_FILE, json_encode(array_values($filtered_notifications)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
|
// Deletes all notifications
|
||||||
function notifications_clear() {
|
function notifications_clear() {
|
||||||
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
||||||
|
|
||||||
@@ -109,6 +117,8 @@ function notifications_clear() {
|
|||||||
file_put_contents($NOTIFICATION_API_FILE, json_encode(array()));
|
file_put_contents($NOTIFICATION_API_FILE, json_encode(array()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
|
// Mark a notification read based on GUID
|
||||||
function mark_notification_as_read($guid) {
|
function mark_notification_as_read($guid) {
|
||||||
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
||||||
$max_attempts = 3;
|
$max_attempts = 3;
|
||||||
@@ -152,10 +162,12 @@ function mark_notification_as_read($guid) {
|
|||||||
echo "Failed to read notification file after $max_attempts attempts.";
|
echo "Failed to read notification file after $max_attempts attempts.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
function notifications_mark_all_read() {
|
function notifications_mark_all_read() {
|
||||||
mark_notification_as_read(null);
|
mark_notification_as_read(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
function get_unread_notifications() {
|
function get_unread_notifications() {
|
||||||
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
$NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json';
|
||||||
|
|
||||||
|
|||||||
@@ -40,3 +40,4 @@ $timestamp = $date->format('Y-m-d_H-i-s');
|
|||||||
// ###################################
|
// ###################################
|
||||||
// ## TimeZone processing end
|
// ## TimeZone processing end
|
||||||
// ###################################
|
// ###################################
|
||||||
|
|
||||||
|
|||||||
@@ -389,6 +389,7 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
|
|||||||
// not initialized properly, reload
|
// not initialized properly, reload
|
||||||
if(isMetadata && val == "" )
|
if(isMetadata && val == "" )
|
||||||
{
|
{
|
||||||
|
console.warn(`Metadata setting value is empty: ${codeName}`);
|
||||||
clearCache();
|
clearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,7 +605,7 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
|
|||||||
data-myparam="${codeName}"
|
data-myparam="${codeName}"
|
||||||
data-myparam-plugin="${prefix}"
|
data-myparam-plugin="${prefix}"
|
||||||
data-myevent="${event}"
|
data-myevent="${event}"
|
||||||
onclick="addToExecutionQueue(this)"
|
onclick="addToExecutionQueue_settingEvent(this)"
|
||||||
>
|
>
|
||||||
<i title="${getString(event + "_event_tooltip")}" class="fa ${getString(event + "_event_icon")}">
|
<i title="${getString(event + "_event_tooltip")}" class="fa ${getString(event + "_event_icon")}">
|
||||||
</i>
|
</i>
|
||||||
|
|||||||
@@ -768,11 +768,9 @@ def check_and_run_user_event(db, all_plugins, pluginsState):
|
|||||||
# Split the line by '|', and take the third and fourth columns (indices 2 and 3)
|
# Split the line by '|', and take the third and fourth columns (indices 2 and 3)
|
||||||
columns = line.strip().split('|')[2:4]
|
columns = line.strip().split('|')[2:4]
|
||||||
|
|
||||||
if len(columns) != 2:
|
event, param = "", ""
|
||||||
remaining_lines.append(line)
|
if len(columns) == 2:
|
||||||
continue
|
event, param = columns
|
||||||
|
|
||||||
event, param = columns
|
|
||||||
|
|
||||||
if event == 'test':
|
if event == 'test':
|
||||||
show_events_completed = True
|
show_events_completed = True
|
||||||
|
|||||||
Reference in New Issue
Block a user