";
+ }
+
break;
case 'url':
$command = str_replace("localhost",$_SERVER['SERVER_NAME'],$command);
diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php
index ffd618fb65..3b73fd7f37 100644
--- a/pandora_console/include/auth/mysql.php
+++ b/pandora_console/include/auth/mysql.php
@@ -269,32 +269,8 @@ function process_user_login_remote ($login, $pass, $api = false) {
else {
delete_user_pass_ldap ($login);
}
-
- $permissions = array();
- if($config['ldap_advanced_config']){
- $i = 0;
-
- $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
- foreach ($ldap_adv_perms as $ldap_adv_perm) {
- $attributes = $ldap_adv_perm['groups_ldap'];
-
- foreach ($attributes as $attr) {
- $attr = explode('=', $attr, 2);
- foreach ($sr[$attr[0]] as $s_attr) {
- if(preg_match('/' . $attr[1] . '/', $s_attr)){
- $permissions[$i]["profile"] = $ldap_adv_perm['profile'];
- $permissions[$i]["groups"] = $ldap_adv_perm['group'];
- $permissions[$i]["tags"] = implode(",",$ldap_adv_perm['tags']);
- $i++;
- }
- }
- }
- }
- } else {
- $permissions[0]["profile"] = $config['default_remote_profile'];
- $permissions[0]["groups"][] = $config['default_remote_group'];
- $permissions[0]["tags"] = $config['default_assign_tags'];
- }
+
+ $permissions = fill_permissions_ldap($sr);
if(empty($permissions)) {
$config["auth_error"] = __("User not found in database or incorrect password");
return false;
@@ -388,33 +364,7 @@ function process_user_login_remote ($login, $pass, $api = false) {
}
}
- $permissions = array();
- if($config['ldap_advanced_config']){
- $i = 0;
-
- $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
-
- foreach ($ldap_adv_perms as $ldap_adv_perm) {
- $attributes = $ldap_adv_perm['groups_ldap'];
-
- foreach ($attributes as $attr) {
- $attr = explode('=', $attr, 2);
- foreach ($sr[$attr[0]] as $s_attr) {
- if(preg_match('/' . $attr[1] . '/', $s_attr)){
- $permissions[$i]["profile"] = $ldap_adv_perm['profile'];
- $permissions[$i]["groups"] = $ldap_adv_perm['group'];
- $permissions[$i]["tags"] = implode(",",$ldap_adv_perm['tags']);
- $i++;
- }
- }
- }
- }
- } else {
- $permissions[0]["profile"] = $config['default_remote_profile'];
- $permissions[0]["groups"][] = $config['default_remote_group'];
- $permissions[0]["tags"] = $config['default_assign_tags'];
- }
-
+ $permissions = fill_permissions_ldap($sr);
if(empty($permissions)) {
$config["auth_error"] = __("User not found in database or incorrect password");
return false;
@@ -904,10 +854,11 @@ function create_user_and_permisions_ldap ($id_user, $password, $user_info,
$id_profile = $permission["profile"];
$id_groups = $permission["groups"];
$tags = $permission["tags"];
+ $no_hierarchy = (bool)$permission["no_hierarchy"] ? 1 : 0;
foreach ($id_groups as $id_group) {
$profile = profile_create_user_profile(
- $id_user, $id_profile, $id_group, false, $tags);
+ $id_user, $id_profile, $id_group, false, $tags, $no_hierarchy);
}
if ( defined("METACONSOLE") && $syncronize ) {
@@ -934,7 +885,7 @@ function create_user_and_permisions_ldap ($id_user, $password, $user_info,
db_process_sql_insert ("tusuario", $values);
foreach ($id_groups as $id_group) {
$profile = profile_create_user_profile ($id_user,
- $id_profile, $id_group, false, $tags);
+ $id_profile, $id_group, false, $tags, $no_hierarchy);
}
}
@@ -1141,6 +1092,46 @@ function check_permission_ldap ($id_user, $password, $user_info,
}
}
+/**
+ * Fill permissions array with setup values
+ *
+ * @param string sr return value from LDAP connection
+ *
+ * @return array with all permission on LDAP authentication
+ */
+function fill_permissions_ldap ($sr) {
+ global $config;
+
+ $permissions = array();
+ if(!$config['ldap_advanced_config']){
+ $permissions[0]["profile"] = $config['default_remote_profile'];
+ $permissions[0]["groups"][] = $config['default_remote_group'];
+ $permissions[0]["tags"] = $config['default_assign_tags'];
+ $permissions[0]["no_hierarchy"] = $config['default_no_hierarchy'];
+ return $permissions;
+ }
+
+ // Decode permissions in advanced mode
+ $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
+ foreach ($ldap_adv_perms as $ldap_adv_perm) {
+ $attributes = $ldap_adv_perm['groups_ldap'];
+ foreach ($attributes as $attr) {
+ $attr = explode('=', $attr, 2);
+ foreach ($sr[$attr[0]] as $s_attr) {
+ if(preg_match('/' . $attr[1] . '/', $s_attr)){
+ $permissions[] = array(
+ "profile" => $ldap_adv_perm['profile'],
+ "groups" => $ldap_adv_perm['group'],
+ "tags" => implode(",",$ldap_adv_perm['tags']),
+ "no_hierarchy" => (bool)$ldap_adv_perm['no_hierarchy'] ? 1 : 0
+ );
+ }
+ }
+ }
+ }
+ return $permissions;
+}
+
/**
* Update local user pass from ldap user
*
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index 5101d1045a..18f1ba08b3 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -22,7 +22,7 @@
/**
* Pandora build version and version
*/
-$build_version = 'PC190103';
+$build_version = 'PC190115';
$pandora_version = 'v7.0NG.730';
// Do not overwrite default timezone set if defined.
diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php
index 1e43ae46fd..f2056f058e 100644
--- a/pandora_console/include/functions.php
+++ b/pandora_console/include/functions.php
@@ -3400,5 +3400,39 @@ function validate_csrf_code() {
function generate_hash_to_api(){
hash('sha256', db_get_value ('value', 'tupdate_settings', '`key`', 'customer_key'));
+}
+
+/**
+ * Disable the profiller and display de result
+ *
+ * @param string Key to identify the profiler run.
+ * @param string Way to display the result
+ * "link" (default): Click into word "Performance" to display the profilling info.
+ * "console": Display with a message in pandora_console.log.
+ */
+function pandora_xhprof_display_result($key = "", $method = "link") {
+ // Check if function exists
+ if (!function_exists('tideways_xhprof_disable')) {
+ error_log("Cannot find tideways_xhprof_disable function");
+ return;
}
+
+ $run_id = uniqid();
+ $data = tideways_xhprof_disable();
+ $source = "pandora_$key";
+ file_put_contents(
+ sys_get_temp_dir() . "/" . $run_id . ".$source.xhprof",
+ serialize($data)
+ );
+ $new_url = "http://{$_SERVER['HTTP_HOST']}/profiler/index.php?run={$run_id}&source={$source}";
+ switch($method) {
+ case "console":
+ error_log("'{$new_url}'");
+ case "link":
+ default:
+ echo "Performance\n";
+ break;
+
+ }
+}
?>
diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php
index 7b4592171b..b1d258e223 100644
--- a/pandora_console/include/functions_agents.php
+++ b/pandora_console/include/functions_agents.php
@@ -1233,8 +1233,8 @@ function agents_get_modules ($id_agent = null, $details = false,
ON tagente.id_agente = tasg.id_agent
WHERE tagente_modulo.delete_pending = 0
AND %s
- GROUP BY tagente_modulo.id_agente_modulo
- ORDER BY tagente_modulo.nombre',
+ GROUP BY 1
+ ORDER BY 1',
($details != 'tagente_modulo.*' && $indexed) ? 'tagente_modulo.id_agente_modulo,' : '',
io_safe_output(implode (",", (array) $details)),
$sql_tags_join,
diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php
index 53479ae7ed..8695ad9b1d 100644
--- a/pandora_console/include/functions_api.php
+++ b/pandora_console/include/functions_api.php
@@ -32,6 +32,7 @@ include_once($config['homedir'] . "/include/functions_servers.php");
include_once($config['homedir'] . "/include/functions_planned_downtimes.php");
include_once($config['homedir'] . "/include/functions_db.php");
include_once($config['homedir'] . "/include/functions_event_responses.php");
+include_once($config['homedir'] . "/include/functions_policies.php");
enterprise_include_once ('include/functions_local_components.php');
enterprise_include_once ('include/functions_events.php');
enterprise_include_once ('include/functions_agents.php');
@@ -6448,6 +6449,63 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) {
array('type' => 'string', 'data' => __('SNMP policy module updated.')));
}
+/**
+ * Remove an agent from a policy.
+ * @param $id Id of the policy
+ * @param $id2 Id of the agent policy
+ * @param $trash1
+ * @param $trash2
+ *
+ * Example:
+ * api.php?op=set&op2=remove_agent_from_policy&apipass=1234&user=admin&pass=pandora&id=11&id2=2
+ */
+function api_set_remove_agent_from_policy ($id, $id2, $thrash2, $thrash3) {
+ global $config;
+
+ if (!check_acl($config['id_user'], 0, "AW")){
+ returnError('forbidden', 'string');
+ return;
+ }
+
+ if ($id == '' || !$id) {
+ returnError('error_parameter', __('Error deleting agent from policy. Policy cannot be left blank.'));
+ return;
+ }
+
+ if ($id2 == '' || !$id2) {
+ returnError('error_parameter', __('Error deleting agent from policy. Agent cannot be left blank.'));
+ return;
+ }
+
+ $policy = policies_get_policy ($id, false, false);
+ $agent = db_get_row_filter('tagente', array('id_agente' => $id2));
+ $policy_agent = db_get_row_filter('tpolicy_agents', array('id_policy' => $id ,'id_agent' => $id2));
+
+ if (empty ($policy)){
+ returnError('error_policy', __('This policy does not exist.'));
+ return;
+ }
+ if (empty ($agent)){
+ returnError('error_agent', __('This agent does not exist.'));
+ return;
+ }
+ if (empty ($policy_agent)){
+ returnError('error_policy_agent', __('This agent does not exist in this policy.'));
+ return;
+ }
+
+ $return = policies_change_delete_pending_agent($policy_agent['id']);
+ $data = __('Successfully added to delete pending id agent %d to id policy %d.', $id2, $id);
+
+ if ($return === false)
+ returnError('error_delete_policy_agent', 'Could not be deleted id agent %d from id policy %d', $id2, $id);
+ else
+ returnData('string', array('type' => 'string', 'data' => $data));
+
+
+}
+
+
/**
* Create a new group. And return the id_group of the new group.
*
@@ -9716,6 +9774,11 @@ function api_set_create_event($id, $trash1, $other, $returnType) {
return;
}
$values['id_grupo'] = $other['data'][1];
+
+ if (groups_get_name($values['id_grupo']) === false) {
+ returnError('error_parameter', 'Group ID does not exist');
+ return;
+ }
}
else {
returnError('error_parameter', 'Group ID required.');
@@ -10059,7 +10122,7 @@ function api_get_netflow_get_summary ($discard_1, $discard_2, $params) {
}
//http://localhost/pandora_console/include/api.php?op=set&op2=validate_event_by_id&id=23&apipass=1234&user=admin&pass=pandora
-function api_set_validate_event_by_id ($id, $trash1, $trash2, $returnType) {
+function api_set_validate_event_by_id ($id, $trash1 = null, $trash2 = null, $returnType = 'string') {
global $config;
$data['type'] = 'string';
$check_id = db_get_value('id_evento', 'tevento', 'id_evento', $id);
@@ -10078,7 +10141,7 @@ function api_set_validate_event_by_id ($id, $trash1, $trash2, $returnType) {
'ack_utimestamp' => $ack_utimestamp,
'estado' => 1
);
-
+
$result = db_process_sql_update('tevento', $values, array('id_evento' => $id));
if ($result === false) {
diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index bd0c78bd76..17f6d9b345 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -312,6 +312,8 @@ function config_update_config () {
$error_update[] = __('Autocreate profile group');
if (!config_update_value ('default_assign_tags', implode(",",get_parameter ('default_assign_tags'))))
$error_update[] = __('Autocreate profile tags');
+ if (!config_update_value ('default_no_hierarchy', (int)get_parameter ('default_no_hierarchy')))
+ $error_update[] = __('Automatically assigned no hierarchy');
if (!config_update_value ('autocreate_blacklist', get_parameter ('autocreate_blacklist')))
$error_update[] = __('Autocreate blacklist');
@@ -1452,7 +1454,10 @@ function config_process_config () {
if (!isset ($config['default_assign_tags'])) {
config_update_value ( 'default_assign_tags', '');
}
-
+ if (!isset ($config['default_no_hierarchy'])) {
+ config_update_value ('default_no_hierarchy', 0);
+ }
+
if (!isset ($config['ldap_server'])) {
config_update_value ( 'ldap_server', 'localhost');
}
diff --git a/pandora_console/include/functions_groupview.php b/pandora_console/include/functions_groupview.php
index e9b7ca7c1d..55256313b2 100644
--- a/pandora_console/include/functions_groupview.php
+++ b/pandora_console/include/functions_groupview.php
@@ -68,6 +68,7 @@ function groupview_get_modules_counters($groups_ids = false) {
ta.id_grupo AS g
FROM $table ta
WHERE ta.id_grupo IN ($groups_ids)
+ AND ta.disabled = 0
GROUP BY ta.id_grupo
UNION ALL
SELECT SUM(ta.normal_count) AS module_normal,
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index 16e222ca5c..06257a5457 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -735,8 +735,11 @@ function html_print_extended_select_for_post_process($name, $selected = '',
$selected_float = (float)$selected;
$found = false;
- if (array_key_exists(number_format($selected, 14, '.', ','), $fields))
- $found = true;
+ if($selected){
+ if (array_key_exists(number_format($selected, 14, '.', ','), $fields)) {
+ $found = true;
+ }
+ }
if (!$found) {
$fields[$selected] = floatval($selected);
@@ -1017,7 +1020,7 @@ function html_print_input_text_extended ($name, $value, $id, $alt, $size, $maxle
++$idcounter;
$valid_attrs = array ("accept", "disabled", "maxlength",
- "name", "readonly", "size", "value", "accesskey",
+ "name", "readonly", "placeholder", "size", "value", "accesskey",
"class", "dir", "id", "lang", "style", "tabindex",
"title", "xml:lang", "onfocus", "onblur", "onselect",
"onchange", "onclick", "ondblclick", "onmousedown",
diff --git a/pandora_console/include/functions_profile.php b/pandora_console/include/functions_profile.php
index 01d876697d..292d2892a7 100644
--- a/pandora_console/include/functions_profile.php
+++ b/pandora_console/include/functions_profile.php
@@ -79,14 +79,10 @@ function profile_create_user_profile ($id_user,
$tags = '',
$no_hierarchy = false
) {
-
global $config;
if (empty ($id_profile) || $id_group < 0)
- return false;
-
- // Secondary server is an enterprise function
- if (!enterprise_installed() && $no_hierarchy) return false;
+ return false;
// Checks if the user exists
$result_user = users_get_user_by_id($id_user);
diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php
index 72a222becd..a4be0d445e 100755
--- a/pandora_console/include/functions_treeview.php
+++ b/pandora_console/include/functions_treeview.php
@@ -278,6 +278,11 @@ function treeview_printModuleTable($id_module, $server_data = false, $no_head =
));
$salida = ui_get_snapshot_image($link, $is_snapshot) . ' ';
}
+
+ if($salida !== NULL){
+ $last_data_str = html_print_image('images/clock2.png', true, array('title' => $last_data["timestamp"], 'width' => '18px'));
+ }
+
$last_data_str .= $salida;
}
else {
diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js
index 7067e1d560..e69fb155e0 100644
--- a/pandora_console/include/graphs/flot/pandora.flot.js
+++ b/pandora_console/include/graphs/flot/pandora.flot.js
@@ -362,10 +362,11 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark,
tickFormatter: xFormatter,
},
yaxis: {
- color: tick_color,
- axisLabelUseCanvas: true,
- axisLabelFontSizePixels: font_size,
- axisLabelFontFamily: font+'Font',
+ font: {
+ size: font_size + 2,
+ color: 'rgb(84, 84, 84)',
+ family: font+'Font'
+ },
ticks: yFormatter,
},
legend: {
@@ -417,7 +418,7 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark,
div_attributes += "min-height: 2.5em;";
}
- div_attributes += '" title="'+title+'" class="'+font+'" '+ ' style="overflow: hidden;"';
+ div_attributes += '" title="'+title+'" style="overflow: hidden;"';
format.push([i,'
'
+ label
diff --git a/pandora_console/include/help/en/help_plugin_macros.php b/pandora_console/include/help/en/help_plugin_macros.php
index 1660c45e13..6d1e508b21 100644
--- a/pandora_console/include/help/en/help_plugin_macros.php
+++ b/pandora_console/include/help/en/help_plugin_macros.php
@@ -31,10 +31,10 @@ Hidden this macros because they cannot edit in the module form
-->
_plugin_parameters_ : Plug-in Parameters of the module.
-
_name_tag_ : Nombre de los tags asociados al módulo.
-
_email_tag_ : Emails asociados a los tags de módulos.
-
_phone_tag_ : Teléfonos asociados a los tags de módulos.
-
_moduletags_ : Teléfonos asociados a los tags de módulos.
+
_name_tag_ : Names of the tags associated to the module.
+
_email_tag_ : Emails associated to module tags.
+
_phone_tag_ : Phone numbers associated to module tags.
+
_moduletags_ : URLs associated to module tags.
_agentcustomfield_n_: Agent custom field number n (eg. _agentcustomfield_9_).
diff --git a/pandora_console/include/help/es/help_plugin_macros.php b/pandora_console/include/help/es/help_plugin_macros.php
index 701d15f35e..77c97aa4d7 100644
--- a/pandora_console/include/help/es/help_plugin_macros.php
+++ b/pandora_console/include/help/es/help_plugin_macros.php
@@ -30,9 +30,9 @@ Hidden this macros because they cannot edit in the module form
-->
_plugin_parameters_ : Parámetros del Plug-in del módulo.
-
_name_tag_ : Names of the tags associated to the module.
-
_email_tag_ : Emails associated to the module tags.
-
_phone_tag_ : Phone numbers associated to the module tags.
-
_moduletags_ : URLs associated to the module tags.
+
_name_tag_ : Nombre de los tags asociados al módulo.
+
_email_tag_ : Emails asociados a los tags de módulos.
+
_phone_tag_ : Teléfonos asociados a los tags de módulos.
+
_moduletags_ : URLs asociadas a los tags de módulos.
_agentcustomfield_n_: Campo personalizado número n del agente (eg. _agentcustomfield_9_).
diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js
index 2b323a55f1..1ca0759801 100644
--- a/pandora_console/include/javascript/pandora.js
+++ b/pandora_console/include/javascript/pandora.js
@@ -594,12 +594,51 @@ function post_process_select_init_unit(name,selected) {
function post_process_select_events_unit(name,selected) {
$('.' + name + '_toggler').click(function() {
- $('#' + name + '_select option[value=none]').attr("selected",true);
- $('#text-' + name + '_text').val("");
+ var value = $('#text-' + name + '_text').val();
+
+ var count = $('#' + name + '_select option')
+ .filter(function(i, item) {
+
+ if ($(item).val() == value)
+ return true;
+ else return false;
+ })
+ .length;
+
+ if (count != 1) {
+ $('#' + name + '_select')
+ .append($("