-- -- (C) 2013-26 - ntop.org -- local dirs = ntop.getDirs() local info = ntop.getInfo() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path require "label_utils" local script_manager = require("script_manager") local template_utils = require("template_utils") local recording_utils = require("recording_utils") local alert_entities = require("alert_entities") local page_utils = {} local is_nedge = ntop.isnEdge() -- ################################# local active_section = nil local active_entry = nil local active_sub_entry = nil local zoneinfo = 'null' local temp_zoneinfo = ntop.getInfo().zoneinfo local newline = string.find(temp_zoneinfo, "\n") -- WARNING: in FreeBSD, the zoneinfo ends with a newline character, so remove the newline and everything works fine if newline then temp_zoneinfo = string.sub(temp_zoneinfo, 1, newline - 1) end if temp_zoneinfo ~= nil then zoneinfo = "( /^[\\x00-\\xFF]*$/.test('" .. temp_zoneinfo .. "') && moment.tz.zone('" .. temp_zoneinfo .. "') != null ? '" .. temp_zoneinfo .. "' : function() { console.warn('zoneinfo not valid:' + (/^[\\x00-\\xFF]*$/.test('" .. temp_zoneinfo .. "') ? '" .. temp_zoneinfo .. "' : 'Invalid string') ); return null; }())" end -- ################################# page_utils.menu_sections = { monitoring = { key = "monitoring", i18n_title = "monitoring", icon = "fas fa-satellite-dish" }, dashboard = { key = "dashboard", i18n_title = "index_page.dashboard", icon = "fas fa-tachometer-alt" }, alerts = { key = "alerts", i18n_title = "details.alerts", icon = "fas fa-exclamation-triangle" }, flows = { key = "flows", i18n_title = "flows", icon = "fas fa-stream" }, hosts = { key = "hosts", i18n_title = "hosts", icon = "fas fa-laptop" }, maps = { key = "maps", i18n_title = "maps", icon = "fas fa-map" }, collection = { key = "collection", i18n_title = "flow_devices.exporters", icon = "fas fa-file-export", zmq_only = true --[[ only for non-packet ZMQ interfaces --]] }, if_stats = { key = "if_stats", i18n_title = "interface", icon = "fas fa-ethernet" }, system_stats = { key = "system_stats", i18n_title = "system", icon = "fas fa-desktop" }, admin = { key = "admin", i18n_title = "settings", icon = "fas fa-cog" }, alert_exclusions = { key = "alert_exclusions", i18n_title = "edit_check.exclusion_list", icon = "fas fa-bell-slash" }, dev = { key = "dev", i18n_title = "developer", icon = "fas fa-code" }, about = { key = "about", i18n_title = "help", icon = "fas fa-life-ring" }, nanalyst = { key = "nanalyst", i18n_title = "nanalyst", -- icon = "fa-solid fa-headset" icon = "fa-solid fa-magnifying-glass-chart" -- icon = "fa-solid fa-brain" }, health = { key = "health", i18n_title = "health", icon = "fas fa-laptop-medical" }, pollers = { key = "pollers", i18n_title = "pollers", icon = "fas fa-heartbeat" }, tools = { key = "tools", i18n_title = "tools", icon = "fas fa-cogs" }, pools = { key = "pools", i18n_title = "pools.pools", icon = "fas fa-users" }, notifications = { key = "notifications", i18n_title = "endpoint_notifications.notifications", icon = "fas fa-bell" }, checks = { key = "checks", i18n_title = "about.checks" }, policies = { key = "policies", i18n_title = "policies", icon = "fa-solid fa-book-open" }, as = { key = "as", i18n_title = "as", icon = "fas fa-globe" }, -- nEdge views = { key = "views", i18n_title = "views", icon = "fas fa-bars" } } -- ################################# -- help_link: this variable contains the contextual link to the documentation page_utils.menu_entries = { -- Monitoring active_monitoring = { key = "active_monitoring", i18n_title = "active_monitoring_stats.active_monitoring", section = "monitoring" }, network_discovery = { key = "network_discovery", i18n_title = "discover.network_discovery", section = "monitoring" }, vulnerability_scan = { key = "vulnerability_scan", i18n_title = "scan_hosts", section = "monitoring" }, -- Dashboard traffic_dashboard = { key = "traffic_dashboard", i18n_title = "dashboard.traffic_dashboard", section = "dashboard", help_link = "https://www.ntop.org/guides/ntopng/user_interface/network_interface/dashboard/dashboard.html" }, traffic_report = { key = "traffic_report", i18n_title = "report.traffic_report", section = "dashboard", help_link = "https://www.ntop.org/guides/ntopng/flow_dump/clickhouse/reports.html" }, assets_dashboard = { key = "assets_dashboard", i18n_title = "assets", section = "dashboard", help_link = "https://www.ntop.org/guides/ntopng/flow_dump/clickhouse/reports.html" }, traffic_analysis = { key = "traffic_analysis", i18n_title = "db_explorer.traffic_analysis", section = "dashboard", help_link = "https://www.ntop.org/guides/ntopng/flow_dump/clickhouse/historical_flows.html" }, -- Alerts detected_alerts = { key = "detected_alerts", i18n_title = "show_alerts.detected_alerts", section = "alerts", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/alerts_explorer.html" }, alerts_dashboard = { key = "alerts_dashboard", i18n_title = "alerts_dashboard.alerts_dashboard", section = "alerts" }, flow_alerts_explorer = { key = "flow_alerts_explorer", i18n_title = "flow_alerts_explorer.label", section = "alerts" }, alerts_list = { key = "alerts_list", i18n_title = "details.alerts_list", section = "alerts" }, alerts_analysis = { key = "alerts_analysis", i18n_title = "details.alerts_analysis", section = "alerts" }, alerts_graph = { key = "alerts_graph", i18n_title = "details.alerts_graph", section = "alerts" }, alerts_geomap = { key = "alerts_geomap", i18n_title = "details.alerts_geomap", section = "alerts" }, -- Flows flows = { key = "flows", i18n_title = "flows", section = "flows", help_link = "https://www.ntop.org/guides/ntopng/user_interface/network_interface/flows/flows.html" }, active_flows = { key = "active_flows", i18n_title = "active_flows", section = "flows" }, flow_details = { key = "flow_details", i18n_title = "flow_details.flow_details", section = "flows" }, db_explorer = { key = "db_explorer", i18n_title = "db_explorer.historical_data_explorer", section = "flows", help_link = "https://www.ntop.org/guides/ntopng/flow_dump/clickhouse/historical_flows.html" }, historical_flows = { key = "db_explorer", i18n_title = "historical_flows", section = "flows", help_link = "https://www.ntop.org/guides/ntopng/flow_dump/clickhouse/historical_flows.html" }, server_ports = { key = "server_ports", i18n_title = "server_ports.server_ports", section = "flows", help_link = "https://www.ntop.org/guides/ntopng/user_interface/network_interface/flows/server_ports.html" }, -- Hosts hosts = { key = "hosts", i18n_title = "hosts", section = "hosts", help_link = "https://www.ntop.org/guides/ntopng/user_interface/network_interface/hosts/hosts.html#id1" }, hosts_asn_mode = { key = "hosts", i18n_title = "hosts", section = "views", help_link = "https://www.ntop.org/guides/ntopng/user_interface/network_interface/hosts/hosts.html#id1" }, devices = { key = "devices", i18n_title = "layer_2", section = "hosts" }, assets = { key = "assets", i18n_title = "assets", section = "hosts" }, -- Chatbot (nAnalyst) nanalyst = { key = "nanalyst", i18n_title = "nanalyst", section = "nanalyst" }, -- Interface interface = { key = "interface", i18n_title = "interface_details", section = "if_stats" }, networks = { key = "networks", i18n_title = "networks", section = "if_stats", help_link = "https://www.ntop.org/guides/ntopng/user_interface/network_interface/interface/networks.html" }, vlans = { key = "vlans", i18n_title = "vlan_stats.vlans", section = "if_stats" }, host_pools = { key = "host_pools", i18n_title = "host_pools.host_pools", section = "if_stats" }, autonomous_systems = { key = "autonomous_systems", i18n_title = "as_stats.autonomous_systems", section = "if_stats", help_link = "https://www.ntop.org/guides/ntopng/user_interface/network_interface/interface/autonomous_systems.html" }, -- ASN Mode exporters_interfaces_traffic_asn_mode = { key = "exporters_interfaces_traffic_asn_mode", i18n_title = "exporters_interfaces_configuration.network_communications", section = "as" }, historical_autonomous_systems_asn_mode = { key = "historical_autonomous_systems_asn_mode", i18n_title = "db_explorer.historical_data_explorer", section = "as" }, active_flows_asn_mode = { key = "active_flows_asn_mode", i18n_title = "active_flows", section = "views" }, historical_flows_asn_mode = { key = "historical_flows_asn_mode", i18n_title = "historical_flows", section = "views" }, server_ports_asn_mode = { key = "server_ports", i18n_title = "server_ports.server_ports", section = "views" }, countries = { key = "countries", i18n_title = "countries", section = "if_stats", help_link = "https://www.ntop.org/guides/ntopng/user_interface/network_interface/interface/countries.html" }, operating_systems = { key = "operating_systems", i18n_title = "operating_systems", section = "if_stats", help_link = "https://www.ntop.org/guides/ntopng/user_interface/network_interface/interface/operating_systems.html" }, containers = { key = "containers", i18n_title = "containers_stats.containers", section = "if_stats" }, pods = { key = "pods", i18n_title = "containers_stats.pods", section = "if_stats" }, -- Pollers snmp = { key = "snmp", i18n_title = "prefs.snmp", section = "pollers" }, assets_snmp = { key = "assets_snmp", i18n_title = "assets_snmp", section = "pollers" }, snmp_monitoring = { key = "snmp_monitoring", i18n_title = "prefs.snmp", section = "monitoring" }, infrastructure_dashboard = { key = "infrastructure_dashboard", i18n_title = "infrastructure_dashboard.infrastructure_dashboard", section = "pollers" }, -- Status (Health) system_status = { key = "system_status", i18n_title = "system_status", section = "health" }, interfaces_status = { key = "interfaces_status", i18n_title = "system_interfaces_status", section = "health" }, alerts_status = { key = "alerts_status", i18n_title = "system_alerts_status", section = "health" }, influxdb_status = { key = "influxdb_status", i18n_title = "InfluxDB", section = "health" }, redis_status = { key = "redis_status", i18n_title = "Redis", section = "health" }, clickhouse_status = { key = "clickhouse", i18n_title = "ClickHouse", section = "health" }, -- exporters event_exporters = { key = "event_exporters", i18n_title = "event_exporters.event_exporters", section = "collection" }, sflow_exporters = { key = "sflow_exporters", i18n_title = "flows_page.sflow_devices", section = "collection" }, exporters = { key = "exporters", i18n_title = "flow_devices.flow_exporters", section = "collection", help_link = "https://www.ntop.org" }, nprobe = { key = "nprobe", i18n_title = "flow_devices.nprobe_instances", section = "collection" }, exporters_interfaces_stats = { key = "exporters_interfaces_stats", i18n_title = "flow_devices.exporters_interfaces_stats", section = "collection" }, observation_points = { key = "observation_points", i18n_title = "flow_devices.observation_points", section = "collection", help_link = "https://www.ntop.org" }, exporter_sites = { key = "exporter_sites", i18n_title = "exporter_sites_page.exporter_sites", section = "collection", help_link = "https://www.ntop.org" }, -- Map analysis_map = { key = "analysis_map", i18n_title = "analysis", section = "maps" }, geo_map = { key = "geo_map", i18n_title = "geo_map.geo_map", section = "maps", help_link = "https://www.ntop.org/guides/ntopng/user_interface/network_interface/maps/geo_map.html" }, hosts_map = { key = "hosts_map", i18n_title = "flows_page.hosts", section = "maps" }, -- Settings nedge_users = { key = "nedge_users", i18n_title = "manage_users.manage_users", section = "admin", help_link = "https://www.ntop.org/guides/nedge/users.html#" }, manage_users = { key = "manage_users", i18n_title = ternary(is_nedge, "nedge.system_users", "manage_users.manage_users"), section = "admin", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/settings/users.html" }, preferences = { key = "preferences", i18n_title = "prefs.preferences", section = "admin", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/settings/preferences.html" }, categories = { key = "categories", i18n_title = "custom_categories.apps_and_categories", section = "admin", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/settings/applications_and_categories.html#custom-applications" }, category_lists = { key = "category_lists", i18n_title = "category_lists.category_lists", section = "admin" }, labels = { key = "labels", i18n_title = "labels_page.labels", section = "admin" }, conf_backup = { key = "conf_backup", i18n_title = "conf_backup.conf_backup", section = "admin" }, conf_restore = { key = "conf_restore", i18n_title = "conf_backup.conf_restore", section = "admin" }, manage_configurations = { key = "manage_configurations", i18n_title = "manage_configurations.manage_configurations", section = "admin" }, -- Policies device_protocols = { key = "device_protocols", i18n_title = "device_protocols.device_protocols", section = "policies" }, access_control_list = { key = "access_control_list", i18n_title = "access_control_list", section = "policies" }, network_config = { key = "network_config", i18n_title = "checks.network_configuration", section = "policies" }, traffic_rules = { key = "traffic_rules", i18n_title = "if_stats_config.traffic_rules", section = "policies", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/policies/traffic_rules.html" }, profiles = { key = "profiles", i18n_title = "traffic_profiles.traffic_profiles", section = "policies", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/policies/traffic_profiles.html" }, alert_exclusions = { key = "alert_exclusions", i18n_title = "edit_check.exclusion_list", section = "policies", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/behavioural_checks_exclusion.html" }, alert_exclusions_hosts = { key = "alert_exclusions", subkey = "hosts", i18n_title = alert_entities.host.i18n_label, section = "alert_exclusions", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/available_alerts.html" }, alert_exclusions_flows = { key = "alert_exclusions", subkey = "flows", i18n_title = alert_entities.flow.i18n_label, section = "alert_exclusions", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/available_alerts.html" }, alert_exclusions_domains = { key = "alert_exclusions", subkey = "domains", i18n_title = "domain", section = "alert_exclusions", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/available_alerts.html" }, scripts_config = { key = "scripts_config", i18n_title = "about.checks", section = "policies", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/available_alerts.html" }, scripts_config_all = { key = "scripts_config", subkey = "all", i18n_title = "all", section = "policies", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/available_alerts.html" }, scripts_config_hosts = { key = "scripts_config", subkey = "hosts", i18n_title = alert_entities.host.i18n_label, section = "policies", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/available_alerts.html" }, scripts_config_interfaces = { key = "scripts_config", subkey = "interfaces", i18n_title = alert_entities.interface.i18n_label, section = "policies", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/available_alerts.html" }, scripts_config_networks = { key = "scripts_config", subkey = "networks", i18n_title = alert_entities.network.i18n_label, section = "policies", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/available_alerts.html" }, scripts_config_snmp_devices = { key = "scripts_config", subkey = "snmp_devices", i18n_title = alert_entities.snmp_device.i18n_label, section = "policies", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/available_alerts.html" }, scripts_config_flows = { key = "scripts_config", subkey = "flows", i18n_title = alert_entities.flow.i18n_label, section = "policies", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/available_alerts.html" }, scripts_config_system = { key = "scripts_config", subkey = "system", i18n_title = alert_entities.system.i18n_label, section = "policies", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/available_alerts.html" }, scripts_config_syslog = { key = "scripts_config", subkey = "syslog", i18n_title = "syslog.syslog", section = "policies", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/available_alerts.html" }, scripts_config_active_monitoring = { key = "scripts_config", subkey = "active_monitoring", i18n_title = "active_monitoring", section = "policies", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/available_alerts.html" }, scripts_config_as = { key = "scripts_config", subkey = "as", i18n_title = "as", section = "policies", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/others/available_alerts.html" }, device_exclusions = { key = "device_exclusions", i18n_title = "edit_check.device_exclusion", section = "policies" }, -- Notifications endpoint_notifications = { key = "endpoint_notifications", i18n_title = "endpoint_notifications.endpoint_list", section = "notifications", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/available_endpoints.html#available-endpoints" }, endpoint_recipients = { key = "endpoint_recipients", i18n_title = "endpoint_notifications.enpoint_recipients_list", section = "notifications", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/alerts/available_endpoints.html#available-endpoints" }, -- Tools export_data = { key = "export_data", i18n_title = "manage_data.export", section = "tools" }, -- Pools host_members = { key = "host_members", i18n_title = "host_pools.host_members", section = "pools" }, manage_pools = { key = "manage_pools", i18n_title = "pools.pools", section = "pools" }, -- Home live_capture = { key = "live_capture", i18n_title = "live_capture.active_live_captures", section = "home" }, -- Developer directories = { key = "directories", i18n_title = "about.directories", section = "dev", help_link = "https://www.ntop.org/guides/ntopng/scripts/distributing_scripts.html" }, checks_dev = { key = "checks_dev", i18n_title = "about.checks", section = "dev", help_link = "https://www.ntop.org/guides/ntopng/scripts/checks.html" }, analyze_db = { key = "analyze_db", i18n_title = "about.analyze_db", section = "dev", help_link = "https://www.ntop.org/guides/ntopng/advanced_features/index.html" }, analyze_pcap = { key = "analyze_pcap", i18n_title = "about.analyze_pcap", section = "dev", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/developer/analyze_pcap_file.html" }, alert_definitions = { key = "alert_definitions", i18n_title = "about.alert_defines", section = "dev", help_link = "https://www.ntop.org/guides/ntopng/scripts/alert_definitions.html" }, ts_definitions = { key = "ts_definitions", i18n_title = "about.ts_defines", section = "dev", }, api = { key = "api", i18n_title = "lua_c_api", section = "dev" }, rest_api = { key = "rest_api", i18n_title = "swagger_api", section = "dev" }, manage_data = { key = "manage_data", i18n_title = "manage_data.manage_data", section = "dev", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/developer/manage_data.html" }, -- Help about = { key = "about", i18n_title = "about.about", section = "about", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/help/about.html" }, license = { key = "license", i18n_title = "license_page.license", section = "about" }, limits = { key = "limits", i18n_title = "limits_page.limits", section = "about" }, blog = { key = "blog", i18n_title = "about.ntop_blog", section = "about" }, telegram = { key = "telegram", i18n_title = "about.telegram", section = "about" }, report_issue = { key = "report_issue", i18n_title = "about.report_issue", section = "about" }, manual = { key = "manual", i18n_title = "about.readme_and_manual", section = "about" }, suggest_feature = { key = "suggest_feature", i18n_title = "about.suggest_feature", section = "about" }, -- Just a divider for horizontal rows in the menu divider = { key = "divider" }, -- nEdge gateways_users = { key = "gateways_users", i18n_title = "dashboard.gateways_users", section = "dashboard" }, nedge_flows = { key = "nedge_flows", i18n_title = "flows", section = "hosts" }, nedge_interfaces = { key = "nedge_interfaces", i18n_title = "interfaces", section = "dashboard" }, users = { key = "users", i18n_title = "users.users", section = "hosts", help_link = "https://www.ntop.org/guides/ntopng/user_interface/shared/settings/preferences.html#user-authentication" }, system_setup = { key = "system_setup", i18n_title = "nedge.system_setup", section = "system_stats", help_link = "https://www.ntop.org/guides/nedge/get_started.html" }, dhcp_static_leases = { key = "dhcp_static_leases", i18n_title = "nedge.static_dhcp_leases", section = "system_stats" }, dhcp_active_leases = { key = "dhcp_active_leases", i18n_title = "nedge.active_dhcp_leases", section = "system_stats" }, port_forwarding = { key = "port_forwarding", i18n_title = "nedge.port_forwarding", section = "system_stats" }, rules_config = { key = "rules_config", i18n_title = "nedge.rules_config_title", section = "system_stats" }, forwarders_config = { key = "forwarders_config", i18n_title = "nedge.repeaters_config_title", section = "system_stats" } } -- Extend the menu entries with the scripts local menu, entries_data = script_manager.getMenuEntries() page_utils.scripts_menu = menu or {} if entries_data then for k, v in pairs(entries_data) do page_utils.menu_entries[k] = v end end -- ################################# -- NOTE: this function must be called after page_utils.print_header_and_set_active_menu_entry function page_utils.print_page_title(title, mini_title) local help_link = page_utils.menu_entries[active_entry].help_link or "" print("
") print("

" .. title .. "

") if (not isEmptyString(help_link)) then print("") end if mini_title and not isEmptyString(mini_title) then print("" .. mini_title .. "") end print("
") end -- ################################# -- NOTE: this function is called by the web pages in order to -- set the active entry and section and highlight it into the menu function page_utils.print_header_and_set_active_menu_entry(entry, i18n_params, alt_title) require "locales_utils" entry = entry or page_utils.menu_entries.traffic_dashboard active_section = entry.section active_entry = entry.key if entry.subkey then active_sub_entry = entry.subkey end page_utils.print_header(alt_title or i18n(entry.i18n_title, i18n_params) or entry.i18n_title) end -- ################################# function page_utils.get_active_section() return (active_section) end function page_utils.get_active_entry() return (active_entry) end function page_utils.get_active_sub_entry() return (active_sub_entry) end -- ################################# -- @brief Encode the HTML entities in a string. -- Useful when printing dissected data which may result in XSS -- e.g., curl -u admin:admin1 "http://devel:3000/" -- @param s The string to escape. -- @return The string with HTML entities properly escaped function page_utils.safe_html(s) if not s then return '' end ret = string.gsub(s, "[}{\">/<'&]", { ["&"] = "&", ["<"] = "<", [">"] = ">", ['"'] = """, ["'"] = "'", ["/"] = "/" }) return (ret) end -- ################################# function page_utils.is_dark_mode_enabled(theme) local dark_mode = false local user = "admin" if _SESSION["user"] then user = _SESSION["user"] end local theme = theme or ntop.getPref("ntopng.user." .. user .. ".theme") if not isEmptyString(theme) then dark_mode = (theme == "dark") end return dark_mode end -- ################################# function page_utils.print_header(title, addLoginJS) local http_prefix = ntop.getHttpPrefix() local static_file_epoch = ntop.getStaticFileEpoch() .. "" local dark_mode = page_utils.is_dark_mode_enabled(_POST["toggle_theme"]) local page_title = i18n("welcome_to", { product = info.product }) local favicon_path = nil local username = _SESSION["user"] local user_lang = ntop.getPref("ntopng.user." .. username .. ".language") local language = ternary(isEmptyString(user_lang), "en", user_lang) local locale_path = dirs.installdir .. "/scripts/locales/" .. language .. ".lua" local locale_when = ntop.fileLastChange(locale_path) if title ~= nil then page_title = info.product .. " - " .. title end print [[ ]] print(page_title) print [[ ]] if (dark_mode) then print [[]] end if (ntop.isPro() or ntop.isnEdge()) and ntop.exists(dirs.installdir .. "/httpdocs/img/custom_favicon.ico") then favicon_path = http_prefix .. "/img/custom_favicon.ico" end if (favicon_path ~= nil) then print [[]] else print [[]] end print [[ ]] if addLoginJS then print [[]] end if (ntop.isPro() and ntop.exists(dirs.installdir .. "/httpdocs/css/custom-theme.css")) then print [[ ]] end print [[ ]] print([[ ]]) end -- ################################# function page_utils.print_header_minimal(title, addLoginJS) local http_prefix = ntop.getHttpPrefix() local page_title = i18n("welcome_to", { product = info.product }) if title ~= nil then page_title = info.product .. " - " .. title end local admin_lang = ntop.getPref("ntopng.user.admin.language") local language = ternary(isEmptyString(admin_lang), "en", admin_lang) local locale_path = dirs.installdir .. "/scripts/locales/" .. language .. ".lua" local locale_when = ntop.fileLastChange(locale_path) local static_file_epoch = ntop.getStaticFileEpoch() .. "" print [[ ]] print(page_title) print [[ ]] if (ntop.isPro() or ntop.isnEdge()) and ntop.exists(dirs.installdir .. "/httpdocs/img/custom_favicon.ico") then favicon_path = http_prefix .. "/img/custom_favicon.ico" end if (favicon_path ~= nil) then print [[]] else print [[]] end print [[ ]] end -- ################################# function page_utils.get_navbar_context(title, base_url, items_table, label_url, back_url) local help_link = page_utils.menu_entries[active_entry].help_link or nil local icon = page_utils.menu_sections[active_section].icon or "" local navbar = { main_icon = icon, main_title = title, base_url = base_url, items_table = items_table, label_url = label_url, back_url = back_url, help_link = help_link } return navbar end -- ################################# function page_utils.get_new_navbar_context(title, base_url, items_table, label_url, back_url) local help_link = page_utils.menu_entries[active_entry].help_link or nil local icon = page_utils.menu_sections[active_section].icon or "" local navbar = { main_title = { icon = icon, label = title }, base_url = base_url, items_table = items_table, label_url = label_url, back_url = back_url, help_link = help_link } return navbar end -- ################################# function page_utils.print_navbar(title, base_url, items_table, label_url, back_url, end_items) local help_link = page_utils.menu_entries[active_entry].help_link or nil local icon = page_utils.menu_sections[active_section].icon or "" local context = { navbar = { title = "" .. " " .. title, base_url = base_url, items_table = items_table, label_url = label_url, back_url = back_url, help_link = help_link, end_items = end_items } } print(template_utils.gen("pages/components/page-navbar.template", context)) end -- ################################# local menubar_structure = {} function page_utils.init_menubar() menubar_structure = {} end -- ################################# function page_utils.add_menubar_section(section) menubar_structure[#menubar_structure + 1] = section end -- ################################# local function print_submenu(section, container_list_name) local active_subpage = page_utils.get_active_entry() local active_subsubpage = page_utils.get_active_sub_entry() local section_key = section.section.key local section_id = section_key .. "-submenu" local list_name = section_id .. "-list" print [[
]] end -- ################################# local function print_section(section, list_name) local active_page = page_utils.get_active_section() local show_section = false local section_has_submenu = (section.entries and #section.entries > 0) if (not section.hidden) then if not section_has_submenu then show_section = true else -- The section is shown only if at least one of its sub entries -- is shown for _, section_entry in pairs(section.entries or {}) do if not section_entry.hidden then show_section = true break end end end end if show_section then local section_key = section.section.key local section_id = section_key .. "-submenu" print [[