2011-08-01 Tomas Palacios <tomas.palacios@artica.es>

* godmode/massive: fixed a bug regarding warnings,
        SQL errors and undefined variables in massive alert ops.

        * godmode/snmpconsole/snmp_alert.php
          godmode/users/profile_list.php: fixed a bug regarding creation
        of snmp alerts and profiles with no info at all.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4659 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Aldrioth 2011-08-01 16:52:26 +00:00
parent d983c38f45
commit e6d02b7540
7 changed files with 73 additions and 51 deletions

View File

@ -66,7 +66,7 @@ $id_alert_compounds = (array) get_parameter ('id_alert_compounds');
$add = (bool) get_parameter_post ('add');
if ($add) {
if(empty($id_agents))
if(empty($id_agents) || $id_agents[0] == 0)
ui_print_result_message (false, '', __('Could not be added').". ".__('No agents selected'));
else {
$action = (int) get_parameter ('action');

View File

@ -44,7 +44,7 @@ if (is_ajax ()) {
}
function process_manage_add ($id_alert_template, $id_agents, $module_names) {
if (empty ($id_agents)) {
if (empty ($id_agents) || $id_agents[0] == 0) {
echo '<h3 class="error">'.__('No agents selected').'</h3>';
return false;
}

View File

@ -65,7 +65,7 @@ $id_alert_compounds = (array) get_parameter ('id_alert_compounds');
$delete = (bool) get_parameter_post ('delete');
if ($delete) {
if(empty($id_agents))
if(empty($id_agents) || $id_agents[0] == 0)
ui_print_result_message (false, '', __('Could not be deleted').". ".__('No agents selected'));
else {
$action = (int) get_parameter ('action');

View File

@ -51,7 +51,7 @@ function process_manage_delete ($id_alert_template, $id_agents, $module_names) {
return false;
}
if (empty ($id_agents)) {
if (empty ($id_agents) || $id_agents[0] == 0) {
echo '<h3 class="error">'.__('No agents selected').'</h3>';
return false;
}

View File

@ -93,9 +93,9 @@ switch($action) {
ui_print_result_message ($result, __('Successfully disabled'), __('Could not be disabled'));
$info = 'Alert: ' . json_encode($id_disabled_alerts);
$info = 'Alert: ' . json_encode($id_enabled_alerts);
if ($result) {
db_pandora_audit("Masive management", "Disaable alert", false, false, $info);
db_pandora_audit("Masive management", "Disable alert", false, false, $info);
}
else {
db_pandora_audit("Masive management", "Fail try to Disable alert", false, false, $info);

View File

@ -65,9 +65,14 @@ if (isset ($_GET["update_alert"]) && $_GET["update_alert"] == "-1") {
'max_alerts' => $max_alerts,
'min_alerts' => $min_alerts,
'priority' => $priority);
$result = db_process_sql_insert('talert_snmp', $values);
if (!$source_ip || !$oid) {
$result = '';
}
else {
$result = db_process_sql_insert('talert_snmp', $values);
}
if ($result === false) {
if (!$result) {
echo '<h3 class="error">'.__('There was a problem creating the alert').'</h3>';
}
else {
@ -75,15 +80,21 @@ if (isset ($_GET["update_alert"]) && $_GET["update_alert"] == "-1") {
}
} else {
$sql = sprintf ("UPDATE talert_snmp SET
priority = %d, id_alert = %d, al_field1 = '%s', al_field2 = '%s', al_field3 = '%s', description = '%s', agent = '%s', custom_oid = '%s',
oid = '%s', time_threshold = %d, max_alerts = %d, min_alerts = %d WHERE id_as = %d",
$priority, $alert_type, $al_field1, $al_field2, $al_field3, $description, $source_ip, $custom_value,
$oid, $time_threshold, $max_alerts, $min_alerts, $id_as);
$result = db_process_sql ($sql);
if ($result === false) {
if (!$source_ip || !$oid) {
$result = '';
}
else {
$sql = sprintf ("UPDATE talert_snmp SET
priority = %d, id_alert = %d, al_field1 = '%s', al_field2 = '%s', al_field3 = '%s', description = '%s', agent = '%s', custom_oid = '%s',
oid = '%s', time_threshold = %d, max_alerts = %d, min_alerts = %d WHERE id_as = %d",
$priority, $alert_type, $al_field1, $al_field2, $al_field3, $description, $source_ip, $custom_value,
$oid, $time_threshold, $max_alerts, $min_alerts, $id_as);
$result = db_process_sql ($sql);
}
if (!$result) {
echo '<h3 class="error">'.__('There was a problem updating the alert').'</h3>';
} else {
echo '<h3 class="suc">'.__('Successfully updated').'</h3>';

View File

@ -89,30 +89,35 @@ if ($update_profile) {
$alert_management = (bool) get_parameter ("alert_management");
$pandora_management = (bool) get_parameter ("pandora_management");
$sql = sprintf ('UPDATE tperfil SET
name = "%s", incident_view = %d, incident_edit = %d,
incident_management = %d, agent_view = %d, agent_edit = %d,
alert_edit = %d, user_management = %d, db_management = %d,
alert_management = %d, pandora_management = %d WHERE id_perfil = %d',
$name, $incident_view, $incident_edit, $incident_management,
$agent_view, $agent_edit, $alert_edit, $user_management,
$db_management, $alert_management, $pandora_management,
$id_profile);
$ret = db_process_sql ($sql);
if ($ret !== false) {
$info = 'Name: ' . $name . ' Incident view: ' . $incident_view .
' Incident edit: ' . $incident_edit . ' Incident management: ' . $incident_management .
' Agent view: ' . $agent_view . ' Agent edit: ' . $agent_edit .
' Alert edit: ' . $alert_edit . ' User management: ' . $user_management .
' DB management: ' . $db_management . ' Alert management: ' . $alert_management .
' Pandora Management: ' . $pandora_management;
db_pandora_audit("User management",
"Update profile ". $name, false, false, $info);
echo '<h3 class="suc">'.__('Successfully updated').'</h3>';
if ($name) {
$sql = sprintf ('UPDATE tperfil SET
name = "%s", incident_view = %d, incident_edit = %d,
incident_management = %d, agent_view = %d, agent_edit = %d,
alert_edit = %d, user_management = %d, db_management = %d,
alert_management = %d, pandora_management = %d WHERE id_perfil = %d',
$name, $incident_view, $incident_edit, $incident_management,
$agent_view, $agent_edit, $alert_edit, $user_management,
$db_management, $alert_management, $pandora_management,
$id_profile);
$ret = db_process_sql ($sql);
if ($ret !== false) {
$info = 'Name: ' . $name . ' Incident view: ' . $incident_view .
' Incident edit: ' . $incident_edit . ' Incident management: ' . $incident_management .
' Agent view: ' . $agent_view . ' Agent edit: ' . $agent_edit .
' Alert edit: ' . $alert_edit . ' User management: ' . $user_management .
' DB management: ' . $db_management . ' Alert management: ' . $alert_management .
' Pandora Management: ' . $pandora_management;
db_pandora_audit("User management",
"Update profile ". $name, false, false, $info);
echo '<h3 class="suc">'.__('Successfully updated').'</h3>';
}
else {
echo '<h3 class="error"'.__('There was a problem updating this profile').'</h3>';
}
}
else {
echo '<h3 class="error"'.__('There was a problem updating this profile').'</h3>';
echo '<h3 class="error"'.__('Profile name cannot be empty').'</h3>';
}
$id_profile = 0;
}
@ -143,22 +148,28 @@ if ($create_profile) {
'db_management' => $db_management,
'alert_management' => $alert_management,
'pandora_management' => $pandora_management);
$ret = db_process_sql_insert('tperfil', $values);
if ($name) {
$ret = db_process_sql_insert('tperfil', $values);
if ($ret !== false) {
echo '<h3 class="suc">'.__('Successfully created').'</h3>';
$info = 'Name: ' . $name . ' Incident view: ' . $incident_view .
' Incident edit: ' . $incident_edit . ' Incident management: ' . $incident_management .
' Agent view: ' . $agent_view . ' Agent edit: ' . $agent_edit .
' Alert edit: ' . $alert_edit . ' User management: ' . $user_management .
' DB management: ' . $db_management . ' Alert management: ' . $alert_management .
' Pandora Management: ' . $pandora_management;
db_pandora_audit("User management",
"Created profile ". $name, false, false, $info);
if ($ret !== false) {
echo '<h3 class="suc">'.__('Successfully created').'</h3>';
$info = 'Name: ' . $name . ' Incident view: ' . $incident_view .
' Incident edit: ' . $incident_edit . ' Incident management: ' . $incident_management .
' Agent view: ' . $agent_view . ' Agent edit: ' . $agent_edit .
' Alert edit: ' . $alert_edit . ' User management: ' . $user_management .
' DB management: ' . $db_management . ' Alert management: ' . $alert_management .
' Pandora Management: ' . $pandora_management;
db_pandora_audit("User management",
"Created profile ". $name, false, false, $info);
}
else {
echo '<h3 class="error">'.__('There was a problem creating this profile').'</h3>';
}
}
else {
echo '<h3 class="error">'.__('There was a problem creating this profile').'</h3>';
echo '<h3 class="error"'.__('There was a problem creating this profile').'</h3>';
}
$id_profile = 0;
}