From e3f606530a21f1aefe16a97b192b63cdb4660777 Mon Sep 17 00:00:00 2001 From: alejandro Date: Thu, 9 Mar 2023 13:16:28 +0100 Subject: [PATCH 01/19] changed the way of getting data out of windows to make it faster --- pandora_agents/unix/plugins/autodiscover | 243 +++++++++-------------- 1 file changed, 89 insertions(+), 154 deletions(-) diff --git a/pandora_agents/unix/plugins/autodiscover b/pandora_agents/unix/plugins/autodiscover index 03b2c3d76d..01b9bd3d96 100644 --- a/pandora_agents/unix/plugins/autodiscover +++ b/pandora_agents/unix/plugins/autodiscover @@ -6,21 +6,22 @@ # # (c) A. Kevin Rojas # +# Edited in 2023 by Alejandro Sánchez +# # TO DO LIST: # - Enable child services detection (Windows) # - Make CPU/Memory usage available for child services (Windows) # ################################################### - try: from sys import argv from sys import stderr from sys import exit + import psutil from subprocess import Popen from subprocess import PIPE from subprocess import DEVNULL from subprocess import getstatusoutput - import psutil except ModuleNotFoundError as err: print("{} error: {}. Exiting...".format(argv[0], err), file=stderr) exit(1) @@ -28,99 +29,100 @@ except ModuleNotFoundError as err: module_list = [] VERSION = "1.2" +def win_service(servicelist, option=False, memcpu=False): -######################################################################################### -# Powershell class -######################################################################################### -class PSCheck: - @staticmethod - def check_service(servicename, option=False, memcpu=False): - """Check services with powershell by parsing their DisplayName. Returns a dict\ - list with the name of the service and a boolean with its status.\n - Requires service name (case insensitive).""" - pscall = Popen(["powershell", "Get-Service", "-Name", "'*"+ str(servicename) + "*'", - "|", "Select-Object", "-ExpandProperty", "Name"], - stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) - result = pscall.communicate() - result = str(result[0]).strip().split("\n") - procname = '' - if result != '': - output = [] - for element in result: - if element != '': - # Get process name - procname = PSCheck.get_serviceprocess(element) - # Get process status - parstatus = PSCheck.getstatus(element) - if memcpu and parstatus == 1: - usage = get_memcpu(str(procname), str(element)) - output += usage - # Generate module with name and status - parent = service_module(str(element), parstatus) - output += parent - if option: - children = PSCheck.getchildren(element, memcpu) - if isinstance(children, list) and len(children) > 1: - for child in children: - output += child - else: - output += children - else: - next - - if output and element and procname: - return ({"name" : element, "process" : procname, "modules": output}) + modules_default = [] + modules_percentage=[] + ## take all services + services=psutil.win_service_iter() + for service in services: + if service.name() in servicelist: + serv=service.as_dict() + if serv['status']=='running': + value=1 else: - return (None) + value=0 - @staticmethod - def getchildren(servicename, memcpu=False): - """Gets Dependent services of a given Windows service""" - pschild = Popen(["powershell", "Get-Service", "-Name '" + str(servicename) + - "' -DS", "|", "Select-Object", "-ExpandProperty", "Name"], - stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) - children = pschild.communicate()[0].strip() - kids = [] - for child in (children.split("\n") if children != "" else []): - status = PSCheck.getstatus(child) - kids += service_module(str(child), status, "Service " + str(servicename) + " - Status") - if status: - if memcpu: - kidsusage = get_memcpu(str(child)) - for usage in kidsusage: - kids += usage + ## create module for each service + parent = build_module("Service " + str(serv['name']) + " - Status", value,"generic_proc") + modules_default +=parent + + # memory and cpu percentage + if memcpu: + ## process + srv_pid = service.pid() + process = psutil.Process(srv_pid) + proc_name = process.name() + ##cpu + value_cpu=process.cpu_percent(interval=0.5) + parent = build_module("Service " + str(proc_name) + " - CPU usage", value_cpu,"generic_data") + parent[0].update([("unit","%"),("module_parent",str(serv['name']))]) + modules_percentage +=parent + ##mem + value_mem=process.memory_percent() + parent = build_module("Service " + str(proc_name) + " - Memory usage", value_mem,"generic_data") + parent[0].update([("unit","%"),("module_parent",str(serv['name']))]) + modules_percentage +=parent + + + for module in modules_default: + print_module(module, 1) + if memcpu: + for module in modules_percentage: + print_module(module, 1) + +def lnx_service(services_list, memcpu=False): + """Creates modules for Linux servers""" + modules = [] + sysctl = getstatusoutput("command -v systemctl")[0] + servic = getstatusoutput("command -v service")[0] + for srvc in services_list: + status = None + if sysctl == 0: + ### Systemd available + syscall = Popen(["systemctl", "show", "-pLoadState", "-pActiveState", srvc], stdout=PIPE, + stdin=DEVNULL, universal_newlines=True) + result = syscall.communicate() + srvstatus = result[0].strip().lower().split("\n") + if srvstatus[0] == "loadstate=not-found": + next + else: + if srvstatus[1] == "activestate=active": + modules += build_module("Service " + srvc + " - Status", 1, "generic_proc") + status = 1 + elif srvstatus[1] == "activestate=inactive": + modules += build_module("Service " +srvc+ " - Status", 0, "generic_proc") + status = 0 + elif sysctl != 0 and servic == 0: + ### Systemd not available, switch to service command + syscall = Popen(["service", srvc, "status"], stdout=PIPE, + stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) + result = syscall.communicate()[0].lower() + if "is running" in result: + modules += build_module("Service " + srvc + " - Status", 1, "generic_proc") + status = 1 + elif "is stopped" in result: + modules += build_module("Service " +srvc+ " - Status", 0, "generic_proc") + status = 0 else: next - return kids - - @staticmethod - def getstatus(servicename): - """Gets the status of a given Windows service""" - running = Popen(["powershell", "Get-Service", "-Name '" + str(servicename) + - "' |", "Select-Object", "-ExpandProperty", "Status"], - stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) - status = running.communicate()[0].strip() - return int(status == "Running") - - @staticmethod - def get_serviceprocess(servicename): - """Gets name of the process of the service""" - service = psutil.win_service_get(servicename) - srv_pid = service.pid() - process = psutil.Process(srv_pid) - proc_name = process.name() - return proc_name + else: + print("No systemd or service commands available. Exiting...", file=stderr) + exit() + if status: + module_list.append(srvc) + if memcpu: + modules += get_memcpu(srvc, None) + + for m in modules: + print_module(m, 1) -######################################################################################### -# Services creation -######################################################################################### - -def service_module(name, value, parent=None): +def build_module(name, value, module_type, parent=None): #print ("service_module BEGIN "+str(now(0,1))) module = [{ - "name" : "Service "+ name + " - Status", - "type" : "generic_proc", + "name" : name , + "type" : module_type, "value" : value, "module_parent" : parent, }] @@ -167,74 +169,6 @@ def proc_percentbyname(procname): ############# 03/03/2020 next #print ("proc_percentbyname END "+str(now(0,1))) return [sum(memory),sum(cpu)] - -def win_service(servicelist, option=False, memcpu=False): - """Creates modules for Windows servers.""" - modules = [] - for srvc in servicelist: - if srvc and len(srvc) > 2: - output = PSCheck.check_service(srvc, option, memcpu) - if output is not None and output["modules"]: - modules += PSCheck.check_service(srvc.strip(), option, memcpu)["modules"] - module_list.append(srvc) - #winprocess = output["name"] - #if memcpu == True: - # modules += get_memcpu(winprocess) ## Only available for parent service ATM. - else: - next - else: - next - for module in modules: - print_module(module, 1) - - -def lnx_service(services_list, memcpu=False): - """Creates modules for Linux servers""" - modules = [] - sysctl = getstatusoutput("command -v systemctl")[0] - servic = getstatusoutput("command -v service")[0] - for srvc in services_list: - status = None - if sysctl == 0: - ### Systemd available - syscall = Popen(["systemctl", "show", "-pLoadState", "-pActiveState", srvc], stdout=PIPE, - stdin=DEVNULL, universal_newlines=True) - result = syscall.communicate() - srvstatus = result[0].strip().lower().split("\n") - if srvstatus[0] == "loadstate=not-found": - next - else: - if srvstatus[1] == "activestate=active": - modules += service_module(srvc, 1) - status = 1 - elif srvstatus[1] == "activestate=inactive": - modules += service_module(srvc, 0) - status = 0 - elif sysctl != 0 and servic == 0: - ### Systemd not available, switch to service command - syscall = Popen(["service", srvc, "status"], stdout=PIPE, - stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) - result = syscall.communicate()[0].lower() - if "is running" in result: - modules += service_module(srvc, 1) - status = 1 - elif "is stopped" in result: - modules += service_module(srvc, 0) - status = 0 - else: - next - else: - print("No systemd or service commands available. Exiting...", file=stderr) - exit() - if status: - module_list.append(srvc) - if memcpu: - modules += get_memcpu(srvc, None) - - for m in modules: - print_module(m, 1) - - ######################################################################################### # print_module function ######################################################################################### @@ -356,6 +290,7 @@ def main(): service_list = ["MySQL", "postgresql", "pgsql", "oracle", "MSSQL", "IISADMIN", "apache", "nginx", "W3svc", "NTDS", "Netlogon", "DNS", "MSExchangeADTopology", "MSExchangeServiceHost", "MSExchangeSA", "MSExchangeTransport"] + discover(OS, service_list) elif psutil.LINUX: OS = "Linux" From 79fbab3696d805dbae89065bc753aab0fab6967e Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 13 Mar 2023 21:17:55 +0100 Subject: [PATCH 02/19] Tubercles removal --- pandora_console/godmode/alerts/alert_list.list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 45e7a26714..a2b0f242da 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -672,7 +672,7 @@ foreach ($simple_alerts as $alert) { '[…]', '' ); - $data[2] .= ' '; $data[2] .= html_print_image( 'images/details.svg', From ca39fa856034d3b18bded872a65948aeab315ddb Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 13 Mar 2023 21:21:25 +0100 Subject: [PATCH 03/19] #10669 Fix configure_user issue --- pandora_console/godmode/users/configure_user.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index bb1c5d1c73..1555a1c2fc 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -1826,13 +1826,17 @@ if (is_metaconsole() === true) { true ); } + + // User Profile definition table. (Only where user is not creating). + if ($new_user === false && ((bool) check_acl($config['id_user'], 0, 'UM') === true)) { + profile_print_profile_table($id, io_safe_output($json_profile), false, ($is_err === true)); + } } else { $access_or_pagination = $size_pagination; // WIP: Only for node. include_once 'user_management.php'; } - if ((bool) $config['admin_can_add_user'] === true) { html_print_csrf_hidden(); html_print_input_hidden((($new_user === true) ? 'create_user' : 'update_user'), 1); From f0a424a493475e8d25bf07f9b7bcf0b32c71707a Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 14 Mar 2023 08:04:05 +0100 Subject: [PATCH 04/19] Module manager fix --- .../godmode/agentes/module_manager.php | 57 +++++++++++++------ 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index bc544b2861..55fa922381 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -1071,27 +1071,50 @@ if ((bool) check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === tr echo ''; } -$modalCreateModule = '
'; -$input_type = html_print_input_hidden('edit_module', 1, true); -$input_type .= html_print_select( - policies_type_modules_availables($sec2), - 'moduletype', - '', - '', - '', - '', - true, - false, - false, - '', - false, - 'max-width:300px;' +// Form table for Module creation. +$createModuleTable = new stdClass(); +$createModuleTable->id = 'module_creation_modal'; +$createModuleTable->class = 'filter-table-adv'; +$createModuleTable->data = []; + +$createModuleTable->data[0][] = html_print_label_input_block( + __('Select module type'), + html_print_select( + policies_type_modules_availables($sec2), + 'moduletype', + '', + '', + '', + '', + true, + false, + false, + '', + false, + 'max-width:300px;' + ) ); -$modalCreateModule .= $input_type; +$createModuleTable->data[1][] = html_print_label_input_block( + '', + html_print_anchor( + [ + 'href' => 'https://pandorafms.com/Library/Library/', + 'class' => 'color-black-grey invert_filter', + 'content' => __('Get more modules on Monitoring Library'), + ], + true + ) +); + +$createModuleFormTable = html_print_input_hidden('edit_module', 1, true); +$createModuleFormTable .= html_print_table($createModuleTable, true); +// Form definition. +$modalCreateModule = ''; +$modalCreateModule .= $createModuleFormTable; $modalCreateModule .= html_print_div( [ - 'class' => 'action-buttons', + 'class' => 'action-buttons-right-forced', 'content' => html_print_submit_button( __('Create'), 'create_module', From 3ab0b1c4cb4ce5b6bec19fcbeb7b5e532334faa7 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 14 Mar 2023 08:04:48 +0100 Subject: [PATCH 05/19] Minor fixes --- .../godmode/users/configure_user.php | 6 ++--- .../include/class/AgentWizard.class.php | 26 ++++++++++--------- pandora_console/include/styles/pandora.css | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 1555a1c2fc..cb7227b316 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -1011,13 +1011,13 @@ if (!$new_user) { $user_id .= html_print_input_hidden('id_user', $id, true); $user_id .= ''; - $apiTokenContentElements[] = ''.__('API Token').''; + $apiTokenContentElements[] = ''.__('API Token').''; $apiTokenContentElements[] = html_print_button( __('Renew'), 'renew_api_token', false, sprintf( - 'javascript:renewAPIToken(\'%s\', \'%s\', \'%s\')', + 'javascript:renewAPIToken("%s", "%s", "%s")', __('Warning'), __('The API token will be renewed. After this action, the last token you were using will not work. Are you sure?'), 'user_profile_form', @@ -1033,7 +1033,7 @@ if (!$new_user) { 'show_api_token', false, sprintf( - 'javascript:showAPIToken(\'%s\', \'%s\')', + 'javascript:showAPIToken("%s", "%s")', __('API Token'), base64_encode(__('Your API Token is:').' 
'.users_get_API_token($id).'
 '.__('Please, avoid share this string with others.')), ), diff --git a/pandora_console/include/class/AgentWizard.class.php b/pandora_console/include/class/AgentWizard.class.php index 9c25403458..2580d17371 100644 --- a/pandora_console/include/class/AgentWizard.class.php +++ b/pandora_console/include/class/AgentWizard.class.php @@ -1329,7 +1329,7 @@ class AgentWizard extends HTML $table->rowstyle[$i] = 'color:#ccc;'; $data[0] .= ' '; $data[0] .= html_print_image( - 'images/error.png', + 'images/alert-warning@svg.svg', true, ['title' => $msgError] ); @@ -1347,7 +1347,7 @@ class AgentWizard extends HTML // Img Server. if ($this->serverType == SERVER_TYPE_ENTERPRISE_SATELLITE) { $img_server = html_print_image( - 'images/satellite.png', + 'images/satellite@os.svg', true, [ 'title' => __('Enterprise Satellite server'), @@ -1357,7 +1357,7 @@ class AgentWizard extends HTML } else { if ($module['execution_type'] == EXECUTION_TYPE_PLUGIN) { $img_server = html_print_image( - 'images/plugin.png', + 'images/plugins@svg.svg', true, [ 'title' => __('Plugin server'), @@ -1367,7 +1367,7 @@ class AgentWizard extends HTML } else { if ($this->protocol === 'wmi') { $img_server = html_print_image( - 'images/wmi.png', + 'images/WMI@svg.svg', true, [ 'title' => __('WMI server'), @@ -1376,7 +1376,7 @@ class AgentWizard extends HTML ); } else { $img_server = html_print_image( - 'images/op_network.png', + 'images/network@svg.svg', true, [ 'title' => __('Network server'), @@ -4090,7 +4090,7 @@ class AgentWizard extends HTML $blockTitle .= ''.$block['name']; $blockTitle .= '  '; $blockTitle .= html_print_image( - 'images/tip_help.png', + 'images/info@svg.svg', true, [ 'title' => __('Modules selected'), @@ -4110,7 +4110,7 @@ class AgentWizard extends HTML $blockTitle .= '  '; $blockTitle .= html_print_image( - 'images/tip_help.png', + 'images/info@svg.svg', true, [ 'title' => __('Modules selected'), @@ -4205,6 +4205,9 @@ class AgentWizard extends HTML $table->size[4] = '140px'; $table->size[5] = '3%'; + $table->align = []; + $table->align[1] = 'center'; + // If is needed show current value, we must correct the table. if ($showCurrentValue === true) { // Correct headers. @@ -4273,7 +4276,7 @@ class AgentWizard extends HTML false, false, '', - $md5IdBlock, + $md5IdBlock.' w100p', '', '', false, @@ -4293,8 +4296,9 @@ class AgentWizard extends HTML 1, 20, $module['description'], - 'form=\'form-create-modules\' class=\'min-height-50px\'', - true + 'form=\'form-create-modules\'', + true, + 'w100p' ); } @@ -4703,8 +4707,6 @@ class AgentWizard extends HTML 'toggle_class' => '', 'container_class' => 'white-box-content', 'main_class' => $class, - 'img_a' => 'images/arrow_down_green.png', - 'img_b' => 'images/arrow_right_green.png', 'clean' => false, 'reverseImg' => $reverseImg, 'switch' => $buttonSwitch, diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 4324dc0175..6fc9930212 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -9306,7 +9306,7 @@ div.stat-win-spinner img { color: #fff !important; font-size: 1.2em; margin-right: 5px !important; - margin-top: -4px; + margin-top: 1px; } .select2-results From 397c4bd72064a472bf8e4490c671078fe3105f46 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 14 Mar 2023 08:35:05 +0100 Subject: [PATCH 06/19] Fix plugin icon --- pandora_console/godmode/wizards/DiscoveryTaskList.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index f610f48e4d..1c3642b075 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -731,7 +731,7 @@ class DiscoveryTaskList extends HTML case DISCOVERY_CLOUD_AZURE_COMPUTE: // Discovery Applications MySQL. $data[6] = html_print_image( - 'images/plugin@svg.svg', + 'images/plugins@svg.svg', true, [ 'title' => __('Discovery Cloud Azure Compute'), @@ -744,7 +744,7 @@ class DiscoveryTaskList extends HTML case DISCOVERY_CLOUD_AWS_EC2: // Discovery Applications MySQL. $data[6] = html_print_image( - 'images/plugin@svg.svg', + 'images/plugins@svg.svg', true, [ 'title' => __('Discovery Cloud AWS EC2'), @@ -856,7 +856,7 @@ class DiscoveryTaskList extends HTML } else { // APP or external script recon task. $data[6] = html_print_image( - 'images/plugin@svg.svg', + 'images/plugins@svg.svg', true, ['class' => 'main_menu_icon invert_filter'] ).'  '; From e71014607ac7a0ca1ad71dbbb24880086af4d3c3 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 14 Mar 2023 09:05:59 +0100 Subject: [PATCH 07/19] 10669 fix revision --- pandora_console/godmode/users/configure_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index cb7227b316..287de6a316 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -60,7 +60,7 @@ if ($enterprise_include === true) { $id = get_parameter('id', get_parameter('id_user', '')); // Check if we are the same user for edit or we have a proper profile for edit users. if ($id !== $config['id_user']) { - if ((is_centralized() === true) || (bool) check_acl($config['id_user'], 0, 'UM') === false) { + if ((bool) check_acl($config['id_user'], 0, 'UM') === false) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to access User Management' From 93a912b76b14093e0d92dbd3fff3c980c43eb188 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 14 Mar 2023 10:01:09 +0100 Subject: [PATCH 08/19] Fix MR --- pandora_console/extras/mr/62.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/extras/mr/62.sql b/pandora_console/extras/mr/62.sql index 76f0a84c4e..9a96b37aff 100644 --- a/pandora_console/extras/mr/62.sql +++ b/pandora_console/extras/mr/62.sql @@ -155,4 +155,6 @@ INSERT INTO `twelcome_tip_file` (`twelcome_tip_file`, `filename`, `path`) VALUES (20, 'zoom_en_graficas.png', 'images/tips/'), (22, 'politica_de_pass.png', 'images/tips/'); +ALTER TABLE `tusuario` ADD COLUMN `show_tips_startup` TINYINT UNSIGNED NOT NULL DEFAULT 1; + COMMIT; From b428e77e7cf26e9234ced2e10dbf2eba2d965faf Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 14 Mar 2023 13:11:57 +0100 Subject: [PATCH 09/19] User management for meta --- pandora_console/general/header.php | 1 - .../godmode/users/configure_user.php | 269 ++---------------- pandora_console/godmode/users/user_list.php | 2 - .../godmode/users/user_management.php | 218 ++++++++------ pandora_console/include/functions_profile.php | 16 +- 5 files changed, 161 insertions(+), 345 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 40f6c3a382..b0cbc0cec5 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -407,7 +407,6 @@ echo sprintf('
', $menuTypeClass); // User. - // $headerUserImage = (is_user_admin($config['id_user']) === true) ? 'images/header_user_admin_green.png' : 'images/header_user_green.png'; $headerUser = []; $headerUser[] = html_print_image( 'images/edit_user@header.svg', diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 287de6a316..ecc3a76b72 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -1,5 +1,4 @@ 'user_form_title', - 'content' => ((bool) $id === true) ? sprintf('%s [ %s ]', __('Update User'), $id) : __('Create User'), - ] - ); -} - if (!$new_user) { $user_id = '

'.__('User ID').':

'; $user_id .= ''.$id.''; @@ -1282,8 +1272,9 @@ if (is_metaconsole() === false) { if (is_metaconsole() === true) { $array_filters = get_filters_custom_fields_view(0, true); - $search_custom_fields_view = '

'.__('Search custom field view').' '.ui_print_help_tip(__('Load by default the selected view in custom field view'), true).'

'; - $search_custom_fields_view .= html_print_select( + $searchCustomFieldView = []; + $searchCustomFieldView[] = __('Search custom field view'); + $searchCustomFieldView[] = html_print_select( $array_filters, 'default_custom_view', $user_info['default_custom_view'], @@ -1295,7 +1286,10 @@ if (is_metaconsole() === true) { true, '', false - ).'
'; + ).ui_print_input_placeholder( + __('Load by default the selected view in custom field view'), + true + ); } $values = [ @@ -1377,6 +1371,8 @@ $home_screen .= html_print_input_text( false ); +$home_screen = ''; + $size_pagination = '

'.__('Block size for pagination').'

'; $size_pagination .= html_print_input_text( 'block_size', @@ -1395,19 +1391,20 @@ if ($id === $config['id_user']) { ); } -if (enterprise_installed() && is_metaconsole() === true) { +if (enterprise_installed() === true && is_metaconsole() === true) { $user_info_metaconsole_access = 'only_console'; if (isset($user_info['metaconsole_access'])) { $user_info_metaconsole_access = $user_info['metaconsole_access']; } - // TODO review help tips on meta. - $meta_access = '

'.__('Metaconsole access').' './* ui_print_help_icon('meta_access', true). */ '

'; $metaconsole_accesses = [ 'basic' => __('Basic'), 'advanced' => __('Advanced'), ]; - $meta_access .= html_print_select( + + $outputMetaAccess = []; + $outputMetaAccess[] = __('Metaconsole access'); + $outputMetaAccess[] = html_print_select( $metaconsole_accesses, 'metaconsole_access', $user_info_metaconsole_access, @@ -1417,51 +1414,9 @@ if (enterprise_installed() && is_metaconsole() === true) { true, false, false - ).'
'; + ); } -/* - $not_login = '

'.__('Not Login').'

'; - $not_login .= ui_print_help_tip( - __('The user with not login set only can access to API.'), - true - ); - $not_login .= html_print_checkbox_switch( - 'not_login', - 1, - $user_info['not_login'], - true - ).'
'; - - $local_user = '

'.__('Local user').'

'; - $local_user .= ui_print_help_tip( - __('The user with local authentication enabled will always use local authentication.'), - true - ); - $local_user .= html_print_checkbox_switch( - 'local_user', - 1, - $user_info['local_user'], - true - ).'
'; - - $session_time = '

'.__('Session Time'); - $session_time .= ui_print_help_tip( - __('This is defined in minutes, If you wish a permanent session should putting -1 in this field.'), - true - ).'

'; - $session_time .= html_print_input_text( - 'session_time', - $user_info['session_time'], - '', - 5, - 5, - true.false, - false, - '', - 'class="input_line_small"' - ).'
'; -*/ $user_groups = implode(',', array_keys((users_get_groups($id, 'AR', $display_all_group)))); if (empty($user_groups) === false) { @@ -1582,31 +1537,6 @@ if (empty($doubleAuthElementsContent) === false) { $doubleAuthentication = ''; } - -/* - if (isset($double_authentication)) { - $double_authentication .= '
'; -}*/ - - - - - - - - - - - - - - - - - - - - $autorefresh_list_out = []; if (is_metaconsole() === false || is_centralized() === true) { $autorefresh_list_out['operation/agentes/estado_agente'] = 'Agent detail'; @@ -1665,31 +1595,32 @@ if (isset($autorefresh_list) === false) { } } - - if (is_metaconsole() === true) { enterprise_include_once('include/functions_metaconsole.php'); $access_node = db_get_value('metaconsole_access_node', 'tusuario', 'id_user', $id); - $metaconsole_agents_manager = '

'.__('Enable agents managment').'

'; - $metaconsole_agents_manager .= html_print_checkbox_switch( + $metaconsoleAgentManager = []; + $metaconsoleAgentManager[] = __('Enable agents managment'); + $metaconsoleAgentManager[] = html_print_checkbox_switch( 'metaconsole_agents_manager', 1, $user_info['metaconsole_agents_manager'], true - ).'
'; + ); - $metaconsole_access_node = '

'.__('Enable node access').ui_print_help_tip(__('With this option enabled, the user will can access to nodes console'), true).'

'; - $metaconsole_access_node .= html_print_checkbox( + $metaconsoleAgentManager[] = __('Enable node access').ui_print_help_tip( + __('With this option enabled, the user will can access to nodes console'), + true + ); + $metaconsoleAgentManager[] = html_print_checkbox_switch( 'metaconsole_access_node', 1, $access_node, true - ).'
'; + ); } - echo '
'; echo ''; @@ -1701,141 +1632,8 @@ if (!$id) { $user_id_create = $user_id; } -if (is_metaconsole() === true) { - $access_or_pagination = $meta_access; - if ($id != '' && !$is_err) { - $div_user_info = ' - '; - } else { - $div_user_info = ' - '; - } - - echo '
-
- -

Extra info

'.$email.$phone.$not_login.$local_user.$session_time.'
-
-
-
'.$language.$access_or_pagination.$skin.$default_event_filter.$double_authentication.'
- -
'.$timezone; - - echo $search_custom_fields_view.$metaconsole_agents_manager.$metaconsole_access_node; - - $autorefresh_show = '

'._('Autorefresh').ui_print_help_tip( - __('This will activate autorefresh in selected pages'), - true - ).'

'; - $select_out = html_print_select( - $autorefresh_list_out, - 'autorefresh_list_out[]', - '', - '', - '', - '', - true, - true, - true, - '', - false, - 'width:100%' - ); - $arrows = ' '; - $select_in = html_print_select( - $autorefresh_list, - 'autorefresh_list[]', - '', - '', - '', - '', - true, - true, - true, - '', - false, - 'width:100%' - ); - - $table_ichanges = '
'; - - $autorefresh_show .= $table_ichanges; - - // Time autorefresh. - $times = get_refresh_time_array(); - $time_autorefresh = '

'.__('Time autorefresh'); - $time_autorefresh .= ui_print_help_tip( - __('Interval of autorefresh of the elements, by default they are 30 seconds, needing to enable the autorefresh first'), - true - ).'

'; - $time_autorefresh .= html_print_select( - $times, - 'time_autorefresh', - $user_info['time_autorefresh'], - '', - '', - '', - true, - false, - false - ).'
'; - - - echo '
-
-
'.$autorefresh_show.$time_autorefresh.'
-
-
'.$comments.'
-
'; - - if (empty($ehorus) === false) { - html_print_div( - [ - 'class' => 'user_edit_third_row white_box', - 'content' => $ehorus, - ], - true - ); - } - - // User Profile definition table. (Only where user is not creating). - if ($new_user === false && ((bool) check_acl($config['id_user'], 0, 'UM') === true)) { - profile_print_profile_table($id, io_safe_output($json_profile), false, ($is_err === true)); - } -} else { - $access_or_pagination = $size_pagination; - // WIP: Only for node. - include_once 'user_management.php'; -} +// User management form. +require_once 'user_management.php'; if ((bool) $config['admin_can_add_user'] === true) { html_print_csrf_hidden(); @@ -1916,7 +1714,7 @@ if (is_metaconsole() === false) { $(document).ready(function() { // Set up the picker to update target timezone and country select lists. $('#timezone-image').timezonePicker({ - target: '#timezone', + target: '#timezone1', }); // Optionally an auto-detect button to trigger JavaScript geolocation. @@ -1938,17 +1736,6 @@ if (is_metaconsole() === false) { var json_profile = $('#hidden-json_profile'); /* data['passwordManage_table'] = html_print_table($passwordManageTable, true); +if (users_is_admin() === true) { + $userManagementTable->rowclass['captions_loginErrorUser'] = 'field_half_width w50p'; + $userManagementTable->cellclass['captions_loginErrorUser'][0] = 'wrap'; + $userManagementTable->cellclass['captions_loginErrorUser'][1] = 'wrap'; + $notLoginCheckContent = []; + $notLoginCheckContent[] = ''.__('Not Login').''; + $notLoginCheckContent[] = html_print_checkbox_switch( + 'not_login', + 1, + $user_info['not_login'], + true + ); -$userManagementTable->rowclass['captions_loginErrorUser'] = 'field_half_width w50p'; -$userManagementTable->cellclass['captions_loginErrorUser'][0] = 'wrap'; -$userManagementTable->cellclass['captions_loginErrorUser'][1] = 'wrap'; -$notLoginCheckContent = []; -$notLoginCheckContent[] = ''.__('Not Login').''; -$notLoginCheckContent[] = html_print_checkbox_switch( - 'not_login', - 1, - $user_info['not_login'], - true -); + $userManagementTable->data['captions_loginErrorUser'][0] = html_print_div( + [ + 'class' => 'margin-top-10', + 'style' => 'display: flex; flex-direction: row-reverse; align-items: center;', + 'content' => implode('', $notLoginCheckContent), + ], + true + ); + $userManagementTable->data['captions_loginErrorUser'][0] .= ui_print_input_placeholder( + __('The user with not login set only can access to API.'), + true + ); -$userManagementTable->data['captions_loginErrorUser'][0] = html_print_div( - [ - 'class' => 'margin-top-10', - 'style' => 'display: flex; flex-direction: row-reverse; align-items: center;', - 'content' => implode('', $notLoginCheckContent), - ], - true -); -$userManagementTable->data['captions_loginErrorUser'][0] .= ui_print_input_placeholder( - __('The user with not login set only can access to API.'), - true -); + $localUserCheckContent = []; + $localUserCheckContent[] = ''.__('Local User').''; + $localUserCheckContent[] = html_print_checkbox_switch( + 'local_user', + 1, + $user_info['local_user'], + true + ); -$localUserCheckContent = []; -$localUserCheckContent[] = ''.__('Local User').''; -$localUserCheckContent[] = html_print_checkbox_switch( - 'local_user', - 1, - $user_info['local_user'], - true -); + $userManagementTable->data['captions_loginErrorUser'][1] = html_print_div( + [ + 'class' => 'margin-top-10', + 'style' => 'display: flex; flex-direction: row-reverse; align-items: center;', + 'content' => implode('', $localUserCheckContent), + ], + true + ); + $userManagementTable->data['captions_loginErrorUser'][1] .= ui_print_input_placeholder( + __('The user with local authentication enabled will always use local authentication.'), + true + ); +} -$userManagementTable->data['captions_loginErrorUser'][1] = html_print_div( - [ - 'class' => 'margin-top-10', - 'style' => 'display: flex; flex-direction: row-reverse; align-items: center;', - 'content' => implode('', $localUserCheckContent), - ], - true -); -$userManagementTable->data['captions_loginErrorUser'][1] .= ui_print_input_placeholder( - __('The user with local authentication enabled will always use local authentication.'), - true -); $userManagementTable->data['show_tips_startup'][0] = html_print_checkbox_switch('show_tips_startup', 1, ($user_info['show_tips_startup'] === null) ? true : $user_info['show_tips_startup'], true); $userManagementTable->data['show_tips_startup'][1] = ''.__('Show usage tips at startup').''; @@ -551,10 +553,10 @@ $userManagementTable->data['fields_autorefreshTime'][0] .= ui_print_input_placeh // Title for Language and Appearance. $userManagementTable->data['title_lookAndFeel'] = html_print_subtitle_table(__('Language and Appearance')); // Language and color scheme. -$userManagementTable->rowclass['captions_lang_colorscheme'] = 'field_half_width'; -$userManagementTable->rowclass['fields_lang_colorscheme'] = 'field_half_width'; -$userManagementTable->data['captions_lang_colorscheme'][0] = __('Language'); -$userManagementTable->data['fields_lang_colorscheme'][0] = html_print_select_from_sql( +$userManagementTable->rowclass['line1_looknfeel'] = 'field_half_width'; +$userManagementTable->rowclass['line2_looknfeel'] = 'field_half_width'; +$userManagementTable->data['line1_looknfeel'][0] = __('Language'); +$userManagementTable->data['line2_looknfeel'][0] = html_print_select_from_sql( 'SELECT id_language, name FROM tlanguage', 'language', $user_info['language'], @@ -564,8 +566,15 @@ $userManagementTable->data['fields_lang_colorscheme'][0] = html_print_select_fro true ); -$userManagementTable->data['captions_lang_colorscheme'][1] = __('User color scheme'); -$userManagementTable->data['fields_lang_colorscheme'][1] = skins_print_select($id_usr, 'skin', $user_info['id_skin'], '', __('None'), 0, true); +if (is_metaconsole() === true) { + if (users_is_admin() === true) { + $userManagementTable->data['line1_looknfeel'][1] = $outputMetaAccess[0]; + $userManagementTable->data['line2_looknfeel'][1] = $outputMetaAccess[1]; + } +} else { + $userManagementTable->data['line1_looknfeel'][1] = __('User color scheme'); + $userManagementTable->data['line2_looknfeel'][1] = skins_print_select($id_usr, 'skin', $user_info['id_skin'], '', __('None'), 0, true); +} $userManagementTable->rowclass['captions_blocksize_eventfilter'] = 'field_half_width'; $userManagementTable->rowclass['fields_blocksize_eventfilter'] = 'field_half_width'; @@ -591,41 +600,55 @@ $userManagementTable->data['fields_blocksize_eventfilter'][1] = html_print_selec false, false ); +if (is_metaconsole() === false) { + // Home screen table. + $homeScreenTable = new stdClass(); + $homeScreenTable->class = 'w100p table_section full_section'; + $homeScreenTable->id = 'home_screen_table'; + $homeScreenTable->style = []; + $homeScreenTable->rowclass = []; + $homeScreenTable->data = []; + // Home screen. + $homeScreenTable->data['captions_homescreen'][0] = __('Home screen'); + $homeScreenTable->colspan['captions_homescreen'][0] = 2; + $homeScreenTable->rowclass['captions_homescreen'] = 'field_half_width'; + $homeScreenTable->rowclass['fields_homescreen'] = 'field_half_width flex'; + $homeScreenTable->data['fields_homescreen'][0] = html_print_select( + $homeScreenValues, + 'section', + io_safe_output($user_info['section']), + 'show_data_section();', + '', + -1, + true, + false, + false + ); + $homeScreenTable->data['fields_homescreen'][1] = html_print_div( + [ + 'class' => 'w100p', + 'content' => $customHomeScreenDataField, + ], + true + ); -// Home screen table. -$homeScreenTable = new stdClass(); -$homeScreenTable->class = 'w100p table_section full_section'; -$homeScreenTable->id = 'home_screen_table'; -$homeScreenTable->style = []; -$homeScreenTable->rowclass = []; -$homeScreenTable->data = []; + $userManagementTable->rowclass['homescreen_table'] = 'w100p'; + $userManagementTable->data['homescreen_table'] = html_print_table($homeScreenTable, true); +} -// Home screen. -$homeScreenTable->data['captions_homescreen'][0] = __('Home screen'); -$homeScreenTable->colspan['captions_homescreen'][0] = 2; -$homeScreenTable->rowclass['captions_homescreen'] = 'field_half_width'; -$homeScreenTable->rowclass['fields_homescreen'] = 'field_half_width flex'; -$homeScreenTable->data['fields_homescreen'][0] = html_print_select( - $homeScreenValues, - 'section', - io_safe_output($user_info['section']), - 'show_data_section();', - '', - -1, - true, - false, - false -); -$homeScreenTable->data['fields_homescreen'][1] = html_print_div( - [ - 'class' => 'w100p', - 'content' => $customHomeScreenDataField, - ], - true -); +if (is_metaconsole() === true && users_is_admin() === true) { + $userManagementTable->rowclass['search_custom1_looknfeel'] = 'field_half_width'; + $userManagementTable->rowclass['search_custom2_looknfeel'] = 'field_half_width flex-column'; + $userManagementTable->data['search_custom1_looknfeel'][0] = $searchCustomFieldView[0]; + $userManagementTable->data['search_custom2_looknfeel'][0] = $searchCustomFieldView[1]; -$userManagementTable->rowclass['homescreen_table'] = 'w100p'; -$userManagementTable->data['homescreen_table'] = html_print_table($homeScreenTable, true); + $userManagementTable->rowclass['agent_manager1_looknfeel'] = 'field_half_width'; + $userManagementTable->rowclass['agent_manager2_looknfeel'] = 'field_half_width flex-column'; + $userManagementTable->data['agent_manager1_looknfeel'][0] = $metaconsoleAgentManager[0]; + $userManagementTable->data['agent_manager1_looknfeel'][1] = $metaconsoleAgentManager[2]; + $userManagementTable->data['agent_manager2_looknfeel'][0] = $metaconsoleAgentManager[1]; + $userManagementTable->data['agent_manager2_looknfeel'][1] = $metaconsoleAgentManager[3]; +} // Timezone. $userManagementTable->rowclass['captions_timezone'] = 'field_half_width'; @@ -639,14 +662,15 @@ $userManagementTable->data['fields_timezone'][0] .= ui_print_input_placeholder( __('The timezone must be that of the associated server.'), true ); - -$userManagementTable->data['fields_timezone'][1] = html_print_div( - [ - 'id' => 'timezone-picker', - 'content' => implode('', $timezoneContent), - ], - true -); +if (is_metaconsole() === false) { + $userManagementTable->data['fields_timezone'][1] = html_print_div( + [ + 'id' => 'timezone-picker', + 'content' => implode('', $timezoneContent), + ], + true + ); +} // Title for Language and Appearance. $userManagementTable->data['title_additionalSettings'] = html_print_subtitle_table(__('Additional settings')); @@ -743,3 +767,19 @@ html_print_table($userManagementTable); if ($new_user === false && ((bool) check_acl($config['id_user'], 0, 'UM') === true)) { profile_print_profile_table($id, io_safe_output($json_profile), false, ($is_err === true)); } + +?> + \ No newline at end of file diff --git a/pandora_console/include/functions_profile.php b/pandora_console/include/functions_profile.php index d656cdeff2..f9d52ae289 100644 --- a/pandora_console/include/functions_profile.php +++ b/pandora_console/include/functions_profile.php @@ -191,15 +191,9 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c $table->id = 'table_profiles'; $table->width = '100%'; $table->class = 'info_table'; - if (is_metaconsole() === true) { - $table->head_colspan[0] = 0; - $table->width = '100%'; - $table->class = 'databox_tactical data'; - $table->title = $title; - } else { - echo '
'; - echo '

'.$title.'

'; - } + + echo '
'; + echo '

'.$title.'

'; $table->data = []; $table->head = []; @@ -405,9 +399,7 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c array_push($table->data, $data); html_print_table($table, $return); - if (is_metaconsole() === false) { - echo '
'; - } + echo '
'; unset($table); } From 00ba02e23e292b8d525d20f4fc99292a234775d1 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 14 Mar 2023 13:26:21 +0100 Subject: [PATCH 10/19] Visual changes PDFs slicebar --- pandora_console/include/chart_generator.php | 7 +-- pandora_console/include/functions.php | 13 +++++ pandora_console/include/functions_events.php | 2 +- .../include/functions_reporting_html.php | 50 ++++++++++--------- .../include/graphs/functions_flot.php | 6 ++- pandora_console/include/styles/events.css | 5 ++ 6 files changed, 54 insertions(+), 29 deletions(-) diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index 7bc4785011..2e9ec50479 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -27,8 +27,6 @@ */ // Begin. -require_once 'config.php'; - require_once __DIR__.'/config.php'; require_once __DIR__.'/functions.php'; require_once __DIR__.'/functions_db.php'; @@ -87,7 +85,7 @@ if (check_login(false) === false) {

Access is not granted

-