2013-01-18 10:56:46 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
|
|
|
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
|
|
|
// Please see http://pandorafms.org for full contribution list
|
|
|
|
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation for version 2.
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
$groups = users_get_groups($id_user, 'ER');
|
|
|
|
|
2014-11-18 11:27:04 +01:00
|
|
|
$propagate = db_get_value('propagate','tgrupo','id_grupo',$id_group);
|
|
|
|
|
2014-11-18 15:18:00 +01:00
|
|
|
if ($id_group > 0) {
|
2014-11-18 11:27:04 +01:00
|
|
|
if ($propagate) {
|
|
|
|
$childrens_ids = array($id_group);
|
|
|
|
|
|
|
|
$childrens = groups_get_childrens($id_group);
|
|
|
|
|
|
|
|
if (!empty($childrens)) {
|
|
|
|
foreach ($childrens as $child) {
|
|
|
|
$childrens_ids[] = (int)$child['id_grupo'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$childrens_ids = array();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$childrens_ids = array_keys($groups);
|
|
|
|
}
|
|
|
|
|
2013-01-18 10:56:46 +01:00
|
|
|
//Group selection
|
2013-07-17 17:58:15 +02:00
|
|
|
if ($id_group > 0 && in_array ($id_group, array_keys ($groups))) {
|
2014-11-18 11:27:04 +01:00
|
|
|
if ($propagate) {
|
|
|
|
$sql_post = " AND id_grupo IN (" . implode(',', $childrens_ids) . ")";
|
2013-01-18 10:56:46 +01:00
|
|
|
}
|
|
|
|
else {
|
2014-11-18 11:27:04 +01:00
|
|
|
//If a group is selected and it's in the groups allowed
|
|
|
|
$sql_post = " AND id_grupo = $id_group";
|
2013-01-18 10:56:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-11-18 15:18:00 +01:00
|
|
|
$sql_post = " AND id_grupo IN (" . implode (",", array_keys ($groups)) . ")";
|
2013-01-18 10:56:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Skip system messages if user is not PM
|
|
|
|
if (!check_acl ($id_user, 0, "PM")) {
|
|
|
|
$sql_post .= " AND id_grupo != 0";
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ($status) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
$sql_post .= " AND estado = " . $status;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
$sql_post .= " AND (estado = 0 OR estado = 2)";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($search != "") {
|
2015-01-30 11:33:04 +01:00
|
|
|
$sql_post .= ' AND (evento LIKE "%'. io_safe_input($search) . '%"'. ' OR id_evento LIKE "%$search%")';
|
2013-01-18 10:56:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($event_type != "") {
|
|
|
|
// If normal, warning, could be several (going_up_warning, going_down_warning... too complex
|
|
|
|
// for the user so for him is presented only "warning, critical and normal"
|
|
|
|
if ($event_type == "warning" || $event_type == "critical"
|
|
|
|
|| $event_type == "normal") {
|
|
|
|
$sql_post .= " AND event_type LIKE '%$event_type%' ";
|
|
|
|
}
|
|
|
|
elseif ($event_type == "not_normal") {
|
2013-11-19 14:28:35 +01:00
|
|
|
$sql_post .= " AND (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
|
2013-01-18 10:56:46 +01:00
|
|
|
}
|
|
|
|
elseif ($event_type != "all") {
|
|
|
|
$sql_post .= " AND event_type = '" . $event_type."'";
|
|
|
|
}
|
2013-03-20 Miguel de Dios <miguel.dedios@artica.es>
* mobile/operation/events.php, mobile/include/ui.class.php,
mobile/index.php: added first version of events section.
* include/functions_incidents.php, include/functions_users.php,
include/functions.php, include/functions_groups.php,
include/functions_events.php, include/functions_html.php,
operation/events/events.build_table.php,
operation/events/events.build_query.php,
operation/events/events_list.php: some changes for interact with
mobile version.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7872 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-03-20 13:29:33 +01:00
|
|
|
|
2013-01-18 10:56:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($severity != -1) {
|
2013-03-20 Miguel de Dios <miguel.dedios@artica.es>
* mobile/operation/events.php, mobile/include/ui.class.php,
mobile/index.php: added first version of events section.
* include/functions_incidents.php, include/functions_users.php,
include/functions.php, include/functions_groups.php,
include/functions_events.php, include/functions_html.php,
operation/events/events.build_table.php,
operation/events/events.build_query.php,
operation/events/events_list.php: some changes for interact with
mobile version.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7872 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-03-20 13:29:33 +01:00
|
|
|
switch ($severity) {
|
2013-01-18 10:56:46 +01:00
|
|
|
case EVENT_CRIT_WARNING_OR_CRITICAL:
|
2014-09-01 15:23:45 +02:00
|
|
|
$sql_post .= "
|
|
|
|
AND (criticity = " . EVENT_CRIT_WARNING . " OR
|
|
|
|
criticity = " . EVENT_CRIT_CRITICAL . ")";
|
2013-01-18 10:56:46 +01:00
|
|
|
break;
|
|
|
|
case EVENT_CRIT_NOT_NORMAL:
|
|
|
|
$sql_post .= " AND criticity != " . EVENT_CRIT_NORMAL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$sql_post .= " AND criticity = $severity";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// In metaconsole mode the agent search is performed by name
|
2013-03-20 Miguel de Dios <miguel.dedios@artica.es>
* mobile/operation/events.php, mobile/include/ui.class.php,
mobile/index.php: added first version of events section.
* include/functions_incidents.php, include/functions_users.php,
include/functions.php, include/functions_groups.php,
include/functions_events.php, include/functions_html.php,
operation/events/events.build_table.php,
operation/events/events.build_query.php,
operation/events/events_list.php: some changes for interact with
mobile version.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7872 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-03-20 13:29:33 +01:00
|
|
|
if ($meta) {
|
|
|
|
if ($text_agent != __('All')) {
|
2013-01-18 10:56:46 +01:00
|
|
|
$sql_post .= " AND agent_name LIKE '%$text_agent%'";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch ($id_agent) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
// Agent doesnt exist. No results will returned
|
|
|
|
$sql_post .= " AND 1 = 0";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$sql_post .= " AND id_agente = " . $id_agent;
|
|
|
|
break;
|
|
|
|
}
|
2014-08-27 19:09:07 +02:00
|
|
|
}
|
|
|
|
|
2014-09-01 15:23:45 +02:00
|
|
|
if ($meta) {
|
|
|
|
//There is another filter.
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!empty($text_module)) {
|
|
|
|
$sql_post .= ' AND id_agentmodule IN (
|
|
|
|
SELECT id_agente_modulo
|
|
|
|
FROM tagente_modulo
|
|
|
|
WHERE nombre = "' . $text_module . '"
|
|
|
|
)';
|
|
|
|
}
|
2013-01-18 10:56:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($id_user_ack != "0")
|
|
|
|
$sql_post .= " AND id_usuario = '" . $id_user_ack . "'";
|
|
|
|
|
2014-10-09 13:50:05 +02:00
|
|
|
if (!isset($date_from)) {
|
|
|
|
$date_from = "";
|
|
|
|
}
|
|
|
|
if (!isset($date_to)) {
|
|
|
|
$date_to = "";
|
|
|
|
}
|
2013-01-18 10:56:46 +01:00
|
|
|
|
2014-05-20 16:40:43 +02:00
|
|
|
if (($date_from == '') && ($date_to == '')) {
|
|
|
|
if ($event_view_hr > 0) {
|
|
|
|
$unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR);
|
|
|
|
$sql_post .= " AND (utimestamp > " . $unixtime . ")";
|
|
|
|
}
|
2014-10-09 13:50:05 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-05-20 16:40:43 +02:00
|
|
|
if ($date_from != '') {
|
2014-10-09 13:50:05 +02:00
|
|
|
$udate_from = strtotime($date_from . " 00:00:00");
|
2014-05-20 16:40:43 +02:00
|
|
|
$sql_post .= " AND (utimestamp >= " . $udate_from . ")";
|
|
|
|
|
|
|
|
}
|
|
|
|
if ($date_to != '') {
|
2014-10-09 13:50:05 +02:00
|
|
|
$udate_to = strtotime($date_to . " 23:59:59");
|
2014-05-20 16:40:43 +02:00
|
|
|
$sql_post .= " AND (utimestamp <= " . $udate_to . ")";
|
|
|
|
}
|
2013-01-18 10:56:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//Search by tag
|
|
|
|
if (!empty($tag_with)) {
|
|
|
|
$sql_post .= ' AND ( ';
|
|
|
|
$first = true;
|
|
|
|
foreach ($tag_with as $id_tag) {
|
|
|
|
if ($first) $first = false;
|
|
|
|
else $sql_post .= " OR ";
|
2014-11-18 11:27:04 +01:00
|
|
|
$sql_post .= "tags = '" . tags_get_name($id_tag) . "'";
|
2013-01-18 10:56:46 +01:00
|
|
|
}
|
|
|
|
$sql_post .= ' ) ';
|
|
|
|
}
|
|
|
|
if (!empty($tag_without)) {
|
|
|
|
$sql_post .= ' AND ( ';
|
|
|
|
$first = true;
|
|
|
|
foreach ($tag_without as $id_tag) {
|
|
|
|
if ($first) $first = false;
|
2013-02-05 18:24:37 +01:00
|
|
|
else $sql_post .= " AND ";
|
2013-03-20 Miguel de Dios <miguel.dedios@artica.es>
* mobile/operation/events.php, mobile/include/ui.class.php,
mobile/index.php: added first version of events section.
* include/functions_incidents.php, include/functions_users.php,
include/functions.php, include/functions_groups.php,
include/functions_events.php, include/functions_html.php,
operation/events/events.build_table.php,
operation/events/events.build_query.php,
operation/events/events_list.php: some changes for interact with
mobile version.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7872 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-03-20 13:29:33 +01:00
|
|
|
|
2014-11-18 15:18:00 +01:00
|
|
|
$sql_post .= "tags <> '" . tags_get_name($id_tag) . "'";
|
2013-01-18 10:56:46 +01:00
|
|
|
}
|
|
|
|
$sql_post .= ' ) ';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Filter/Only alerts
|
|
|
|
if (isset($filter_only_alert)) {
|
|
|
|
if ($filter_only_alert == 0)
|
|
|
|
$sql_post .= " AND event_type NOT LIKE '%alert%'";
|
|
|
|
else if ($filter_only_alert == 1)
|
|
|
|
$sql_post .= " AND event_type LIKE '%alert%'";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tags ACLS
|
2013-07-17 17:58:15 +02:00
|
|
|
if ($id_group > 0 && in_array ($id_group, array_keys ($groups))) {
|
|
|
|
$group_array = (array) $id_group;
|
2013-01-18 10:56:46 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$group_array = array_keys($groups);
|
|
|
|
}
|
|
|
|
|
2014-12-03 10:27:27 +01:00
|
|
|
$tags_acls_condition = tags_get_acl_tags($id_user, $group_array, 'ER',
|
|
|
|
'event_condition', 'AND', '', $meta, array(), true); //FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)"
|
2013-01-18 10:56:46 +01:00
|
|
|
|
2014-08-25 11:02:45 +02:00
|
|
|
if (($tags_acls_condition != ERR_WRONG_PARAMETERS) && ($tags_acls_condition != ERR_ACL)&& ($tags_acls_condition != -110000)) {
|
|
|
|
$sql_post .= $tags_acls_condition;
|
|
|
|
}
|
2013-01-18 10:56:46 +01:00
|
|
|
|
|
|
|
// Metaconsole fitlers
|
2013-03-20 Miguel de Dios <miguel.dedios@artica.es>
* mobile/operation/events.php, mobile/include/ui.class.php,
mobile/index.php: added first version of events section.
* include/functions_incidents.php, include/functions_users.php,
include/functions.php, include/functions_groups.php,
include/functions_events.php, include/functions_html.php,
operation/events/events.build_table.php,
operation/events/events.build_query.php,
operation/events/events_list.php: some changes for interact with
mobile version.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7872 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-03-20 13:29:33 +01:00
|
|
|
if ($meta) {
|
2014-09-01 15:23:45 +02:00
|
|
|
$enabled_nodes = db_get_all_rows_sql('
|
|
|
|
SELECT id
|
|
|
|
FROM tmetaconsole_setup
|
|
|
|
WHERE disabled = 0');
|
2013-01-18 10:56:46 +01:00
|
|
|
|
2013-03-20 Miguel de Dios <miguel.dedios@artica.es>
* mobile/operation/events.php, mobile/include/ui.class.php,
mobile/index.php: added first version of events section.
* include/functions_incidents.php, include/functions_users.php,
include/functions.php, include/functions_groups.php,
include/functions_events.php, include/functions_html.php,
operation/events/events.build_table.php,
operation/events/events.build_query.php,
operation/events/events_list.php: some changes for interact with
mobile version.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7872 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-03-20 13:29:33 +01:00
|
|
|
if (empty($enabled_nodes)) {
|
2013-01-18 10:56:46 +01:00
|
|
|
$sql_post .= ' AND 1 = 0';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$enabled_nodes_id = array();
|
2013-03-20 Miguel de Dios <miguel.dedios@artica.es>
* mobile/operation/events.php, mobile/include/ui.class.php,
mobile/index.php: added first version of events section.
* include/functions_incidents.php, include/functions_users.php,
include/functions.php, include/functions_groups.php,
include/functions_events.php, include/functions_html.php,
operation/events/events.build_table.php,
operation/events/events.build_query.php,
operation/events/events_list.php: some changes for interact with
mobile version.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7872 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-03-20 13:29:33 +01:00
|
|
|
foreach ($enabled_nodes as $en) {
|
2013-01-18 10:56:46 +01:00
|
|
|
$enabled_nodes_id[] = $en['id'];
|
|
|
|
}
|
2014-09-01 15:23:45 +02:00
|
|
|
$sql_post .= ' AND server_id IN (' .
|
|
|
|
implode(',',$enabled_nodes_id) . ')';
|
2013-01-18 10:56:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|