'.ui_print_help_tip(
__('The minimum recomended interval for Recon Task is 5 minutes'),
true
).html_print_extended_select_for_time(
@@ -898,7 +898,7 @@ class HostDevices extends Wizard
],
[
'label' => '
'.ui_print_help_tip(
- __('Plese upload a new file to overwrite this content.'),
+ __('Please upload a new file to overwrite this content.'),
true
),
'arguments' => [
diff --git a/pandora_console/images/visual_console.menu.png b/pandora_console/images/visual_console.menu.png
new file mode 100644
index 0000000000..818beae6f2
Binary files /dev/null and b/pandora_console/images/visual_console.menu.png differ
diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php
index 9476b41718..b49a884832 100644
--- a/pandora_console/include/ajax/events.php
+++ b/pandora_console/include/ajax/events.php
@@ -257,6 +257,11 @@ if ($save_event_filter) {
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
$values['id_source_event'] = get_parameter('id_source_event');
+
+ if (is_metaconsole()) {
+ $values['server_id'] = get_parameter('server_id');
+ }
+
$exists = (bool) db_get_value_filter(
'id_filter',
'tevent_filter',
@@ -305,6 +310,10 @@ if ($update_event_filter) {
$values['user_comment'] = get_parameter('user_comment');
$values['id_source_event'] = get_parameter('id_source_event');
+ if (is_metaconsole()) {
+ $values['server_id'] = get_parameter('server_id');
+ }
+
if (io_safe_output($values['tag_with']) == '["0"]') {
$values['tag_with'] = '[]';
}
@@ -371,6 +380,13 @@ if ($get_filter_values) {
}
}
+ if (is_metaconsole()) {
+ $server_name = db_get_value('server_name', 'tmetaconsole_setup', 'id', $event_filter['server_id']);
+ if ($server_name !== false) {
+ $event_filter['server_name'] = $server_name;
+ }
+ }
+
$event_filter['module_search'] = io_safe_output(db_get_value_filter('nombre', 'tagente_modulo', ['id_agente_modulo' => $event_filter['id_agent_module']]));
}
@@ -402,6 +418,8 @@ if ($load_filter_modal) {
);
echo '
';
?>
';
$output .= '';
+ $output .= '';
+
if (isset($this->map['__simulated']) === false) {
// Load context menu if manageable networkmap.
- $output .= '';
+ $output .= '';
}
- $output .= '';
+ $output .= '';
// Open networkconsole_id div.
$output .= '
__('Tactical View'),
'icon' => ui_get_full_url(
- 'images/op_monitoring.menu_gray.png'
+ 'images/menu/op_monitoring.menu_gray.png'
),
'url' => ui_get_full_url(
'index.php?sec=view&sec2=operation/agentes/tactical'
@@ -122,7 +122,7 @@ class OrderInterpreter extends Wizard
[
'name' => __('Agent Management'),
'icon' => ui_get_full_url(
- 'images/gm_resources.menu_gray.png'
+ 'images/menu/gm_resources.menu_gray.png'
),
'url' => ui_get_full_url(
'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente'
@@ -140,7 +140,7 @@ class OrderInterpreter extends Wizard
[
'name' => __('General Setup'),
'icon' => ui_get_full_url(
- 'images/gm_setup.menu_gray.png'
+ 'images/menu/gm_setup.menu_gray.png'
),
'url' => ui_get_full_url(
'index.php?sec=general&sec2=godmode/setup/setup§ion=general'
@@ -156,7 +156,7 @@ class OrderInterpreter extends Wizard
[
'name' => __('Manage Policies'),
'icon' => ui_get_full_url(
- 'images/gm_configuration.menu_gray.png'
+ 'images/menu/gm_configuration.menu_gray.png'
),
'url' => ui_get_full_url(
'index.php?sec=gmodules&sec2=enterprise/godmode/policies/policies'
@@ -170,7 +170,7 @@ class OrderInterpreter extends Wizard
[
'name' => __('List Alerts'),
'icon' => ui_get_full_url(
- 'images/gm_alerts.menu_gray.png'
+ 'images/menu/gm_alerts.menu_gray.png'
),
'url' => ui_get_full_url(
'index.php?sec=galertas&sec2=godmode/alerts/alert_list'
@@ -194,7 +194,7 @@ class OrderInterpreter extends Wizard
[
'name' => __('View Events'),
'icon' => ui_get_full_url(
- 'images/op_events.menu_gray.png'
+ 'images/menu/op_events.menu_gray.png'
),
'url' => ui_get_full_url(
'index.php?sec=eventos&sec2=operation/events/events'
@@ -218,7 +218,7 @@ class OrderInterpreter extends Wizard
[
'name' => __('Dashboard'),
'icon' => ui_get_full_url(
- 'images/op_reporting.menu_gray.png'
+ 'images/menu/op_reporting.menu_gray.png'
),
'url' => ui_get_full_url(
'index.php?sec=reporting&sec2=operation/dashboard/dashboard'
@@ -232,7 +232,7 @@ class OrderInterpreter extends Wizard
[
'name' => __('Visual Console'),
'icon' => ui_get_full_url(
- 'images/op_network.menu_gray.png'
+ 'images/menu/op_network.menu_gray.png'
),
'url' => ui_get_full_url(
'index.php?sec=network&sec2=godmode/reporting/map_builder'
@@ -246,7 +246,7 @@ class OrderInterpreter extends Wizard
[
'name' => __('Manage Servers'),
'icon' => ui_get_full_url(
- 'images/gm_servers.menu_gray.png'
+ 'images/menu/gm_servers.menu_gray.png'
),
'url' => ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/modificar_server'
@@ -260,7 +260,7 @@ class OrderInterpreter extends Wizard
[
'name' => __('Edit User'),
'icon' => ui_get_full_url(
- 'images/gm_users.menu_gray.png'
+ 'images/menu/gm_users.menu_gray.png'
),
'url' => ui_get_full_url(
'index.php?sec=workspace&sec2=operation/users/user_edit'
@@ -270,7 +270,7 @@ class OrderInterpreter extends Wizard
[
'name' => __('Tree View'),
'icon' => ui_get_full_url(
- 'images/op_monitoring.menu_gray.png'
+ 'images/menu/op_monitoring.menu_gray.png'
),
'url' => ui_get_full_url(
'index.php?sec=view&sec2=operation/tree'
@@ -280,7 +280,7 @@ class OrderInterpreter extends Wizard
[
'name' => __('Network Component'),
'icon' => ui_get_full_url(
- 'images/gm_configuration.menu_gray.png'
+ 'images/menu/gm_configuration.menu_gray.png'
),
'url' => ui_get_full_url(
'index.php?sec=gmodules&sec2=godmode/modules/manage_network_components'
@@ -294,7 +294,7 @@ class OrderInterpreter extends Wizard
[
'name' => __('Task List'),
'icon' => ui_get_full_url(
- 'images/gm_discovery.menu.png'
+ 'images/menu/gm_discovery.menu.png'
),
'url' => ui_get_full_url(
'index.php?sec=discovery&sec2=godmode/servers/discovery&wiz=tasklist'
@@ -338,7 +338,7 @@ class OrderInterpreter extends Wizard
[
'name' => __('Update Manager'),
'icon' => ui_get_full_url(
- 'images/um_messages.menu_gray.png'
+ 'images/menu/um_messages.menu_gray.png'
),
'url' => ui_get_full_url(
'index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=setup'
@@ -352,7 +352,7 @@ class OrderInterpreter extends Wizard
[
'name' => __('Manage Agent Groups'),
'icon' => ui_get_full_url(
- 'images/gm_users.menu_gray.png'
+ 'images/menu/gm_users.menu_gray.png'
),
'url' => ui_get_full_url(
'index.php?sec=gagente&sec2=godmode/groups/group_list&tab=groups'
diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php
index 70fb1d4e60..dc0dca6df4 100644
--- a/pandora_console/include/class/Tree.class.php
+++ b/pandora_console/include/class/Tree.class.php
@@ -1,15 +1,30 @@
getAgentSearchFilter();
$agent_status_filter = $this->getAgentStatusFilter();
$module_search_filter = $this->getModuleSearchFilter();
- $module_status_filter = $this->getModuleStatusFilter();
+ $module_status_filter = $this->getModuleStatusFilterFromTestado($this->filter['statusModule']);
$condition = $this->L2condition;
$condition_inside = $this->L2conditionInside;
diff --git a/pandora_console/include/class/TreeGroup.class.php b/pandora_console/include/class/TreeGroup.class.php
index 53d7f510f6..4b94cf8405 100644
--- a/pandora_console/include/class/TreeGroup.class.php
+++ b/pandora_console/include/class/TreeGroup.class.php
@@ -1,32 +1,86 @@
L1fieldName = 'id_group';
$this->L1extraFields = [
@@ -42,18 +96,37 @@ class TreeGroup extends Tree
}
+ /**
+ * Setter propagate counters.
+ *
+ * @param boolean $value True or ffalse.
+ *
+ * @return void
+ */
public function setPropagateCounters($value)
{
$this->propagateCounters = (bool) $value;
}
+ /**
+ * Setter all groups.
+ *
+ * @param boolean $value True or ffalse.
+ *
+ * @return void
+ */
public function setDisplayAllGroups($value)
{
$this->displayAllGroups = (bool) $value;
}
+ /**
+ * Get data.
+ *
+ * @return void
+ */
protected function getData()
{
if ($this->id == -1) {
@@ -66,22 +139,36 @@ class TreeGroup extends Tree
}
+ /**
+ * Filter search groups.
+ *
+ * @return string
+ */
protected function getGroupSearchFilter()
{
return '';
}
+ /**
+ * First level tree.
+ *
+ * @return void
+ */
protected function getFirstLevel()
{
$processed_items = $this->getProcessedGroups();
- if (!empty($processed_items)) {
- // Filter by group name. This should be done after rerieving the items cause we need the possible items descendants
- if (!empty($this->filter['searchGroup'])) {
- // Save the groups which intersect with the user groups
- $groups = db_get_all_rows_filter('tgrupo', ['nombre' => '%'.$this->filter['searchGroup'].'%']);
- if ($groups == false) {
+ if (empty($processed_items) === false) {
+ // Filter by group name. This should be done after rerieving
+ // the items cause we need the possible items descendants.
+ if (empty($this->filter['searchGroup']) === false) {
+ // Save the groups which intersect with the user groups.
+ $groups = db_get_all_rows_filter(
+ 'tgrupo',
+ ['nombre' => '%'.$this->filter['searchGroup'].'%']
+ );
+ if ($groups === false) {
$groups = [];
}
@@ -90,7 +177,7 @@ class TreeGroup extends Tree
$groups,
function ($userGroups, $group) use ($userGroupsACL) {
$group_id = $group['id_grupo'];
- if (isset($userGroupsACL[$group_id])) {
+ if (isset($userGroupsACL[$group_id]) === true) {
$userGroups[$group_id] = $userGroupsACL[$group_id];
}
@@ -99,14 +186,22 @@ class TreeGroup extends Tree
[]
);
- $result = self::extractGroupsWithIDs($processed_items, $ids_hash);
+ $result = self::extractGroupsWithIDs(
+ $processed_items,
+ $ids_hash
+ );
$processed_items = ($result === false) ? [] : $result;
}
- // groupID filter. To access the view from tactical views f.e.
- if (!empty($this->filter['groupID'])) {
- $result = self::extractItemWithID($processed_items, $this->filter['groupID'], 'group', $this->strictACL);
+ // GroupID filter. To access the view from tactical views f.e.
+ if (empty($this->filter['groupID']) === false) {
+ $result = self::extractItemWithID(
+ $processed_items,
+ $this->filter['groupID'],
+ 'group',
+ $this->strictACL
+ );
$processed_items = ($result === false) ? [] : [$result];
}
@@ -116,56 +211,64 @@ class TreeGroup extends Tree
}
+ /**
+ * Process group
+ *
+ * @return mixed
+ */
protected function getProcessedGroups()
{
$processed_groups = [];
- // Index and process the groups
+ // Index and process the groups.
$groups = $this->getGroupCounters();
// If user have not permissions in parent, set parent node to 0 (all)
- // Avoid to do foreach for admins
- if (!users_can_manage_group_all('AR')) {
+ // Avoid to do foreach for admins.
+ if (users_can_manage_group_all('AR') === false) {
foreach ($groups as $id => $group) {
- if (!isset($this->userGroups[$groups[$id]['parent']])) {
+ if (isset($this->userGroups[$groups[$id]['parent']]) === false) {
$groups[$id]['parent'] = 0;
}
}
}
- // Build the group hierarchy
+ // Build the group hierarchy.
foreach ($groups as $id => $group) {
- if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) {
+ if (isset($groups[$id]['parent']) === true
+ && ($groups[$id]['parent'] != 0)
+ ) {
$parent = $groups[$id]['parent'];
- // Parent exists
- if (!isset($groups[$parent]['children'])) {
+ // Parent exists.
+ if (isset($groups[$parent]['children']) === false) {
$groups[$parent]['children'] = [];
}
- // Store a reference to the group into the parent
+ // Store a reference to the group into the parent.
$groups[$parent]['children'][] = &$groups[$id];
- // This group was introduced into a parent
+ // This group was introduced into a parent.
$groups[$id]['have_parent'] = true;
}
}
- // Sort the children groups
+ // Sort the children groups.
foreach ($groups as $id => $group) {
- if (isset($groups[$id]['children'])) {
+ if (isset($groups[$id]['children']) === true) {
usort($groups[$id]['children'], ['Tree', 'cmpSortNames']);
}
}
- // Filter groups and eliminates the reference to children groups out of her parent
+ // Filter groups and eliminates the reference to
+ // children groups out of her parent.
$groups = array_filter(
$groups,
function ($group) {
return !$group['have_parent'];
}
);
- // Propagate child counters to her parents
- if ($this->propagateCounters) {
+ // Propagate child counters to her parents.
+ if ($this->propagateCounters === true) {
self::processCounters($groups);
- // Filter groups and eliminates the reference to empty groups
+ // Filter groups and eliminates the reference to empty groups.
$groups = $this->deleteEmptyGroups($groups);
} else {
$groups = $this->deleteEmptyGroupsNotPropagate($groups);
diff --git a/pandora_console/include/class/TreeGroupEdition.class.php b/pandora_console/include/class/TreeGroupEdition.class.php
index f9be10ebaf..490a682865 100644
--- a/pandora_console/include/class/TreeGroupEdition.class.php
+++ b/pandora_console/include/class/TreeGroupEdition.class.php
@@ -1,31 +1,81 @@
id == -1) {
@@ -34,46 +84,54 @@ class TreeGroupEdition extends TreeGroup
}
+ /**
+ * Get process group.
+ *
+ * @return mixed
+ */
protected function getProcessedGroups()
{
$processed_groups = [];
- // Index and process the groups
+ // Index and process the groups.
$groups = $this->getGroupCounters();
// If user have not permissions in parent, set parent node to 0 (all)
- // Avoid to do foreach for admins
- if (!users_can_manage_group_all('AR')) {
+ // Avoid to do foreach for admins.
+ if (users_can_manage_group_all('AR') === false) {
foreach ($groups as $id => $group) {
- if (!isset($this->userGroups[$groups[$id]['parent']])) {
+ if (isset($this->userGroups[$groups[$id]['parent']]) === false) {
$groups[$id]['parent'] = 0;
}
}
}
- // Build the group hierarchy
+ // Build the group hierarchy.
foreach ($groups as $id => $group) {
- if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) {
+ if (isset($groups[$id]['parent']) === true
+ && ($groups[$id]['parent'] != 0)
+ ) {
$parent = $groups[$id]['parent'];
- // Parent exists
- if (!isset($groups[$parent]['children'])) {
+ // Parent exists.
+ if (isset($groups[$parent]['children']) === false) {
$groups[$parent]['children'] = [];
}
- // Store a reference to the group into the parent
+ // Store a reference to the group into the parent.
$groups[$parent]['children'][] = &$groups[$id];
- // This group was introduced into a parent
+ // This group was introduced into a parent.
$groups[$id]['have_parent'] = true;
}
}
- // Sort the children groups
+ // Sort the children groups.
foreach ($groups as $id => $group) {
- if (isset($groups[$id]['children'])) {
+ if (isset($groups[$id]['children']) === true) {
usort($groups[$id]['children'], ['Tree', 'cmpSortNames']);
}
}
- // Filter groups and eliminates the reference to children groups out of her parent
+ // Filter groups and eliminates the reference
+ // to children groups out of her parent.
$groups = array_filter(
$groups,
function ($group) {
@@ -81,11 +139,25 @@ class TreeGroupEdition extends TreeGroup
}
);
+ // Filter groups that user has permission.
+ $groups = array_filter(
+ $groups,
+ function ($group) {
+ global $config;
+ return check_acl($config['id_user'], $group['id'], 'AR');
+ }
+ );
+
usort($groups, ['Tree', 'cmpSortNames']);
return $groups;
}
+ /**
+ * Get group counters.
+ *
+ * @return mixed
+ */
protected function getGroupCounters()
{
$messages = [
@@ -93,10 +165,25 @@ class TreeGroupEdition extends TreeGroup
'cancel' => __('Cancel'),
'messg' => __('Are you sure?'),
];
- $sql = 'SELECT id_grupo AS gid,
- nombre as name, parent, icon
+
+ $group_acl = '';
+ if (users_can_manage_group_all('AR') === false) {
+ $user_groups_str = implode(',', $this->userGroupsArray);
+ $group_acl = sprintf(
+ 'AND id_grupo IN (%s)',
+ $user_groups_str
+ );
+ }
+
+ $sql = sprintf(
+ 'SELECT id_grupo AS gid,
+ nombre as name,
+ parent,
+ icon
FROM tgrupo
- ';
+ WHERE 1=1 %s',
+ $group_acl
+ );
$stats = db_get_all_rows_sql($sql);
$group_stats = [];
@@ -107,7 +194,9 @@ class TreeGroupEdition extends TreeGroup
$group_stats[$group['gid']]['id'] = $group['gid'];
$group_stats[$group['gid']]['type'] = 'group';
- $group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]);
+ $group_stats[$group['gid']] = $this->getProcessedItem(
+ $group_stats[$group['gid']]
+ );
$group_stats[$group['gid']]['delete']['messages'] = $messages;
$group_stats[$group['gid']]['edit'] = 1;
$group_stats[$group['gid']]['alerts'] = '';
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index 40cfe78ae0..1cd5f34cd9 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,8 +20,8 @@
/**
* Pandora build version and version
*/
-$build_version = 'PC210324';
-$pandora_version = 'v7.0NG.752';
+$build_version = 'PC210511';
+$pandora_version = 'v7.0NG.754';
// Do not overwrite default timezone set if defined.
$script_tz = @date_default_timezone_get();
@@ -97,7 +97,7 @@ require_once $ownDir.'functions.php';
// We need a timezone BEFORE calling config_process_config.
// If not we will get ugly warnings. Set Europe/Madrid by default
// Later will be replaced by the good one.
-if (!is_dir($_SERVER['DOCUMENT_ROOT'].$config['homeurl']) || !is_dir($_SERVER['DOCUMENT_ROOT'].$config['homeurl_static'])) {
+if (!is_dir($config['homedir'])) {
$url = explode('/', $_SERVER['REQUEST_URI']);
$flag_url = 0;
foreach ($url as $key => $value) {
diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php
index 19520f9791..c6c4a190e4 100644
--- a/pandora_console/include/constants.php
+++ b/pandora_console/include/constants.php
@@ -626,6 +626,7 @@ define('DISCOVERY_APP_SAP', 10);
define('DISCOVERY_APP_DB2', 11);
define('DISCOVERY_APP_MICROSOFT_SQL_SERVER', 12);
define('DISCOVERY_CLOUD_GCP_COMPUTE_ENGINE', 13);
+define('DISCOVERY_CLOUD_AWS_S3', 14);
// Force task build tmp results.
define('DISCOVERY_REVIEW', 0);
diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php
index 13e59f7247..8b7c81c9f9 100644
--- a/pandora_console/include/db/mysql.php
+++ b/pandora_console/include/db/mysql.php
@@ -1496,6 +1496,7 @@ function db_run_sql_file($location)
// Undo results
}
+ $config['db_run_sql_file_error'] = $mysqli->error;
return false;
}
}
diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php
index f26dc60ea5..32312238ce 100644
--- a/pandora_console/include/functions.php
+++ b/pandora_console/include/functions.php
@@ -2252,12 +2252,16 @@ function check_login($output=true)
return true;
}
} else {
+ include_once $config['homedir'].'/mobile/include/db.class.php';
+ include_once $config['homedir'].'/mobile/include/system.class.php';
include_once $config['homedir'].'/mobile/include/user.class.php';
if (isset($_SESSION['user'])) {
- $user = $_SESSION['user'];
+ $user = User::getInstance();
$id_user = $user->getIdUser();
if (is_user($id_user)) {
+ $_SESSION['id_usuario'] = $id_user;
+ $config['id_user'] = $id_user;
return true;
}
}
@@ -2853,7 +2857,11 @@ function can_user_access_node()
{
global $config;
- $userinfo = get_user_info($config['id_user']);
+ static $userinfo;
+
+ if ($userinfo === null) {
+ $userinfo = get_user_info($config['id_user']);
+ }
if (is_metaconsole()) {
return $userinfo['is_admin'] == 1 ? 1 : $userinfo['metaconsole_access_node'];
diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php
index ceef73049d..c0f27fa0a6 100644
--- a/pandora_console/include/functions_agents.php
+++ b/pandora_console/include/functions_agents.php
@@ -1,27 +1,38 @@
.
+ * @param boolean $meta_fields If true, then id_agente is returned instead id_tagente.
*
* @return array An array with all agents in the group or an empty array
*/
@@ -1096,7 +1115,8 @@ function agents_get_group_agents(
$serialized=false,
$separator='|',
$add_alert_bulk_op=false,
- $force_serialized=false
+ $force_serialized=false,
+ $meta_fields=false
) {
global $config;
@@ -1268,11 +1288,19 @@ function agents_get_group_agents(
if (is_metaconsole()) {
$table_name = 'tmetaconsole_agent ta LEFT JOIN tmetaconsole_agent_secondary_group tasg ON ta.id_agente = tasg.id_agent';
- $fields = [
- 'ta.id_tagente AS id_agente',
- 'alias',
- 'ta.id_tmetaconsole_setup AS id_server',
- ];
+ if ($meta_fields === true) {
+ $fields = [
+ 'id_agente',
+ 'alias',
+ 'ta.id_tmetaconsole_setup AS id_server',
+ ];
+ } else {
+ $fields = [
+ 'ta.id_tagente AS id_agente',
+ 'alias',
+ 'ta.id_tmetaconsole_setup AS id_server',
+ ];
+ }
} else {
$table_name = 'tagente LEFT JOIN tagent_secondary_group ON id_agente=id_agent';
@@ -3253,6 +3281,7 @@ function agents_get_agent_custom_field($agent_id, $custom_field_name)
* @param boolean $selection Show common (false) or all modules (true).
* @param boolean $return Return (false) or dump to output (true).
* @param boolean $index_by_name Use module name as key.
+ * @param boolean $pure_return Return as retrieved from DB.
*
* @return array With modules or null if error.
*/
@@ -3261,7 +3290,8 @@ function select_modules_for_agent_group(
$id_agents,
$selection,
$return=true,
- $index_by_name=false
+ $index_by_name=false,
+ $pure_return=false
) {
global $config;
$agents = (empty($id_agents)) ? [] : implode(',', $id_agents);
@@ -3341,6 +3371,10 @@ function select_modules_for_agent_group(
return;
}
+ if ($pure_return === true) {
+ return $modules;
+ }
+
$modules_array = [];
foreach ($modules as $value) {
if ($index_by_name) {
@@ -3841,6 +3875,70 @@ function agents_get_last_status_change($id_agent)
}
+/**
+ * Checks if group allow more agents due itself limitation.
+ *
+ * @param integer $id_group Id of the group.
+ * @param boolean $generateEvent If true and the check fails, will generate an event.
+ * @param string $action Action for perform (only if generateEvent is true).
+ *
+ * @return boolean True if allow more agents.
+ */
+function group_allow_more_agents(
+ int $id_group,
+ bool $generateEvent=false,
+ string $action='create'
+):bool {
+ global $config;
+
+ $groupMaxAgents = (int) db_get_value('max_agents', 'tgrupo', sprintf('id_grupo = %d', $id_group));
+ $groupCountAgents = (int) db_get_num_rows(sprintf('SELECT nombre FROM tagente WHERE id_grupo = "%s"', $id_group));
+
+ // If `max_agents` is not defined or the count of agents in the group is below of max agents allowed.
+ $output = ($groupMaxAgents === 0 || $groupCountAgents < $groupMaxAgents);
+
+ if ($output === false && $generateEvent === true) {
+ // Get the group name.
+ $groupName = db_get_value(
+ 'nombre',
+ 'tgrupo',
+ 'id_grupo',
+ $id_group
+ );
+ // New event.
+ $evt = new Event;
+ // Set parameters.
+ $evt->evento(
+ sprintf(
+ 'Agent cannot be %sd due to the maximum agent limit for group %s',
+ $action,
+ $groupName
+ )
+ );
+ $evt->id_grupo($id_group);
+ $evt->id_agente(0);
+ $evt->id_agentmodule(0);
+ $evt->id_usuario($config['id_user']);
+ $evt->estado(EVENT_STATUS_NEW);
+ $evt->event_type(EVENTS_SYSTEM);
+ $evt->criticity(EVENT_CRIT_WARNING);
+ $evt->timestamp(date('Y-m-d H:i:s'));
+ $evt->utimestamp(time());
+ $evt->data(0);
+ $evt->source('agent_creation');
+ // Any fields are only available in meta.
+ if (is_metaconsole() === true) {
+ $evt->id_source_event(0);
+ }
+
+ // Save the event.
+ $evt->save();
+ }
+
+ return $output;
+}
+
+
/**
* Return the list of agents for a planned downtime
*
@@ -3850,7 +3948,7 @@ function agents_get_last_status_change($id_agent)
*
* @return array
*/
-function get_planned_downtime_agents_list($id_downtime, $filter_cond, $id_groups_str)
+function get_planned_downtime_agents_list($id_downtime, $filter_cond, $id_groups_str):array
{
$agents = [];
diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php
index 9e27001d15..bfa2733840 100644
--- a/pandora_console/include/functions_alerts.php
+++ b/pandora_console/include/functions_alerts.php
@@ -173,13 +173,22 @@ function alerts_get_event_status_group($idGroup, $type='alert_fired', $query='AN
$idAgents = array_values($agents);
}
- $result = db_get_all_rows_sql(
+ $sql = sprintf(
'SELECT id_evento
- FROM tevento
- WHERE estado = 0 AND id_agente IN (0,'.implode(',', $idAgents).') '.$typeWhere.$query.'
- ORDER BY id_evento DESC LIMIT 1'
+ FROM tevento
+ WHERE estado = 0
+ AND id_agente IN (0, %s)
+ %s
+ %s
+ ORDER BY id_evento DESC
+ LIMIT 1',
+ implode(',', $idAgents),
+ $typeWhere,
+ $query
);
+ $result = db_get_all_rows_sql($sql);
+
if ($result === false) {
return false;
}
@@ -439,10 +448,11 @@ function alerts_delete_alert_action($id_alert_action)
* Clone an alert action.
*
* @param int Id of the original alert action
+ * @param int Agent group id if it wants to be changed when clone.
*
* @return mixed Id of the cloned action or false in case of fail.
*/
-function alerts_clone_alert_action($id_alert_action)
+function alerts_clone_alert_action($id_alert_action, $id_group)
{
$id_alert_action = safe_int($id_alert_action, 1);
if (empty($id_alert_action)) {
@@ -455,6 +465,10 @@ function alerts_clone_alert_action($id_alert_action)
return false;
}
+ if ($id_group != '') {
+ $action['id_group'] = $id_group;
+ }
+
unset($action['id']);
return alerts_create_alert_action($action['name'].' '.__('copy'), $action['id_alert_command'], $action);
@@ -1121,10 +1135,11 @@ function alerts_get_alert_template_field3_recovery($id_alert_template)
* Duplicates an alert template.
*
* @param int Id of an alert template.
+ * @param int Agent group id if it wants to be changed when duplicate.
*
* @return mixed Duplicates an alert template or false if something goes wrong.
*/
-function alerts_duplicate_alert_template($id_alert_template)
+function alerts_duplicate_alert_template($id_alert_template, $id_group)
{
$template = alerts_get_alert_template($id_alert_template);
@@ -1132,6 +1147,10 @@ function alerts_duplicate_alert_template($id_alert_template)
return false;
}
+ if ($id_group != '') {
+ $template['id_group'] = $id_group;
+ }
+
$name = io_safe_input(__('Copy of').' ').$template['name'];
$type = $template['type'];
@@ -2125,8 +2144,6 @@ function get_group_alerts(
$disabled = $filter;
}
- $filter .= ' AND talert_template_modules.disabled = 0 ';
-
switch ($disabled) {
case 'notfired':
$filter .= ' AND times_fired = 0 AND talert_template_modules.disabled = 0';
@@ -2144,9 +2161,13 @@ function get_group_alerts(
$filter .= ' AND talert_template_modules.disabled = 0';
break;
- default:
+ case 'all':
$filter .= '';
break;
+
+ default:
+ $filter .= ' AND talert_template_modules.disabled = 0 ';
+ break;
}
// WHEN SELECT ALL TAGS TO FILTER ALERTS
@@ -2186,8 +2207,8 @@ function get_group_alerts(
WHERE 1 = 0';
} else {
$subQuery = 'SELECT id_agente_modulo
- FROM tagente_modulo
- WHERE delete_pending = 0
+ FROM tagente_modulo tam
+ WHERE delete_pending = 0 AND tam.disabled = 0
AND id_agente IN (SELECT id_agente
FROM tagente ta
LEFT JOIN tagent_secondary_group tasg
@@ -2734,7 +2755,7 @@ function alerts_ui_update_or_create_actions($update=true)
$al_action = alerts_get_alert_action($id);
if ($al_action !== false) {
if ($al_action['id_group'] == 0) {
- if (! check_acl($config['id_user'], 0, 'PM')) {
+ if (! check_acl($config['id_user'], 0, 'PM') && ! check_acl($config['id_user'], 0, 'LM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Alert Management'
diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php
index aebef6c06b..a39d9da92a 100644
--- a/pandora_console/include/functions_api.php
+++ b/pandora_console/include/functions_api.php
@@ -43,11 +43,12 @@ use PandoraFMS\Enterprise\Cluster;
/**
* Parse the "other" parameter.
*
- * @param string $other
- * @param mixed $otherType
+ * @param string $other
+ * @param mixed $otherType
+ * @param boolean $rawDecode Decode string in which the sequences with percent (%) signs followed by two hex digits have been replaced with literal characters.
* @return mixed
*/
-function parseOtherParameter($other, $otherType)
+function parseOtherParameter($other, $otherType, $rawDecode)
{
switch ($otherType) {
case 'url_encode':
@@ -65,12 +66,12 @@ function parseOtherParameter($other, $otherType)
'data' => explode($separator, $other),
];
foreach ($returnVar['data'] as $index => $element) {
- $returnVar['data'][$index] = urldecode($element);
+ $returnVar['data'][$index] = $rawDecode ? rawurldecode($element) : urldecode($element);
}
} else {
$returnVar = [
'type' => 'string',
- 'data' => urldecode($other),
+ 'data' => $rawDecode ? rawurldecode($other) : urldecode($other),
];
}
break;
@@ -375,6 +376,103 @@ function api_get_test_event_replication_db()
// -------------------------DEFINED OPERATIONS FUNCTIONS-----------------
+
+
+/**
+ * Example: http://localhost/pandora_console/include/api.php?op=get&op2=license&user=admin&apipass=1234&pass=pandora&return_type=json
+ * Retrieve license information.
+ *
+ * @param null $trash1 Not used.
+ * @param null $trash1 Not used.
+ * @param null $trash1 Not used.
+ * @param string $returnType Return type (string, json...).
+ *
+ * @return void
+ */
+function api_get_license($trash1, $trash2, $trash3, $returnType='json')
+{
+ global $config;
+ check_login();
+
+ if (! check_acl($config['id_user'], 0, 'PM')) {
+ returnError('forbidden', $returnType);
+ return;
+ }
+
+ enterprise_include_once('include/functions_license.php');
+ $license = enterprise_hook('license_get_info');
+ if ($license === ENTERPRISE_NOT_HOOK) {
+ // Not an enterprise environment?
+ if (license_free()) {
+ $license = 'PANDORA_FREE';
+ }
+
+ returnData(
+ $returnType,
+ [
+ 'type' => 'array',
+ 'data' => ['license_mode' => $license],
+ ]
+ );
+ return;
+ }
+
+ returnData(
+ $returnType,
+ [
+ 'type' => 'array',
+ 'data' => $license,
+ ]
+ );
+
+}
+
+
+/**
+ * Example: http://localhost/pandora_console/include/api.php?op=get&op2=license_remaining&user=admin&apipass=1234&pass=pandora&return_type=json
+ * Retrieve license status agents or modules left.
+ *
+ * @param null $trash1 Not used.
+ * @param null $trash1 Not used.
+ * @param null $trash1 Not used.
+ * @param string $returnType Return type (string, json...).
+ *
+ * @return void
+ */
+function api_get_license_remaining(
+ $trash1,
+ $trash2,
+ $trash3,
+ $returnType='json'
+) {
+ enterprise_include_once('include/functions_license.php');
+ $license = enterprise_hook('license_get_info');
+ if ($license === ENTERPRISE_NOT_HOOK) {
+ if (license_free()) {
+ returnData(
+ $returnType,
+ [
+ 'type' => 'integer',
+ 'data' => PHP_INT_MAX,
+ ]
+ );
+ } else {
+ returnError('get-license', 'Failed to verify license.');
+ }
+
+ return;
+ }
+
+ returnData(
+ $returnType,
+ [
+ 'type' => 'integer',
+ 'data' => ($license['limit'] - $license['count_enabled']),
+ ]
+ );
+}
+
+
function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db)
{
$returnAllGroup = true;
@@ -1381,6 +1479,12 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3)
return;
}
+ // Check if group allow more agents or have limit stablished.
+ if (group_allow_more_agents($idGroup, true, 'update') === false) {
+ returnError('Agent cannot be updated due to the maximum agent limit for this group');
+ return;
+ }
+
// Check selected parent
if ($idParent != 0) {
$parentCheck = agents_check_access_agent($idParent);
@@ -1510,6 +1614,302 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3)
}
+/**
+ * Update an agent by indicating a pair of field - value separated by comma.
+ *
+ * @param integer $id_agent Id (or alias) agent to upadate.
+ * @param boolean $use_agent_alias Use alias instead of id.
+ * @param array $params Pair of parameter/value separated by comma. Available fields are:
+ * 'alias',
+ * 'direccion',
+ * 'id_parent',
+ * 'id_grupo',
+ * 'cascade_protection',
+ * 'cascade_protection_module',
+ * 'intervalo',
+ * 'id_os',
+ * 'server_name',
+ * 'custom_id',
+ * 'modo',
+ * 'disabled',
+ * 'comentarios'
+ *
+ * eg . http://127.0.0.1/pandora_console/include/api.php?op=set&op2=update_agent_field&id=pandora&other=id_os,1|alias,pandora|direccion,192.168.10.16|id_parent,1cascade_protection,1|cascade_protection_module,1|intervalo,5||modo|3|&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora
+ */
+function api_set_update_agent_field($id_agent, $use_agent_alias, $params)
+{
+ global $config;
+ $return = false;
+
+ if (defined('METACONSOLE')) {
+ return;
+ }
+
+ if (!check_acl($config['id_user'], 0, 'AW')) {
+ returnError('forbidden', 'string');
+ return;
+ }
+
+ // Check the agent.
+ if ((bool) $use_agent_alias === true) {
+ $agents_by_alias = agents_get_agent_id_by_alias($id_agent);
+ if (empty($agents_by_alias) === false) {
+ foreach ($agents_by_alias as $agent) {
+ if (agents_check_access_agent($agent['id_agente'], 'AW') === true) {
+ $agents[] = $agent['id_agente'];
+ }
+ }
+
+ if (empty($agents) === true) {
+ returnError('forbidden', 'string');
+ return;
+ }
+ } else {
+ returnError('Alias does not match any agent.');
+ return;
+ }
+ } else {
+ if (!util_api_check_agent_and_print_error($id_agent, 'string', 'AW')) {
+ return;
+ }
+
+ $agents[] = $id_agent;
+ }
+
+ // Serialize the data for update.
+ if ($params['type'] === 'array') {
+ // Keys available to change.
+ $available_fields = [
+ 'alias',
+ 'direccion',
+ 'id_parent',
+ 'id_grupo',
+ 'cascade_protection',
+ 'cascade_protection_module',
+ 'intervalo',
+ 'id_os',
+ 'server_name',
+ 'custom_id',
+ 'modo',
+ 'disabled',
+ 'comentarios',
+ ];
+
+ foreach ($params['data'] as $key_value) {
+ list($key, $value) = explode(',', $key_value, 2);
+ if (in_array($key, $available_fields) === true) {
+ $fields[$key] = $value;
+ }
+ }
+ }
+
+ if (empty($fields) === true) {
+ returnError('Selected field not available. Please, select one the fields avove');
+ return;
+ }
+
+ // Check fields.
+ foreach ($fields as $field => $data) {
+ switch ($field) {
+ case 'alias':
+ if (empty($data)) {
+ returnError('No agent alias specified');
+ return;
+ }
+ break;
+
+ case 'id_grupo':
+ if (db_get_value_sql('SELECT FROM tgrupo WHERE id_grupo = '.$data) === false) {
+ returnError('The group doesn`t exist.');
+ return;
+ }
+ break;
+
+ case 'id_os':
+ if (db_get_value_sql('SELECT id_os FROM tconfig_os WHERE id_os = '.$data) === false) {
+ returnError('The OS doesn`t exist.');
+ return;
+ }
+ break;
+
+ case 'server_name':
+ $server_name = db_get_value_sql('SELECT name FROM tserver WHERE BINARY name LIKE "'.$data.'"');
+ if ($server_name === false) {
+ returnError('The server doesn`t exist.');
+ return;
+ }
+ break;
+
+ case 'cascade_protection':
+ if ($data == 1) {
+ if (($field['id_parent'] != 0) && (db_get_value_sql(
+ 'SELECT id_agente_modulo
+ FROM tagente_modulo
+ WHERE id_agente = '.$fields['id_parent'].' AND id_agente_modulo = '.$fields['cascade_protection_module']
+ ) === false)
+ ) {
+ returnError('Cascade protection is not applied because it is not a parent module');
+ }
+ } else {
+ unset($fields['cascade_protection']);
+ }
+ break;
+
+ case 'id_grupo':
+ // Check ACL group.
+ if (!check_acl($config['id_user'], $data, 'AW')) {
+ returnError('forbidden', 'string');
+ return;
+ }
+
+ if ($data == 0) {
+ $agent_update_error = 'The agent could not be modified. For security reasons, use a group other than 0.';
+ returnError($agent_update_error);
+ return;
+ }
+ break;
+
+ case 'id_parent':
+ $parentCheck = agents_check_access_agent($data);
+ if (is_null($parentCheck) === true) {
+ returnError('The parent agent does not exist.');
+ return;
+ }
+
+ if ($parentCheck === false) {
+ returnError('The user cannot access to parent agent.');
+ return;
+ }
+ break;
+
+ default:
+ // Default empty.
+ break;
+ }
+ }
+
+ // Var applied in case there is more than one agent.
+ $return = false;
+ $applied = 0;
+ foreach ($agents as $agent) {
+ $values_old = db_get_row_filter(
+ 'tagente',
+ ['id_agente' => $agent],
+ [
+ 'id_grupo',
+ 'disabled',
+ ]
+ );
+
+ $tpolicy_group_old = db_get_all_rows_sql(
+ 'SELECT id_policy FROM tpolicy_groups
+ WHERE id_group = '.$values_old['id_grupo']
+ );
+
+ $return = db_process_sql_update(
+ 'tagente',
+ $fields,
+ ['id_agente' => $agent]
+ );
+
+ if ((count($agents) > 1) && $return !== 0) {
+ $applied += 1;
+ }
+
+ if ($return && !isset($field['direccion'])) {
+ // register ip for this agent in 'taddress'.
+ agents_add_address($agent, $field['direccion']);
+ }
+
+ if ($return) {
+ // Update config file
+ if (isset($field['disabled']) && $values_old['disabled'] != $field['disabled']) {
+ enterprise_hook(
+ 'config_agents_update_config_token',
+ [
+ $agent,
+ 'standby',
+ $field['disabled'],
+ ]
+ );
+ }
+
+ if ($tpolicy_group_old) {
+ foreach ($tpolicy_group_old as $key => $value) {
+ $tpolicy_agents_old = db_get_sql(
+ 'SELECT * FROM tpolicy_agents
+ WHERE id_policy = '.$value['id_policy'].' AND id_agent = '.$agent
+ );
+
+ if ($tpolicy_agents_old) {
+ $result2 = db_process_sql_update(
+ 'tpolicy_agents',
+ ['pending_delete' => 1],
+ [
+ 'id_agent' => $agent,
+ 'id_policy' => $value['id_policy'],
+ ]
+ );
+ }
+ }
+ }
+
+ $tpolicy_group = db_get_all_rows_sql(
+ 'SELECT id_policy FROM tpolicy_groups
+ WHERE id_group = '.$field['id_grupo']
+ );
+
+ if ($tpolicy_group) {
+ foreach ($tpolicy_group as $key => $value) {
+ $tpolicy_agents = db_get_sql(
+ 'SELECT * FROM tpolicy_agents
+ WHERE id_policy = '.$value['id_policy'].' AND id_agent ='.$agent
+ );
+
+ if (!$tpolicy_agents) {
+ db_process_sql_insert(
+ 'tpolicy_agents',
+ [
+ 'id_policy' => $value['id_policy'],
+ 'id_agent' => $agent,
+ ]
+ );
+ } else {
+ $result3 = db_process_sql_update(
+ 'tpolicy_agents',
+ ['pending_delete' => 0],
+ [
+ 'id_agent' => $agent,
+ 'id_policy' => $value['id_policy'],
+ ]
+ );
+ }
+ }
+ }
+ }
+ }
+
+ if (count($agents) > 1) {
+ returnData(
+ 'string',
+ [
+ 'type' => 'string',
+ 'data' => __('Updated %d/%d agents', $applied, count($agents)),
+ ]
+ );
+ } else {
+ returnData(
+ 'string',
+ [
+ 'type' => 'string',
+ 'data' => __('Agent updated.'),
+ ]
+ );
+ }
+
+}
+
+
/**
* Create a new agent, and print the id for new agent.
*
@@ -1578,10 +1978,12 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3)
// Check if agent exists (BUG WC-50518-2).
if ($alias == '' && $alias_as_name === 0) {
returnError('No agent alias specified');
- } else if (agents_get_agent_id($server_name)) {
+ } else if (agents_get_agent_id($nombre_agente)) {
returnError('The agent name already exists in DB.');
} else if (db_get_value_sql('SELECT id_grupo FROM tgrupo WHERE id_grupo = '.$grupo) === false) {
returnError('The group does not exist.');
+ } else if (group_allow_more_agents($grupo, true, 'create') === false) {
+ returnError('Agent cannot be created due to the maximum agent limit for this group');
} else if (db_get_value_sql('SELECT id_os FROM tconfig_os WHERE id_os = '.$id_os) === false) {
returnError('The OS does not exist.');
} else if ($server_name === false) {
@@ -2015,9 +2417,9 @@ function api_get_all_agents($thrash1, $thrash2, $other, $returnType)
}
$ag_groups = implode(',', (array) $ag_groups);
- }
- $where .= ' AND (id_grupo IN ('.$ag_groups.') OR id_group IN ('.$ag_groups.'))';
+ $where .= ' AND (id_grupo IN ('.$ag_groups.') OR id_group IN ('.$ag_groups.'))';
+ }
}
if (isset($other['data'][3])) {
@@ -6276,6 +6678,136 @@ function api_set_delete_module_template_by_names($id, $id2, $other, $trash1)
}
+/**
+ * Validate an alert
+ *
+ * @param string $id1 Alert template name (eg. 'Warning condition')
+ * @param string $trash1 Do nnot use.
+ * @param array $other [1] id/name agent.
+ * [2] id/name module
+ * [3] Use agent/module alias.
+ * @param string $trash2 Do not use
+ * @return void
+ */
+function api_set_validate_alert($id1, $trash1, $other, $trash2)
+{
+ global $config;
+
+ if (defined('METACONSOLE')) {
+ return;
+ }
+
+ if (!check_acl($config['id_user'], 0, 'LW')) {
+ returnError('forbidden');
+ return;
+ }
+
+ if ($id1 === '') {
+ returnError(
+ 'error_validate_alert',
+ __('Error validating alert. Id_template cannot be left blank.')
+ );
+ return;
+ }
+
+ if ($other['data'][0] == '') {
+ returnError(
+ 'error_validate_alert',
+ __('Error validating alert. Id_agent cannot be left blank.')
+ );
+ return;
+ }
+
+ if ($other['data'][1] == '') {
+ returnError(
+ 'error_validate_alert',
+ __('Error validating alert. Id_module cannot be left blank.')
+ );
+ return;
+ }
+
+ if ($other['data'][2] == 1) {
+ $use_alias = true;
+ }
+
+ $values = [
+ 'alert_name' => $id1,
+ 'id_agent' => $other['data'][0],
+ 'id_agent_module' => $other['data'][1],
+ ];
+
+ if ($use_alias === true) {
+ $id_agents = agents_get_agent_id_by_alias($values['id_agent']);
+
+ foreach ($id_agents as $id) {
+ $values['id_agent'] = $id['id_agente'];
+ $values['id_agent_module'] = db_get_value_filter(
+ 'id_agente_modulo as id_module',
+ 'tagente_modulo',
+ [
+ 'id_agente' => $values['id_agent'],
+ 'nombre' => $values['id_agent_module'],
+ ]
+ );
+
+ $id_template = db_get_value_filter(
+ 'id as id_template',
+ 'talert_templates',
+ [
+ 'name' => $values['alert_name'],
+ ]
+ );
+
+ // Get alert id.
+ $id_alert = db_get_value_filter(
+ 'id as id_alert',
+ 'talert_template_modules',
+ [
+ 'id_agent_module' => $values['id_agent_module'],
+ 'id_alert_template' => $id_template,
+ ]
+ );
+ }
+
+ $result = alerts_validate_alert_agent_module($id_alert);
+ } else {
+ $id_template = db_get_value_filter(
+ 'id as id_template',
+ 'talert_templates',
+ [
+ 'name' => $values['alert_name'],
+ ]
+ );
+
+ // Get alert id.
+ $id_alert = db_get_value_filter(
+ 'id as id_alert',
+ 'talert_template_modules',
+ [
+ 'id_agent_module' => $values['id_agent_module'],
+ 'id_alert_template' => $id_template,
+ ]
+ );
+
+ if ($id_alert === false) {
+ returnError(
+ 'error_validate_alert',
+ __('Error validating alert. Specified alert does not exist.')
+ );
+ return;
+ }
+
+ $result = alerts_validate_alert_agent_module($id_alert);
+ }
+
+ if ($result) {
+ returnData('string', ['type' => 'string', 'data' => 'Alert succesfully validated']);
+ } else {
+ returnData('string', ['type' => 'string', 'data' => __('Error validating alert')]);
+ }
+}
+
+
/**
* Validate all alerts. And return a message with the result of the operation.
*
@@ -6481,7 +7013,7 @@ function api_set_stop_downtime($id, $thrash1, $other, $thrash3)
$data = db_get_row_sql($sql);
if ($data['type_execution'] == 'periodically' && $data['executed'] == 1) {
- returnError('error_stop_downtime', __('Error stopping downtime. Periodical and running planned downtime cannot be stopped.'));
+ returnError('error_stop_downtime', __('Error stopping downtime. Periodical and running scheduled downtime cannot be stopped.'));
return;
}
@@ -6967,7 +7499,7 @@ function api_set_planned_downtimes_additem($id, $thrash1, $other, $thrash3)
}
if (empty($agents)) {
- returnError('No agents to create planned downtime items');
+ returnError('No agents to create scheduled downtime items');
} else {
if (!empty($returned['bad_modules'])) {
$bad_modules = __("and this modules are doesn't exists or not applicable a this agents: ").implode(', ', $returned['bad_modules']);
@@ -6992,114 +7524,6 @@ function api_set_planned_downtimes_additem($id, $thrash1, $other, $thrash3)
}
-/**
- * Add data module to policy. And return id from new module.
- *
- * @param string $id Id of the target policy.
- * @param $thrash1 Don't use.
- * @param array $other it's array, $other as param is
;;;
- * ;;;;;;;;
- * ;;;;;
- * ;;;;;
- * ;; in this order
- * and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_)
- * example:
- *
- * example:
- *
- * api.php?op=set&op2=add_data_module_policy&id=1&other=data_module_policy_example_name~2~data%20module%20created%20by%20Api~2~0~0~50.00~10~20~180~~21~35~~1~module_begin%0dmodule_name%20pandora_process%0dmodule_type%20generic_data%0dmodule_exec%20ps%20aux%20|%20grep%20pandora%20|%20wc%20-l%0dmodule_end&other_mode=url_encode_separator_~
- *
- * @param $thrash3 Don't use
- */
-function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3)
-{
- if (defined('METACONSOLE')) {
- return;
- }
-
- if ($id == '') {
- returnError('The data module could not be added to policy. Id_policy cannot be left blank.');
- return;
- }
-
- if (enterprise_hook('policies_check_user_policy', [$id]) === false) {
- returnError('forbidden', 'string');
- return;
- }
-
- if ($other['data'][0] == '') {
- returnError('The data module could not be added to policy. Module_name cannot be left blank.');
- return;
- }
-
- // Check if the module is already in the policy
- $name_module_policy = enterprise_hook('policies_get_modules', [$id, ['name' => $other['data'][0]], 'name']);
-
- if ($name_module_policy === ENTERPRISE_NOT_HOOK) {
- returnError('The data module could not be added to policy.');
- return;
- }
-
- $disabled_types_event = [];
- $disabled_types_event[EVENTS_GOING_UNKNOWN] = (int) !$other['data'][16];
- $disabled_types_event = json_encode($disabled_types_event);
-
- $values = [];
- $values['id_tipo_modulo'] = $other['data'][1];
- $values['description'] = $other['data'][2];
- $values['id_module_group'] = $other['data'][3];
- $values['min'] = $other['data'][4];
- $values['max'] = $other['data'][5];
- $values['post_process'] = $other['data'][6];
- $values['module_interval'] = $other['data'][7];
- $values['min_warning'] = $other['data'][8];
- $values['max_warning'] = $other['data'][9];
- $values['str_warning'] = $other['data'][10];
- $values['min_critical'] = $other['data'][11];
- $values['max_critical'] = $other['data'][12];
- $values['str_critical'] = $other['data'][13];
- $values['history_data'] = $other['data'][14];
- $values['configuration_data'] = $other['data'][15];
- $values['disabled_types_event'] = $disabled_types_event;
- $values['module_macros'] = $other['data'][17];
- $values['min_ff_event'] = $other['data'][18];
- $values['each_ff'] = $other['data'][19];
- $values['min_ff_event_normal'] = $other['data'][20];
- $values['min_ff_event_warning'] = $other['data'][21];
- $values['min_ff_event_critical'] = $other['data'][22];
- $values['ff_timeout'] = $other['data'][23];
- $values['ff_type'] = $other['data'][24];
-
- if ($name_module_policy !== false) {
- if ($name_module_policy[0]['name'] == $other['data'][0]) {
- returnError(
- 'The data module could not be added to policy. The module is already in the policy.'
- );
- return;
- }
- }
-
- $success = enterprise_hook(
- 'policies_create_module',
- [
- $other['data'][0],
- $id,
- 1,
- $values,
- false,
- ]
- );
-
- if ($success) {
- // returnData('string', array('type' => 'string', 'data' => __('Data module added to policy. Is necessary to apply the policy in order to changes take effect.')));
- returnData('string', ['type' => 'string', 'data' => $success]);
- } else {
- returnError('The data module could not be added to policy.');
- }
-
-}
-
-
/**
* Update data module in policy. And return id from new module.
*
@@ -8283,6 +8707,8 @@ function api_set_create_group($id, $thrash1, $other, $thrash3)
$values['custom_id'] = $safe_other_data[5];
$values['contact'] = $safe_other_data[6];
$values['other'] = $safe_other_data[7];
+ $values['max_agents'] = $safe_other_data[8];
+ $values['password'] = $safe_other_data[9];
$id_group = groups_create_group($group_name, $values);
@@ -8362,7 +8788,8 @@ function api_set_update_group($id_group, $thrash2, $other, $thrash3)
$disabled = $other['data'][5];
$custom_id = $other['data'][6];
$contact = $other['data'][7];
- $other = $other['data'][8];
+ $otherData = $other['data'][8];
+ $maxAgents = $other['data'][9];
$return = db_process_sql_update(
'tgrupo',
@@ -8375,7 +8802,8 @@ function api_set_update_group($id_group, $thrash2, $other, $thrash3)
'disabled' => $disabled,
'custom_id' => $custom_id,
'contact' => $contact,
- 'other' => $other,
+ 'other' => $otherData,
+ 'max_agents' => $maxAgents,
],
['id_grupo' => $id_group]
);
@@ -11117,10 +11545,10 @@ function api_set_add_user_profile($id, $thrash1, $other, $thrash2)
return;
}
- $group = $other['data'][0];
+ $group = (int) $other['data'][0];
$profile = $other['data'][1];
- if (db_get_value('id_grupo', 'tgrupo', 'id_grupo', $group) === false) {
+ if ($group !== 0 && db_get_value('id_grupo', 'tgrupo', 'id_grupo', $group) === false) {
returnError('There is not any group with the ID provided.');
return;
}
@@ -12423,6 +12851,7 @@ function api_set_create_tag($id, $trash1, $other, $returnType)
// http://127.0.0.1/pandora_console/include/api.php?op=set&op2=create_event&id=name_event&other=2|system|3|admin|2|1|10|0|comments||Pandora||critical_inst|warning_inst|unknown_inst|other||&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora
+// http://127.0.0.1/pandora_console/include/api.php?op=set&op2=create_event&id=name_event&other=textodelevento|10|2|0|admin|going_down_critical|4|&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora
function api_set_create_event($id, $trash1, $other, $returnType)
{
global $config;
diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index 49ae33b20d..e118cf4d52 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -26,7 +26,12 @@
* ============================================================================
*/
- // Config functions.
+// Config functions.
+require_once __DIR__.'/../vendor/autoload.php';
+require_once __DIR__.'/functions.php';
+enterprise_include_once('include/functions_config.php');
+use PandoraFMS\Core\DBMaintainer;
+use PandoraFMS\Core\Config;
/**
@@ -147,6 +152,8 @@ function config_update_config()
}
$error_update = [];
+ $errors = [];
+ $warnings = [];
$sec2 = get_parameter('sec2');
@@ -193,8 +200,20 @@ function config_update_config()
$error_update[] = __('Use cert.');
}
- if (!config_update_value('attachment_store', (string) get_parameter('attachment_store'))) {
+ $attachment_store = (string) get_parameter('attachment_store');
+ if (file_exists($attachment_store) === false
+ || is_writable($attachment_store) === false
+ ) {
$error_update[] = __('Attachment store');
+ $error_update[] .= __(
+ "Path doesn't exists or is not writable"
+ );
+ } else {
+ if (config_update_value('attachment_store', $attachment_store) === false) {
+ $error_update[] = __(
+ 'Attachment store.'
+ );
+ }
}
if (!config_update_value('list_ACL_IPs_for_API', (string) get_parameter('list_ACL_IPs_for_API'))) {
@@ -300,7 +319,7 @@ function config_update_config()
}
if (!config_update_value('past_planned_downtimes', get_parameter('past_planned_downtimes'))) {
- $error_update[] = __('Allow create planned downtimes in the past');
+ $error_update[] = __('Allow create scheduled downtimes in the past');
}
if (!config_update_value('limit_parameters_massive', get_parameter('limit_parameters_massive'))) {
@@ -1452,6 +1471,31 @@ function config_update_config()
break;
case 'hist_db':
+ if ($config['dbname'] == get_parameter('history_db_name')
+ && $config['dbport'] == get_parameter('history_db_port')
+ && $config['dbhost'] == io_input_password(get_parameter('history_db_host'))
+ ) {
+ // Same definition for active and historical database!
+ // This is a critical error.
+ $config['error_config_update_config']['correct'] = false;
+ $config['error_config_update_config']['message'] = __(
+ 'Active and historical database cannot be the same.'
+ );
+ return;
+ } else {
+ if (!config_update_value('history_db_host', get_parameter('history_db_host'))) {
+ $error_update[] = __('Host');
+ }
+
+ if (!config_update_value('history_db_port', get_parameter('history_db_port'))) {
+ $error_update[] = __('Port');
+ }
+
+ if (!config_update_value('history_db_name', get_parameter('history_db_name'))) {
+ $error_update[] = __('Database name');
+ }
+ }
+
if (!config_update_value('history_db_enabled', get_parameter('history_db_enabled'))) {
$error_update[] = __('Enable history database');
}
@@ -1460,18 +1504,6 @@ function config_update_config()
$error_update[] = __('Enable history event');
}
- if (!config_update_value('history_db_host', get_parameter('history_db_host'))) {
- $error_update[] = __('Host');
- }
-
- if (!config_update_value('history_db_port', get_parameter('history_db_port'))) {
- $error_update[] = __('Port');
- }
-
- if (!config_update_value('history_db_name', get_parameter('history_db_name'))) {
- $error_update[] = __('Database name');
- }
-
if (!config_update_value('history_db_user', get_parameter('history_db_user'))) {
$error_update[] = __('Database user');
}
@@ -1511,6 +1543,68 @@ function config_update_config()
) {
$error_update[] = __('Delay');
}
+
+ if ((bool) $config['history_db_enabled'] === true) {
+ $dbm = new DBMaintainer(
+ [
+ 'host' => $config['history_db_host'],
+ 'port' => $config['history_db_port'],
+ 'name' => $config['history_db_name'],
+ 'user' => $config['history_db_user'],
+ 'pass' => $config['history_db_pass'],
+ ]
+ );
+
+ // Performs several checks and installs if needed.
+ if ($dbm->checkDatabaseDefinition() === true
+ && $dbm->isInstalled() === false
+ ) {
+ // Target is ready but several tasks are pending.
+ $dbm->process();
+ } else if ($dbm->check() !== true) {
+ $errors[] = $dbm->getLastError();
+ }
+ }
+
+ // Historical configuration tokens (stored in historical db).
+ if (Config::set(
+ 'days_purge',
+ get_parameter('history_dbh_purge'),
+ true
+ ) !== true
+ ) {
+ $error_update[] = __('Historical database purge');
+ }
+
+ if (Config::set(
+ 'history_partitions_auto',
+ get_parameter_switch('history_partitions_auto', 0),
+ true
+ ) !== true
+ ) {
+ $error_update[] = __('Historical database partitions');
+ }
+
+ if (Config::set(
+ 'event_purge',
+ get_parameter('history_dbh_events_purge'),
+ true
+ ) !== true
+ ) {
+ $error_update[] = __('Historical database events purge');
+ }
+
+ if (Config::set(
+ 'string_purge',
+ get_parameter('history_dbh_string_purge'),
+ true
+ ) !== true
+ ) {
+ $error_update[] = __('Historical database string purge');
+ }
+
+ // Disable history db in history db.
+ Config::set('history_db_enabled', 0, true);
break;
case 'ehorus':
@@ -1563,7 +1657,11 @@ function config_update_config()
$integria_hostname = (string) get_parameter('integria_hostname', $config['integria_hostname']);
if (parse_url($integria_hostname, PHP_URL_SCHEME) === null) {
- $integria_hostname = 'http://'.$integria_hostname;
+ if (empty($_SERVER['HTTPS']) === false) {
+ $integria_hostname = 'https://'.$integria_hostname;
+ } else {
+ $integria_hostname = 'http://'.$integria_hostname;
+ }
}
if (!config_update_value('integria_hostname', $integria_hostname)) {
@@ -1685,6 +1783,14 @@ function config_update_config()
$config['error_config_update_config']['correct'] = true;
}
+ if (count($errors) > 0) {
+ $config['error_config_update_config']['errors'] = $errors;
+ }
+
+ if (count($warnings) > 0) {
+ $config['error_config_update_config']['warnings'] = $warnings;
+ }
+
enterprise_include_once('include/functions_policies.php');
$enterprise = enterprise_include_once('include/functions_skins.php');
if ($enterprise !== ENTERPRISE_NOT_HOOK) {
@@ -3268,6 +3374,32 @@ function config_user_set_custom_config()
}
}
+ if ((isset($userinfo['id_skin']) && $userinfo['id_skin'] !== 0)) {
+ if ((int) $userinfo['id_skin'] === 1) {
+ $config['style'] = 'pandora';
+ }
+
+ if ((int) $userinfo['id_skin'] === 2) {
+ $config['style'] = 'pandora_black';
+ }
+ }
+
+ $skin = get_parameter('skin', false);
+ $sec2_aux = get_parameter('sec2');
+
+ if ($sec2_aux != 'godmode/groups/group_list' && $skin !== false) {
+ $id_user_aux = get_parameter('id');
+ if ($id_user_aux == $config['id_user']) {
+ if ((int) $skin === 1 || (int) $skin === 0) {
+ $config['style'] = 'pandora';
+ }
+
+ if ((int) $skin === 2) {
+ $config['style'] = 'pandora_black';
+ }
+ }
+ }
+
if (defined('METACONSOLE')) {
$config['metaconsole_access'] = $userinfo['metaconsole_access'];
}
diff --git a/pandora_console/include/functions_cron.php b/pandora_console/include/functions_cron.php
index 0853b6ea6e..aebeeb7e42 100644
--- a/pandora_console/include/functions_cron.php
+++ b/pandora_console/include/functions_cron.php
@@ -697,6 +697,33 @@ function cron_list_table()
$args = unserialize($task['args']);
break;
+ case 'cron_task_generate_csv_log':
+ if ($manage_pandora) {
+ $data[0] = '';
+ $data[0] .= html_print_image(
+ 'images/target.png',
+ true,
+ [
+ 'title' => __('Force run'),
+ 'class' => 'invert_filter',
+ ]
+ );
+ $data[0] .= '';
+ } else {
+ $data[0] = '';
+ }
+
+ $data[1] = $task['id_usuario'];
+ $data[2] = db_get_value(
+ 'name',
+ 'tuser_task',
+ 'id',
+ $task['id_user_task']
+ );
+ $args = unserialize($task['args']);
+ break;
+
default:
// Ignore.
break;
diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php
index e50d15fbb2..bab64dd5fe 100644
--- a/pandora_console/include/functions_custom_graphs.php
+++ b/pandora_console/include/functions_custom_graphs.php
@@ -113,7 +113,7 @@ function custom_graphs_create(
* @param $returnAllGroup Wheter to return graphs of group All or not.
* @param $privileges Privileges to check in user group
*
- * @return Custom graphs of a an user. Empty array if none.
+ * @return array graphs of a an user. Empty array if none.
*/
function custom_graphs_get_user($id_user=0, $only_names=false, $returnAllGroup=true, $privileges='RR')
{
@@ -133,9 +133,14 @@ function custom_graphs_get_user($id_user=0, $only_names=false, $returnAllGroup=t
continue;
}
- $all_graph = db_get_all_rows_in_table('tgraph', 'name');
- if ($all_graph !== false) {
- $all_graphs = array_merge($all_graphs, $all_graph);
+ $tmp_graphs = db_get_all_rows_in_table('tgraph', 'name');
+ if ($tmp_graphs !== false) {
+ foreach ($tmp_graphs as $g) {
+ $g['id_tgraph'] = $g['id_graph'];
+ $g['id_graph'] = $connection['id'].'|'.$g['id_graph'];
+ $g['name'] = $g['name'].' ('.$connection['server_name'].')';
+ $all_graphs[] = $g;
+ }
}
metaconsole_restore_db();
@@ -168,10 +173,15 @@ function custom_graphs_get_user($id_user=0, $only_names=false, $returnAllGroup=t
$graphs[$graph['id_graph']] = $graph['name'];
} else {
$graphs[$graph['id_graph']] = $graph;
+ $id_graph = 'id_graph';
+ if ((bool) is_metaconsole() === true) {
+ $id_graph = 'id_tgraph';
+ }
+
$graphsCount = db_get_value_sql(
'SELECT COUNT(id_gs)
FROM tgraph_source
- WHERE id_graph = '.$graph['id_graph']
+ WHERE id_graph = '.$graph[$id_graph]
);
$graphs[$graph['id_graph']]['graphs_count'] = $graphsCount;
}
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 1ca61fbe9b..1f838f34ba 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -712,6 +712,7 @@ function events_update_status($id_evento, $status, $filter=null, $history=false)
* @param boolean $validatedEvents If true, evaluate validated events.
* @param boolean $recursiveGroups If true, filtered groups and their children
* will be search.
+ * @param boolean $nodeConnected Already connected to node (uses tevento).
*
* @return array Events.
* @throws Exception On error.
@@ -727,7 +728,8 @@ function events_get_all(
$return_sql=false,
$having='',
$validatedEvents=false,
- $recursiveGroups=true
+ $recursiveGroups=true,
+ $nodeConnected=false
) {
global $config;
@@ -1017,7 +1019,10 @@ function events_get_all(
);
}
- $table = events_get_events_table(is_metaconsole(), $history);
+ $table = events_get_events_table(
+ (is_metaconsole() && $nodeConnected === false),
+ $history
+ );
$tevento = sprintf(
' %s te',
$table
@@ -1028,7 +1033,7 @@ function events_get_all(
$tagente_table = 'tagente';
$tagente_field = 'id_agente';
$conditionMetaconsole = '';
- if (is_metaconsole()) {
+ if (is_metaconsole() && $nodeConnected === false) {
$tagente_table = 'tmetaconsole_agent';
$tagente_field = 'id_tagente';
$conditionMetaconsole = ' AND ta.id_tmetaconsole_setup = te.server_id ';
@@ -1075,7 +1080,7 @@ function events_get_all(
);
}
- if (is_metaconsole()) {
+ if (is_metaconsole() && $nodeConnected === false) {
// Id source event.
if (!empty($filter['id_source_event'])) {
$sql_filters[] = sprintf(
@@ -1087,8 +1092,15 @@ function events_get_all(
// User comment.
if (!empty($filter['user_comment'])) {
+ // For filter field.
$sql_filters[] = sprintf(
' AND lower(te.user_comment) like lower("%%%s%%") ',
+ io_safe_input($filter['user_comment'])
+ );
+
+ // For show comments on event details.
+ $sql_filters[] = sprintf(
+ ' OR lower(te.user_comment) like lower("%%%s%%") ',
$filter['user_comment']
);
}
@@ -1239,7 +1251,7 @@ function events_get_all(
// Query_table.
'',
// Meta.
- is_metaconsole(),
+ is_metaconsole() && $nodeConnected === false,
// Childrens_ids.
[],
// Force_group_and_tag.
@@ -1265,7 +1277,7 @@ function events_get_all(
// Query_table.
'',
// Meta.
- is_metaconsole(),
+ is_metaconsole() && $nodeConnected === false,
// Childrens_ids.
[],
// Force_group_and_tag.
@@ -1291,7 +1303,7 @@ function events_get_all(
// Query_table.
'',
// Meta.
- is_metaconsole(),
+ is_metaconsole() && $nodeConnected === false,
// Childrens_ids.
[],
// Force_group_and_tag.
@@ -1312,7 +1324,7 @@ function events_get_all(
// Module search.
$agentmodule_join = 'LEFT JOIN tagente_modulo am ON te.id_agentmodule = am.id_agente_modulo';
- if (is_metaconsole()) {
+ if (is_metaconsole() && $nodeConnected === false) {
$agentmodule_join = '';
} else if (!empty($filter['module_search'])) {
$agentmodule_join = 'INNER JOIN tagente_modulo am ON te.id_agentmodule = am.id_agente_modulo';
@@ -1339,7 +1351,7 @@ function events_get_all(
}
$extra = '';
- if (is_metaconsole()) {
+ if (is_metaconsole() && $nodeConnected === false) {
$extra = ', server_id';
}
@@ -1405,7 +1417,7 @@ function events_get_all(
}
$server_join = '';
- if (is_metaconsole()) {
+ if (is_metaconsole() && $nodeConnected === false) {
$server_join = ' LEFT JOIN tmetaconsole_setup ts
ON ts.id = te.server_id';
if (!empty($filter['server_id'])) {
@@ -3001,15 +3013,11 @@ function events_get_agent(
) {
global $config;
- if (!is_numeric($date)) {
+ if (is_numeric($date) === false) {
$date = time_w_fixed_tz($date);
}
- if (is_metaconsole() && $events_group === false) {
- $id_server = true;
- }
-
- if (empty($date)) {
+ if (empty($date) === true) {
$date = get_system_time();
}
@@ -3144,7 +3152,7 @@ function events_get_agent(
}
}
- if (is_metaconsole() && $id_server) {
+ if (is_metaconsole() === true && empty($id_server) === false) {
$sql_where .= ' AND server_id = '.$id_server;
}
@@ -3161,7 +3169,7 @@ function events_get_agent(
} else {
return events_get_events_no_grouped(
$sql_where,
- (is_metaconsole() && $id_server) ? true : false,
+ (is_metaconsole() === true && empty($id_server) === false) ? true : false,
$history
);
}
@@ -3664,22 +3672,37 @@ function events_page_responses($event, $childrens_ids=[])
);
}
- $table_responses->data[] = $data;
+ if ((tags_checks_event_acl(
+ $config['id_user'],
+ $event['id_grupo'],
+ 'EM',
+ $event['clean_tags'],
+ $childrens_ids
+ )) || (tags_checks_event_acl(
+ $config['id_user'],
+ $event['id_grupo'],
+ 'EW',
+ $event['clean_tags'],
+ $childrens_ids
+ ))
+ ) {
+ $table_responses->data[] = $data;
- // Comments.
- $data = [];
- $data[0] = __('Comment');
- $data[1] = '';
- $data[2] = html_print_button(
- __('Add comment'),
- 'comment_button',
- false,
- '$(\'#link_comments\').trigger(\'click\');',
- 'class="sub next w70p"',
- true
- );
+ // Comments.
+ $data = [];
+ $data[0] = __('Comment');
+ $data[1] = '';
+ $data[2] = html_print_button(
+ __('Add comment'),
+ 'comment_button',
+ false,
+ '$(\'#link_comments\').trigger(\'click\');',
+ 'class="sub next w70p"',
+ true
+ );
- $table_responses->data[] = $data;
+ $table_responses->data[] = $data;
+ }
if (tags_checks_event_acl(
$config['id_user'],
@@ -3723,7 +3746,7 @@ function events_page_responses($event, $childrens_ids=[])
['id_group' => $id_groups]
);
- if (empty($event_responses)) {
+ if (empty($event_responses) || (!check_acl($config['id_user'], 0, 'EW') && !check_acl($config['id_user'], 0, 'EM'))) {
$data[1] = ''.__('N/A').'';
} else {
$responses = [];
@@ -4293,6 +4316,8 @@ function events_page_details($event, $server='')
$serverstring = '';
}
+ $table_class = 'table_modal_alternate';
+
// Details.
$table_details = new stdClass;
$table_details->width = '100%';
@@ -4300,7 +4325,7 @@ function events_page_details($event, $server='')
$table_details->head = [];
$table_details->cellspacing = 0;
$table_details->cellpadding = 0;
- $table_details->class = 'table_modal_alternate';
+ $table_details->class = $table_class;
/*
* Useless switch.
@@ -4329,7 +4354,7 @@ function events_page_details($event, $server='')
if (!empty($agent)) {
$data = [];
- $data[0] = ''.__('Name').'
';
+ $data[0] = ''.__('Name').'
';
if (can_user_access_node() && is_metaconsole() && empty($event['server_id']) === true) {
$data[1] = ui_print_truncate_text(
$agent['alias'],
@@ -4362,12 +4387,12 @@ function events_page_details($event, $server='')
$table_details->data[] = $data;
$data = [];
- $data[0] = ''.__('IP Address').'
';
+ $data[0] = ''.__('IP Address').'
';
$data[1] = empty($agent['direccion']) ? ''.__('N/A').'' : $agent['direccion'];
$table_details->data[] = $data;
$data = [];
- $data[0] = ''.__('OS').'
';
+ $data[0] = ''.__('OS').'
';
$data[1] = ui_print_os_icon($agent['id_os'], true, true);
if (!empty($agent['os_version'])) {
$data[1] .= ' ('.$agent['os_version'].')';
@@ -4376,17 +4401,17 @@ function events_page_details($event, $server='')
$table_details->data[] = $data;
$data = [];
- $data[0] = ''.__('Last contact').'
';
+ $data[0] = ''.__('Last contact').'
';
$data[1] = ($agent['ultimo_contacto'] == '1970-01-01 00:00:00') ? ''.__('N/A').'' : ui_print_timestamp($agent['ultimo_contacto'], true);
$table_details->data[] = $data;
$data = [];
- $data[0] = ''.__('Last remote contact').'
';
+ $data[0] = ''.__('Last remote contact').'
';
$data[1] = ($agent['ultimo_contacto_remoto'] == '1970-01-01 00:00:00') ? ''.__('N/A').'' : date_w_fixed_tz($agent['ultimo_contacto_remoto']);
$table_details->data[] = $data;
$data = [];
- $data[0] = ''.__('Custom fields').'
';
+ $data[0] = ''.__('Custom fields').'
';
$data[1] = html_print_button(
__('View custom fields'),
'custom_button',
@@ -4418,13 +4443,13 @@ function events_page_details($event, $server='')
if (!empty($module)) {
// Module name.
$data = [];
- $data[0] = ''.__('Name').'
';
+ $data[0] = ''.__('Name').'
';
$data[1] = $module['nombre'];
$table_details->data[] = $data;
// Module group.
$data = [];
- $data[0] = ''.__('Module group').'
';
+ $data[0] = ''.__('Module group').'
';
$id_module_group = $module['id_module_group'];
if ($id_module_group == 0) {
$data[1] = __('No assigned');
@@ -4461,7 +4486,7 @@ function events_page_details($event, $server='')
if ($acl_graph) {
$data = [];
- $data[0] = ''.__('Graph').'
';
+ $data[0] = ''.__('Graph').'
';
$module_type = -1;
if (isset($module['module_type'])) {
@@ -4497,7 +4522,7 @@ function events_page_details($event, $server='')
$link = "winopeng_var('".$url.'?'.$graph_params_str."','".$win_handle."', 800, 480)";
$data[1] = '';
- $data[1] .= html_print_image('images/chart_curve.png', true);
+ $data[1] .= html_print_image('images/chart_curve.png', true, ['class' => 'invert_filter']);
$data[1] .= '';
$table_details->data[] = $data;
}
@@ -4510,20 +4535,26 @@ function events_page_details($event, $server='')
if ($event['id_alert_am'] != 0) {
$data = [];
- $data[0] = ''.__('Source').'
';
+ $data[0] = ''.__('Source').'
';
$data[1] = '';
$standby = db_get_value('standby', 'talert_template_modules', 'id', $event['id_alert_am']);
if (!$standby) {
$data[1] .= html_print_image(
'images/bell.png',
true,
- ['title' => __('Go to data overview')]
+ [
+ 'title' => __('Go to data overview'),
+ 'class' => 'invert_filter',
+ ]
);
} else {
$data[1] .= html_print_image(
'images/bell_pause.png',
true,
- ['title' => __('Go to data overview')]
+ [
+ 'title' => __('Go to data overview'),
+ 'class' => 'invert_filter',
+ ]
);
}
@@ -4542,7 +4573,7 @@ function events_page_details($event, $server='')
$table_details->data[] = $data;
$data = [];
- $data[0] = ''.__('Priority').'
';
+ $data[0] = ''.__('Priority').'
';
$priority_code = db_get_value('priority', 'talert_template_modules', 'id', $event['id_alert_am']);
$alert_priority = get_priority_name($priority_code);
@@ -5152,7 +5183,8 @@ function events_page_comments($event, $ajax=false)
$childrens_ids
))) && $config['show_events_in_local'] == false || $config['event_replication'] == false
) {
- $comments_form = '