0 && give_acl ($config['id_user'], 0, "IM")) { $sql = sprintf ("DELETE FROM ttrap WHERE id_trap = %d", $id_trap); $result = process_sql ($sql); print_error_message ($result, __('Event successfully deleted'), __('Error removing event')); } else { audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to delete SNMP event ID #".$id_trap); } } // Check Event (only incident write access). if (isset ($_GET["check"])) { $id_trap = (int) get_parameter_get ("check", 0); if ($id_trap > 1 && give_acl ($config['id_user'], 0, "IW")) { $sql = sprintf ("UPDATE ttrap SET status = 1, id_usuario = '%s' WHERE id_trap = %d", $config["id_user"], $id_trap); $result = process_sql ($sql); print_error_message ($result, __('Event successfully updated'), __('Error updating event')); } else { audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to checkout SNMP Trap ID".$id_trap); } } // Mass-process DELETE if (isset ($_POST["deletebt"])) { $trap_ids = get_parameter_post ("snmptrapid", array ()); if (is_array ($trap_ids) && give_acl ($config['id_user'], 0, "IW")) { foreach ($trap_ids as $id_trap) { $sql = sprintf ("DELETE FROM ttrap WHERE id_trap = %d", $id_trap); process_sql ($sql); } } else { audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to mass-delete SNMP Trap ID"); } } // Mass-process UPDATE if (isset ($_POST["updatebt"])) { $trap_ids = get_parameter_post ("snmptrapid", array ()); if (is_array ($trap_ids) && give_acl ($config['id_user'], 0, "IW")) { foreach ($trap_ids as $id_trap) { $sql = sprintf ("UPDATE ttrap SET status = 1, id_usuario = '%s' WHERE id_trap = %d", $config["id_user"], $id_trap); process_sql ($sql); } } else { audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to mass-delete SNMP Trap ID"); } } echo "

Pandora SNMP > ".__('SNMP console')."

"; $offset = (int) get_parameter ('offset',0); $sql = sprintf ("SELECT * FROM ttrap ORDER BY timestamp DESC LIMIT %d,%d",$offset,$config['block_size']); $traps = get_db_all_rows_sql ($sql); if (empty ($traps)) { echo '
'.__('There are no SNMP traps in database').'
'; return; } echo ''; echo ''; echo ''; echo '
'.__('Status').''.__('Alert').''.__('Action').'
'; echo ' - '.__('Validated event'); echo '
'; echo ' - '.__('Not validated event'); echo '
'; echo ' - '.__('Alert fired'); echo '
'; echo ' - '.__('Alert not fired'); echo '
'; echo ' - '.__('Validate event'); echo '
'; echo ' - '.__('Delete event'); echo '
'; echo '
'; // Prepare index for paginationi $trapcount = get_db_sql ("SELECT COUNT(*) FROM ttrap"); pagination ($trapcount, "index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view", $offset); echo "
"; echo '
'; $table->cellpadding = 4; $table->cellspacing = 4; $table->width = 735; $table->class = "databox"; $table->head = array (); $table->size = array (); $table->data = array (); $table->align = array (); $table->head[0] = __('Status'); $table->align[0] = "center"; $table->head[1] = __('SNMP Agent'); $table->align[1] = "center"; $table->head[2] = __('OID'); $table->align[2] = "center"; $table->head[3] = __('Value'); $table->align[3] = "center"; $table->head[4] = __('Custom'); $table->align[4] = "center"; $table->head[5] = __('User ID'); $table->align[5] = "center"; $table->head[6] = __('Timestamp'); $table->size[6] = 130; $table->align[6] = "center"; $table->head[7] = __('Alert'); $table->align[7] = "center"; $table->head[8] = __('Action'); $table->align[8] = "center"; $table->head[9] = print_checkbox_extended ("allbox", 1, false, false, "javascript:CheckAll();", 'class="chk" title="'.__('All').'"', true); $table->align[9] = "center"; // Skip offset records foreach ($traps as $trap) { $data = array (); //Status if ($trap["status"] == 0) { $data[0] = ''; } else { $data[0] = ''; } // Agent matching source address $agent = get_agent_with_ip ($trap['source']); if ($agent !== false && ! give_acl ($config["id_user"], $agent["id_grupo"], "AR")) { //Agent found, no rights continue; } elseif ($agent === false) { //Agent not found $data[1] = $trap["source"]; if (give_acl ($config["id_user"], 0, "AW")) { //We have rights to create agents $data[1] = ''.$data[1].''; } } else { //Agent found $data[1] = ''; $data[1] .= ''.$agent["nombre"].''; } //OID $data[2] = $trap["oid"]; if (empty ($data[2])) $data[2] = __('N/A'); //Value $data[3] = substr ($trap["value"], 0, 15); if (empty ($data[3])) { $data[3] = __('N/A'); } elseif (strlen ($trap["value"]) > 15) { $data[3] = ''.$data[3].'...'; } //Custom $data[4] = $trap["value_custom"]; if (empty ($data[4])) { $data[4] = __('N/A'); } elseif (strlen ($trap["value_custom"]) > 15) { $data[4] = ''.$data[4].'...'; } //User if (!empty ($trap["status"])) { $data[5] = ''.substr ($trap["id_usuario"], 0, 8).''; $data[5] .= ' '.dame_nombre_real($trap["id_usuario"]).''; } else { $data[5] = '--'; } // Timestamp $data[6] = $trap["timestamp"]; //Alert fired if (!empty ($trap["alerted"])) { $idx = count ($table->data); switch ($trap["priority"]) { case 0: $table->rowclass[$idx] = "datos_blue"; break; case 1: $table->rowclass[$idx] = "datos_grey"; break; case 2: $table->rowclass[$idx] = "datos_green"; break; case 3: $table->rowclass[$idx] = "datos_yellow"; break; case 4: $table->rowclass[$idx] = "datos_red"; break; default: $table->rowclass[$idx] = "datos_grey"; } $data[7] = ''; } else { $data[7] = ''; } //Actions $data[8] = ""; if (empty ($trap["status"]) && give_acl ($config["id_user"], 0, "IW")) { $data[8] .= ''; } if (give_acl ($config["id_user"], 0, "IW")) { $data[8] .= ''; } $data[9] = print_checkbox_extended ("snmptrapid[]", $trap["id_trap"], false, false, '', 'class="chk"', true); array_push ($table->data, $data); } print_table ($table); unset ($table); echo '
'; print_submit_button (__('Validate'), "updatebt", false, 'class="sub ok"'); if (give_acl ($config['id_user'], 0, "IM")) { print_submit_button (__('Delete'), "deletebt", false, 'class="sub delete" onClick="javascript:confirm(\''.__('Are you sure').'\')"'); } echo "
"; ?>