Removed Networkmaps on mobile console

This commit is contained in:
fermin831 2018-09-13 15:48:26 +02:00
parent b39b876cb2
commit 1096319faf
4 changed files with 0 additions and 519 deletions

View File

@ -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();

View File

@ -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',

View File

@ -1,246 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
require_once ('../include/functions_networkmap.php');
class Networkmap {
private $correct_acl = false;
private $acl = "AR";
private $id = 0;
private $network_map = null;
function __construct($id = false) {
$system = System::getInstance();
if ($id === false)
$this->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('<p style="color: #ff0000;">' . __('No networkmaps') . '</p>');
$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('<p style="color: #ff0000;">' . __('Map could not be generated') . '</p>');
$ui->endContent();
$ui->showPage();
return;
}
$ui->contentAddHtml('<div style="width: auto; overflow-x: auto; text-align: center;">');
$ui->contentAddHtml('<img style="width: 90%;" src="' . $url_img . '" />');
$ui->contentAddHtml('</div>');
}
else {
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('Map could not be generated') . '</p>');
$ui->endContent();
$ui->showPage();
return;
}
$ui->endContent();
$ui->showPage();
}
}
?>

View File

@ -1,250 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
ob_start();
require_once ('../include/functions_networkmap.php');
ob_get_clean(); //Fixed unused javascript code.
class Networkmaps {
private $correct_acl = false;
private $acl = "AR";
private $default = true;
private $default_filters = array();
private $group = 0;
private $type = 0;
private $list_types = null;
function __construct() {
$system = System::getInstance();
if ($system->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')] = '<a class="ui-link" data-ajax="false" href="index.php?page=networkmap&id=' . $networkmap['id_networkmap'] . '">' . io_safe_output($networkmap['name']) . '</a>';
$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('<p style="color: #ff0000;">' . __('No networkmaps') . '</p>');
}
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;
}
}
}
?>