diff --git a/front/devices.php b/front/devices.php index a2cb9aa8..7588f9b6 100755 --- a/front/devices.php +++ b/front/devices.php @@ -550,10 +550,10 @@ function initializeDatatable (status) { 'createdCell': function (td, cellData, rowData, row, col) { if (!emptyArr.includes(cellData)){ $(td).html (` - + ${cellData} - + `); diff --git a/front/network.php b/front/network.php index 6d7a9b6e..b24a406a 100755 --- a/front/network.php +++ b/front/network.php @@ -525,53 +525,57 @@ // --------------------------------------------------------------------------- - function getChildren(node, list, path) + // Recursively get children nodes and build a tree + function getChildren(node, list, path, visited = []) { - var children = []; - - // loop thru all items and find childern... - for(var i in list) - { - //... of the current node - - if(list[i].parentMac.toLowerCase() == node.mac.toLowerCase() && !hiddenMacs.includes(list[i].parentMac)) - { - - visibleNodesCount++ - - // and process them - children.push(getChildren(list[i], list, path + ((path == "") ? "" : '|') + list[i].parentMac, hiddenMacs)) + var children = []; + // Check for infinite recursion by seeing if the node has been visited before + if (visited.includes(node.mac.toLowerCase())) { + console.error("Infinite recursion detected at node:", node.mac); + write_notification("[ERROR] ⚠ Infinite recursion detected. You probably have assigned the Internet node to another children node or to itself. Please open a new issue on GitHub and describe how you did it.", 'interrupt') + return { error: "Infinite recursion detected", node: node.mac }; } - } - // note the total number of leaf nodes to calculate the font scaling - if(children.length == 0) - { - leafNodesCount++ - } else - { - parentNodesCount++ - } - - return { - name: node.name, - path: path, - mac: node.mac, - port: node.port, - id: node.mac, - parentMac: node.parentMac, - icon: node.icon, - type: node.type, - status: node.status, - hasChildren: children.length > 0 || hiddenMacs.includes(node.mac), - hiddenChildren: hiddenMacs.includes(node.mac), - qty: children.length, - children: children - }; - + // Add current node to visited list + visited.push(node.mac.toLowerCase()); + + // Loop through all items to find children of the current node + for (var i in list) { + if (list[i].parentMac.toLowerCase() == node.mac.toLowerCase() && !hiddenMacs.includes(list[i].parentMac)) { + + visibleNodesCount++; + + // Process children recursively, passing a copy of the visited list + children.push(getChildren(list[i], list, path + ((path == "") ? "" : '|') + list[i].parentMac, visited)); + } + } + + // Track leaf and parent node counts + if (children.length == 0) { + leafNodesCount++; + } else { + parentNodesCount++; + } + + return { + name: node.name, + path: path, + mac: node.mac, + port: node.port, + id: node.mac, + parentMac: node.parentMac, + icon: node.icon, + type: node.type, + status: node.status, + hasChildren: children.length > 0 || hiddenMacs.includes(node.mac), + hiddenChildren: hiddenMacs.includes(node.mac), + qty: children.length, + children: children + }; } + // --------------------------------------------------------------------------- function getHierarchy() diff --git a/front/plugins/_publisher_email/email_smtp.py b/front/plugins/_publisher_email/email_smtp.py index 1d881e38..0ef5c2ae 100755 --- a/front/plugins/_publisher_email/email_smtp.py +++ b/front/plugins/_publisher_email/email_smtp.py @@ -111,7 +111,7 @@ def send(pHTML, pText): mylog('debug', [f'[{pluginName}] SMTP_REPORT_TO: {hide_email(str(get_setting_value("SMTP_REPORT_TO")))} SMTP_USER: {hide_email(str(get_setting_value("SMTP_USER")))}']) - subject, from_email, to_email, message_html, message_text = sanitize_email_content('Net AlertX Report', get_setting_value("SMTP_REPORT_FROM"), get_setting_value("SMTP_REPORT_TO"), pHTML, pText) + subject, from_email, to_email, message_html, message_text = sanitize_email_content('NetAlertX Report', get_setting_value("SMTP_REPORT_FROM"), get_setting_value("SMTP_REPORT_TO"), pHTML, pText) # Compose email msg = MIMEMultipart('alternative') diff --git a/front/report_templates/report_sample.html b/front/report_templates/report_sample.html index 45aef2ba..85195617 100755 --- a/front/report_templates/report_sample.html +++ b/front/report_templates/report_sample.html @@ -13,7 +13,7 @@
- Net Alertx + NetAlertx diff --git a/front/report_templates/report_template.html b/front/report_templates/report_template.html index 09fe10b3..c96a2a66 100755 --- a/front/report_templates/report_template.html +++ b/front/report_templates/report_template.html @@ -22,7 +22,7 @@
- Net Alertx + NetAlertx diff --git a/front/report_templates/report_template_new_version.html b/front/report_templates/report_template_new_version.html index d655ed30..9d1f9940 100755 --- a/front/report_templates/report_template_new_version.html +++ b/front/report_templates/report_template_new_version.html @@ -22,7 +22,7 @@
- Net Alertx + NetAlertx