2010-08-31 Sergio Martin <sergio.martin@artica.es>

* operation/search_agents.php
	operation/search_graphs.php
	operation/search_alerts.php
	operation/search_reports.php
	operation/search_maps.php
	operation/search_results.php
	operation/search_users.php: Restructured and fixed
	ACLs in the global search for bug 3053592



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3194 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2010-08-31 07:27:22 +00:00
parent 418905f04a
commit b36219ab38
8 changed files with 1031 additions and 786 deletions

View File

@ -1,3 +1,14 @@
2010-08-31 Sergio Martin <sergio.martin@artica.es>
* operation/search_agents.php
operation/search_graphs.php
operation/search_alerts.php
operation/search_reports.php
operation/search_maps.php
operation/search_results.php
operation/search_users.php: Restructured and fixed
ACLs in the global search for bug 3053592
2010-08-30 Sergio Martin <sergio.martin@artica.es>
* operation/agentes/alerts_status.php: Fixed the

View File

@ -0,0 +1,225 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// 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.
global $config;
$searchAgents = check_acl($config['id_user'], 0, "AR");
$selectNameUp = '';
$selectNameDown = '';
$selectOsUp = '';
$selectOsDown = '';
$selectIntervalUp = '';
$selectIntervalDown = '';
$selectGroupUp = '';
$selectGroupDown = '';
$selectLastContactUp = '';
$selectLastContactDown = '';
switch ($sortField) {
case 'name':
switch ($sort) {
case 'up':
$selectNameUp = $selected;
$order = array('field' => 'nombre', 'order' => 'ASC');
break;
case 'down':
$selectNameDown = $selected;
$order = array('field' => 'nombre', 'order' => 'DESC');
break;
}
break;
case 'os':
switch ($sort) {
case 'up':
$selectOsUp = $selected;
$order = array('field' => 'id_os', 'order' => 'ASC');
break;
case 'down':
$selectOsDown = $selected;
$order = array('field' => 'id_os', 'order' => 'DESC');
break;
}
break;
case 'interval':
switch ($sort) {
case 'up':
$selectIntervalUp = $selected;
$order = array('field' => 'intervalo', 'order' => 'ASC');
break;
case 'down':
$selectIntervalDown = $selected;
$order = array('field' => 'intervalo', 'order' => 'DESC');
break;
}
break;
case 'group':
switch ($sort) {
case 'up':
$selectGroupUp = $selected;
$order = array('field' => 'id_grupo', 'order' => 'ASC');
break;
case 'down':
$selectGroupDown = $selected;
$order = array('field' => 'id_grupo', 'order' => 'DESC');
break;
}
break;
case 'last_contact':
switch ($sort) {
case 'up':
$selectLastContactUp = $selected;
$order = array('field' => 'ultimo_contacto', 'order' => 'ASC');
break;
case 'down':
$selectLastContactDown = $selected;
$order = array('field' => 'ultimo_contacto', 'order' => 'DESC');
break;
}
break;
default:
$selectNameUp = $selected;
$selectNameDown = '';
$selectOsUp = '';
$selectOsDown = '';
$selectIntervalUp = '';
$selectIntervalDown = '';
$selectGroupUp = '';
$selectGroupDown = '';
$selectLastContactUp = '';
$selectLastContactDown = '';
$order = array('field' => 'nombre', 'order' => 'ASC');
break;
}
$agents = false;
if ($searchAgents) {
$sql = "SELECT id_agente, tagente.nombre, tagente.id_os, tagente.intervalo, tagente.id_grupo, tagente.disabled
FROM tagente
INNER JOIN tgrupo
ON tgrupo.id_grupo = tagente.id_grupo
WHERE tagente.nombre COLLATE utf8_general_ci LIKE '%" . $stringSearchSQL . "%' OR
tgrupo.nombre LIKE '%" . $stringSearchSQL . "%'
ORDER BY " . $order['field'] . " " . $order['order'] . "
LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$agents = process_sql($sql);
if($agents !== false) {
// ACLs check
$agents_id = array();
foreach($agents as $key => $agent){
if (!give_acl ($config["id_user"], $agent["id_grupo"], "AR")) {
unset($agents[$key]);
} else {
$agents_id[] = $agent["id_agente"];
}
}
if(!$agents_id) {
$agent_condition = "";
}else {
// Condition with the visible agents
$agent_condition = " AND id_agente IN (".implode(',',$agents_id).")";
}
$sql = "SELECT count(id_agente) AS count
FROM tagente
INNER JOIN tgrupo
ON tgrupo.id_grupo = tagente.id_grupo
WHERE (tagente.nombre COLLATE utf8_general_ci LIKE '%" . $stringSearchSQL . "%' OR
tgrupo.nombre LIKE '%" . $stringSearchSQL . "%')".$agent_condition;
$totalAgents = get_db_row_sql($sql);
$totalAgents = $totalAgents['count'];
}
}
if (!$agents) {
echo "<br><div class='nf'>" . __("Zero results found") . "</div>\n";
}
else {
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "98%";
$table->class = "databox";
$table->head = array ();
$table->head[0] = __('Agent') . ' ' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=name&sort=up"><img src="images/sort_up.png" style="' . $selectNameUp . '" /></a>' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=name&sort=down"><img src="images/sort_down.png" style="' . $selectNameDown . '" /></a>';
$table->head[1] = __('OS'). ' ' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=os&sort=up"><img src="images/sort_up.png" style="' . $selectOsUp . '" /></a>' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=os&sort=down"><img src="images/sort_down.png" style="' . $selectOsDown . '" /></a>';
$table->head[2] = __('Interval'). ' ' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=interval&sort=up"><img src="images/sort_up.png" style="' . $selectIntervalUp . '" /></a>' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=interval&sort=down"><img src="images/sort_down.png" style="' . $selectIntervalDown . '" /></a>';
$table->head[3] = __('Group'). ' ' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=group&sort=up"><img src="images/sort_up.png" style="' . $selectGroupUp . '" /></a>' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=group&sort=down"><img src="images/sort_down.png" style="' . $selectGroupDown . '" /></a>';
$table->head[4] = __('Modules');
$table->head[5] = __('Status');
$table->head[6] = __('Alerts');
$table->head[7] = __('Last contact'). ' ' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=last_contact&sort=up"><img src="images/sort_up.png" style="' . $selectLastContactUp . '" /></a>' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=last_contact&sort=down"><img src="images/sort_down.png" style="' . $selectLastContactDown . '" /></a>';
$table->align = array ();
$table->align[0] = "left";
$table->align[1] = "center";
$table->align[2] = "center";
$table->align[3] = "center";
$table->align[4] = "center";
$table->align[5] = "center";
$table->align[6] = "center";
$table->align[7] = "right";
$table->data = array ();
foreach ($agents as $agent) {
$agent_info = get_agent_module_info ($agent["id_agente"]);
$modulesCell = '<b>'. $agent_info["modules"] . '</b>';
if ($agent_info["monitor_normal"] > 0)
$modulesCell .= '</b> : <span class="green">'.$agent_info["monitor_normal"].'</span>';
if ($agent_info["monitor_warning"] > 0)
$modulesCell .= ' : <span class="yellow">'.$agent_info["monitor_warning"].'</span>';
if ($agent_info["monitor_critical"] > 0)
$modulesCell .= ' : <span class="red">'.$agent_info["monitor_critical"].'</span>';
if ($agent_info["monitor_unknown"] > 0)
$modulesCell .= ' : <span class="grey">'.$agent_info["monitor_unknown"].'</span>';
if ($agent['disabled']) {
$cellName = "<em>" . print_agent_name ($agent["id_agente"], true, "upper") .print_help_tip(__('Disabled'), true) . "</em>";
}
else {
$cellName = print_agent_name ($agent["id_agente"], true, "upper");
}
array_push($table->data, array(
$cellName,
print_os_icon ($agent["id_os"], false, true),
$agent['intervalo'],
print_group_icon ($agent["id_grupo"], true),
$modulesCell,
$agent_info["status_img"],
$agent_info["alert_img"],
print_timestamp ($agent_info["last_contact"], true)));
}
echo "<br />";pagination ($totalAgents);
print_table ($table); unset($table);
pagination ($totalAgents);
}
?>

View File

@ -0,0 +1,220 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// 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.
global $config;
include_once('include/functions_alerts.php');
$searchAlerts = check_acl($config['id_user'], 0, "AR");
$selectDisabledUp = '';
$selectDisabledDown = '';
$selectAgentUp = '';
$selectAgentDown = '';
$selectModuleUp = '';
$selectModuleDown = '';
$selectTemplateUp = '';
$selectTemplateDown = '';
switch ($sortField) {
case 'disabled':
switch ($sort) {
case 'up':
$selectAgentUp = $selected;
$order = array('field' => 'disabled', 'order' => 'ASC');
break;
case 'down':
$selectAgentDown = $selected;
$order = array('field' => 'disabled', 'order' => 'DESC');
break;
}
break;
case 'agent':
switch ($sort) {
case 'up':
$selectAgentUp = $selected;
$order = array('field' => 'agent_name', 'order' => 'ASC');
break;
case 'down':
$selectAgentDown = $selected;
$order = array('field' => 'agent_name', 'order' => 'DESC');
break;
}
break;
case 'module':
switch ($sort) {
case 'up':
$selectModuleUp = $selected;
$order = array('field' => 'module_name', 'order' => 'ASC');
break;
case 'down':
$selectModuleDown = $selected;
$order = array('field' => 'module_name', 'order' => 'DESC');
break;
}
break;
case 'template':
switch ($sort) {
case 'up':
$selectTemplateUp = $selected;
$order = array('field' => 'template_name', 'order' => 'ASC');
break;
case 'down':
$selectTemplateDown = $selected;
$order = array('field' => 'template_name', 'order' => 'DESC');
break;
}
break;
default:
$selectDisabledUp = '';
$selectDisabledDown = '';
$selectAgentUp = $selected;
$selectAgentDown = '';
$selectModuleUp = '';
$selectModuleDown = '';
$selectTemplateUp = '';
$selectTemplateDown = '';
$order = array('field' => 'agent_name', 'order' => 'ASC');
break;
}
$alerts = false;
if($searchAlerts) {
$agents = array_keys(get_group_agents(array_keys(get_user_groups($config["id_user"], 'AR', false))));
/*$whereAlerts = ' AND (t2.nombre LIKE "%'.$stringSearchSQL.'%" OR t3.nombre LIKE "%'.$stringSearchSQL.'%"
OR t4.name LIKE "%'.$stringSearchSQL.'%") ';*/
$whereAlerts = false;
$alertsraw = get_agent_alerts_simple ($agents, "all_enabled", array('offset' => get_parameter ('offset',0), 'limit' => $config['block_size'], 'order' => $order['field'] . " " . $order['order']), $whereAlerts);
$stringSearchPHP = substr($stringSearchSQL,1,strlen($stringSearchSQL)-2);
$alerts = array();
foreach($alertsraw as $key => $alert){
$finded = false;
$alerts[$key]['disabled'] = $alert['disabled'];
$alerts[$key]['id_agente'] = get_agentmodule_agent($alert['id_agent_module']);
$alerts[$key]['agent_name'] = $alert['agent_name'];
$alerts[$key]['module_name'] = $alert['agent_module_name'];
$alerts[$key]['template_name'] = $alert['template_name'];
$actions = get_alert_agent_module_actions($alert['id']);
// Check substring into agent, module, template and action names
if(strpos($alert['agent_name'], $stringSearchPHP) !== false) {
$finded = true;
}
if(!$finded) {
if(strpos($alert['agent_module_name'], $stringSearchPHP) !== false) {
$finded = true;
}
}
if(!$finded) {
if(strpos($alert['template_name'], $stringSearchPHP) !== false) {
$finded = true;
}
}
foreach($actions as $action) {
$actions_name[] = $action['name'];
if(!$finded) {
if(strpos($action['name'], $stringSearchPHP) !== false) {
$finded = true;
}
}
}
$alerts[$key]['actions'] = implode(',',$actions_name);
if(!$finded) {
unset($alerts[$key]);
}
}
$totalAlerts = count($alerts);
}
if ($alerts === false || $totalAlerts == 0) {
echo "<br><div class='nf'>" . __("Zero results found") . "</div>\n";
}
else {
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "98%";
$table->class = "databox";
$table->head = array ();
$table->head[0] = '' . ' ' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=disabled&sort=up"><img src="images/sort_up.png" style="' . $selectDisabledUp . '" /></a>' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=disabled&sort=down"><img src="images/sort_down.png" style="' . $selectDisabledDown . '" /></a>';
$table->head[1] = __('Agent') . ' ' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=agent&sort=up"><img src="images/sort_up.png" style="' . $selectAgentUp . '" /></a>' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=agent&sort=down"><img src="images/sort_down.png" style="' . $selectAgentDown . '" /></a>';
$table->head[2] = __('Module') . ' ' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=module&sort=up"><img src="images/sort_up.png" style="' . $selectModuleUp . '" /></a>' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=module&sort=down"><img src="images/sort_down.png" style="' . $selectModuleDown . '" /></a>';
$table->head[3] = __('Template') . ' ' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=template&sort=up"><img src="images/sort_up.png" style="' . $selectTemplateUp . '" /></a>' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=template&sort=down"><img src="images/sort_down.png" style="' . $selectTemplateDown . '" /></a>';
$table->head[4] = __('Action');
$table->align = array ();
$table->align[0] = "center";
$table->align[1] = "left";
$table->align[2] = "left";
$table->align[3] = "left";
$table->align[4] = "left";
$table->valign = array ();
$table->valign[0] = "top";
$table->valign[1] = "top";
$table->valign[2] = "top";
$table->valign[3] = "top";
$table->valign[4] = "top";
$table->data = array ();
foreach ($alerts as $alert) {
if ($alert['disabled'])
$disabledCell = print_image ('images/lightbulb_off.png', true, array('title' => 'disable', 'alt' => 'disable'));
else
$disabledCell = print_image ('images/lightbulb.png', true, array('alt' => 'enable', 'title' => 'enable'));
$actionCell = '';
if (strlen($alert["actions"]) > 0) {
$arrayActions = explode(',', $alert["actions"]);
$actionCell = '<ul class="action_list">';
foreach ($arrayActions as $action)
$actionCell .= '<li><div><span class="action_name">' . $action . '</span></div><br /></li>';
$actionCell .= '</ul>';
}
array_push($table->data, array(
$disabledCell,
print_agent_name ($alert["id_agente"], true, "upper"),
$alert["module_name"],
$alert["template_name"],$actionCell
));
}
echo "<br />";pagination ($totalAlerts);
print_table ($table); unset($table);
pagination ($totalAlerts);
}
?>

View File

@ -0,0 +1,84 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// 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.
global $config;
include_once('include/functions_custom_graphs.php');
$searchGraphs = check_acl($config["id_user"], 0, "IR");
$graphs = false;
if ($searchGraphs) {
//Check ACL
$usergraphs = get_user_custom_graphs($config['id_user'], true);
$usergraphs_id = array_keys($usergraphs);
if(!$usergraphs_id){
$graphs_condition = " AND 1<>1";
}else {
$graphs_condition = " AND id_graph IN (".implode(',',$usergraphs_id).")";
}
$sql = "SELECT id_graph, name, description FROM tgraph WHERE (name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%')".$graphs_condition.
" LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$graphs = process_sql($sql);
if($graphs !== false) {
$sql = "SELECT COUNT(id_graph) AS count FROM tgraph WHERE name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%'";
$totalGraphs = get_db_row_sql($sql);
$totalGraphs = $totalGraphs['count'];
}
}
if ($graphs === false) {
echo "<br><div class='nf'>" . __("Zero results found") . "</div>\n";
}
else {
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "98%";
$table->class = "databox";
$table->head = array ();
$table->head[0] = __('Graph name');
$table->head[1] = __('Description');
$table->data = array ();
foreach ($graphs as $graph) {
array_push($table->data, array(
"<a href='?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id=" .
$graph['id_graph'] . "'>" . $graph['name'] . "</a>",
$graph['description']
));
}
echo "<br />";pagination ($totalGraphs);
print_table ($table); unset($table);
pagination ($totalGraphs);
}
switch ($searchTab) {
case 'agents':
require_once('search_agents.php');
break;
case 'users':
require_once('search_users.php');
break;
case 'alerts':
require_once('search_alerts.php');
break;
}
?>

View File

@ -0,0 +1,82 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// 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.
global $config;
$searchMaps = check_acl($config["id_user"], 0, "IR");
$maps = false;
if ($searchMaps) {
$sql = "SELECT t1.id, t1.name, t1.id_group,
(SELECT COUNT(*) FROM tlayout_data AS t2 WHERE t2.id_layout = t1.id) AS count
FROM tlayout AS t1 WHERE t1.name LIKE '%" . $stringSearchSQL . "%'
LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$maps = process_sql($sql);
if($maps !== false) {
$maps_id = array();
foreach($maps as $key => $map) {
if (!give_acl ($config["id_user"], $map["id_group"], "AR")) {
unset($maps[$key]);
}else {
$maps_id[] = $map['id'];
}
}
if(!$maps_id) {
$maps_condition = "";
}else {
// Condition with the visible agents
$maps_condition = " AND id IN (\"".implode('","',$maps_id)."\")";
}
$sql = "SELECT COUNT(id) AS count FROM tlayout WHERE name LIKE '%" . $stringSearchSQL . "%'".$maps_condition;
$totalMaps = get_db_row_sql($sql);
$totalMaps = $totalMaps['count'];
}
}
if ($maps === false) {
echo "<br><div class='nf'>" . __("Zero results found") . "</div>\n";
}
else {
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "98%";
$table->class = "databox";
$table->head = array ();
$table->head[0] = __('Name');
$table->head[1] = __('Group');
$table->head[2] = __('Elements');
$table->align = array ();
$table->align[1] = "center";
$table->align[2] = "center";
$table->data = array ();
foreach ($maps as $map) {
array_push($table->data, array(
"<a href='?sec=visualc&sec2=operation/visual_console/render_view&id=" .
$map['id'] . "'>" . $map['name'] . "</a>",
print_group_icon ($layout["id_group"], true) . "&nbsp;" . get_group_name ($layout["id_group"]),
$map['count']
));
}
echo "<br />";pagination ($totalMaps);
print_table ($table); unset($table);
pagination ($totalMaps);
}
?>

View File

@ -0,0 +1,97 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// 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.
global $config;
include_once('include/functions_reports.php');
$linkReport = false;
$searchReports = check_acl ($config["id_user"], 0, "IR");
if (give_acl ($config['id_user'], 0, "IW")) {
$linkReport = true;
}
$reports = false;
//Check ACL
$userreports = get_reports();
$userreports_id = array();
foreach($userreports as $userreport) {
$userreports_id[] = $userreport['id_report'];
}
if(!$userreports_id){
$reports_condition = " AND 1<>1";
}else {
$reports_condition = " AND id_report IN (".implode(',',$userreports_id).")";
}
$reports = false;
if($searchReports) {
$sql = "SELECT id_report, name, description FROM treport WHERE name LIKE '%" . $stringSearchSQL . "%'".$reports_condition.
" LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$reports = process_sql($sql);
$sql = "SELECT COUNT(id_report) AS count FROM treport WHERE name LIKE '%" . $stringSearchSQL . "%'";
$totalReports = get_db_row_sql($sql);
$totalReports = $totalReports['count'];
}
if ($reports === false) {
echo "<br><div class='nf'>" . __("Zero results found") . "</div>\n";
}
else {
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "98%";
$table->class = "databox";
$table->head = array ();
$table->head[0] = __('Report name');
$table->head[1] = __('Description');
$table->head[2] = __('HTML');
$table->head[3] = __('XML');
enterprise_hook ('load_custom_reporting_1');
$table->align = array ();
$table->align[2] = "center";
$table->align[3] = "center";
$table->align[4] = "center";
$table->data = array ();
foreach ($reports as $report) {
if($linkReport) {
$reportstring = "<a href='?sec=greporting&sec2=godmode/reporting/reporting_builder&action=edit&id_report=" . $report['id_report'] . "' title='" . __("Edit") . "'>" . $report['name'] . "</a>";
} else {
$reportstring = $report['name'];
}
$data = array(
$reportstring,
$report['description'],
'<a href="index.php?sec=reporting&sec2=operation/reporting/reporting_viewer&id='.$report['id_report'].'"><img src="images/reporting.png" /></a>',
'<a href="ajax.php?page=operation/reporting/reporting_xml&id='.$report['id_report'].'"><img src="images/database_lightning.png" /></a>'
);
enterprise_hook ('load_custom_reporting_2');
array_push($table->data, $data);
}
echo "<br />";pagination ($totalReports);
print_table ($table); unset($table);
pagination ($totalReports);
}
?>

View File

@ -2,7 +2,7 @@
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -18,24 +18,29 @@ require_once ("include/functions_reporting.php");
// Load enterprise extensions
enterprise_include ('operation/reporting/custom_reporting.php');
$searchGraphs = $searchAgents = (check_acl ($config['id_user'], 0, "AW") || check_acl ($config['id_user'], 0, "AR"));
$linkEditUser = check_acl ($config['id_user'], 0, "UM");
$searchMaps = give_acl ($config["id_user"], 0, "AR");
$searchAgents = $searchAlerts = check_acl($config['id_user'], 0, "AR");
$searchUsers = check_acl($config['id_user'], 0, "UM");
$searchMaps = $searchReports = $searchGraphs = check_acl($config["id_user"], 0, "IR");
$arrayKeywords = explode(' ', $config['search_keywords']);
$temp = array();
foreach($arrayKeywords as $keyword)
array_push($temp, "%" . $keyword . "%");
array_push($temp, "%" . safe_input($keyword) . "%");
$stringSearchSQL = implode(" ",$temp);
if ($config['search_category'] == "all") $searchTab = "agents";
else $searchTab = $config['search_category'];
if ($config['search_category'] == "all")
$searchTab = "agents";
else
$searchTab = $config['search_category'];
//INI SECURITY ACL
if ((!$searchAgents) && ($searchTab == 'agents')) $searchTab = "users";
if ((!$searchGraphs) && ($searchTab == 'graphs')) $searchTab = "users";
if ((!$searchMaps) && ($searchTab == 'maps')) $searchTab = "users";
if((!$searchAgents && !$searchUsers && !$searchMaps) ||
(!$searchUsers && $searchTab == 'users') ||
(!$searchAgents && ($searchTab == 'agents' || $searchTab == 'alerts')) ||
(!$searchGraphs && ($searchTab == 'graphs' || $searchTab == 'maps' || $searchTab == 'reports'))){
$searchTab = "";
}
//END SECURITY ACL
$offset = get_parameter ('offset',0);
@ -44,785 +49,73 @@ $order = null;
$sortField = get_parameter('sort_field');
$sort = get_parameter('sort', 'none');
$selected = 'border: 1px solid black;';
if($searchAgents) {
$agents_tab = array('text' => "<a href='index.php?search_category=agents&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
. print_image ("images/bricks.png", true, array ("title" => __('Agents'))) . "</a>", 'active' => $searchTab == "agents");
}else {
$agents_tab = '';
}
if($searchUsers) {
$users_tab = array('text' => "<a href='index.php?search_category=users&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
. print_image ("images/group.png", true, array ("title" => __('Users'))) . "</a>", 'active' => $searchTab == "users");
}else {
$users_tab = '';
}
if($searchAlerts) {
$alerts_tab = array('text' => "<a href='index.php?search_category=alerts&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
. print_image ("images/god2.png", true, array ("title" => __('Alerts'))) . "</a>", 'active' => $searchTab == "alerts");
}else {
$alerts_tab = '';
}
if($searchGraphs) {
$graphs_tab = array('text' => "<a href='index.php?search_category=graphs&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
. print_image ("images/chart_curve.png", true, array ("title" => __('Graphs'))) . "</a>", 'active' => $searchTab == "graphs");
}else {
$graphs_tab = '';
}
if($searchReports) {
$reports_tab = array('text' => "<a href='index.php?search_category=reports&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
. print_image ("images/reporting.png", true, array ("title" => __('Reports'))) . "</a>", 'active' => $searchTab == "reports");
}else {
$reports_tab = '';
}
if($searchMaps) {
$maps_tab = array('text' => "<a href='index.php?search_category=maps&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
. print_image ("images/camera.png", true, array ("title" => __('Maps'))) . "</a>", 'active' => $searchTab == "maps");
}else {
$maps_tab = '';
}
$onheader = array('agents' => $agents_tab, 'users' => $users_tab,
'alerts' => $alerts_tab, 'graphs' => $graphs_tab,
'reports' => $reports_tab, 'maps' => $maps_tab);
print_page_header (__("Search").": \"".$config['search_keywords']."\"", "images/zoom.png", false, "", false, $onheader);
switch ($searchTab) {
case 'agents':
$selectNameUp = '';
$selectNameDown = '';
$selectOsUp = '';
$selectOsDown = '';
$selectIntervalUp = '';
$selectIntervalDown = '';
$selectGroupUp = '';
$selectGroupDown = '';
$selectLastContactUp = '';
$selectLastContactDown = '';
switch ($sortField) {
case 'name':
switch ($sort) {
case 'up':
$selectNameUp = $selected;
$order = array('field' => 'nombre', 'order' => 'ASC');
break;
case 'down':
$selectNameDown = $selected;
$order = array('field' => 'nombre', 'order' => 'DESC');
break;
}
break;
case 'os':
switch ($sort) {
case 'up':
$selectOsUp = $selected;
$order = array('field' => 'id_os', 'order' => 'ASC');
break;
case 'down':
$selectOsDown = $selected;
$order = array('field' => 'id_os', 'order' => 'DESC');
break;
}
break;
case 'interval':
switch ($sort) {
case 'up':
$selectIntervalUp = $selected;
$order = array('field' => 'intervalo', 'order' => 'ASC');
break;
case 'down':
$selectIntervalDown = $selected;
$order = array('field' => 'intervalo', 'order' => 'DESC');
break;
}
break;
case 'group':
switch ($sort) {
case 'up':
$selectGroupUp = $selected;
$order = array('field' => 'id_grupo', 'order' => 'ASC');
break;
case 'down':
$selectGroupDown = $selected;
$order = array('field' => 'id_grupo', 'order' => 'DESC');
break;
}
break;
case 'last_contact':
switch ($sort) {
case 'up':
$selectLastContactUp = $selected;
$order = array('field' => 'ultimo_contacto', 'order' => 'ASC');
break;
case 'down':
$selectLastContactDown = $selected;
$order = array('field' => 'ultimo_contacto', 'order' => 'DESC');
break;
}
break;
default:
$selectNameUp = $selected;
$selectNameDown = '';
$selectOsUp = '';
$selectOsDown = '';
$selectIntervalUp = '';
$selectIntervalDown = '';
$selectGroupUp = '';
$selectGroupDown = '';
$selectLastContactUp = '';
$selectLastContactDown = '';
$order = array('field' => 'nombre', 'order' => 'ASC');
break;
}
require_once('search_agents.php');
break;
case 'users':
$selectUserIDUp = '';
$selectUserIDDown = '';
$selectNameUp = '';
$selectNameDown = '';
$selectEmailUp = '';
$selectEmailDown = '';
$selectLastContactUp = '';
$selectLastContactDown = '';
$selectProfileUp = '';
$selectProfileDown = '';
switch ($sortField) {
case 'id_user':
switch ($sort) {
case 'up':
$selectUserIDUp = $selected;
$order = array('field' => 'id_user', 'order' => 'ASC');
break;
case 'down':
$selectUserIDDown = $selected;
$order = array('field' => 'id_user', 'order' => 'DESC');
break;
}
break;
case 'name':
switch ($sort) {
case 'up':
$selectNameUp = $selected;
$order = array('field' => 'fullname', 'order' => 'ASC');
break;
case 'down':
$selectNameDown = $selected;
$order = array('field' => 'fullname', 'order' => 'DESC');
break;
}
break;
case 'email':
switch ($sort) {
case 'up':
$selectLastContactUp = $selected;
$order = array('field' => 'email', 'order' => 'ASC');
break;
case 'down':
$selectEmailDown = $selected;
$order = array('field' => 'email', 'order' => 'DESC');
break;
}
break;
case 'last_contact':
switch ($sort) {
case 'up':
$selectLastContactUp = $selected;
$order = array('field' => 'last_connect', 'order' => 'ASC');
break;
case 'down':
$selectLastContactDown = $selected;
$order = array('field' => 'last_connect', 'order' => 'DESC');
break;
}
break;
case 'last_contact':
switch ($sort) {
case 'up':
$selectLastContactUp = $selected;
$order = array('field' => 'last_connect', 'order' => 'ASC');
break;
case 'down':
$selectLastContactDown = $selected;
$order = array('field' => 'last_connect', 'order' => 'DESC');
break;
}
break;
case 'profile':
switch ($sort) {
case 'up':
$selectProfileUp = $selected;
$order = array('field' => 'is_admin', 'order' => 'ASC');
break;
case 'down':
$selectProfileDown = $selected;
$order = array('field' => 'is_admin', 'order' => 'DESC');
break;
}
break;
default:
$selectUserIDUp = $selected;
$selectUserIDDown = '';
$selectNameUp = '';
$selectNameDown = '';
$selectEmailUp = '';
$selectEmailDown = '';
$selectLastContactUp = '';
$selectLastContactDown = '';
$selectProfileUp = '';
$selectProfileDown = '';
$order = array('field' => 'id_user', 'order' => 'ASC');
break;
}
require_once('search_users.php');
break;
case 'alerts':
require_once('search_alerts.php');
break;
case 'graphs':
require_once('search_graphs.php');
break;
case 'reports':
require_once('search_reports.php');
break;
case 'maps':
require_once('search_maps.php');
break;
case 'alerts':
$selectDisabledUp = '';
$selectDisabledDown = '';
$selectAgentUp = '';
$selectAgentDown = '';
$selectModuleUp = '';
$selectModuleDown = '';
$selectTemplateUp = '';
$selectTemplateDown = '';
switch ($sortField) {
case 'disabled':
switch ($sort) {
case 'up':
$selectAgentUp = $selected;
$order = array('field' => 'disabled', 'order' => 'ASC');
break;
case 'down':
$selectAgentDown = $selected;
$order = array('field' => 'disabled', 'order' => 'DESC');
break;
}
break;
case 'agent':
switch ($sort) {
case 'up':
$selectAgentUp = $selected;
$order = array('field' => 'agent_name', 'order' => 'ASC');
break;
case 'down':
$selectAgentDown = $selected;
$order = array('field' => 'agent_name', 'order' => 'DESC');
break;
}
break;
case 'module':
switch ($sort) {
case 'up':
$selectModuleUp = $selected;
$order = array('field' => 'module_name', 'order' => 'ASC');
break;
case 'down':
$selectModuleDown = $selected;
$order = array('field' => 'module_name', 'order' => 'DESC');
break;
}
break;
case 'template':
switch ($sort) {
case 'up':
$selectTemplateUp = $selected;
$order = array('field' => 'template_name', 'order' => 'ASC');
break;
case 'down':
$selectTemplateDown = $selected;
$order = array('field' => 'template_name', 'order' => 'DESC');
break;
}
break;
default:
$selectDisabledUp = '';
$selectDisabledDown = '';
$selectAgentUp = $selected;
$selectAgentDown = '';
$selectModuleUp = '';
$selectModuleDown = '';
$selectTemplateUp = '';
$selectTemplateDown = '';
$order = array('field' => 'agent_name', 'order' => 'ASC');
break;
}
break;
}
$agents = false;
if ($searchTab == 'agents') {
if ($searchAgents) {
$sql = "SELECT id_agente, tagente.nombre, tagente.id_os, tagente.intervalo, tagente.id_grupo, tagente.disabled
FROM tagente
INNER JOIN tgrupo
ON tgrupo.id_grupo = tagente.id_grupo
WHERE tagente.nombre COLLATE utf8_general_ci LIKE '%" . $stringSearchSQL . "%' OR
tgrupo.nombre LIKE '%" . $stringSearchSQL . "%'
ORDER BY " . $order['field'] . " " . $order['order'] . "
LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$agents = process_sql($sql);
$sql = "SELECT count(id_agente) AS count
FROM tagente
INNER JOIN tgrupo
ON tgrupo.id_grupo = tagente.id_grupo
WHERE tagente.nombre COLLATE utf8_general_ci LIKE '%" . $stringSearchSQL . "%' OR
tgrupo.nombre LIKE '%" . $stringSearchSQL . "%'";
$totalAgents = get_db_row_sql($sql);
$totalAgents = $totalAgents['count'];
}
}
$users = false;
if ($searchTab == 'users') {
$sql = "SELECT id_user, fullname, firstname, lastname, middlename, email, last_connect, is_admin, comments FROM tusuario
WHERE fullname LIKE '%" . $stringSearchSQL . "%' OR
firstname LIKE '%" . $stringSearchSQL . "%' OR
lastname LIKE '%" . $stringSearchSQL . "%' OR
middlename LIKE '%" . $stringSearchSQL . "%' OR
email LIKE '%" . $stringSearchSQL . "%'
ORDER BY " . $order['field'] . " " . $order['order'] . "
LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$users = process_sql($sql);
$sql = "SELECT COUNT(id_user) AS count FROM tusuario
WHERE fullname LIKE '%" . $stringSearchSQL . "%' OR
firstname LIKE '%" . $stringSearchSQL . "%' OR
lastname LIKE '%" . $stringSearchSQL . "%' OR
middlename LIKE '%" . $stringSearchSQL . "%' OR
email LIKE '%" . $stringSearchSQL . "%'";
$totalUsers = get_db_row_sql($sql);
$totalUsers = $totalUsers['count'];
}
$alerts = false;
if ($searchTab == 'alerts') {
$sql = "SELECT t1.disabled, t3.id_agente, t3.nombre AS agent_name, t2.nombre AS module_name, t4.name AS template_name,
(SELECT GROUP_CONCAT(t6.name)
FROM talert_template_module_actions AS t5
INNER JOIN talert_actions AS t6 ON t6.id = t5.id_alert_action
WHERE t5.id_alert_template_module = t1.id) AS actions
FROM talert_template_modules AS t1
INNER JOIN tagente_modulo AS t2
ON t1.id_agent_module = t2.id_agente_modulo
INNER JOIN tagente AS t3
ON t2.id_agente = t3.id_agente
INNER JOIN talert_templates AS t4
ON t1.id_alert_template = t4.id
ORDER BY " . $order['field'] . " " . $order['order'] . "
LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$alerts = process_sql($sql);
$sql = "SELECT COUNT(t1.id) AS count
FROM talert_template_modules AS t1
INNER JOIN tagente_modulo AS t2
ON t1.id_agent_module = t2.id_agente_modulo
INNER JOIN tagente AS t3
ON t2.id_agente = t3.id_agente
INNER JOIN talert_templates AS t4
ON t1.id_alert_template = t4.id";
$totalAlerts = get_db_row_sql($sql);
$totalAlerts = $totalAlerts['count'];
}
$graphs = false;
if ($searchTab == 'graphs') {
if ($searchGraphs) {
$sql = "SELECT id_graph, name, description FROM tgraph WHERE name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%'
LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$graphs = process_sql($sql);
$sql = "SELECT COUNT(id_graph) AS count FROM tgraph WHERE name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%'";
$totalGraphs = get_db_row_sql($sql);
$totalGraphs = $totalGraphs['count'];
}
}
$reports = false;
if (($config['search_category'] == 'all') || ($config['search_category'] == 'reports')) {
$sql = "SELECT id_report, name, description FROM treport WHERE name LIKE '%" . $stringSearchSQL . "%'
LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$reports = process_sql($sql);
$sql = "SELECT COUNT(id_report) AS count FROM treport WHERE name LIKE '%" . $stringSearchSQL . "%'";
$totalReports = get_db_row_sql($sql);
$totalReports = $totalReports['count'];
}
$maps = false;
if (($config['search_category'] == 'all') || ($config['search_category'] == 'maps')) {
if ($searchMaps) {
$sql = "SELECT t1.id, t1.name, t1.id_group,
(SELECT COUNT(*) FROM tlayout_data AS t2 WHERE t2.id_layout = t1.id) AS count
FROM tlayout AS t1 WHERE t1.name LIKE '%" . $stringSearchSQL . "%'
LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$maps = process_sql($sql);
$sql = "SELECT COUNT(id) AS count FROM tlayout WHERE name LIKE '%" . $stringSearchSQL . "%'";
$totalMaps = get_db_row_sql($sql);
$totalMaps = $totalMaps['count'];
}
}
///////// INI MENU AND TABS /////////////
$img_style = array ("class" => "top", "width" => 16);
echo "
<div id='menu_tab_frame_view'>
<div id='menu_tab_left'>
<ul class='mn'>
<li class='view'>" . __('Search') . ": \"" . $config['search_keywords'] . "\"</li>
</ul>
</div>
<div id='menu_tab'>
<ul class='mn'>";
if ($searchAgents)
{
if ($searchTab == "agents")
echo "<li class='nomn_high'>";
else
echo "<li class='nomn'>";
echo "<a href='?search_category=agents&keywords=".$config['search_keywords']."&head_search_keywords=Search'>";
print_image ("images/bricks.png", false, $img_style);
echo "&nbsp;".__('Agents')."</a>";
echo "</li>";
}
if ($searchTab == "users")
echo "<li class='nomn_high'>";
else
echo "<li class='nomn'>";
echo "<a href='?search_category=users&keywords=".$config['search_keywords']. "&head_search_keywords=Search'> ";
print_image ("images/group.png", false, $img_style);
echo "&nbsp;".__('Users')."</a>";
echo "</li>";
if ($searchTab == "alerts")
echo "<li class='nomn_high'>";
else
echo "<li class='nomn'>";
echo "<a href='?search_category=alerts&keywords=".$config['search_keywords']."&head_search_keywords=Search'> ";
print_image ("images/god2.png", false, $img_style);
echo "&nbsp;".__('Alerts')."</a>";
echo "</li>";
if ($searchGraphs)
{
if ($searchTab == "graphs")
echo "<li class='nomn_high'>";
else
echo "<li class='nomn'>";
echo "<a href='?search_category=graphs&keywords=".$config['search_keywords']."&head_search_keywords=Search'> ";
print_image ("images/chart_curve.png", false, $img_style);
echo "&nbsp;".__('Graphs'). "</a>";
echo "</li>";
}
if ($searchTab == "reports")
echo "<li class='nomn_high'>";
else
echo "<li class='nomn'>";
echo "<a href='?search_category=reports&keywords=".$config['search_keywords']."&head_search_keywords=Search'> ";
print_image ("images/reporting.png", false, $img_style);
echo "&nbsp;".__('Reports')."</a>";
echo "</li>";
if ($searchMaps)
{
if ($searchTab == "maps")
echo "<li class='nomn_high'>";
else
echo "<li class='nomn'>";
echo "<a href='?search_category=maps&keywords=".$config['search_keywords']."&head_search_keywords=Search'> ";
print_image ("images/camera.png", false, $img_style);
echo "&nbsp;".__('Maps')."</a>";
echo "</li>";
}
echo "</ul>
</div>
</div>";
echo "<div style='height: 25px'> </div>";
///////// END MENU AND TABS /////////////
if (($agents === false) && ($users === false) && ($alerts === false) && ($graphs === false)
&& ($reports === false) && ($maps === false)) {
echo "<br><div class='nf'>" . __("Zero results found") . "</div>\n";
}
else {
if ($agents !== false) {
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "98%";
$table->class = "databox";
$table->head = array ();
$table->head[0] = __('Agent') . ' ' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=name&sort=up"><img src="images/sort_up.png" style="' . $selectNameUp . '" /></a>' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=name&sort=down"><img src="images/sort_down.png" style="' . $selectNameDown . '" /></a>';
$table->head[1] = __('OS'). ' ' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=os&sort=up"><img src="images/sort_up.png" style="' . $selectOsUp . '" /></a>' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=os&sort=down"><img src="images/sort_down.png" style="' . $selectOsDown . '" /></a>';
$table->head[2] = __('Interval'). ' ' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=interval&sort=up"><img src="images/sort_up.png" style="' . $selectIntervalUp . '" /></a>' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=interval&sort=down"><img src="images/sort_down.png" style="' . $selectIntervalDown . '" /></a>';
$table->head[3] = __('Group'). ' ' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=group&sort=up"><img src="images/sort_up.png" style="' . $selectGroupUp . '" /></a>' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=group&sort=down"><img src="images/sort_down.png" style="' . $selectGroupDown . '" /></a>';
$table->head[4] = __('Modules');
$table->head[5] = __('Status');
$table->head[6] = __('Alerts');
$table->head[7] = __('Last contact'). ' ' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=last_contact&sort=up"><img src="images/sort_up.png" style="' . $selectLastContactUp . '" /></a>' .
'<a href="index.php?search_category=agents&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=last_contact&sort=down"><img src="images/sort_down.png" style="' . $selectLastContactDown . '" /></a>';
$table->align = array ();
$table->align[0] = "left";
$table->align[1] = "center";
$table->align[2] = "center";
$table->align[3] = "center";
$table->align[4] = "center";
$table->align[5] = "center";
$table->align[6] = "center";
$table->align[7] = "right";
$table->data = array ();
foreach ($agents as $agent) {
$agent_info = get_agent_module_info ($agent["id_agente"]);
$modulesCell = '<b>'. $agent_info["modules"] . '</b>';
if ($agent_info["monitor_normal"] > 0)
$modulesCell .= '</b> : <span class="green">'.$agent_info["monitor_normal"].'</span>';
if ($agent_info["monitor_warning"] > 0)
$modulesCell .= ' : <span class="yellow">'.$agent_info["monitor_warning"].'</span>';
if ($agent_info["monitor_critical"] > 0)
$modulesCell .= ' : <span class="red">'.$agent_info["monitor_critical"].'</span>';
if ($agent_info["monitor_unknown"] > 0)
$modulesCell .= ' : <span class="grey">'.$agent_info["monitor_unknown"].'</span>';
if ($agent['disabled']) {
$cellName = "<em>" . print_agent_name ($agent["id_agente"], true, "upper") .print_help_tip(__('Disabled'), true) . "</em>";
}
else {
$cellName = print_agent_name ($agent["id_agente"], true, "upper");
}
array_push($table->data, array(
$cellName,
print_os_icon ($agent["id_os"], false, true),
$agent['intervalo'],
print_group_icon ($agent["id_grupo"], true),
$modulesCell,
$agent_info["status_img"],
$agent_info["alert_img"],
print_timestamp ($agent_info["last_contact"], true)));
}
echo "<br />";pagination ($totalAgents);
print_table ($table); unset($table);
pagination ($totalAgents);
}
if ($users !== false) {
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "98%";
$table->class = "databox";
$table->head = array ();
$table->head[0] = __('User ID') . ' ' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=id_user&sort=up"><img src="images/sort_up.png" style="' . $selectUserIDUp . '" /></a>' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=id_user&sort=down"><img src="images/sort_down.png" style="' . $selectUserIDDown . '" /></a>';
$table->head[1] = __('Name') . ' ' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=name&sort=up"><img src="images/sort_up.png" style="' . $selectNameUp . '" /></a>' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=name&sort=down"><img src="images/sort_down.png" style="' . $selectNameDown . '" /></a>';
$table->head[2] = __('Email') . ' ' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=email&sort=up"><img src="images/sort_up.png" style="' . $selectEmailUp . '" /></a>' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=email&sort=down"><img src="images/sort_down.png" style="' . $selectEmailDown . '" /></a>';
$table->head[3] = __('Last contact') . ' ' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=last_contact&sort=up"><img src="images/sort_up.png" style="' . $selectLastContactUp . '" /></a>' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=last_contact&sort=down"><img src="images/sort_down.png" style="' . $selectLastContactDown . '" /></a>';
$table->head[4] = __('Profile') . ' ' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=profile&sort=up"><img src="images/sort_up.png" style="' . $selectProfileUp . '" /></a>' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=profile&sort=down"><img src="images/sort_down.png" style="' . $selectProfileDown . '" /></a>';
$table->head[5] = __('Description');
$table->data = array ();
foreach ($users as $user) {
if ($linkEditUser)
$userIDCell = "<a href='?sec=gusuarios&sec2=godmode/users/configure_user&id=" .
$user['id_user'] . "'>" . $user['id_user'] . "</a>";
else
$userIDCell = $user['id_user'];
if ($user["is_admin"]) {
$profileCell = print_image ("images/user_suit.png", true,
array ("alt" => __('Admin'),
"title" => __('Administrator'))).'&nbsp;';
} else {
$profileCell = print_image ("images/user_green.png", true,
array ("alt" => __('User'),
"title" => __('Standard User'))).'&nbsp;';
}
$profileCell .= '<a href="#" class="tip"><span>';
$result = get_db_all_rows_field_filter ("tusuario_perfil", "id_usuario", $user['id_user']);
if ($result !== false) {
foreach ($result as $row) {
$profileCell .= get_profile_name ($row["id_perfil"]);
$profileCell .= " / ";
$profileCell .= get_group_name ($row["id_grupo"]);
$profileCell .= "<br />";
}
} else {
$profileCell .= __('The user doesn\'t have any assigned profile/group');
}
$profileCell .= "</span></a>";
array_push($table->data, array(
$userIDCell,
$user['fullname'],
"<a href='mailto:" . $user['email'] . "'>" . $user['email'] . "</a>",
print_timestamp ($user["last_connect"], true),
$profileCell,
$user['comments']));
}
echo "<br />";pagination ($totalUsers);
print_table ($table); unset($table);
pagination ($totalUsers);
}
if ($alerts !== false) {
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "98%";
$table->class = "databox";
$table->head = array ();
$table->head[0] = '' . ' ' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=disabled&sort=up"><img src="images/sort_up.png" style="' . $selectDisabledUp . '" /></a>' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=disabled&sort=down"><img src="images/sort_down.png" style="' . $selectDisabledDown . '" /></a>';
$table->head[1] = __('Agent') . ' ' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=agent&sort=up"><img src="images/sort_up.png" style="' . $selectAgentUp . '" /></a>' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=agent&sort=down"><img src="images/sort_down.png" style="' . $selectAgentDown . '" /></a>';
$table->head[2] = __('Module') . ' ' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=module&sort=up"><img src="images/sort_up.png" style="' . $selectModuleUp . '" /></a>' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=module&sort=down"><img src="images/sort_down.png" style="' . $selectModuleDown . '" /></a>';
$table->head[3] = __('Template') . ' ' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=template&sort=up"><img src="images/sort_up.png" style="' . $selectTemplateUp . '" /></a>' .
'<a href="index.php?search_category=alerts&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=template&sort=down"><img src="images/sort_down.png" style="' . $selectTemplateDown . '" /></a>';
$table->head[4] = __('Action');
$table->align = array ();
$table->align[0] = "center";
$table->align[1] = "left";
$table->align[2] = "left";
$table->align[3] = "left";
$table->align[4] = "left";
$table->valign = array ();
$table->valign[0] = "top";
$table->valign[1] = "top";
$table->valign[2] = "top";
$table->valign[3] = "top";
$table->valign[4] = "top";
$table->data = array ();
foreach ($alerts as $alert) {
if ($alert['disabled'])
$disabledCell = print_image ('images/lightbulb_off.png', true, array('title' => 'disable', 'alt' => 'disable'));
else
$disabledCell = print_image ('images/lightbulb.png', true, array('alt' => 'enable', 'title' => 'enable'));
$actionCell = '';
if (strlen($alert["actions"]) > 0) {
$arrayActions = explode(',', $alert["actions"]);
$actionCell = '<ul class="action_list">';
foreach ($arrayActions as $action)
$actionCell .= '<li><div><span class="action_name">' . $action . '</span></div><br /></li>';
$actionCell .= '</ul>';
}
array_push($table->data, array(
$disabledCell,
print_agent_name ($alert["id_agente"], true, "upper"),
$alert["module_name"],
$alert["template_name"],$actionCell
));
}
echo "<br />";pagination ($totalAlerts);
print_table ($table); unset($table);
pagination ($totalAlerts);
}
if ($graphs !== false) {
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "98%";
$table->class = "databox";
$table->head = array ();
$table->head[0] = __('Graph name');
$table->head[1] = __('Description');
$table->align = array ();
$table->align[1] = "center";
$table->align[2] = "center";
$table->data = array ();
foreach ($graphs as $graph) {
array_push($table->data, array(
"<a href='?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id=" .
$graph['id_graph'] . "'>" . $graph['name'] . "</a>",
$graph['description']
));
}
echo "<br />";pagination ($totalGraphs);
print_table ($table); unset($table);
pagination ($totalGraphs);
}
if ($reports !== false) {
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "98%";
$table->class = "databox";
$table->head = array ();
$table->head[0] = __('Report name');
$table->head[1] = __('Description');
$table->head[2] = __('HTML');
$table->head[3] = __('XML');
enterprise_hook ('load_custom_reporting_1');
$table->align = array ();
$table->align[0] = "center";
$table->align[1] = "center";
$table->align[2] = "center";
$table->align[3] = "center";
$table->data = array ();
foreach ($reports as $report) {
$data = array(
"<a href='?sec=greporting&sec2=godmode/reporting/reporting_builder&edit_report=1&id_report=" . $report['id_report'] . "' title='" . __("Edit") . "'>" .
$report['name'] . "</a>",
$report['description'],
'<a href="index.php?sec=reporting&sec2=operation/reporting/reporting_viewer&id='.$report['id_report'].'"><img src="images/reporting.png" /></a>',
'<a href="ajax.php?page=operation/reporting/reporting_xml&id='.$report['id_report'].'"><img src="images/database_lightning.png" /></a>'
);
enterprise_hook ('load_custom_reporting_2');
array_push($table->data, $data);
}
echo "<br />";pagination ($totalReports);
print_table ($table); unset($table);
pagination ($totalReports);
}
if ($maps !== false) {
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "98%";
$table->class = "databox";
$table->head = array ();
$table->head[0] = __('Name');
$table->head[1] = __('Group');
$table->head[2] = __('Elements');
$table->align = array ();
$table->align[0] = "center";
$table->align[1] = "center";
$table->align[2] = "center";
$table->data = array ();
foreach ($maps as $map) {
array_push($table->data, array(
"<a href='?sec=visualc&sec2=operation/visual_console/render_view&id=" .
$map['id'] . "'>" . $map['name'] . "</a>",
print_group_icon ($layout["id_group"], true) . "&nbsp;" . get_group_name ($layout["id_group"]),
$map['count']
));
}
echo "<br />";pagination ($totalMaps);
print_table ($table); unset($table);
pagination ($totalMaps);
}
}
?>

View File

@ -0,0 +1,233 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// 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.
global $config;
$searchUsers = check_acl($config['id_user'], 0, "UM");
$selectUserIDUp = '';
$selectUserIDDown = '';
$selectNameUp = '';
$selectNameDown = '';
$selectEmailUp = '';
$selectEmailDown = '';
$selectLastContactUp = '';
$selectLastContactDown = '';
$selectProfileUp = '';
$selectProfileDown = '';
switch ($sortField) {
case 'id_user':
switch ($sort) {
case 'up':
$selectUserIDUp = $selected;
$order = array('field' => 'id_user', 'order' => 'ASC');
break;
case 'down':
$selectUserIDDown = $selected;
$order = array('field' => 'id_user', 'order' => 'DESC');
break;
}
break;
case 'name':
switch ($sort) {
case 'up':
$selectNameUp = $selected;
$order = array('field' => 'fullname', 'order' => 'ASC');
break;
case 'down':
$selectNameDown = $selected;
$order = array('field' => 'fullname', 'order' => 'DESC');
break;
}
break;
case 'email':
switch ($sort) {
case 'up':
$selectLastContactUp = $selected;
$order = array('field' => 'email', 'order' => 'ASC');
break;
case 'down':
$selectEmailDown = $selected;
$order = array('field' => 'email', 'order' => 'DESC');
break;
}
break;
case 'last_contact':
switch ($sort) {
case 'up':
$selectLastContactUp = $selected;
$order = array('field' => 'last_connect', 'order' => 'ASC');
break;
case 'down':
$selectLastContactDown = $selected;
$order = array('field' => 'last_connect', 'order' => 'DESC');
break;
}
break;
case 'last_contact':
switch ($sort) {
case 'up':
$selectLastContactUp = $selected;
$order = array('field' => 'last_connect', 'order' => 'ASC');
break;
case 'down':
$selectLastContactDown = $selected;
$order = array('field' => 'last_connect', 'order' => 'DESC');
break;
}
break;
case 'profile':
switch ($sort) {
case 'up':
$selectProfileUp = $selected;
$order = array('field' => 'is_admin', 'order' => 'ASC');
break;
case 'down':
$selectProfileDown = $selected;
$order = array('field' => 'is_admin', 'order' => 'DESC');
break;
}
break;
default:
$selectUserIDUp = $selected;
$selectUserIDDown = '';
$selectNameUp = '';
$selectNameDown = '';
$selectEmailUp = '';
$selectEmailDown = '';
$selectLastContactUp = '';
$selectLastContactDown = '';
$selectProfileUp = '';
$selectProfileDown = '';
$order = array('field' => 'id_user', 'order' => 'ASC');
break;
}
$users = false;
if ($searchUsers) {
$sql = "SELECT id_user, fullname, firstname, lastname, middlename, email, last_connect, is_admin, comments FROM tusuario
WHERE fullname LIKE '%" . $stringSearchSQL . "%' OR
firstname LIKE '%" . $stringSearchSQL . "%' OR
lastname LIKE '%" . $stringSearchSQL . "%' OR
middlename LIKE '%" . $stringSearchSQL . "%' OR
email LIKE '%" . $stringSearchSQL . "%'
ORDER BY " . $order['field'] . " " . $order['order'] . "
LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$users = process_sql($sql);
if($users !== false) {
//Check ACLs
$users_id = array();
foreach($users as $key => $user){
if (!check_acl ($config["id_user"], get_user_groups ($user["id_user"]), "UM") && $config["id_user"] != $user["id_user"]) {
unset($users[$key]);
} else {
$users_id[] = $user["id_user"];
}
}
if(!$users_id) {
$user_condition = "";
}else {
// Condition with the visible agents
$user_condition = " AND id_user IN (\"".implode('","',$users_id)."\")";
}
$sql = "SELECT COUNT(id_user) AS count FROM tusuario
WHERE (fullname LIKE '%" . $stringSearchSQL . "%' OR
firstname LIKE '%" . $stringSearchSQL . "%' OR
lastname LIKE '%" . $stringSearchSQL . "%' OR
middlename LIKE '%" . $stringSearchSQL . "%' OR
email LIKE '%" . $stringSearchSQL . "%')".$user_condition;
$totalUsers = get_db_row_sql($sql);
$totalUsers = $totalUsers['count'];
}
}
if (!$users) {
echo "<br><div class='nf'>" . __("Zero results found") . "</div>\n";
}
else {
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "98%";
$table->class = "databox";
$table->align = array ();
$table->align[4] = "center";
$table->head = array ();
$table->head[0] = __('User ID') . ' ' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=id_user&sort=up"><img src="images/sort_up.png" style="' . $selectUserIDUp . '" /></a>' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=id_user&sort=down"><img src="images/sort_down.png" style="' . $selectUserIDDown . '" /></a>';
$table->head[1] = __('Name') . ' ' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=name&sort=up"><img src="images/sort_up.png" style="' . $selectNameUp . '" /></a>' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=name&sort=down"><img src="images/sort_down.png" style="' . $selectNameDown . '" /></a>';
$table->head[2] = __('Email') . ' ' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=email&sort=up"><img src="images/sort_up.png" style="' . $selectEmailUp . '" /></a>' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=email&sort=down"><img src="images/sort_down.png" style="' . $selectEmailDown . '" /></a>';
$table->head[3] = __('Last contact') . ' ' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=last_contact&sort=up"><img src="images/sort_up.png" style="' . $selectLastContactUp . '" /></a>' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=last_contact&sort=down"><img src="images/sort_down.png" style="' . $selectLastContactDown . '" /></a>';
$table->head[4] = __('Profile') . ' ' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=profile&sort=up"><img src="images/sort_up.png" style="' . $selectProfileUp . '" /></a>' .
'<a href="index.php?search_category=users&keywords=' . $config['search_keywords'] . '&head_search_keywords=abc&offset=' . $offset . '&sort_field=profile&sort=down"><img src="images/sort_down.png" style="' . $selectProfileDown . '" /></a>';
$table->head[5] = __('Description');
$table->data = array ();
foreach ($users as $user) {
$userIDCell = "<a href='?sec=gusuarios&sec2=godmode/users/configure_user&id=" .
$user['id_user'] . "'>" . $user['id_user'] . "</a>";
if ($user["is_admin"]) {
$profileCell = print_image ("images/user_suit.png", true,
array ("alt" => __('Admin'),
"title" => __('Administrator'))).'&nbsp;';
} else {
$profileCell = print_image ("images/user_green.png", true,
array ("alt" => __('User'),
"title" => __('Standard User'))).'&nbsp;';
}
$profileCell .= '<a href="#" class="tip"><span>';
$result = get_db_all_rows_field_filter ("tusuario_perfil", "id_usuario", $user['id_user']);
if ($result !== false) {
foreach ($result as $row) {
$profileCell .= get_profile_name ($row["id_perfil"]);
$profileCell .= " / ";
$profileCell .= get_group_name ($row["id_grupo"]);
$profileCell .= "<br />";
}
} else {
$profileCell .= __('The user doesn\'t have any assigned profile/group');
}
$profileCell .= "</span></a>";
array_push($table->data, array(
$userIDCell,
$user['fullname'],
"<a href='mailto:" . $user['email'] . "'>" . $user['email'] . "</a>",
print_timestamp ($user["last_connect"], true),
$profileCell,
$user['comments']));
}
echo "<br />";pagination ($totalUsers);
print_table ($table); unset($table);
pagination ($totalUsers);
}
?>