From 1096319faf4721b72d1d6c7926c12587ef6263e3 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 13 Sep 2018 15:48:26 +0200 Subject: [PATCH] Removed Networkmaps on mobile console --- pandora_console/mobile/index.php | 10 - pandora_console/mobile/operation/home.php | 13 - .../mobile/operation/networkmap.php | 246 ----------------- .../mobile/operation/networkmaps.php | 250 ------------------ 4 files changed, 519 deletions(-) delete mode 100755 pandora_console/mobile/operation/networkmap.php delete mode 100755 pandora_console/mobile/operation/networkmaps.php diff --git a/pandora_console/mobile/index.php b/pandora_console/mobile/index.php index 04fc1ff92e..2a8f8ed396 100644 --- a/pandora_console/mobile/index.php +++ b/pandora_console/mobile/index.php @@ -34,8 +34,6 @@ require_once('operation/agents.php'); require_once('operation/modules.php'); require_once('operation/module_graph.php'); require_once('operation/agent.php'); -require_once('operation/networkmaps.php'); -require_once('operation/networkmap.php'); require_once('operation/visualmaps.php'); require_once('operation/visualmap.php'); $enterpriseHook = enterprise_include('mobile/include/enterprise.class.php'); @@ -333,14 +331,6 @@ switch ($action) { $agent = new Agent(); $agent->show(); break; - case 'networkmaps': - $networkmaps = new Networkmaps(); - $networkmaps->show(); - break; - case 'networkmap': - $networkmap = new Networkmap(); - $networkmap->show(); - break; case 'visualmaps': $visualmaps = new Visualmaps(); $visualmaps->show(); diff --git a/pandora_console/mobile/operation/home.php b/pandora_console/mobile/operation/home.php index 59728010a5..1a1ff12110 100644 --- a/pandora_console/mobile/operation/home.php +++ b/pandora_console/mobile/operation/home.php @@ -73,13 +73,6 @@ class Home { 'menu_item' => true, 'icon' => 'modules' ); - - $items['networkmaps'] = array( - 'name' => __('Networkmaps'), - 'filename' => 'networkmaps.php', - 'menu_item' => true, - 'icon' => 'network_maps' - ); $items['visualmaps'] = array( 'name' => __('Visual consoles'), 'filename' => 'visualmaps.php', @@ -100,12 +93,6 @@ class Home { 'menu_item' => false, 'icon' => '' ); - $items['networkmap'] = array( - 'name' => __('Networkmap'), - 'filename' => 'networkmap.php', - 'menu_item' => false, - 'icon' => '' - ); $items['visualmap'] = array( 'name' => __('Visualmap'), 'filename' => 'visualmap.php', diff --git a/pandora_console/mobile/operation/networkmap.php b/pandora_console/mobile/operation/networkmap.php deleted file mode 100755 index 9595efaa87..0000000000 --- a/pandora_console/mobile/operation/networkmap.php +++ /dev/null @@ -1,246 +0,0 @@ -getFilters(); - else - $this->id = $id; - - $store_group = db_get_value('store_group', - 'tnetwork_map', 'id_networkmap', $this->id); - - if ($store_group !== false - && $system->checkACL($this->acl, $store_group)) - $this->correct_acl = true; - } - - public function ajax($parameter2 = false) { - $system = System::getInstance(); - - if (!$this->correct_acl) { - return; - } - else { - switch ($parameter2) { - case 'xxx': - //$this->getFilters(); - //$page = $system->getRequest('page', 0); - break; - } - } - } - - private function getFilters() { - $system = System::getInstance(); - - $this->id = (int)$system->getRequest('id', 0); - } - - public function show() { - if (!$this->correct_acl) { - $this->show_fail_acl(); - } - else { - $this->getFilters(); - - $this->networkmap = db_get_row('tnetwork_map', - 'id_networkmap', $this->id); - - $this->show_networkmap(); - } - } - - private function show_fail_acl() { - $error['type'] = 'onStart'; - $error['title_text'] = __('You don\'t have access to this page'); - $error['content_text'] = System::getDefaultACLFailText(); - if (class_exists("HomeEnterprise")) - $home = new HomeEnterprise(); - else - $home = new Home(); - $home->show($error); - } - - private function show_networkmap() { - $ui = Ui::getInstance(); - $system = System::getInstance(); - - $ui->createPage(); - $ui->createDefaultHeader( - sprintf("%s", - $this->networkmap['name']), - $ui->createHeaderButton( - array('icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=networkmaps'))); - $ui->showFooter(false); - $ui->beginContent(); - - //Hack for mobile - global $hack_networkmap_mobile; - $hack_networkmap_mobile = true; - - switch ($this->networkmap['type']) { - case 'groups': - $graph = networkmap_generate_dot_groups ( - __('Pandora FMS'), - $this->networkmap['id_group'], - $this->networkmap['simple'], - $this->networkmap['font_size'], - $this->networkmap['layout'], - (bool)$this->networkmap['nooverlap'], - $this->networkmap['zoom'], - $this->networkmap['distance_nodes'], - $this->networkmap['center'], 1, 0, - $this->networkmap['only_modules_with_alerts'], - $this->networkmap['id_module_group'], - $this->networkmap['hide_policy_modules'], - $this->networkmap['depth'], - $this->networkmap['id_networkmap']); - break; - case 'policies': - $enterprise = enterprise_include('/include/functions_policies.php'); - - if ($enterprise != ENTERPRISE_NOT_HOOK) { - $graph = policies_generate_dot_graph (__('Pandora FMS'), - $this->networkmap['id_group'], - $this->networkmap['simple'], - $this->networkmap['font_size'], - $this->networkmap['layout'], - (bool)$this->networkmap['nooverlap'], - $this->networkmap['zoom'], - $this->networkmap['distance_nodes'], - $this->networkmap['center'], 1, 0, - $this->networkmap['only_modules_with_alerts'], - $this->networkmap['id_module_group'], - $this->networkmap['depth'], - $this->networkmap['id_networkmap']); - } - break; - default: - case 'topology': - $graph = networkmap_generate_dot (__('Pandora FMS'), - $this->networkmap['id_group'], - $this->networkmap['simple'], - $this->networkmap['font_size'], - $this->networkmap['layout'], - (bool)$this->networkmap['nooverlap'], - $this->networkmap['zoom'], - $this->networkmap['distance_nodes'], - $this->networkmap['center'], 1, 0, - $this->networkmap['id_networkmap'], - $this->networkmap['show_snmp_modules'], true, - true); - break; - } - - - - if ($graph === false) { - $ui->contentAddHtml('

' . __('No networkmaps') . '

'); - - $ui->endContent(); - $ui->showPage(); - - return; - } - - - $filter = networkmap_get_filter($this->networkmap['layout']); - - // Generate image and map - // If image was generated just a few minutes ago, then don't regenerate (it takes long) unless regen checkbox is set - $filename_map = safe_url_extraclean ( - $system->getConfig('attachment_store')) . "/networkmap_" . $filter; - $filename_img = safe_url_extraclean ( - $system->getConfig('attachment_store')) . "/networkmap_" . - $filter . "_" . $this->networkmap['font_size']; - $url_img = "../attachment/networkmap_" . - $filter . "_" . $this->networkmap['font_size']; - $filename_dot = safe_url_extraclean( - $system->getConfig("attachment_store")) . "/networkmap_" . $filter; - if ($this->networkmap['simple']) { - $filename_map .= "_simple"; - $filename_img .= "_simple"; - $url_img .= "_simple"; - $filename_dot .= "_simple"; - } - if ($this->networkmap['nooverlap']) { - $filename_map .= "_nooverlap"; - $filename_img .= "_nooverlap"; - $url_img .= "_nooverlap"; - $filename_dot .= "_nooverlap"; - } - $filename_map .= "_" . $this->networkmap['id_networkmap'] . ".map"; - $filename_img .= "_" . $this->networkmap['id_networkmap'] . ".png"; - $url_img .= "_" . $this->networkmap['id_networkmap'] . ".png"; - $filename_dot .= "_" . $this->networkmap['id_networkmap'] . ".dot"; - - if ($this->networkmap['regenerate'] != 1 && file_exists($filename_img) && filemtime($filename_img) > get_system_time () - 300) { - $result = true; - } - else { - $fh = @fopen ($filename_dot, 'w'); - if ($fh === false) { - $result = false; - } - else { - fwrite ($fh, $graph); - $cmd = $filter . " -Tcmapx -o" . $filename_map." -Tpng -o".$filename_img." ".$filename_dot; - $result = system ($cmd); - fclose ($fh); - //unlink ($filename_dot); - } - } - - if ($result !== false) { - if (! file_exists ($filename_map)) { - $ui->contentAddHtml('

' . __('Map could not be generated') . '

'); - - $ui->endContent(); - $ui->showPage(); - - return; - } - $ui->contentAddHtml('
'); - $ui->contentAddHtml(''); - $ui->contentAddHtml('
'); - } - else { - $ui->contentAddHtml('

' . __('Map could not be generated') . '

'); - - $ui->endContent(); - $ui->showPage(); - - return; - } - - $ui->endContent(); - $ui->showPage(); - } -} -?> diff --git a/pandora_console/mobile/operation/networkmaps.php b/pandora_console/mobile/operation/networkmaps.php deleted file mode 100755 index f8f533cc84..0000000000 --- a/pandora_console/mobile/operation/networkmaps.php +++ /dev/null @@ -1,250 +0,0 @@ -checkACL($this->acl)) { - $this->correct_acl = true; - } - else { - $this->correct_acl = false; - } - } - - public function ajax($parameter2 = false) { - $system = System::getInstance(); - - if (!$this->correct_acl) { - return; - } - else { - switch ($parameter2) { - case 'xxx': - //$this->getFilters(); - //$page = $system->getRequest('page', 0); - break; - } - } - } - - private function getFilters() { - $system = System::getInstance(); - $user = User::getInstance(); - - $this->default_filters['group'] = true; - $this->default_filters['type'] = true; - - $this->group = (int)$system->getRequest('group', __("Group")); - if (!$user->isInGroup($this->acl, $this->group)) { - $this->group = 0; - } - if (($this->group === __("Group")) || ($this->group == 0)) { - $this->group = 0; - } - else { - $this->default = false; - $this->default_filters['group'] = false; - } - - $this->type = $system->getRequest('type', __("Type")); - if (($this->type === __("Type")) || ($this->type === '0')) { - $this->type = '0'; - } - else { - $this->default = false; - $this->default_filters['type'] = false; - } - } - - public function show() { - if (!$this->correct_acl) { - $this->show_fail_acl(); - } - else { - $this->getFilters(); - $this->show_networkmaps(); - } - } - - private function show_fail_acl() { - $error['type'] = 'onStart'; - $error['title_text'] = __('You don\'t have access to this page'); - $error['content_text'] = System::getDefaultACLFailText(); - if (class_exists("HomeEnterprise")) - $home = new HomeEnterprise(); - else - $home = new Home(); - $home->show($error); - } - - private function show_networkmaps() { - $ui = Ui::getInstance(); - - $ui->createPage(); - $ui->createDefaultHeader(__("Networkmaps"), - $ui->createHeaderButton( - array('icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=home'))); - $ui->showFooter(false); - $ui->beginContent(); - $filter_title = sprintf(__('Filter Networkmaps by %s'), - $this->filterNetworkmapsGetString()); - $ui->contentBeginCollapsible($filter_title); - $ui->beginForm("index.php?page=networkmaps"); - $system = System::getInstance(); - $groups = users_get_groups_for_select( - $system->getConfig('id_user'), "AR", true, true, false, 'id_grupo'); - $options = array( - 'name' => 'group', - 'title' => __('Group'), - 'label' => __('Group'), - 'items' => $groups, - 'selected' => $this->group - ); - $ui->formAddSelectBox($options); - - $networkmap_types = networkmap_get_filter_types(); - $networkmap_types[0] = __('All'); - $options = array( - 'name' => 'type', - 'title' => __('Type'), - 'label' => __('Type'), - 'items' => $networkmap_types, - 'selected' => $this->type - ); - $ui->formAddSelectBox($options); - - $options = array( - 'icon' => 'refresh', - 'icon_pos' => 'right', - 'text' => __('Apply Filter') - ); - $ui->formAddSubmitButton($options); - $html = $ui->getEndForm(); - $ui->contentCollapsibleAddItem($html); - $ui->contentEndCollapsible(); - $this->listNetworkmapsHtml(); - $ui->endContent(); - $ui->showPage(); - } - - private function listNetworkmapsHtml() { - $system = System::getInstance(); - $ui = Ui::getInstance(); - - // Create filter - $where = array(); - // Order by type field - $where['order'] = 'type'; - - if ($this->group != '0') { - $where['store_group'] = $this->group; - } - else { - $where['store_group'] = array_keys(users_get_groups()); - } - - if ($this->type != '0') - $where['type'] = $this->type; - - $network_maps = db_get_all_rows_filter('tnetwork_map', - $where); - if (empty($network_maps)) { - $network_maps = array(); - } - $list = array(); - foreach ($network_maps as $networkmap) { - // ACL - if (! $system->checkACL("AR", $networkmap['store_group'])) - continue; - - // If enterprise not loaded then skip this code - if ($networkmap['type'] == 'policies' and (!defined('PANDORA_ENTERPRISE'))) - continue; - $row = array(); - $row[__('Name')] = '' . io_safe_output($networkmap['name']) . ''; - $row[__('Type')] = $networkmap['type']; - $row[__('Group')] = ui_print_group_icon($networkmap["store_group"], true, "groups_small", "" , false); - $list[] = $row; - } - - if (count($network_maps) == 0) { - $ui->contentAddHtml('

' . __('No networkmaps') . '

'); - } - else { - $table = new Table(); - $table->id = 'list_networkmaps'; - $table->importFromHash($list); - $ui->contentAddHtml($table->getHTML()); - } - - $ui->contentAddLinkListener('list_networkmaps'); - } - - private function filterNetworkmapsGetString() { - if ($this->default) { - return __("(Default)"); - } - else { - $filters_to_serialize = array(); - - if (!$this->default_filters['group']) { - $filters_to_serialize[] = sprintf(__("Group: %s"), - groups_get_name($this->group, true)); - } - if (!$this->default_filters['type']) { - $networkmap_types = networkmap_get_filter_types(); - $networkmap_types[0] = __('All'); - - $filters_to_serialize[] = sprintf(__("Type: %s"), - $networkmap_types[$this->type]); - } - - $string = '(' . implode(' - ', $filters_to_serialize) . ')'; - - - //~ $networkmap_types = networkmap_get_filter_types(); - //~ $networkmap_types[0] = __('All'); - //~ $type = $networkmap_types[$this->type]; - //~ $group = groups_get_name($this->group, true); - //~ - //~ - //~ $string = sprintf( - //~ __("(Type: %s - Group: %s)"), - //~ $type, $group); - - return $string; - } - } -} -?>