Merge from Develop

This commit is contained in:
m-lopez-f 2015-06-25 10:40:35 +02:00
commit 94c742bfbe
139 changed files with 7630 additions and 5737 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 6.0dev-150616
Version: 6.0dev-150624
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="6.0dev-150616"
pandora_version="6.0dev-150624"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -41,7 +41,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '6.0dev';
use constant AGENT_BUILD => '150616';
use constant AGENT_BUILD => '150624';
# Commands to retrieve total memory information in kB
use constant TOTALMEMORY_CMDS => {

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 6.0dev
%define release 150616
%define release 150624
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 6.0dev
%define release 150616
%define release 150624
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{150616}
{150624}
ViewReadme
{Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("6.0dev(Build 150616)")
#define PANDORA_VERSION ("6.0dev(Build 150624)")
string pandora_path;
string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(6.0dev(Build 150616))"
VALUE "ProductVersion", "(6.0dev(Build 150624))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,6 +1,10 @@
attachment/networkmap_*
attachment/mibs/.index
attachment/pandora_chat.global_counter.txt
attachment/pandora_chat.user_list.json.txt
attachment/collection
attachment/files_repo
include/config.php
pandora_console.log
enterprise
*.bak

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 6.0dev-150616
Version: 6.0dev-150624
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="6.0dev-150616"
pandora_version="6.0dev-150624"
package_pear=0
package_pandora=1

View File

@ -64,6 +64,10 @@ function dbmanager_query ($sql, &$error) {
$backtrace = debug_backtrace();
$error = db_get_last_error();
if (empty($error)) {
return "Empty";
}
return false;
}

View File

@ -19,44 +19,37 @@ function pandora_files_repo_install () {
global $config;
if (isset($config['files_repo_installed'])) {
if ($config['files_repo_installed'] == 1) {
return;
}
}
if (isset($config['files_repo_installed']) && $config['files_repo_installed'] == 1)
return;
$full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/";
$full_sql_dir = $full_extensions_dir."files_repo/sql/";
/* SQL installation */
$file_path = '';
switch ($config['dbtype']) {
case 'mysql':
$sentences = file ($full_sql_dir.'files_repo.sql');
case "mysql":
$file_path = $full_sql_dir . 'files_repo.sql';
break;
case 'postgresql':
$sentences = file ($full_sql_dir.'files_repo.postgreSQL.sql');
case "postgresql":
$file_path = $full_sql_dir . 'files_repo.postgreSQL.sql';
break;
case 'oracle':
$sentences = file ($full_sql_dir.'files_repo.oracle.sql');
case "oracle":
$file_path = $full_sql_dir . 'files_repo.oracle.sql';
break;
}
foreach ($sentences as $sentence) {
if (trim ($sentence) == "")
continue;
$success = db_process_sql ($sentence);
if ($success === false)
return;
if (!empty($file_path)) {
$result = db_process_file($file_path);
if ($result) {
/* Configuration values */
$values = array(
"token" => "files_repo_installed",
"value" => 1
);
db_process_sql_insert('tconfig', $values);
}
}
/* Configuration values */
$values = array(
"token" => "files_repo_installed",
"value" => 1
);
db_process_sql_insert('tconfig', $values);
}
function pandora_files_repo_uninstall () {
@ -76,7 +69,11 @@ function pandora_files_repo_uninstall () {
WHERE "token" LIKE \'files_repo_%\'');
break;
case "oracle":
db_process_sql('DROP TRIGGER "tfiles_repo_group_inc"');
db_process_sql('DROP SEQUENCE "tfiles_repo_group_s"');
db_process_sql('DROP TABLE "tfiles_repo_group"');
db_process_sql('DROP TRIGGER "tfiles_repo_inc"');
db_process_sql('DROP SEQUENCE "tfiles_repo_s"');
db_process_sql('DROP TABLE "tfiles_repo"');
db_process_sql('DELETE FROM tconfig
WHERE token LIKE \'files_repo_%\'');

View File

@ -1,6 +1,16 @@
CREATE TABLE IF NOT EXISTS tfiles_repo (id NUMBER(5, 0) NOT NULL PRIMARY KEY, name VARCHAR(255) NOT NULL, description VARCHAR(500) NULL default '', hash VARCHAR(8) NULL default '');
CREATE TABLE tfiles_repo (
id NUMBER(5, 0) NOT NULL PRIMARY KEY,
name VARCHAR2(255) NOT NULL,
description VARCHAR2(500) NULL,
hash VARCHAR2(8) NULL
);
CREATE SEQUENCE tfiles_repo_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tfiles_repo_inc BEFORE INSERT ON tfiles_repo REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tfiles_repo_s.nextval INTO :NEW.ID FROM dual; END;;
CREATE TABLE IF NOT EXISTS tfiles_repo_group (id NUMBER(10, 0) NOT NULL PRIMARY KEY, id_file NUMBER(5, 0) NOT NULL REFERENCES tfiles_repo(id) ON DELETE CASCADE, id_group NUMBER(4, 0) NOT NULL);
CREATE SEQUENCE tfiles_repo_profile_s INCREMENT BY 1 START WITH 1;
CREATE TABLE tfiles_repo_group (
id NUMBER(10, 0) NOT NULL PRIMARY KEY,
id_file NUMBER(5, 0) NOT NULL REFERENCES tfiles_repo(id) ON DELETE CASCADE,
id_group NUMBER(4, 0) NOT NULL
);
CREATE SEQUENCE tfiles_repo_group_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tfiles_repo_group_inc BEFORE INSERT ON tfiles_repo_group REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tfiles_repo_group_s.nextval INTO :NEW.ID FROM dual; END;;

View File

@ -1,2 +1,15 @@
CREATE TABLE IF NOT EXISTS `tfiles_repo` (`id` int(5) unsigned NOT NULL auto_increment, `name` varchar(255) NOT NULL, `description` varchar(500) NULL default '', `hash` varchar(8) NULL default '', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tfiles_repo_group` (`id` int(10) unsigned NOT NULL auto_increment, `id_file` int(5) unsigned NOT NULL, `id_group` int(4) unsigned NOT NULL, PRIMARY KEY (`id`), FOREIGN KEY (`id_file`) REFERENCES tfiles_repo(`id`) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tfiles_repo` (
`id` int(5) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`description` varchar(500) NULL default '',
`hash` varchar(8) NULL default '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tfiles_repo_group` (
`id` int(10) unsigned NOT NULL auto_increment,
`id_file` int(5) unsigned NOT NULL,
`id_group` int(4) unsigned NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_file`) REFERENCES tfiles_repo(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -216,7 +216,6 @@ function mainInsertData() {
data: inputs.join ("&"),
type: 'GET',
url: action="ajax.php",
timeout: 10000,
dataType: 'json',
success: function (data) {
$('#id_agent_module').append ($('<option></option>').attr ('value', 0).text ("--"));

View File

@ -56,9 +56,9 @@ if (is_ajax ()) {
$default_action = false;
// Try to get actions for the current alert
$sql = 'SELECT t2.name
FROM talert_template_module_actions AS t1
INNER JOIN talert_actions AS t2
INNER JOIN talert_template_modules AS t3
FROM talert_template_module_actions t1
INNER JOIN talert_actions t2
INNER JOIN talert_template_modules t3
ON t3.id = t1.id_alert_template_module
AND t1.id_alert_action = t2.id
WHERE (t3.id_alert_template = ' . $template['id'] . ' AND
@ -130,7 +130,7 @@ function mainModuleGroups() {
//The big query
switch ($config["dbtype"]) {
case "mysql":
$sql = "SELECT COUNT(id_agente) AS count, estado
$sql = "SELECT COUNT(id_agente) AS count, case utimestamp when 0 then 5 else estado end as estado
FROM tagente_estado
WHERE id_agente IN
(SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled IS FALSE)
@ -141,7 +141,8 @@ function mainModuleGroups() {
GROUP BY estado";
break;
case "postgresql":
$sql = "SELECT COUNT(id_agente) AS count, estado
$sql = "SELECT COUNT(id_agente) AS count,
case utimestamp when 0 then 5 else estado end as estado
FROM tagente_estado
WHERE id_agente IN
(SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled = 0)
@ -152,7 +153,7 @@ function mainModuleGroups() {
GROUP BY estado, utimestamp";
break;
case "oracle":
$sql = "SELECT COUNT(id_agente) AS count, estado
$sql = "SELECT COUNT(id_agente) AS count, (case when utimestamp = 0 then 5 else estado end) AS estado
FROM tagente_estado
WHERE id_agente IN
(SELECT id_agente FROM tagente WHERE id_grupo = %d AND (disabled IS NOT NULL AND disabled <> 0))
@ -160,7 +161,7 @@ function mainModuleGroups() {
(SELECT id_agente_modulo
FROM tagente_modulo
WHERE id_module_group = %d AND (disabled IS NOT NULL AND disabled <> 0) AND (delete_pending IS NOT NULL AND delete_pending <> 0))
GROUP BY estado";
GROUP BY (case when utimestamp = 0 then 5 else estado end)";
break;
}

File diff suppressed because one or more lines are too long

View File

@ -26,10 +26,10 @@ INSERT INTO tconfig_os (name, description, icon_name) VALUES ('Mainframe', 'Main
ALTER TABLE tlayout_data ADD COLUMN id_policy_module NUMBER(10, 0) DEFAULT 0 NOT NULL;
UPDATE ttag_module AS t1
UPDATE ttag_module t1
SET t1.id_policy_module = (
SELECT t2.id_policy_module
FROM tagente_modulo AS t2
FROM tagente_modulo t2
WHERE t1.id_agente_modulo = t2.id_agente_modulo);
/* 2014/12/10 */
@ -57,7 +57,7 @@ ALTER TABLE tusuario ADD COLUMN strict_acl NUMBER(5, 0) DEFAULT 0;
-- ---------------------------------------------------------------------
-- Table `talert_commands`
-- ---------------------------------------------------------------------
UPDATE talert_commands SET fields_descriptions = '[\"Destination&#x20;address\",\"Subject\",\"Text\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]', fields_values = '[\"\",\"\",\"_html_editor_\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]' WHERE id = 1 AND name = 'eMail';
UPDATE talert_commands SET fields_descriptions = '["Destination&#x20;address","Subject","Text","","","","","","",""]', fields_values = '["\",\"\",\"_html_editor_\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]' WHERE id = 1 AND name = 'eMail';
-- ---------------------------------------------------------------------
-- Table `tconfig`
@ -98,7 +98,7 @@ CREATE TABLE tsessions_php (
-- Table tplugin
-- ---------------------------------------------------------------------
UPDATE tplugin
SET macros = '{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Target&#x20;IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Sensor\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"5\":{\"macro\":\"_field5_\",\"desc\":\"Additional&#x20;Options\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}',
SET macros = '{"1":{"macro":"_field1_","desc":"Target&#x20;IP","help":"","value":"","hide":""},"2":{"macro":"_field2_","desc":"Username","help":"","value":"","hide":""},"3":{"macro":"_field3_","desc":"Password","help":"","value":"","hide":""},"4":{"macro":"_field4_","desc":"Sensor","help":"","value":"","hide":""},"5":{"macro":"_field5_","desc":"Additional&#x20;Options","help":"","value":"","hide":""}}',
SET parameters = '-h&#x20;_field1_&#x20;-u&#x20;_field2_&#x20;-p&#x20;_field3_&#x20;-s&#x20;_field4_&#x20;--&#x20;_field5_'
WHERE id = 1 AND name = 'IPMI&#x20;Plugin';
@ -107,5 +107,13 @@ WHERE id = 1 AND name = 'IPMI&#x20;Plugin';
-- ---------------------------------------------------------------------
UPDATE trecon_script SET
description = 'Specific&#x20;Pandora&#x20;FMS&#x20;Intel&#x20;DCM&#x20;Discovery&#x20;&#40;c&#41;&#x20;Artica&#x20;ST&#x20;2011&#x20;&lt;info@artica.es&gt;&#x0d;&#x0a;&#x0d;&#x0a;Usage:&#x20;./ipmi-recon.pl&#x20;&lt;task_id&gt;&#x20;&lt;group_id&gt;&#x20;&lt;create_incident_flag&gt;&#x20;&lt;custom_field1&gt;&#x20;&lt;custom_field2&gt;&#x20;&lt;custom_field3&gt;&#x20;&lt;custom_field4&gt;&#x0d;&#x0a;&#x0d;&#x0a;*&#x20;custom_field1&#x20;=&#x20;Network&#x20;i.e.:&#x20;192.168.100.0/24&#x0d;&#x0a;*&#x20;custom_field2&#x20;=&#x20;Username&#x0d;&#x0a;*&#x20;custom_field3&#x20;=&#x20;Password&#x0d;&#x0a;*&#x20;custom_field4&#x20;=&#x20;Additional&#x20;parameters&#x20;i.e.:&#x20;-D&#x20;LAN_2_0',
macros = '{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.:&#x20;192.168.100.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Additional&#x20;parameters\",\"help\":\"Optional&#x20;additional&#x20;parameters&#x20;such&#x20;as&#x20;-D&#x20;LAN_2_0&#x20;to&#x20;use&#x20;IPMI&#x20;ver&#x20;2.0&#x20;instead&#x20;of&#x20;1.5.&#x20;&#x20;These&#x20;options&#x20;will&#x20;also&#x20;be&#x20;passed&#x20;to&#x20;the&#x20;IPMI&#x20;plugin&#x20;when&#x20;the&#x20;current&#x20;values&#x20;are&#x20;read.\",\"value\":\"\",\"hide\":\"\"}}'
macros = '{"1":{"macro":"_field1_","desc":"Network","help":"i.e.:&#x20;192.168.100.0/24","value":"","hide":""},"2":{"macro":"_field2_","desc":"Username","help":"","value":"","hide":""},"3":{"macro":"_field3_","desc":"Password","help":"","value":"","hide":"1"},"4":{"macro":"_field4_","desc":"Additional&#x20;parameters","help":"Optional&#x20;additional&#x20;parameters&#x20;such&#x20;as&#x20;-D&#x20;LAN_2_0&#x20;to&#x20;use&#x20;IPMI&#x20;ver&#x20;2.0&#x20;instead&#x20;of&#x20;1.5.&#x20;&#x20;These&#x20;options&#x20;will&#x20;also&#x20;be&#x20;passed&#x20;to&#x20;the&#x20;IPMI&#x20;plugin&#x20;when&#x20;the&#x20;current&#x20;values&#x20;are&#x20;read.","value":"","hide":""}}'
WHERE id_recon_script = 2 AND name = 'IPMI&#x20;Recon';
-- ---------------------------------------------------------------------
-- Table `tnetwork_component`
-- ---------------------------------------------------------------------
UPDATE tnetwork_component SET snmp_oid ='SELECT&#x20;DNSHostName&#x20;FROM&#x20;Win32_ComputerSystem' WHERE id_nc = 204 AND name = 'Hostname';
UPDATE `tnetwork_component` set `tcp_port`=0 WHERE id_nc=207;
UPDATE `tnetwork_component` set `tcp_port`=0 WHERE id_nc=219;

View File

@ -26,10 +26,10 @@ INSERT INTO "tconfig_os" ("name", "description", "icon_name") VALUES ('Mainframe
ALTER TABLE tlayout_data ADD COLUMN "id_policy_module" INTEGER NOT NULL DEFAULT 0;
UPDATE ttag_module AS t1
UPDATE ttag_module t1
SET t1.id_policy_module = (
SELECT t2.id_policy_module
FROM tagente_modulo AS t2
FROM tagente_modulo t2
WHERE t1.id_agente_modulo = t2.id_agente_modulo);
/* 2014/12/10 */
@ -107,3 +107,11 @@ UPDATE "trecon_script"SET
"description" = 'Specific&#x20;Pandora&#x20;FMS&#x20;Intel&#x20;DCM&#x20;Discovery&#x20;&#40;c&#41;&#x20;Artica&#x20;ST&#x20;2011&#x20;&lt;info@artica.es&gt;&#x0d;&#x0a;&#x0d;&#x0a;Usage:&#x20;./ipmi-recon.pl&#x20;&lt;task_id&gt;&#x20;&lt;group_id&gt;&#x20;&lt;create_incident_flag&gt;&#x20;&lt;custom_field1&gt;&#x20;&lt;custom_field2&gt;&#x20;&lt;custom_field3&gt;&#x20;&lt;custom_field4&gt;&#x0d;&#x0a;&#x0d;&#x0a;*&#x20;custom_field1&#x20;=&#x20;Network&#x20;i.e.:&#x20;192.168.100.0/24&#x0d;&#x0a;*&#x20;custom_field2&#x20;=&#x20;Username&#x0d;&#x0a;*&#x20;custom_field3&#x20;=&#x20;Password&#x0d;&#x0a;*&#x20;custom_field4&#x20;=&#x20;Additional&#x20;parameters&#x20;i.e.:&#x20;-D&#x20;LAN_2_0',
"macros" = '{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.:&#x20;192.168.100.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Additional&#x20;parameters\",\"help\":\"Optional&#x20;additional&#x20;parameters&#x20;such&#x20;as&#x20;-D&#x20;LAN_2_0&#x20;to&#x20;use&#x20;IPMI&#x20;ver&#x20;2.0&#x20;instead&#x20;of&#x20;1.5.&#x20;&#x20;These&#x20;options&#x20;will&#x20;also&#x20;be&#x20;passed&#x20;to&#x20;the&#x20;IPMI&#x20;plugin&#x20;when&#x20;the&#x20;current&#x20;values&#x20;are&#x20;read.\",\"value\":\"\",\"hide\":\"\"}}'
WHERE "id_recon_script" = 2 AND "name" = 'IPMI&#x20;Recon';
-- ---------------------------------------------------------------------
-- Table `tnetwork_component`
-- ---------------------------------------------------------------------
UPDATE tnetwork_component SET snmp_oid ='SELECT&#x20;DNSHostName&#x20;FROM&#x20;Win32_ComputerSystem' WHERE id_nc = 204 AND name = 'Hostname';
UPDATE `tnetwork_component` set `tcp_port`=0 WHERE id_nc=207;
UPDATE `tnetwork_component` set `tcp_port`=0 WHERE id_nc=219;

0
pandora_console/general/login_page.php Normal file → Executable file
View File

View File

@ -33,7 +33,7 @@ if (is_ajax ()) {
$filter[] = '(nombre COLLATE utf8_general_ci LIKE "%' . $string . '%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")';
break;
case "oracle":
$filter[] = '(upper(nombre) LIKE upper("%' . $string . '%") OR upper(direccion) LIKE upper("%'.$string.'%") OR upper(comentarios) LIKE upper("%'.$string.'%"))';
$filter[] = '(upper(nombre) LIKE upper(\'%'.$string.'%\') OR upper(direccion) LIKE upper(\'%'.$string.'%\') OR upper(comentarios) LIKE upper(\'%'.$string.'%\'))';
break;
}
$filter[] = 'id_agente != ' . $id_agent;
@ -115,8 +115,10 @@ if ($new_agent) {
$nombre_agente = $direccion_agente;
$servers = servers_get_names();
if (!empty($servers))
$server_name = reset(array_keys($servers));
if (!empty($servers)) {
$array_keys_servers = array_keys($servers);
$server_name = reset($array_keys_servers);
}
}
if (!$new_agent) {
@ -262,7 +264,9 @@ if (!array_key_exists($server_name, $servers)) {
$table->data[6][0] = __('Server');
if ($new_agent) {
//Set first server by default.
$server_name = reset(array_keys(servers_get_names()));
$servers_get_names = servers_get_names();
$array_keys_servers_get_names = array_keys($servers_get_names);
$server_name = reset($array_keys_servers_get_names);
}
$table->data[6][1] = html_print_select (servers_get_names (),
'server_name', $server_name, '', __('None'), 0, true). ' ' . ui_print_help_icon ('agent_server', true);

View File

@ -48,7 +48,16 @@ $snmpwalk = (int) get_parameter("snmpwalk", 0);
$create_modules = (int) get_parameter("create_modules", 0);
// Get the plugin
$plugin = db_get_row_sql('SELECT * FROM tplugin WHERE execute LIKE "%/snmp_remote.pl"');
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
$plugin = db_get_row_sql("SELECT id, macros FROM tplugin WHERE execute LIKE '%/snmp_remote.pl'");
break;
case 'oracle':
$plugin = db_get_row_sql("SELECT id, TO_CHAR(macros) AS macros FROM tplugin WHERE execute LIKE '%/snmp_remote.pl'");
break;
}
if (empty($plugin)) {
ui_print_info_message(array('message' => __('The SNMP remote plugin doesnt seem to be installed') . '. ' . __('It is necessary to use some features') . '.<br><br>' . __('Please, install the SNMP remote plugin (The name of the plugin must be snmp_remote.pl)'), 'no_close' => true));
@ -465,7 +474,10 @@ if ($create_modules) {
$module_values['id_modulo'] = MODULE_PLUGIN;
$module_values['id_plugin'] = $plugin['id'];
$macros = json_decode($plugin['macros'], true);
// Avoid the return of a string containing the word 'null' if the macros column is not defined
$macros = array();
if (isset($plugin['macros']) && !empty($plugin['macros']))
$macros = json_decode($plugin['macros'], true);
foreach ($macros as $k => $macro) {
switch($macro['macro']) {
@ -518,7 +530,8 @@ if ($create_modules) {
}
}
$module_values['macros'] = io_json_mb_encode($macros);
if (!empty($macros))
$module_values['macros'] = io_json_mb_encode($macros);
unset($module_values['snmp_community']); //snmp_community
unset($module_values['ip_target']); //ip_target
@ -545,7 +558,10 @@ if ($create_modules) {
$module_values['id_modulo'] = MODULE_PLUGIN;
$module_values['id_plugin'] = $plugin['id'];
$macros = json_decode($plugin['macros'], true);
// Avoid the return of a string containing the word 'null' if the macros column is not defined
$macros = array();
if (isset($plugin['macros']) && !empty($plugin['macros']))
$macros = json_decode($plugin['macros'], true);
foreach ($macros as $k => $macro) {
switch($macro['macro']) {
@ -591,7 +607,8 @@ if ($create_modules) {
}
}
$module_values['macros'] = io_json_mb_encode($macros);
if (!empty($macros))
$module_values['macros'] = io_json_mb_encode($macros);
unset($module_values['snmp_community']); //snmp_community
unset($module_values['ip_target']); //ip_target
@ -612,7 +629,10 @@ if ($create_modules) {
$module_values['id_modulo'] = MODULE_PLUGIN;
$module_values['id_plugin'] = $plugin['id'];
$macros = json_decode($plugin['macros'], true);
// Avoid the return of a string containing the word 'null' if the macros column is not defined
$macros = array();
if (isset($plugin['macros']) && !empty($plugin['macros']))
$macros = json_decode($plugin['macros'], true);
foreach ($macros as $k => $macro) {
switch($macro['macro']) {
@ -657,7 +677,8 @@ if ($create_modules) {
}
}
$module_values['macros'] = io_json_mb_encode($macros);
if (!empty($macros))
$module_values['macros'] = io_json_mb_encode($macros);
unset($module_values['snmp_community']); //snmp_community
unset($module_values['ip_target']); //ip_target

View File

@ -357,7 +357,7 @@ if ($id_agente) {
. '</a>';
// Hidden subtab layer
$agent_wizard['sub_menu'] .= '<ul class="mn subsubmenu" style="display:none; float:none;">';
$agent_wizard['sub_menu'] = '<ul class="mn subsubmenu" style="display:none; float:none;">';
$agent_wizard['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">';
$agent_wizard['sub_menu'] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard&wizard_section=snmp_explorer&id_agente='.$id_agente.'">'
. html_print_image ("images/wand_snmp.png", true, array ( "title" => __('SNMP Wizard')))
@ -599,12 +599,23 @@ if (isset( $_GET["fix_module"])) {
$media = reporting_get_agentmodule_data_average ($id_module, 30758400); //Get average over the year
$media *= 1.3;
$error = "";
$result = true;
//If the value of media is 0 or something went wrong, don't delete
if (!empty ($media)) {
$where = array(
'datos' => '>' . $media,
'id_agente_modulo' => $id_module);
db_process_sql_delete('tagente_datos', $where);
$res = db_process_sql_delete('tagente_datos', $where);
if ($res === false) {
$result = false;
$error = modules_get_agentmodule_name($id_module);
}
else if ($res <= 0) {
$result = false;
$error = " - " . __('No data to normalize');
}
}
else {
$result = false;
@ -612,7 +623,7 @@ if (isset( $_GET["fix_module"])) {
}
ui_print_result_message ($result,
__('Deleted data above %d', $media),
__('Deleted data above %f', $media),
__('Error normalizing module %s', $error));
}
@ -1258,10 +1269,10 @@ if ($create_module) {
// =================
if ($delete_module) { // DELETE agent module !
$id_borrar_modulo = (int) get_parameter_get ("delete_module",0);
$module_data = db_get_row_sql ('SELECT *
FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente_modulo.id_agente_modulo=' . $id_borrar_modulo);
$module_data = db_get_row_sql ('SELECT tam.id_agente, tam.nombre
FROM tagente_modulo tam, tagente_estado tae
WHERE tam.id_agente_modulo = tae.id_agente_modulo
AND tam.id_agente_modulo = ' . $id_borrar_modulo);
$id_grupo = (int) agents_get_agent_group($id_agente);
if (! check_acl ($config["id_user"], $id_grupo, "AW")) {
@ -1272,7 +1283,7 @@ if ($delete_module) { // DELETE agent module !
exit;
}
if ($id_borrar_modulo < 1) {
if (empty($module_data) || $id_borrar_modulo < 1) {
db_pandora_audit("HACK Attempt",
"Expected variable from form is not correct");
require ("general/noaccess.php");

View File

@ -169,10 +169,8 @@ if ($multiple_delete) {
// error. NOTICE that we don't delete all data here, just marking for deletion
// and delete some simple data.
$status = '';
$module = db_get_row_sql ('SELECT *
FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente_modulo.id_agente_modulo=' . (int)$id_agent_module_del);
$agent_id_of_module = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', (int)$id_agent_module_del);
if (db_process_sql("UPDATE tagente_modulo
SET nombre = 'pendingdelete', disabled = 1, delete_pending = 1
WHERE id_agente_modulo = " . $id_agent_module_del, "affected_rows", '', true, $status, false) === false) {
@ -180,10 +178,10 @@ if ($multiple_delete) {
}
else {
// Set flag to update module status count
if ($module !== false) {
if ($agent_id_of_module !== false) {
db_process_sql ('UPDATE tagente
SET update_module_count = 1, update_alert_count = 1
WHERE id_agente = ' . $module['id_agente']);
WHERE id_agente = ' . $agent_id_of_module);
}
}
@ -206,7 +204,7 @@ if ($multiple_delete) {
if ($result === false)
$error++;
$result = db_process_delete_temp('tagente_datos_inc',
'id_agente_modulo', $id_agent_module_del);
'id_agente_modulo', $id_agent_module_del);
if ($result === false)
$error++;
break;

View File

@ -1013,6 +1013,7 @@ function delete_relation (num_row, id_relation) {
function validate_post_process() {
var post_process = $("#text-post_process").val();
var new_post_process = post_process.replace(',', '.');
$("#text-post_process").val(new_post_process);
}

View File

@ -29,6 +29,12 @@ $config["past_planned_downtimes"] = isset($config["past_planned_downtimes"]) ? $
require_once ('include/functions_users.php');
// Buttons
$buttons = array(
'text' => "<a href='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'>"
. html_print_image ("images/list.png", true, array ("title" =>__('List'))) . "</a>"
);
// Header
ui_print_page_header(
__("Planned Downtime"),
@ -36,56 +42,52 @@ ui_print_page_header(
false,
"planned_downtime",
true,
"");
$buttons);
//Initialize data
$id_agent = get_parameter ("id_agent");
$id_group = (int) get_parameter ("id_group", 0);
$name = (string) get_parameter ('name', '');
$description = (string) get_parameter ('description', '');
$once_date_from = (string) get_parameter ('once_date_from', date(DATE_FORMAT));
$once_time_from = (string) get_parameter ('once_time_from', date(TIME_FORMAT));
$once_date_to = (string) get_parameter ('once_date_to', date(DATE_FORMAT));
$once_time_to = (string) get_parameter ('once_time_to', date(TIME_FORMAT));
$periodically_day_from = (int) get_parameter ('periodically_day_from', 1);
$periodically_day_to = (int) get_parameter ('periodically_day_to', 31);
$id_group = (int) get_parameter ('id_group');
$name = (string) get_parameter ('name');
$description = (string) get_parameter ('description');
$type_downtime = (string) get_parameter('type_downtime', 'quiet');
$type_execution = (string) get_parameter('type_execution', 'once');
$type_periodicity = (string) get_parameter('type_periodicity', 'weekly');
$once_date_from = (string) get_parameter ('once_date_from', date(DATE_FORMAT));
$once_time_from = (string) get_parameter ('once_time_from', date(TIME_FORMAT));
$once_date_to = (string) get_parameter ('once_date_to', date(DATE_FORMAT));
$once_time_to = (string) get_parameter ('once_time_to', date(TIME_FORMAT, time() + SECONDS_1HOUR));
$periodically_day_from = (int) get_parameter ('periodically_day_from', 1);
$periodically_day_to = (int) get_parameter ('periodically_day_to', 31);
$periodically_time_from = (string) get_parameter ('periodically_time_from', date(TIME_FORMAT));
$periodically_time_to = (string) get_parameter ('periodically_time_to', date(TIME_FORMAT, time() + SECONDS_1HOUR));
$periodically_time_to = (string) get_parameter ('periodically_time_to', date(TIME_FORMAT, time() + SECONDS_1HOUR));
$first_create = (int) get_parameter ('first_create', 0);
$monday = (bool) get_parameter ('monday');
$tuesday = (bool) get_parameter ('tuesday');
$wednesday = (bool) get_parameter ('wednesday');
$thursday = (bool) get_parameter ('thursday');
$friday = (bool) get_parameter ('friday');
$saturday = (bool) get_parameter ('saturday');
$sunday = (bool) get_parameter ('sunday');
$create_downtime = (int) get_parameter ('create_downtime');
$first_create = (int) get_parameter ('first_create');
$create_downtime = (int) get_parameter ('create_downtime');
$update_downtime = (int) get_parameter ('update_downtime');
$edit_downtime = (int) get_parameter ('edit_downtime');
$id_downtime = (int) get_parameter ('id_downtime');
$edit_downtime = (int) get_parameter ('edit_downtime');
$update_downtime = (int) get_parameter ('update_downtime');
$id_downtime = (int) get_parameter ('id_downtime',0);
$insert_downtime_agent = (int) get_parameter ("insert_downtime_agent", 0);
$delete_downtime_agent = (int) get_parameter ("delete_downtime_agent", 0);
$id_agent = (int) get_parameter ('id_agent');
$insert_downtime_agent = (int) get_parameter ('insert_downtime_agent');
$delete_downtime_agent = (int) get_parameter ('delete_downtime_agent');
$groups = users_get_groups ();
$type_downtime = get_parameter('type_downtime', 'quiet');
$type_execution = get_parameter('type_execution', 'once');
$type_periodicity = get_parameter('type_periodicity', 'weekly');
$monday = (bool) get_parameter ('monday');
$tuesday = (bool) get_parameter ('tuesday');
$wednesday = (bool) get_parameter ('wednesday');
$thursday = (bool) get_parameter ('thursday');
$friday = (bool) get_parameter ('friday');
$saturday = (bool) get_parameter ('saturday');
$sunday = (bool) get_parameter ('sunday');
// INSERT A NEW DOWNTIME_AGENT ASSOCIATION
if ($insert_downtime_agent == 1) {
$agents = (array)get_parameter("id_agents", array());
$module_names = (array)get_parameter("module", array());
if ($insert_downtime_agent === 1) {
$agents = (array) get_parameter ('id_agents');
$module_names = (array) get_parameter ('module');
$all_modules = false;
if (empty($module_names)) {
$all_modules = true;
@ -96,24 +98,25 @@ if ($insert_downtime_agent == 1) {
$all_modules = true;
}
for ($a=0; $a < count($agents); $a++) {
$num_agents = count($agents);
for ($a = 0; $a < $num_agents; $a++) {
$id_agente_dt = $agents[$a];
$values = array(
'id_downtime' => $id_downtime,
'id_agent' => $id_agente_dt,
'all_modules' => $all_modules);
'id_downtime' => $id_downtime,
'id_agent' => $id_agente_dt,
'all_modules' => $all_modules
);
$result = db_process_sql_insert('tplanned_downtime_agents', $values);
if ($result && !$all_modules) {
foreach ($module_names as $module_name) {
$module =
modules_get_agentmodule_id($module_name, $id_agente_dt);
$module = modules_get_agentmodule_id($module_name, $id_agente_dt);
$values = array(
'id_downtime' => $id_downtime,
'id_agent' => $id_agente_dt,
'id_agent_module' => $module["id_agente_modulo"]);
'id_downtime' => $id_downtime,
'id_agent' => $id_agente_dt,
'id_agent_module' => $module["id_agente_modulo"]
);
$result = db_process_sql_insert('tplanned_downtime_modules', $values);
if ($result) {
@ -127,21 +130,19 @@ if ($insert_downtime_agent == 1) {
}
// DELETE A DOWNTIME_AGENT ASSOCIATION
if ($delete_downtime_agent == 1) {
if ($delete_downtime_agent === 1) {
$id_da = (int)get_parameter ("id_downtime_agent", 0);
$id_agent_delete = (int)get_parameter('id_agent', 0);
$id_da = (int) get_parameter ('id_downtime_agent');
$row_to_delete = db_get_row('tplanned_downtime_agents', 'id', $id_da);
$result = db_process_sql_delete('tplanned_downtime_agents',
array('id' => $id_da));
$result = db_process_sql_delete('tplanned_downtime_agents', array('id' => $id_da));
if ($result) {
//Delete modules in downtime
db_process_sql_delete('tplanned_downtime_modules',
array('id_downtime' => $row_to_delete['id_downtime'],
'id_agent' => $id_agent_delete));
'id_agent' => $id_agent));
}
}
@ -176,31 +177,35 @@ if ($create_downtime || $update_downtime) {
if (trim(io_safe_output($name)) != '') {
if (!$check) {
$values = array(
'name' => $name,
'description' => $description,
'date_from' => $datetime_from,
'date_to' => $datetime_to,
'executed' => 0,
'id_group' => $id_group,
'only_alerts' => 0,
'monday' => $monday,
'tuesday' => $tuesday,
'wednesday' => $wednesday,
'thursday' => $thursday,
'friday' => $friday,
'saturday' => $saturday,
'sunday' => $sunday,
'periodically_time_from' => $periodically_time_from,
'periodically_time_to' => $periodically_time_to,
'periodically_day_from' => $periodically_day_from,
'periodically_day_to' => $periodically_day_to,
'type_downtime' => $type_downtime,
'type_execution' => $type_execution,
'type_periodicity' => $type_periodicity,
'id_user' => $config['id_user']
'name' => $name,
'description' => $description,
'date_from' => $datetime_from,
'date_to' => $datetime_to,
'executed' => 0,
'id_group' => $id_group,
'only_alerts' => 0,
'monday' => $monday,
'tuesday' => $tuesday,
'wednesday' => $wednesday,
'thursday' => $thursday,
'friday' => $friday,
'saturday' => $saturday,
'sunday' => $sunday,
'periodically_time_from' => $periodically_time_from,
'periodically_time_to' => $periodically_time_to,
'periodically_day_from' => $periodically_day_from,
'periodically_day_to' => $periodically_day_to,
'type_downtime' => $type_downtime,
'type_execution' => $type_execution,
'type_periodicity' => $type_periodicity,
'id_user' => $config['id_user']
);
$result = db_process_sql_insert(
'tplanned_downtime', $values);
if ($config["dbtype"] == 'oracle') {
$values['periodically_time_from'] = '1970/01/01 ' . $values['periodically_time_from'];
$values['periodically_time_to'] = '1970/01/01 ' . $values['periodically_time_to'];
}
$result = db_process_sql_insert('tplanned_downtime', $values);
}
else {
ui_print_error_message(
@ -237,6 +242,11 @@ if ($create_downtime || $update_downtime) {
'type_periodicity' => $type_periodicity,
'id_user' => $config['id_user']
);
if ($config["dbtype"] == 'oracle') {
$values['periodically_time_from'] = '1970/01/01 ' . $values['periodically_time_from'];
$values['periodically_time_to'] = '1970/01/01 ' . $values['periodically_time_to'];
}
$result = db_process_sql_update('tplanned_downtime', $values, array('id' => $id_downtime));
}
else {
@ -267,52 +277,90 @@ if ($create_downtime || $update_downtime) {
// Have any data to show ?
if ($id_downtime > 0) {
// Columns of the table tplanned_downtime
$columns = array(
'id',
'name',
'description',
'date_from',
'date_to',
'executed',
'id_group',
'only_alerts',
'monday',
'tuesday',
'wednesday',
'thursday',
'friday',
'saturday',
'sunday',
'periodically_time_from',
'periodically_time_to',
'periodically_day_from',
'periodically_day_to',
'type_downtime',
'type_execution',
'type_periodicity',
'id_user',
);
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf ("SELECT *
FROM `tplanned_downtime`
WHERE `id` = %d",
$id_downtime);
break;
case "postgresql":
$sql = sprintf ("SELECT *
FROM \"tplanned_downtime\"
WHERE \"id\" = %d",
$id_downtime);
$columns_str = implode(',', $columns);
$sql = "SELECT $columns_str
FROM tplanned_downtime
WHERE id = $id_downtime";
break;
case "oracle":
$sql = sprintf ("SELECT *
FROM tplanned_downtime
WHERE id = %d",
$id_downtime);
// Oracle doesn't have TIME type, so we should transform the DATE value
$new_time_from = "TO_CHAR(periodically_time_from, 'HH24:MI:SS') AS periodically_time_from";
$new_time_to = "TO_CHAR(periodically_time_to, 'HH24:MI:SS') AS periodically_time_to";
$time_from_key = array_search('periodically_time_from', $columns);
$time_to_key = array_search('periodically_time_to', $columns);
if ($time_from_key !== false)
$columns[$time_from_key] = $new_time_from;
if ($time_to_key !== false)
$columns[$time_to_key] = $new_time_to;
$columns_str = implode(',', $columns);
$sql = "SELECT $columns_str
FROM tplanned_downtime
WHERE id = $id_downtime";
break;
}
$result = db_get_row_sql ($sql);
$name = $result["name"];
$description = $result["description"];
$once_date_from = date(DATE_FORMAT, $result["date_from"]);
$once_date_to = date(DATE_FORMAT, $result["date_to"]);
$once_time_from = date(TIME_FORMAT, $result["date_from"]);
$once_time_to = date(TIME_FORMAT, $result["date_to"]);
$monday = $result['monday'];
$tuesday = $result['tuesday'];
$wednesday = $result['wednesday'];
$thursday = $result['thursday'];
$friday = $result['friday'];
$saturday = $result['saturday'];
$sunday = $result['sunday'];
$periodically_time_from = $result['periodically_time_from'];
$periodically_time_to = $result['periodically_time_to'];
$periodically_day_from = $result['periodically_day_from'];
$periodically_day_to = $result['periodically_day_to'];
$type_downtime = $result['type_downtime'];
$type_execution = $result['type_execution'];
$type_periodicity = $result['type_periodicity'];
$executed = $result['executed'];
if ($id_group == 0)
$id_group = $result['id_group'];
$name = (string) $result["name"];
$id_group = (int) $result['id_group'];
$description = (string) $result["description"];
$type_downtime = (string) $result['type_downtime'];
$type_execution = (string) $result['type_execution'];
$type_periodicity = (string) $result['type_periodicity'];
$once_date_from = date(DATE_FORMAT, $result["date_from"]);
$once_date_to = date(DATE_FORMAT, $result["date_to"]);
$once_time_from = date(TIME_FORMAT, $result["date_from"]);
$once_time_to = date(TIME_FORMAT, $result["date_to"]);
$periodically_time_from = (string) $result['periodically_time_from'];
$periodically_time_to = (string) $result['periodically_time_to'];
$periodically_day_from = (int) $result['periodically_day_from'];
$periodically_day_to = (int) $result['periodically_day_to'];
$monday = (bool) $result['monday'];
$tuesday = (bool) $result['tuesday'];
$wednesday = (bool) $result['wednesday'];
$thursday = (bool) $result['thursday'];
$friday = (bool) $result['friday'];
$saturday = (bool) $result['saturday'];
$sunday = (bool) $result['sunday'];
$executed = (bool) $result['executed'];
}
// when the planned down time is in execution, only action to postpone on once type is enabled and the other are disabled.
@ -330,8 +378,8 @@ $table->data[2][0] = __('Description');
$table->data[2][1] = html_print_textarea ('description', 3, 35, $description, '', true);
$table->data[3][0] = __('Type').ui_print_help_tip(__("Quiet: Disable modules that we indicate below.").'<br>'.
__("Disable Agents: Disables the selected agents.").'<br>'.
__("Disable Alerts: Disable alerts for the selected agents."), true);
__("Disable Agents: Disables the selected agents.").'<br>'.
__("Disable Alerts: Disable alerts for the selected agents."), true);
$table->data[3][1] = html_print_select(array('quiet' => __('Quiet'),
'disable_agents' => __('Disabled Agents'),
'disable_agents_alerts' => __('Disabled only Alerts')),
@ -600,23 +648,17 @@ if ($id_downtime > 0) {
}
}
$data[5] = '';
if (($type_downtime != 'disable_agents_alerts')
&& ($type_downtime != 'disable_agents')) {
$href = $executed ? 'javascript:void(0);' : 'javascript:show_editor_module(' . $downtime["id_agente"] . ');';
$data[5] = '<a href="' . $href . '">' .
html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Delete'))) . "</a>";
if (!$executed) {
$data[5] = '';
if ($type_downtime != 'disable_agents_alerts' && $type_downtime != 'disable_agents') {
$data[5] = '<a href="javascript:show_editor_module(' . $downtime["id_agente"] . ');">' .
html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Delete'))) . "</a>";
}
$data[5] .= '<a href="index.php?sec=estado&amp;sec2=godmode/agentes/planned_downtime.editor&id_agent=' . $downtime["id_agente"] .
'&delete_downtime_agent=1&id_downtime_agent=' . $downtime["id"] . '&id_downtime=' . $id_downtime . '">' .
html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete'))) . "</a>";
}
$href = $executed ? 'javascript:void(0);' : 'index.php?sec=estado&amp;sec2=godmode/agentes/planned_downtime.editor';
$data[5] .= '<a href="' . $href .
'&amp;id_agent=' . $downtime["id_agente"] .
'&amp;delete_downtime_agent=1' .
'&amp;id_downtime_agent=' . $downtime["id"] .
'&amp;id_downtime=' . $id_downtime . '">' .
html_print_image("images/cross.png", true,
array("border" => '0', "alt" => __('Delete'))) . "</a>";
$table->data['agent_' . $downtime["id_agente"]] = $data;
}
@ -753,6 +795,10 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri
}
}
function show_executing_alert () {
alert('<?php echo __("This elements cannot be modified while the downtime is being executed"); ?>');
}
function show_editor_module(id_agent) {
//Avoid freak states.
if (action_in_progress)

View File

@ -197,32 +197,19 @@ if ($delete_downtime) {
// Filter parameters
$offset = (int) get_parameter('offset');
$search_text = (string) get_parameter('search_text');
$date_from = (string) get_parameter('date_from');
$date_to = (string) get_parameter('date_to');
$execution_type = (string) get_parameter('execution_type');
$show_archived = (bool) get_parameter('archived');
$agent_id = (int) get_parameter('agent_id');
$agent_name = !empty($agent_id) ? (string) get_parameter('agent_name') : "";
$module_id = (int) get_parameter('module_name_hidden');
$module_name = !empty($module_id) ? (string) get_parameter('module_name') : "";
$filter_params = array();
$filter_params['search_text'] = $search_text;
$filter_params['date_from'] = $date_from;
$filter_params['date_to'] = $date_to;
$filter_params['execution_type'] = $execution_type;
$filter_params['archived'] = $show_archived;
$filter_params['agent_id'] = $agent_id;
$filter_params['agent_name'] = $agent_name;
$filter_params['module_id'] = $module_id;
$filter_params['module_name'] = $module_name;
$filter_params_aux = array();
foreach ($filter_params as $name => $value) {
$filter_params_aux[] = is_bool($value) ? $name."=".(int)$value : "$name=$value";
}
$filter_params_str = !empty($filter_params_aux) ? implode("&", $filter_params_aux) : "";
$search_text = $filter_params['search_text'] = (string) get_parameter('search_text');
$date_from = $filter_params['date_from'] = (string) get_parameter('date_from');
$date_to = $filter_params['date_to'] = (string) get_parameter('date_to');
$execution_type = $filter_params['execution_type'] = (string) get_parameter('execution_type');
$show_archived = $filter_params['archived'] = (bool) get_parameter('archived');
$agent_id = $filter_params['agent_id'] = (int) get_parameter('agent_id');
$agent_name = $filter_params['agent_name'] = (string) (!empty($agent_id) ? get_parameter('agent_name') : '');
$module_id = $filter_params['module_id'] = (int) get_parameter('module_name_hidden');
$module_name = $filter_params['module_name'] = (string) (!empty($module_id) ? get_parameter('module_name') : '');
$filter_params_str = http_build_query($filter_params);
// Table filter
$table = new StdClass();
@ -271,8 +258,7 @@ $agent_input = __('Agent') . '&nbsp;' . ui_print_agent_autocomplete_input($param
$row[] = $agent_input;
// Module
$module_input = __('Module') . '&nbsp;' . html_print_autocomplete_modules('module_name', $module_name, false, true, '', array(), true);
$row[] = $module_input;
$row[] = __('Module') . '&nbsp;' . html_print_autocomplete_modules('module_name', $module_name, false, true, '', array(), true);
$row[] = html_print_submit_button('Search', 'search', false, 'class="sub search"', true);
@ -307,7 +293,7 @@ $table->align[8] = "center";
$table->align[9] = "center";
$groups = users_get_groups ();
if(!empty($groups)) {
if (!empty($groups)) {
$where_values = "1=1";
$groups_string = implode (",", array_keys ($groups));
@ -372,16 +358,77 @@ if(!empty($groups)) {
AND tam.id_agente_modulo = $module_id
AND tpda.all_modules = 1))";
}
// Columns of the table tplanned_downtime
$columns = array(
'id',
'name',
'description',
'date_from',
'date_to',
'executed',
'id_group',
'only_alerts',
'monday',
'tuesday',
'wednesday',
'thursday',
'friday',
'saturday',
'sunday',
'periodically_time_from',
'periodically_time_to',
'periodically_day_from',
'periodically_day_to',
'type_downtime',
'type_execution',
'type_periodicity',
'id_user',
);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$columns_str = implode(',', $columns);
$sql = "SELECT $columns_str
FROM tplanned_downtime
WHERE $where_values
ORDER BY type_execution DESC, date_from DESC
LIMIT ".$config["block_size"]."
OFFSET $offset";
break;
case "oracle":
// Oracle doesn't have TIME type, so we should transform the DATE value
$new_time_from = "TO_CHAR(periodically_time_from, 'HH24:MI:SS') AS periodically_time_from";
$new_time_to = "TO_CHAR(periodically_time_to, 'HH24:MI:SS') AS periodically_time_to";
$time_from_key = array_search('periodically_time_from', $columns);
$time_to_key = array_search('periodically_time_to', $columns);
if ($time_from_key !== false)
$columns[$time_from_key] = $new_time_from;
if ($time_to_key !== false)
$columns[$time_to_key] = $new_time_to;
$columns_str = implode(',', $columns);
$set = array ();
$set['limit'] = $config["block_size"];
$set['offset'] = $offset;
$sql = "SELECT $columns_str
FROM tplanned_downtime
WHERE $where_values
ORDER BY type_execution DESC, date_from DESC";
$sql = oracle_recode_query ($sql, $set);
break;
}
$sql = "SELECT *
FROM tplanned_downtime
WHERE $where_values
ORDER BY type_execution DESC, date_from DESC
LIMIT ".$config["block_size"]."
OFFSET $offset";
$sql_count = "SELECT COUNT(id) AS num
FROM tplanned_downtime
WHERE $where_values";
$downtimes = db_get_all_rows_sql ($sql);
$downtimes_number_res = db_get_all_rows_sql($sql_count);
$downtimes_number = $downtimes_number_res != false ? $downtimes_number_res[0]['num'] : 0;
@ -419,9 +466,9 @@ else {
switch ($downtime['type_execution']) {
case 'once':
$data[5] = date ("Y-m-d H:i", $downtime['date_from']) .
$data[5] = date ("Y-m-d H:i:s", $downtime['date_from']) .
"&nbsp;" . __('to') . "&nbsp;".
date ("Y-m-d H:i", $downtime['date_to']);
date ("Y-m-d H:i:s", $downtime['date_to']);
break;
case 'periodically':
switch ($downtime['type_periodicity']) {
@ -482,9 +529,8 @@ else {
if ($downtime['type_execution'] == 'once' && $downtime["executed"] == 1) {
$data[7] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/planned_downtime.list&amp;' .
'stop_downtime=1&amp;' .
'id_downtime=' . $downtime['id'] . '">' .
$data[7] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list' .
'&stop_downtime=1&id_downtime=' . $downtime['id'] . '&' . $filter_params_str . '">' .
html_print_image("images/cancel.png", true, array("border" => '0', "alt" => __('Stop downtime')));
}
else {
@ -492,12 +538,11 @@ else {
}
if ($downtime["executed"] == 0) {
$data[8] = '<a
href="index.php?sec=estado&amp;sec2=godmode/agentes/planned_downtime.editor&amp;edit_downtime=1&amp;id_downtime='.$downtime['id'].'">' .
$data[8] = '<a href="index.php?sec=estado&amp;sec2=godmode/agentes/planned_downtime.editor&amp;edit_downtime=1&amp;id_downtime='.$downtime['id'].'">' .
html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Update'))) . '</a>';
$data[9] = '<a id="delete_downtime" href="index.php?sec=gagente&amp;sec2=godmode/agentes/planned_downtime.list&amp;'.
'delete_downtime=1&amp;id_downtime='.$downtime['id'].'">' .
html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete')));
$data[9] = '<a id="delete_downtime" href="index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list'.
'&delete_downtime=1&id_downtime=' . $downtime['id'] . '&' . $filter_params_str . '">' .
html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete')));
}
elseif ($downtime["executed"] == 1
&& $downtime['type_execution'] == 'once') {

View File

@ -182,7 +182,7 @@ if ($searchFlag) {
case "mysql":
case "postgresql":
$where .= " AND id_agent_module IN (SELECT t2.id_agente_modulo
FROM tagente AS t1 INNER JOIN tagente_modulo AS t2 ON t1.id_agente = t2.id_agente
FROM tagente t1 INNER JOIN tagente_modulo t2 ON t1.id_agente = t2.id_agente
WHERE t1.nombre LIKE '" . trim($agentName) . "')";
break;
case "oracle":

View File

@ -105,8 +105,8 @@ if ($create_alert) {
if ($action_select != 0) {
$values = array();
$values['fires_min'] = get_parameter ('fires_min');
$values['fires_max'] = get_parameter ('fires_max');
$values['fires_min'] = (int) get_parameter ('fires_min');
$values['fires_max'] = (int) get_parameter ('fires_max');
$values['module_action_threshold'] =
(int)get_parameter ('module_action_threshold');

View File

@ -17,7 +17,6 @@ require_once ($ownDir.'../include/config.php');
global $config;
require_once ($config["homedir"]."/include/functions.php");
require_once ($config["homedir"]."/include/functions_db.php");
enterprise_include ($config["homedir"]."/enterprise/include/functions_reporting_csv.php");
require_once ($config["homedir"]."/include/auth/mysql.php");
error_reporting(E_ALL);

View File

@ -54,7 +54,20 @@ if ((isset ($_GET["operacion"])) && (!isset ($_POST["update_agent"]))) {
// Copy
foreach ($origen_modulo as $id_agentemodulo) {
echo "<br /><br />".__('Filtering data module')."<b> [".modules_get_agentmodule_name ($id_agentemodulo)."]</b>";
$sql = sprintf ("DELETE FROM tagente_datos WHERE id_agente_modulo = %d AND (datos < '%s' OR datos > '%s')", $id_agentemodulo, $min, $max);
if ($config["dbtype"] == 'oracle') {
$sql = sprintf ("DELETE FROM tagente_datos
WHERE id_agente_modulo = %d
AND (datos < TO_BINARY_DOUBLE('%s')
OR datos > TO_BINARY_DOUBLE('%s'))", $id_agentemodulo, $min, $max);
}
else {
$sql = sprintf ("DELETE FROM tagente_datos
WHERE id_agente_modulo = %d
AND (datos < '%s'
OR datos > '%s')", $id_agentemodulo, $min, $max);
}
db_process_sql ($sql);
}
} //if copy modules or alerts

View File

@ -73,7 +73,7 @@ else {
$severity = '';
$status = '';
$search = '';
$text_agent = __('All');
$text_agent = '';
$pagination = '';
$event_view_hr = '';
$id_user_ack = '';
@ -93,7 +93,7 @@ if($update || $create) {
$severity = get_parameter('severity', '');
$status = get_parameter('status', '');
$search = get_parameter('search', '');
$text_agent = get_parameter('text_agent', __('All'));
$text_agent = get_parameter('text_agent', '');
$pagination = get_parameter('pagination', '');
$event_view_hr = get_parameter('event_view_hr', '');
$id_user_ack = get_parameter('id_user_ack', '');
@ -183,11 +183,11 @@ $table->data[0][0] = '<b>'.__('Filter name').'</b>';
$table->data[0][1] = html_print_input_text ('id_name', $id_name, false, 20, 80, true);
$table->data[1][0] = '<b>'.__('Save in group').'</b>' . ui_print_help_tip(__('This group will be use to restrict the visibility of this filter with ACLs'), true);
$table->data[1][1] = html_print_select_groups($config['id_user'], "ER", users_can_manage_group_all(), "id_group_filter", $id_group_filter, '', '', -1, true, false, false, '', false, '', false, false, 'id_group_filter', $strict_user);
$table->data[1][1] = html_print_select_groups($config['id_user'], "ER", users_can_manage_group_all(), "id_group_filter", $id_group_filter, '', '', -1, true, false, false, '', false, '', false, false, 'id_grupo', $strict_user);
$table->data[2][0] = '<b>'.__('Group').'</b>';
$table->data[2][1] = html_print_select_groups($config["id_user"], "ER", true,
'id_group', $id_group, '', '', -1, true, false, false, '', false, false, false, false, 'id_group', $strict_user);
'id_group', $id_group, '', '', -1, true, false, false, '', false, false, false, false, 'id_grupo', $strict_user);
$types = get_event_types ();
// Expand standard array to add not_normal (not exist in the array, used only for searches)

View File

@ -32,7 +32,7 @@ if ($delete) {
$id = (int) get_parameter('id');
$id_filter = db_get_value('id_name', 'tevent_filter', 'id_filter', $id);
$id_filter = db_get_value('id_filter', 'tevent_filter', 'id_filter', $id);
if ($id_filter === false) {
$result = false;

View File

@ -525,7 +525,6 @@ function refreshMapView() {
type: "GET",
dataType: 'json',
url: "ajax.php",
timeout: 10000,
success: function (data) {
if (data.correct) {
mapConnection = data.content;
@ -781,7 +780,6 @@ function setFieldsRequestAjax(id_conexion) {
type: "GET",
dataType: 'json',
url: "ajax.php",
timeout: 10000,
success: function (data) {
if (data.correct) {
$("input[name=map_initial_longitude]").val(data.content.initial_longitude);

View File

@ -145,7 +145,6 @@ function setDefault(id_tgis_map) {
type: "POST",
dataType: 'json',
url: "ajax.php",
timeout: 10000,
success: function (data) {
if (data.correct == 0) {
alert('<?php echo __('There was error on setup the default map.');?>');

View File

@ -215,8 +215,6 @@ function icon_changed () {
data: params.join ("&"),
type: 'POST',
url: action="<?php echo ui_get_full_url("ajax.php", false, false, false); ?>",
async: false,
timeout: 10000,
success: function (result) {
$('#icon_preview').append ($('<img />').attr ('src', result));
}
@ -235,7 +233,6 @@ function parent_changed () {
data: inputs.join ("&"),
type: 'GET',
url: action="<?php echo ui_get_full_url("ajax.php", false, false, false); ?>",
timeout: 10000,
dataType: 'json',
success: function (data) {
var data_ = data;
@ -254,8 +251,6 @@ function parent_changed () {
data: params.join ("&"),
type: 'POST',
url: action="<?php echo ui_get_full_url("ajax.php", false, false, false); ?>",
async: false,
timeout: 10000,
success: function (result) {
$('#parent_preview').append ($('<img />').attr ('src', result));
}

View File

@ -60,8 +60,8 @@ if ($add) {
ui_print_result_message (false, '', __('Could not be added').". ".__('No agents selected'));
else {
$actions = get_parameter ('action');
$fires_min = get_parameter ('fires_min');
$fires_max = get_parameter ('fires_max');
$fires_min = (int) get_parameter ('fires_min');
$fires_max = (int) get_parameter ('fires_max');
if (!empty($actions)) {
$agent_alerts = agents_get_alerts($id_agents);

View File

@ -98,10 +98,10 @@ function process_manage_delete ($id_alert_template, $id_agents, $module_names) {
if (count($module_names) == 1 && $module_names[0] == '0') {
if ($module_selection_mode == 'common') {
$sql = 'SELECT t1.id_agente_modulo
FROM tagente_modulo AS t1
FROM tagente_modulo t1
WHERE t1.id_agente_modulo IN (
SELECT t2.id_agent_module
FROM talert_template_modules AS t2
FROM talert_template_modules t2
WHERE
t2.id_alert_template = ' . $id_alert_template . ')
AND t1.id_agente IN (' . implode(',', $id_agents) . ');';

View File

@ -64,7 +64,7 @@ if (is_ajax ()) {
WHERE id_agente IN (" . implode(',', $id_agents) . ")
AND id_agente_modulo IN (
SELECT t1.id_agente_modulo
FROM ttag_module AS t1
FROM ttag_module t1
WHERE id_tag = " . $id_tag . "
AND id_policy_module = 0)
GROUP BY nombre;");

View File

@ -81,7 +81,7 @@ if ($update) {
$agents_ = db_get_all_rows_sql('
SELECT DISTINCT(t1.id_agente)
FROM tagente AS t1, tagente_modulo AS t2
FROM tagente t1, tagente_modulo t2
WHERE t1.id_agente = t2.id_agente
AND t2.delete_pending = 0 ' . $condition);
foreach ($agents_ as $id_agent) {
@ -112,7 +112,8 @@ if ($update) {
$module_name = array();
}
foreach($module_name as $mod_name) {
$result = process_manage_edit($mod_name['nombre'], $id_agent);
$result = process_manage_edit($mod_name['nombre'],
$id_agent);
$count ++;
$success += (int)$result;
}
@ -123,6 +124,8 @@ if ($update) {
$agents_ = array();
}
foreach ($agents_ as $agent_) {
if ($modules_ == false) {
@ -141,12 +144,15 @@ if ($update) {
"(" . $success . "/" . $count . ")",
__('Could not be updated'));
$info = 'Modules: ' . json_encode($modules_) . ' Agents: ' . json_encode($agents_);
$info = 'Modules: ' . json_encode($modules_) .
' Agents: ' . json_encode($agents_);
if ($success > 0) {
db_pandora_audit("Massive management", "Edit module", false, false, $info);
db_pandora_audit("Massive management", "Edit module", false,
false, $info);
}
else {
db_pandora_audit("Massive management", "Fail try to edit module", false, false, $info);
db_pandora_audit("Massive management",
"Fail try to edit module", false, false, $info);
}
}
@ -174,7 +180,8 @@ if (! $module_type) {
$table->rowstyle['edit6'] = 'display: none';
$table->rowstyle['edit7'] = 'display: none';
}
$agents = agents_get_group_agents (array_keys (users_get_groups ()), false, "none");
$agents = agents_get_group_agents (array_keys (users_get_groups ()),
false, "none");
switch ($config["dbtype"]) {
case "mysql":
case "oracle":
@ -235,7 +242,8 @@ $table->data['form_modules_1'][1] = html_print_select ($types,
'module_type', '', false, __('Select'), -1, true, false, true);
$table->data['form_modules_1'][3] = __('Select all modules of this type') . ' ' .
html_print_checkbox_extended ("force_type", 'type', '', '', false, '', 'style="margin-right: 40px;"', true);
html_print_checkbox_extended ("force_type", 'type', '', '', false,
'', 'style="margin-right: 40px;"', true);
$modules = array ();
if ($module_type != '') {
@ -263,7 +271,8 @@ $table->data['form_agents_1'][1] = html_print_select ($groups, 'groups_select',
' ' . __('Group recursion') . ' ' .
html_print_checkbox ("recursion", 1, false, true, false);
$table->data['form_agents_1'][3] = __('Select all modules of this group') . ' ' .
html_print_checkbox_extended ("force_group", 'group', '', '', false, '', 'style="margin-right: 40px;"', true);
html_print_checkbox_extended ("force_group", 'group', '', '', false,
'', 'style="margin-right: 40px;"', true);
@ -327,8 +336,8 @@ $table->data['edit1'][1] = '<table width="100%">';
$table->data['edit1'][1] .= '<em>' . __('Min.') . '</em>';
$table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '<td align="right">';
$table->data['edit1'][1] .= html_print_input_text('min_warning',
'', '', 5, 15, true);
$table->data['edit1'][1] .= html_print_input_text(
'min_warning', '', '', 5, 15, true);
$table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '</tr>';
$table->data['edit1'][1] .= '<tr>';
@ -336,25 +345,29 @@ $table->data['edit1'][1] = '<table width="100%">';
$table->data['edit1'][1] .= '<em>' . __('Max.') . '</em>';
$table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '<td align="right">';
$table->data['edit1'][1] .= html_print_input_text ('max_warning', '', '', 5, 15, true);
$table->data['edit1'][1] .= html_print_input_text (
'max_warning', '', '', 5, 15, true);
$table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '</tr>';
$table->data['edit1'][1] .= '<tr>';
$table->data['edit1'][1] .= '<td>';
$table->data['edit1'][1] .= '<em>'.__('Str.').'</em>';
$table->data['edit1'][1] .= '<em>' . __('Str.') . '</em>';
$table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '<td align="right">';
$table->data['edit1'][1] .= html_print_input_text ('str_warning', '', '', 5, 15, true);
$table->data['edit1'][1] .= html_print_input_text (
'str_warning', '', '', 5, 15, true);
$table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '</tr>';
$table->data['edit1'][1] .= '<tr>';
$table->data['edit1'][1] .= '<td>';
$table->data['edit1'][1] .= '<em>'.__('Inverse interval').'</em>';
$table->data['edit1'][1] .= '<em>' .
__('Inverse interval') . '</em>';
$table->data['edit1'][1] .= '</td>';
$table->data['edit1'][1] .= '<td align="right">';
$table->data['edit1'][1] .=
html_print_select(
array('' => __('No change'),
array(
'' => __('No change'),
'1' => __('Yes'),
'0' => __('No')),
'warning_inverse','','','', '', true);
@ -369,8 +382,8 @@ $table->data['edit1'][3] = '<table width="100%">';
$table->data['edit1'][3] .= '<em>' . __('Min.') . '</em>';
$table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '<td align="right">';
$table->data['edit1'][3] .= html_print_input_text('min_critical',
'', '', 5, 15, true);
$table->data['edit1'][3] .= html_print_input_text(
'min_critical', '', '', 5, 15, true);
$table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '</tr>';
$table->data['edit1'][3] .= '<tr>';
@ -378,7 +391,8 @@ $table->data['edit1'][3] = '<table width="100%">';
$table->data['edit1'][3] .= '<em>' . __('Max.') . '</em>';
$table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '<td align="right">';
$table->data['edit1'][3] .= html_print_input_text ('max_critical', '', '', 5, 15, true);
$table->data['edit1'][3] .= html_print_input_text(
'max_critical', '', '', 5, 15, true);
$table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '</tr>';
$table->data['edit1'][3] .= '<tr>';
@ -386,12 +400,14 @@ $table->data['edit1'][3] = '<table width="100%">';
$table->data['edit1'][3] .= '<em>'.__('Str.').'</em>';
$table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '<td align="right">';
$table->data['edit1'][3] .= html_print_input_text ('str_critical', '', '', 5, 15, true);
$table->data['edit1'][3] .= html_print_input_text(
'str_critical', '', '', 5, 15, true);
$table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '</tr>';
$table->data['edit1'][3] .= '<tr>';
$table->data['edit1'][3] .= '<td>';
$table->data['edit1'][3] .= '<em>'.__('Inverse interval').'</em>';
$table->data['edit1'][3] .= '<em>' .
__('Inverse interval') . '</em>';
$table->data['edit1'][3] .= '</td>';
$table->data['edit1'][3] .= '<td align="right">';
$table->data['edit1'][3] .=
@ -405,27 +421,40 @@ $table->data['edit1'][3] = '<table width="100%">';
$table->data['edit1'][3] .= '</table>';
$table->data['edit1_1'][0] = '<b>'.__('Description'). '</b>';
$table->data['edit1_1'][1] = html_print_textarea ('descripcion', 2, 50, '', '', true);
$table->data['edit1_1'][1] = html_print_textarea ('descripcion', 2, 50,
'', '', true);
$table->colspan['edit1_1'][1] = 3;
$table->data['edit2'][0] = __('Interval');
$table->data['edit2'][1] = html_print_extended_select_for_time ('module_interval', 0, '', __('No change'), '0', 10, true, 'width: 150px');
$table->data['edit2'][1] = html_print_extended_select_for_time(
'module_interval', 0, '', __('No change'), '0', 10, true, 'width: 150px');
$table->data['edit2'][2] = __('Disabled');
$table->data['edit2'][3] = html_print_select(array('' => __('No change'), '1' => __('Yes'), '0' => __('No')),'disabled','','','', '', true);
$table->data['edit2'][3] = html_print_select(
array(
'' => __('No change'),
'1' => __('Yes'),
'0' => __('No')),
'disabled', '', '', '', '', true);
$table->data['edit3'][0] = __('Post process') .
ui_print_help_icon ('postprocess', true);
$table->data['edit3'][1] = html_print_input_text ('post_process', '', '', 10, 15, true);
$table->data['edit3'][1] = html_print_input_text ('post_process', '',
'', 10, 15, true);
$table->data['edit3'][2] = __('SMNP community');
$table->data['edit3'][3] = html_print_input_text ('snmp_community', '', '', 10, 15, true);
$table->data['edit3'][3] = html_print_input_text ('snmp_community', '',
'', 10, 15, true);
$table->data['edit35'][0] = __('Target IP');
$table->data['edit35'][1] = html_print_input_text ('ip_target', '', '', 15, 60, true);
$table->data['edit35'][1] = html_print_input_text ('ip_target', '', '',
15, 60, true);
$table->data['edit35'][2] = __('SNMP version');
$table->data['edit35'][3] = html_print_select ($snmp_versions, 'tcp_send', '', '', __('No change'), '', true, false, false, '');
$table->data['edit35'][3] = html_print_select ($snmp_versions,
'tcp_send', '', '', __('No change'), '', true, false, false, '');
$table->data['edit36'][0] = __('Auth user');
$table->data['edit36'][1] = html_print_input_text ('plugin_user_snmp', '', '', 15, 60, true);
$table->data['edit36'][2] = __('Auth password') . ui_print_help_tip(__("The pass length must be eight character minimum."), true);
$table->data['edit36'][1] = html_print_input_text ('plugin_user_snmp',
'', '', 15, 60, true);
$table->data['edit36'][2] = __('Auth password') .
ui_print_help_tip(__("The pass length must be eight character minimum."), true);
$table->data['edit36'][3] = html_print_input_text ('plugin_pass_snmp', '', '', 15, 60, true);
$table->data['edit37'][0] = __('Privacy method');
$table->data['edit37'][1] = html_print_select(array('DES' => __('DES'), 'AES' => __('AES')), 'custom_string_1', '', '', __('No change'), '', true);
@ -922,6 +951,7 @@ $(document).ready (function () {
</script>
<?php
function process_manage_edit ($module_name, $agents_select = null) {
if (is_int ($module_name) && $module_name < 0) {
ui_print_error_message(__('No modules selected'));
@ -1026,7 +1056,7 @@ function process_manage_edit ($module_name, $agents_select = null) {
else {
$modules = db_get_all_rows_filter ('tagente_modulo',
array ('id_agente' => $agents_select,
'nombre' => io_safe_input($module_name)),
'nombre' => $module_name),
array ('id_agente_modulo'));
}
}

View File

@ -140,25 +140,33 @@ if ($option == '') {
$option = array_shift(array_keys($options));
}
$alertstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_alerts">'
. html_print_image ('images/op_alerts.png', true,
array ('title' => __('Alerts operations')))
. '</a>', 'active' => $tab == 'massive_alerts');
$alertstab = array(
'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_alerts">'
. html_print_image ('images/op_alerts.png', true,
array ('title' => __('Alerts operations')))
. '</a>',
'active' => $tab == 'massive_alerts');
$userstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users">'
. html_print_image ('images/op_workspace.png', true,
array ('title' => __('Users operations')))
. '</a>', 'active' => $tab == 'massive_users');
$userstab = array(
'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users">'
. html_print_image ('images/op_workspace.png', true,
array ('title' => __('Users operations')))
. '</a>',
'active' => $tab == 'massive_users');
$agentstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_agents">'
. html_print_image ('images/bricks.png', true,
array ('title' => __('Agents operations')))
. '</a>', 'active' => $tab == 'massive_agents');
$agentstab = array(
'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_agents">'
. html_print_image ('images/bricks.png', true,
array ('title' => __('Agents operations')))
. '</a>',
'active' => $tab == 'massive_agents');
$modulestab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_modules">'
. html_print_image ('images/brick.png', true,
array ('title' => __('Modules operations')))
. '</a>', 'active' => $tab == 'massive_modules');
$modulestab = array(
'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_modules">'
. html_print_image ('images/brick.png', true,
array ('title' => __('Modules operations')))
. '</a>',
'active' => $tab == 'massive_modules');
@ -213,7 +221,8 @@ $submit_template_standby = get_parameter('id_alert_template_standby');
$submit_add = get_parameter('crtbutton');
echo '<div id="loading" display="none">';
echo html_print_image("images/wait.gif", true, array("border" => '0')) . '<br />';
echo html_print_image("images/wait.gif", true, array("border" => '0')) .
'<br />';
echo '<strong>' . __('Please wait...') . '</strong>';
echo '</div>';
?>
@ -245,14 +254,19 @@ echo '</div>';
<?php
echo "<br />";
echo '<form method="post" id="form_options" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations">';
echo '<table border="0"><tr><td>';
echo '<table border="0">';
echo '<tr>';
echo '<td>';
echo __("Action");
echo '</td><td>';
echo '</td>';
echo '<td>';
html_print_select($options, 'option', $option, 'this.form.submit()', '',
0, false, false, false);
if ($option == 'edit_agents' || $option == 'edit_modules')
ui_print_help_tip(__("The blank fields will not be updated"));
echo '</td></tr></table>';
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</form>';
echo "<br />";

View File

@ -195,20 +195,20 @@ else {
$table->data[$next_row][1] = '<b>' . __('Tags available') . '</b><br>';
$table->data[$next_row][1] .= html_print_select_from_sql (
"SELECT name, name
"SELECT name AS name1, name AS name2
FROM ttag
WHERE $tags_condition_not
ORDER BY name", 'id_tag_available[]', '', '','','',
ORDER BY name", 'id_tag_available[]', '', '','','',
true, true, false, false, 'width: 200px', '5');
$table->data[$next_row][2] = html_print_image('images/darrowright.png', true, array('id' => 'right', 'title' => __('Add tags to module'))); //html_print_input_image ('add', 'images/darrowright.png', 1, '', true, array ('title' => __('Add tags to module')));
$table->data[$next_row][2] .= '<br><br><br><br>' . html_print_image('images/darrowleft.png', true, array('id' => 'left', 'title' => __('Delete tags to module'))); //html_print_input_image ('add', 'images/darrowleft.png', 1, '', true, array ('title' => __('Delete tags to module')));
$table->data[$next_row][3] = '<b>' . __('Tags selected') . '</b><br>';
$table->data[$next_row][3] .= html_print_select_from_sql (
"SELECT name, name
"SELECT name AS name1, name AS name2
FROM ttag
WHERE $tags_condition_in
ORDER BY name",
ORDER BY name",
'id_tag_selected[]', '', '','','', true, true, false,
false, 'width: 200px', '5');

View File

@ -39,13 +39,13 @@ if (isset ($_GET["get_agent"])) {
if ($editGraph) {
$graphRows = db_get_all_rows_sql("SELECT t1.*,
(SELECT t3.nombre
FROM tagente AS t3
FROM tagente t3
WHERE t3.id_agente =
(SELECT t2.id_agente
FROM tagente_modulo AS t2
FROM tagente_modulo t2
WHERE t2.id_agente_modulo = t1.id_agent_module))
AS agent_name
FROM tgraph_source AS t1
FROM tgraph_source t1
WHERE t1.id_graph = " . $id_graph);
$module_array = array();
$weight_array = array();

View File

@ -35,7 +35,9 @@ if (defined('METACONSOLE'))
$hack_metaconsole = '../../';
if (!defined('METACONSOLE')) {
ui_print_page_header (__('Reporting') .' &raquo; ' . __('Visual Console'), "images/op_reporting.png", false, "map_builder");
ui_print_page_header(
__('Reporting') .' &raquo; ' . __('Visual Console'),
"images/op_reporting.png", false, "map_builder");
}
$id_layout = (int) get_parameter ('id_layout');
@ -64,7 +66,7 @@ if ($delete_layout || $copy_layout) {
// $vconsole_read = check_acl ($config['id_user'], $group_id, "VR");
$vconsole_write = check_acl ($config['id_user'], $group_id, "VW");
$vconsole_manage = check_acl ($config['id_user'], $group_id, "VM");
if (!$vconsole_write && !$vconsole_manage) {
db_pandora_audit("ACL Violation",
"Trying to access map builder");
@ -73,29 +75,36 @@ if ($delete_layout || $copy_layout) {
}
if ($delete_layout) {
db_process_sql_delete ('tlayout_data', array ('id_layout' => $id_layout));
$result = db_process_sql_delete ('tlayout', array ('id' => $id_layout));
db_process_sql_delete('tlayout_data',
array ('id_layout' => $id_layout));
$result = db_process_sql_delete('tlayout',
array ('id' => $id_layout));
if ($result) {
db_pandora_audit( "Visual console builder", "Delete visual console #$id_layout");
db_pandora_audit(
"Visual console builder", "Delete visual console #$id_layout");
ui_print_success_message(__('Successfully deleted'));
db_clean_cache();
}
else {
db_pandora_audit( "Visual console builder", "Fail try to delete visual console #$id_layout");
ui_print_error_message(__('Not deleted. Error deleting data'));
db_pandora_audit(
"Visual console builder", "Fail try to delete visual console #$id_layout");
ui_print_error_message(
__('Not deleted. Error deleting data'));
}
$id_layout = 0;
}
if ($copy_layout) {
// Number of inserts
$ninsert = (int) 0;
// Return from DB the source layout
$layout_src = db_get_all_rows_filter ("tlayout","id = " . $id_layout);
$layout_src = db_get_all_rows_filter("tlayout",
array("id" => $id_layout));
// Name of dst
$name_dst = get_parameter ("name_dst", $layout_src[0]['name'] . " copy");
$name_dst = get_parameter ("name_dst",
$layout_src[0]['name'] . " copy");
// Create the new Console
$idGroup = $layout_src[0]['id_group'];
@ -104,7 +113,12 @@ if ($delete_layout || $copy_layout) {
$width = $layout_src[0]['width'];
$visualConsoleName = $name_dst;
$values = array('name' => $visualConsoleName, 'id_group' => $idGroup, 'background' => $background, 'height' => $height, 'width' => $width);
$values = array(
'name' => $visualConsoleName,
'id_group' => $idGroup,
'background' => $background,
'height' => $height,
'width' => $width);
$result = db_process_sql_insert('tlayout', $values);
$idNewVisualConsole = $result;
@ -113,14 +127,16 @@ if ($delete_layout || $copy_layout) {
$ninsert = 1;
// Return from DB the items of the source layout
$data_layout_src = db_get_all_rows_filter ("tlayout_data", "id_layout = " . $id_layout);
$data_layout_src = db_get_all_rows_filter(
"tlayout_data",
array("id_layout" => $id_layout));
if (!empty($data_layout_src)) {
//By default the id parent 0 is always 0.
$id_relations = array(0 => 0);
for ($a=0; $a < count($data_layout_src); $a++) {
for ($a = 0; $a < count($data_layout_src); $a++) {
// Changing the source id by the new visual console id
$data_layout_src[$a]['id_layout'] = $idNewVisualConsole;
@ -131,7 +147,8 @@ if ($delete_layout || $copy_layout) {
unset($data_layout_src[$a]['id']);
// Configure the cloned Console
$result = db_process_sql_insert('tlayout_data', $data_layout_src[$a]);
$result = db_process_sql_insert('tlayout_data',
$data_layout_src[$a]);
$id_relations[$old_id] = 0;
@ -149,13 +166,15 @@ if ($delete_layout || $copy_layout) {
if ($ninsert == $inserts) {
//Update the ids of parents
$items = db_get_all_rows_filter ("tlayout_data", "id_layout = " . $idNewVisualConsole);
$items = db_get_all_rows_filter("tlayout_data",
array("id_layout" => $idNewVisualConsole));
foreach ($items as $item) {
$new_parent = $id_relations[$item['parent_item']];
db_process_sql_update('tlayout_data',
array('parent_item' => $new_parent), array('id' => $item['id']));
array('parent_item' => $new_parent),
array('id' => $item['id']));
}
@ -178,6 +197,7 @@ if ($delete_layout || $copy_layout) {
}
}
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox data';
$table->data = array ();
@ -208,16 +228,21 @@ $own_info = get_user_info ($config['id_user']);
if ($own_info['is_admin'] || $vconsoles_read)
$maps = visual_map_get_user_layouts ();
else
$maps = visual_map_get_user_layouts ($config['id_user'], false, false, false);
$maps = visual_map_get_user_layouts ($config['id_user'], false,
false, false);
if (!$maps) {
ui_print_info_message ( array('no_close'=>true, 'message'=> __('No maps defined') ) );
ui_print_info_message (
array('no_close'=>true,
'message'=> __('No maps defined')));
}
else {
foreach ($maps as $map) {
// ACL for the visual console permission
$vconsole_write = check_acl ($config['id_user'], $map['id_group'], "VW");
$vconsole_manage = check_acl ($config['id_user'], $map['id_group'], "VM");
$vconsole_write = check_acl ($config['id_user'],
$map['id_group'], "VW");
$vconsole_manage = check_acl ($config['id_user'],
$map['id_group'], "VM");
$data = array ();
@ -260,13 +285,15 @@ else {
}
if ($vconsoles_write || $vconsoles_manage) {
if (!defined('METACONSOLE'))
if (!defined('METACONSOLE')) {
echo '<form action="index.php?sec=reporting&amp;sec2=godmode/reporting/visual_console_builder" method="post">';
else {
}
else {
echo '<form action="index.php?sec=screen&sec2=screens/screens&action=visualmap&action2=new&operation=new_visualmap&tab=data&pure=' . $pure . '" method="post">';
}
html_print_input_hidden ('edit_layout', 1);
html_print_submit_button (__('Create'), '', false, 'class="sub next"');
html_print_submit_button (__('Create'), '', false,
'class="sub next"');
echo '</form>';
}
echo '</div>';

View File

@ -14,6 +14,7 @@
global $config;
require_once ($config['homedir'] . '/include/functions_custom_graphs.php');
require_once ($config['homedir'] . '/include/db/oracle.php');
// Login check
check_login ();
@ -462,7 +463,21 @@ switch ($action) {
$description = $item['description'];
$period = $item['period'];
$exception_condition = $item['exception_condition'];
$exception_condition_value = $item['exception_condition_value'];
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$exception_condition_value =
$item['exception_condition_value'];
break;
case "oracle":
$exception_condition_value =
oracle_format_float_to_php(
$item['exception_condition_value']);
break;
}
$show_resume = $item['show_resume'];
$show_graph = $item['show_graph'];
$order_uptodown = $item['order_uptodown'];
@ -885,13 +900,16 @@ else
<td>
<?php
html_print_select(array(), 'inventory_modules[]', '', $script = '', __('None'), 0, false, true, true, '', false, "min-width: 180px");
if (empty($inventory_modules)) {
$array_inventory_modules = array(0 => 0);
}
else {
$array_inventory_modules = implode(',', $inventory_modules);
}
html_print_input_hidden('inventory_modules_selected', $array_inventory_modules);
$array_inventory_modules =
implode(',', $inventory_modules);
html_print_input_hidden(
'inventory_modules_selected',
$array_inventory_modules);
?>
</td>
</tr>
@ -1075,7 +1093,12 @@ else
</tr>
<tr id="row_exception_condition_value" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Value'); ?></td>
<td style=""><?php html_print_input_text('exception_condition_value', $exception_condition_value, '', 5, 5); ?></td>
<td style="">
<?php
html_print_input_text('exception_condition_value',
$exception_condition_value, '', 5, 5);
?>
</td>
</tr>
<tr id="row_exception_condition" style="" class="datos">
<td><?php echo __('Condition');?></td>
@ -1237,8 +1260,9 @@ function print_SLA_list($width, $action, $idItem = null) {
global $config;
global $meta;
$report_item_type = db_get_value('type', 'treport_content', 'id_rc',
$idItem);
$report_item_type = db_get_value(
oracle_encapsule_fields_with_same_name_to_instructions('type'),
'treport_content', 'id_rc', $idItem);
?>
<table class="databox data" id="sla_list" border="0" cellpadding="4" cellspacing="4" width="100%">
<thead>
@ -1265,7 +1289,9 @@ function print_SLA_list($width, $action, $idItem = null) {
case 'update':
case 'edit':
echo '<tbody id="list_sla">';
$itemsSLA = db_get_all_rows_filter('treport_content_sla_combined', array('id_report_content' => $idItem));
$itemsSLA = db_get_all_rows_filter(
'treport_content_sla_combined',
array('id_report_content' => $idItem));
if ($itemsSLA === false) {
$itemsSLA = array();
}
@ -1301,9 +1327,29 @@ function print_SLA_list($width, $action, $idItem = null) {
echo '<td class="sla_list_service_col">' . printSmallFont($nameService) . '</th>';
}
echo '<td class="sla_list_sla_min_col">' . $item['sla_min'] . '</td>';
echo '<td class="sla_list_sla_max_col">' . $item['sla_max'] . '</td>';
echo '<td class="sla_list_sla_limit_col">' . $item['sla_limit'] . '</td>';
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$item_sla_min = $item['sla_min'];
$item_sla_max = $item['sla_max'];
$item_sla_limit = $item['sla_limit'];
break;
case "oracle":
$item_sla_min =
oracle_format_float_to_php($item['sla_min']);
$item_sla_max =
oracle_format_float_to_php($item['sla_max']);
$item_sla_limit =
oracle_format_float_to_php($item['sla_limit']);
break;
}
echo '<td class="sla_list_sla_min_col">' .
$item_sla_min . '</td>';
echo '<td class="sla_list_sla_max_col">' .
$item_sla_max . '</td>';
echo '<td class="sla_list_sla_limit_col">' .
$item_sla_limit . '</td>';
echo '<td class="sla_list_action_col" style="text-align: center;">
<a href="javascript: deleteSLARow(' . $item['id'] . ');">' . html_print_image("images/cross.png", true) . '</a>
</td>';

View File

@ -26,6 +26,18 @@ if (! check_acl ($config['id_user'], 0, "RW")) {
include_once($config['homedir'] . "/include/functions_agents.php");
enterprise_include_once ('include/functions_metaconsole.php');
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$type_escaped = "type";
break;
case "oracle":
$type_escaped = db_encapsule_fields_with_same_name_to_instructions(
"type");
break;
}
if ($config ['metaconsole'] == 1 and defined('METACONSOLE')) {
$agents = array();
$agents = metaconsole_get_report_agents($idReport);
@ -44,11 +56,11 @@ else {
FROM
(
SELECT t1.*, id_agente
FROM treport_content AS t1
LEFT JOIN tagente_modulo AS t2
FROM treport_content t1
LEFT JOIN tagente_modulo t2
ON t1.id_agent_module = id_agente_modulo
) AS t4
INNER JOIN tagente AS t5
) t4
INNER JOIN tagente t5
ON (t4.id_agent = t5.id_agente OR t4.id_agente = t5.id_agente)
WHERE t4.id_report = ' . $idReport);
break;
@ -65,6 +77,7 @@ else {
INNER JOIN tagente t5
ON (t4.id_agent = t5.id_agente OR t4.id_agente = t5.id_agente)
WHERE t4.id_report = ' . $idReport);
break;
}
@ -82,8 +95,8 @@ else {
case "postgresql":
$rows = db_get_all_rows_sql('
SELECT t1.id_agent_module, t2.nombre
FROM treport_content AS t1
INNER JOIN tagente_modulo AS t2
FROM treport_content t1
INNER JOIN tagente_modulo t2
ON t1.id_agent_module = t2.id_agente_modulo
WHERE t1.id_report = ' . $idReport);
break;
@ -107,13 +120,13 @@ else {
// Filter report items created from metaconsole in normal console list and the opposite
if (defined('METACONSOLE') and $config['metaconsole'] == 1) {
$where_types = ' AND ((server_name IS NOT NULL AND length(server_name) != 0) OR type IN (\'general\',\'SLA\',\'exception\',\'top_n\'))';
$where_types = ' AND ((server_name IS NOT NULL AND length(server_name) != 0) OR ' . $type_escaped . ' IN (\'general\',\'SLA\',\'exception\',\'top_n\'))';
}
else
$where_types = ' AND ((server_name IS NULL OR length(server_name) = 0) OR type IN (\'general\',\'SLA\',\'exception\',\'top_n\'))';
$where_types = ' AND ((server_name IS NULL OR length(server_name) = 0) OR ' . $type_escaped . ' IN (\'general\',\'SLA\',\'exception\',\'top_n\'))';
$rows = db_get_all_rows_sql('
SELECT DISTINCT(type)
SELECT DISTINCT(' . $type_escaped . ')
FROM treport_content
WHERE id_report = ' . $idReport . $where_types);
if ($rows === false) {
@ -165,7 +178,7 @@ if (!defined("METACONSOLE")) {
ui_toggle($form, __("Filters") );
}
else {
$table = null;
$table = new stdClass();
$table->width = '96%';
$table->class = "databox_filters";
$table->cellpadding = 0;
@ -209,10 +222,12 @@ if ($moduleFilter != 0) {
// Filter report items created from metaconsole in normal console list and the opposite
if (defined('METACONSOLE') and $config['metaconsole'] == 1) {
$where .= ' AND ((server_name IS NOT NULL AND length(server_name) != 0) OR type IN (\'general\',\'SLA\',\'exception\',\'top_n\'))';
$where .= ' AND ((server_name IS NOT NULL AND length(server_name) != 0) ' .
'OR ' . $type_escaped . ' IN (\'general\', \'SLA\', \'exception\', \'availability\', \'top_n\'))';
}
else
$where .= ' AND ((server_name IS NULL OR length(server_name) = 0) OR type IN (\'general\',\'SLA\',\'exception\',\'top_n\'))';
$where .= ' AND ((server_name IS NULL OR length(server_name) = 0) ' .
'OR ' . $type_escaped . ' IN (\'general\', \'SLA\', \'exception\', \'availability\', \'top_n\'))';
switch ($config["dbtype"]) {
case "mysql":

View File

@ -946,8 +946,17 @@ switch ($action) {
$values['friday'] = get_parameter('friday', 0);
$values['saturday'] = get_parameter('saturday', 0);
$values['sunday'] = get_parameter('sunday', 0);
$values['time_from'] = get_parameter('time_from');
$values['time_to'] = get_parameter('time_to');
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$values['time_from'] = get_parameter('time_from');
$values['time_to'] = get_parameter('time_to');
break;
case "oracle":
$values['time_from'] = '#to_date(\'' . get_parameter('time_from') . '\',\'hh24:mi:ss\')';
$values['time_to'] = '#to_date(\'' . get_parameter('time_to') . '\', \'hh24:mi:ss\')';
break;
}
$values['group_by_agent'] = get_parameter ('checkbox_row_group_by_agent');
$values['show_resume'] = get_parameter ('checkbox_show_resume');
$values['order_uptodown'] = get_parameter ('radiobutton_order_uptodown');
@ -1064,7 +1073,22 @@ switch ($action) {
$values['style'] = io_safe_input(json_encode($style));
if ($good_format) {
$resultOperationDB = db_process_sql_update('treport_content', $values, array('id_rc' => $idItem));
switch ($config["dbtype"]) {
case "oracle":
if (isset($values['type'])) {
$values[
db_encapsule_fields_with_same_name_to_instructions(
"type")] = $values['type'];
unset($values['type']);
}
break;
}
$resultOperationDB = db_process_sql_update(
'treport_content',
$values,
array('id_rc' => $idItem));
}
else {
$resultOperationDB = false;
@ -1203,8 +1227,8 @@ switch ($action) {
$values['time_to'] = get_parameter('time_to');
break;
case "oracle":
$values['time_from'] = '#to_date(\'' . get_parameter('time_from') . '\',\'hh24:mi\')';
$values['time_to'] = '#to_date(\'' . get_parameter('time_to') . '\', \'hh24:mi\')';
$values['time_from'] = '#to_date(\'' . get_parameter('time_from') . '\',\'hh24:mi:ss\')';
$values['time_to'] = '#to_date(\'' . get_parameter('time_to') . '\', \'hh24:mi:ss\')';
break;
}
$values['group_by_agent'] = get_parameter ('checkbox_row_group_by_agent',0);
@ -1307,6 +1331,17 @@ switch ($action) {
$values['style'] = io_safe_input(json_encode($style));
if ($good_format) {
switch ($config["dbtype"]) {
case "oracle":
if (isset($values['type'])) {
$values[
db_encapsule_fields_with_same_name_to_instructions(
"type")] = $values['type'];
unset($values['type']);
}
break;
}
$result = db_process_sql_insert(
'treport_content', $values);
@ -1339,11 +1374,15 @@ switch ($action) {
}
switch ($config["dbtype"]) {
case "mysql":
db_process_sql_update('treport_content', array('`order`' => $max + 1), array('id_rc' => $idItem));
db_process_sql_update('treport_content',
array('`order`' => $max + 1),
array('id_rc' => $idItem));
break;
case "postgresql":
case "oracle":
db_process_sql_update('treport_content', array('"order"' => $max + 1), array('id_rc' => $idItem));
db_process_sql_update('treport_content',
array('"order"' => $max + 1),
array('id_rc' => $idItem));
break;
}
$resultOperationDB = true;
@ -1415,8 +1454,8 @@ switch ($action) {
case 'module':
$sql = "
SELECT t1.id_rc, t2.nombre
FROM treport_content AS t1
LEFT JOIN tagente_modulo AS t2
FROM treport_content t1
LEFT JOIN tagente_modulo t2
ON t1.id_agent_module = t2.id_agente_modulo
WHERE %s
ORDER BY nombre %s
@ -1428,11 +1467,11 @@ switch ($action) {
FROM
(
SELECT t1.*, id_agente
FROM treport_content AS t1
LEFT JOIN tagente_modulo AS t2
FROM treport_content t1
LEFT JOIN tagente_modulo t2
ON t1.id_agent_module = id_agente_modulo
) AS t4
LEFT JOIN tagente AS t5
) t4
LEFT JOIN tagente t5
ON (t4.id_agent = t5.id_agente OR t4.id_agente = t5.id_agente)
WHERE %s
ORDER BY t5.nombre %s

View File

@ -114,7 +114,8 @@ foreach ($layoutDatas as $layoutData) {
html_print_input_hidden('status_' . $layoutData['id'], $layoutData['status_calculated']);
html_print_input_hidden('status_' . $layoutData['id'],
$layoutData['status_calculated']);
}
@ -126,11 +127,28 @@ echo '</div>';
html_print_input_hidden('background_width', $widthBackground);
html_print_input_hidden('background_height', $heightBackground);
$backgroundSizes = getimagesize($config['homedir'] . '/images/console/background/' . $background);
$backgroundSizes = getimagesize(
$config['homedir'] . '/images/console/background/' . $background);
html_print_input_hidden('background_original_width', $backgroundSizes[0]);
html_print_input_hidden('background_original_height', $backgroundSizes[1]);
// Loading dialog
echo "<div id='loading_in_progress_dialog' style='display: none; text-align: center;' title='" . __('Action in progress') . "'>" .
__('Loading in progress') . '<br />' .
html_print_image("images/spinner.gif", true) .
"</div>";
echo "<div id='saving_in_progress_dialog' style='display: none; text-align: center;' title='" . __('Action in progress') . "'>" .
__('Saving in progress') . '<br />' .
html_print_image("images/spinner.gif", true) .
"</div>";
echo "<div id='delete_in_progress_dialog' style='display: none; text-align: center;' title='" . __('Action in progress') . "'>" .
__('Deletion in progress') . '<br />' .
html_print_image("images/spinner.gif", true) .
"</div>";
//CSS
ui_require_css_file ('color-picker');
ui_require_css_file ('jquery-ui-1.8.17.custom');

View File

@ -85,14 +85,14 @@ if ((isset ($_GET["update"])) OR ((isset ($_GET["create"])))) {
$recon_ports = get_parameter_post ("recon_ports", "");
$id_os = get_parameter_post ("id_os", 10);
$snmp_community = get_parameter_post ("snmp_community", "public");
$id_recon_script = get_parameter ("id_recon_script", 'NULL');
$id_recon_script = get_parameter ("id_recon_script", 0);
$mode = get_parameter ("mode", "");
$field1 = get_parameter ("field1", "");
$field2 = get_parameter ("field2", "");
$field3 = get_parameter ("field3", "");
$field4 = get_parameter ("field4", "");
if ($mode == "network_sweep")
$id_recon_script = 'NULL';
$id_recon_script = 0;
else
$id_network_profile = 0;
@ -149,9 +149,9 @@ if (isset($_GET["update"])) {
$reason = '';
if ($name != "") {
if (($id_recon_script == 'NULL') && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
if ((empty($id_recon_script)) && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
$result = db_process_sql_update('trecon_task', $values, $where);
elseif ($id_recon_script != 'NULL')
elseif (!empty($id_recon_script))
$result = db_process_sql_update('trecon_task', $values, $where);
else {
if (!preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
@ -201,13 +201,13 @@ if (isset($_GET["create"])) {
$reason = "";
if ($name != "") {
if (($id_recon_script == 'NULL') && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
if (empty($id_recon_script) && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
{
$result = db_process_sql_insert('trecon_task', $values);
$reason = __("Network provided is not correct");
}
elseif ($id_recon_script != 'NULL') {
elseif (!empty($id_recon_script)) {
$result = db_process_sql_insert('trecon_task', $values);
}
else {

View File

@ -42,10 +42,28 @@ if (is_ajax ()) {
$get_recon_script_macros = get_parameter('get_recon_script_macros');
if ($get_recon_script_macros) {
$id_recon_script = get_parameter('id', 0);
$id_recon_script = (int) get_parameter('id');
$id_recon_task = (int) get_parameter('id_rt');
$recon_script_macros = db_get_value('macros', 'trecon_script', 'id_recon_script',
$id_recon_script);
if (!empty($id_recon_task) && empty($id_recon_script)) {
$recon_script_macros = db_get_value('macros', 'trecon_task', 'id_rt', $id_recon_task);
}
else if (!empty($id_recon_task)) {
$recon_task_id_rs = (int) db_get_value('id_recon_script', 'trecon_task', 'id_rt', $id_recon_task);
if ($id_recon_script == $recon_task_id_rs) {
$recon_script_macros = db_get_value('macros', 'trecon_task', 'id_rt', $id_recon_task);
}
else {
$recon_script_macros = db_get_value('macros', 'trecon_script', 'id_recon_script', $id_recon_script);
}
}
else if (!empty($id_recon_script)) {
$recon_script_macros = db_get_value('macros', 'trecon_script', 'id_recon_script', $id_recon_script);
}
else {
$recon_script_macros = array();
}
$macros = array();
$macros['base64'] = base64_encode($recon_script_macros);
@ -59,10 +77,10 @@ if (is_ajax ()) {
}
// Edit mode
if (isset ($_GET["update"]) or (isset($_GET["crt"]))) {
if (isset($_GET["update"]) || (isset($_GET["crt"]))) {
$update_recon = true;
if (isset ($_GET["crt"])) {
if (isset($_GET["crt"])) {
if ($_GET["crt"] != "update") {
$update_recon = false;
}
@ -75,7 +93,7 @@ if (isset ($_GET["update"]) or (isset($_GET["crt"]))) {
if (!isset($id_rt)) {
$id_rt = (int) get_parameter_get ("update");
}
$row = db_get_row ("trecon_task","id_rt",$id_rt);
$row = db_get_row ("trecon_task", "id_rt", $id_rt);
$name = $row["name"];
$network = $row["subnet"];
$id_recon_server = $row["id_recon_server"];
@ -105,7 +123,7 @@ if (isset ($_GET["update"]) or (isset($_GET["crt"]))) {
$macros = $row["macros"];
}
}
elseif (isset ($_GET["create"]) or isset($_GET["crt"])) {
elseif (isset($_GET["create"]) || isset($_GET["crt"])) {
$create_recon = true;
if (isset ($_GET["crt"])) {
if ($_GET["crt"] != "Create") {
@ -228,11 +246,13 @@ $table->data[5][1] = html_print_select_from_sql ($sql, "id_network_profile", $id
// Recon script
$data[1] = '';
$table->data[6][0] = "<b>".__('Recon script');
$table->data[6][1] = html_print_select_from_sql ('SELECT id_recon_script, name FROM trecon_script',
"id_recon_script", $id_recon_script, 'get_explanation_recon_script($(\'#id_recon_script\').val())', '', '', true);
$table->data[6][1] .= $data[1] .= html_print_input_hidden('macros',
base64_encode($macros),true);
$sql = 'SELECT id_recon_script, name
FROM trecon_script
ORDER BY name';
$table->data[6][1] = html_print_select_from_sql ($sql, "id_recon_script", $id_recon_script, '', '', '', true);
$table->data[6][1] .= "<span id='spinner_recon_script' style='display: none;'>" . html_print_image ("images/spinner.gif", true) . "</span>";
$table->data[6][1] .= $data[1] .= html_print_input_hidden('macros', base64_encode($macros),true);
// OS
$table->data[7][0] = "<b>".__('OS');
@ -263,18 +283,14 @@ $table->data[10][1] = html_print_select ($values, "create_incident", $create_inc
$table->data[11][0] = "<b>".__('SNMP Default community');
$table->data[11][1] = html_print_input_text ('snmp_community', $snmp_community, '', 35, 0, true);
// SNMP default community
$table->data[11][0] = "<b>".__('SNMP Default community');
$table->data[11][1] = html_print_input_text ('snmp_community', $snmp_community, '', 35, 0, true);
// Explanation
$explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id_recon_script);
$table->data[12][0] = "<b>" . __('Explanation') . "</b>";
$table->data[12][1] = "<span id='spinner_layour' style='display: none;'>" . html_print_image ("images/spinner.gif", true) .
$table->data[12][1] = "<span id='spinner_layout' style='display: none;'>" . html_print_image ("images/spinner.gif", true) .
"</span>" . html_print_textarea('explanation', 4, 60, $explanation, 'style="width: 388px;"', true);
// A hidden "model row" to clone it from javascript to add fields dynamicly
// A hidden "model row" to clone it from javascript to add fields dynamicaly
$data = array ();
$data[0] = 'macro_desc';
$data[0] .= ui_print_help_tip ('macro_help', true);
@ -341,91 +357,131 @@ echo "</form>";
ui_require_javascript_file ('pandora_modules');
?>
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready (function () {
if($('#mode').val() == 'recon_script') {
$(".recon_script").attr ('style', '');
$(".network_sweep").attr ('style', 'display:none');
}
else if($('#mode').val() == 'network_sweep') {
$(".network_sweep").attr ('style', '');
$(".recon_script").attr ('style', 'display:none');
}
$('#mode').change(function() {
if(this.value == 'recon_script') {
$(".recon_script").attr ('style', '');
$(".network_sweep").attr ('style', 'display:none');
$("#textarea_explanation").css('display', 'none');
$("#spinner_layour").css('display', '');
get_explanation_recon_script($("#id_recon_script").val());
}
else if(this.value == 'network_sweep') {
$(".network_sweep").attr ('style', '');
$(".recon_script").attr ('style', 'display:none');
}
});
});
$("#interval_manual_defined").change(function() {
var xhrManager = function () {
var manager = {};
manager.tasks = [];
manager.addTask = function (xhr) {
manager.tasks.push(xhr);
}
manager.stopTasks = function () {
while (manager.tasks.length > 0)
manager.tasks.pop().abort();
}
return manager;
};
var taskManager = new xhrManager();
$('select#interval_manual_defined').change(function() {
if ($("#interval_manual_defined").val() == 1) {
$('#interval_manual_container').css('visibility', 'hidden');
$('#text-interval_text').val('0');
$('#hidden-interval').val('0');
$('#interval_manual_container').hide();
$('#text-interval_text').val(0);
$('#hidden-interval').val(0);
}
else {
$('#interval_manual_container').css('visibility', '');
$('#text-interval_text').val('10');
$('#hidden-interval').val('600');
$('#interval_units').val('60');
$('#interval_manual_container').show();
$('#text-interval_text').val(10);
$('#hidden-interval').val(600);
$('#interval_units').val(60);
}
}).change();
$('select#id_recon_script').change(function() {
if ($('select#mode').val() == 'recon_script')
get_explanation_recon_script($(this).val());
});
$('select#mode').change(function() {
var type = $(this).val();
$("#interval_manual_defined").trigger('change');
if (type == 'recon_script') {
$(".recon_script").show();
$(".network_sweep").hide();
get_explanation_recon_script($("#id_recon_script").val());
}
else if (type == 'network_sweep') {
$(".recon_script").hide();
$(".network_sweep").show();
}
}).change();
function get_explanation_recon_script(id) {
jQuery.post ("ajax.php",
{"page" : "godmode/servers/manage_recontask_form",
"get_explanation" : 1,
"id" : id
function get_explanation_recon_script (id) {
// Stop old ajax tasks
taskManager.stopTasks();
// Show the spinners
$("#textarea_explanation").hide();
$("#spinner_layout").show();
var xhr = jQuery.ajax ({
data: {
'page': 'godmode/servers/manage_recontask_form',
'get_explanation': 1,
'id': id,
'id_rt': <?php echo json_encode((int)$id_rt); ?>
},
function (data, status) {
$("#spinner_layour").css('display', 'none');
$("#textarea_explanation").css('display', '');
$("#textarea_explanation").val(data);
}
);
var params = [];
params.push("page=godmode/servers/manage_recontask_form");
params.push("get_recon_script_macros=1");
params.push("id=" + id);
jQuery.ajax ({
data: params.join ("&"),
url: "<?php echo $config['homeurl']; ?>ajax.php",
type: 'POST',
dataType: 'text',
complete: function (xhr, textStatus) {
$("#spinner_layout").hide();
},
success: function (data, textStatus, xhr) {
$("#textarea_explanation").val(data);
$("#textarea_explanation").show();
},
error: function (xhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
taskManager.addTask(xhr);
// Delete all the macro fields
$('.macro_field').remove();
$("#spinner_recon_script").show();
var xhr = jQuery.ajax ({
data: {
'page': 'godmode/servers/manage_recontask_form',
'get_recon_script_macros': 1,
'id': id,
'id_rt': <?php echo json_encode((int)$id_rt); ?>
},
url: "<?php echo $config['homeurl']; ?>ajax.php",
type: 'POST',
url: action = get_php_value('absolute_homeurl') + "ajax.php",
async: false,
timeout: 10000,
dataType: 'json',
success: function (data) {
// Delete all the macro fields
$('.macro_field').remove();
if (data['array'] != null) {
$('#hidden-macros').val(data['base64']);
jQuery.each (data['array'], function (i, macro) {
if (macro['desc'] != '') {
complete: function (xhr, textStatus) {
$("#spinner_recon_script").hide();
forced_title_callback();
},
success: function (data, textStatus, xhr) {
if (data.array !== null) {
$('#hidden-macros').val(data.base64);
jQuery.each (data.array, function (i, macro) {
if (macro.desc != '') {
add_macro_field(macro, 'table_recon-macro');
}
});
}
forced_title_callback();
},
error: function (xhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
taskManager.addTask(xhr);
}
/* ]]> */
</script>

View File

@ -781,7 +781,7 @@ ui_require_javascript_file('pandora_modules');
});
function show_locked_dialog(id_plugin) {
function show_locked_dialog(id_plugin, plugin_name) {
var parameters = {};
parameters['page'] = "godmode/servers/plugin";
parameters["get_list_modules_and_component_locked_plugin"] = 1;
@ -793,7 +793,10 @@ ui_require_javascript_file('pandora_modules');
data: parameters,
dataType: "html",
success: function(data) {
var title = $("#dialog_locked").prop('title').replace(/%s/, plugin_name);
$("#dialog_locked")
.prop('title', title)
.html(data);
$("#dialog_locked")
.dialog ({

View File

@ -53,6 +53,7 @@ echo '</script>';
echo '<form method="post">';
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';

View File

@ -51,6 +51,7 @@ if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_us
}
// Load enterprise extensions
enterprise_include_once ('include/functions_setup.php');
enterprise_include_once ('include/functions_io.php');
enterprise_include_once ('godmode/setup/setup.php');
/*

View File

@ -55,7 +55,7 @@ $table->data[0][1] = html_print_select_from_sql (
$table->data[1][0] = __('Remote config directory') .
ui_print_help_tip (__("Directory where agent remote configuration is stored."), true);
$table->data[1][1] = html_print_input_text ('remote_config', $config["remote_config"], '', 30, 100, true);
$table->data[1][1] = html_print_input_text ('remote_config', io_safe_output($config["remote_config"]), '', 30, 100, true);
$table->data[6][0] = __('Auto login (hash) password');
$table->data[6][1] = html_print_input_text ('loginhash_pwd', io_output_password($config["loginhash_pwd"]), '', 15, 15, true);
@ -74,7 +74,7 @@ $table->data[11][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button_ext
$table->data[11][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('https', 0, '', $config["https"], true);
$table->data[14][0] = __('Attachment store') . ui_print_help_tip (__("Directory where temporary data is stored."), true);
$table->data[14][1] = html_print_input_text ('attachment_store', $config["attachment_store"], '', 50, 255, true);
$table->data[14][1] = html_print_input_text ('attachment_store', io_safe_output($config["attachment_store"]), '', 50, 255, true);
$table->data[15][0] = __('IP list with API access') . ui_print_help_icon ("ip_api_list", true);
if (isset($_POST["list_ACL_IPs_for_API"])) {

View File

@ -46,7 +46,7 @@ require_once ('include/functions_themes.php');
require_once ('include/functions_gis.php');
$table = new stdClass();
$table->width = '98%';
$table->width = '100%';
$table->data = array ();
$row = 0;
@ -187,7 +187,7 @@ $row++;
$table->data[$row][0] = __('Font path');
$fonts = load_fonts();
$table->data[$row][1] = html_print_select($fonts, 'fontpath', $config["fontpath"], '', '', 0, true);
$table->data[$row][1] = html_print_select($fonts, 'fontpath', io_safe_output($config["fontpath"]), '', '', 0, true);
$row++;

View File

@ -598,6 +598,7 @@ if (!empty ($id) && !$new_user) {
if (!defined("METACONSOLE"))
echo '<h4>'. __('Profiles/Groups assigned to this user') . '</h4>';
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox data';
if (defined("METACONSOLE")) {

View File

@ -15,10 +15,14 @@
// GNU General Public License for more details.
global $config;
require_once ('include/functions_agents.php');
include_once ('include/functions_reporting.php');
require_once ($config['homedir'] . '/include/functions_agents.php');
include_once ($config['homedir'] . '/include/functions_reporting.php');
enterprise_include_once ('include/functions_metaconsole.php');
// Clean the possible blanks introduced by the included files
ob_clean();
// Get list of agent + ip
// Params:
// * search_agents 1
@ -55,7 +59,6 @@ if ($get_agents_group) {
}
if ($search_agents && ((!defined('METACONSOLE')) || $force_local)) {
require_once ('include/functions_agents.php');
$id_agent = (int) get_parameter('id_agent');
$string = (string) get_parameter('q'); /* q is what autocomplete plugin gives */
@ -100,7 +103,7 @@ if ($search_agents && ((!defined('METACONSOLE')) || $force_local)) {
$filter_agents[] = '(nombre LIKE \'%'.$string.'%\')';
break;
case "oracle":
$filter_agents[] = '(UPPER(nombre) LIKE UPPER(\'%'.$string.'%\')';
$filter_agents[] = '(UPPER(nombre) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$agents = agents_get_agents($filter_agents, array ('id_agente', 'nombre', 'direccion'));
@ -160,7 +163,6 @@ if ($search_agents && ((!defined('METACONSOLE')) || $force_local)) {
}
echo json_encode($data);
return;
}
elseif ($search_agents && ($config['metaconsole'] == 1) && defined('METACONSOLE')) {
@ -170,6 +172,7 @@ elseif ($search_agents && ($config['metaconsole'] == 1) && defined('METACONSOLE'
$id_group = (int) get_parameter('id_group', -1);
$addedItems = html_entity_decode((string) get_parameter('add'));
$addedItems = json_decode($addedItems);
$all = (string)get_parameter('all', 'all');
if ($addedItems != null) {
foreach ($addedItems as $item) {
@ -177,6 +180,13 @@ elseif ($search_agents && ($config['metaconsole'] == 1) && defined('METACONSOLE'
}
}
$data = array();
$fields = array(
'id_tagente AS id_agente', 'nombre',
'direccion', 'id_tmetaconsole_setup AS id_server'
);
$filter = array();
if ($id_group != -1) {
@ -190,66 +200,98 @@ elseif ($search_agents && ($config['metaconsole'] == 1) && defined('METACONSOLE'
}
}
switch ($all) {
case 'enabled':
$filter['disabled'] = 0;
break;
}
if (!empty($id_agent)) {
$filter['id_agente'] = $id_agent;
}
if (!empty($string)) {
$search_filters = array();
//Get agents for only the name.
$filter_agents = $filter;
switch ($config['dbtype']) {
case "mysql":
//Get agents for only the name.
$search_filters[] = "(nombre COLLATE utf8_general_ci LIKE '%$string%')";
//Get agents for only the address
$search_filters[] = "(direccion LIKE '%$string%')";
//Get agents for only the description
$search_filters[] = "(comentarios LIKE '%$string%')";
$filter_agents[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%")';
break;
case "postgresql":
//Get agents for only the name.
$search_filters[] = "(nombre LIKE '%$string%')";
//Get agents for only the address
$search_filters[] = "(direccion LIKE '%$string%')";
//Get agents for only the description
$search_filters[] = "(comentarios LIKE '%$string%')";
$filter_agents[] = '(nombre LIKE \'%'.$string.'%\')';
break;
case "oracle":
//Get agents for only the name.
$search_filters[] = "(UPPER(nombre) LIKE UPPER('%$string%')";
//Get agents for only the address
$search_filters[] = "(UPPER(direccion) LIKE UPPER('%$string%'))";
//Get agents for only the description
$search_filters[] = "(UPPER(comentarios) LIKE UPPER('%$string%'))";
$filter_agents[] = '(UPPER(nombre) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$search_filters_str = implode($search_filters, ' OR ');
if (!empty($search_filters_str))
$filter[] = "($search_filters_str)";
}
$fields = array(
'id_tagente AS id_agente', 'nombre',
'direccion', 'id_tmetaconsole_setup AS id_server'
);
$agents = db_get_all_rows_filter('tmetaconsole_agent', $filter, $fields);
$data = array();
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'ip' => io_safe_output($agent['direccion']),
'filter' => 'description',
'id_server' => $agent['id_server']);
$agents = db_get_all_rows_filter('tmetaconsole_agent', $filter_agents, $fields);
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'ip' => io_safe_output($agent['direccion']),
'id_server' => $agent['id_server'],
'filter' => 'agent');
}
}
//Get agents for only the address
$filter_address = $filter;
switch ($config['dbtype']) {
case "mysql":
$filter_address[] = '(nombre COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND direccion LIKE "%'.$string.'%")';
break;
case "postgresql":
$filter_address[] = '(nombre NOT LIKE \'%'.$string.'%\' AND direccion LIKE \'%'.$string.'%\')';
break;
case "oracle":
$filter_address[] = '(UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$agents = db_get_all_rows_filter('tmetaconsole_agent', $filter_address, $fields);
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'ip' => io_safe_output($agent['direccion']),
'id_server' => $agent['id_server'],
'filter' => 'address');
}
}
//Get agents for only the description
$filter_description = $filter;
switch ($config['dbtype']) {
case "mysql":
$filter_description[] = '(nombre COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND direccion NOT LIKE "%'.$string.'%" AND comentarios LIKE "%'.$string.'%")';
break;
case "postgresql":
$filter_description[] = '(nombre NOT LIKE \'%'.$string.'%\' AND direccion NOT LIKE \'%'.$string.'%\' AND comentarios LIKE \'%'.$string.'%\')';
break;
case "oracle":
$filter_description[] = '(UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(comentarios) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$agents = db_get_all_rows_filter('tmetaconsole_agent', $filter_description, $fields);
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'ip' => io_safe_output($agent['direccion']),
'id_server' => $agent['id_server'],
'filter' => 'description');
}
}
}
echo json_encode($data);
return;
}
?>
return;
?>

0
pandora_console/include/ajax/reporting.ajax.php Normal file → Executable file
View File

View File

@ -17,6 +17,25 @@ global $config;
check_login ();
$get_image_path_status = get_parameter('get_image_path_status', 0);
if ($get_image_path_status){
$img_src = get_parameter("img_src");
$only_src = get_parameter("only_src", 0);
$result = array();
$result['bad'] = html_print_image($img_src . '_bad.png', true, '', $only_src);
$result['ok'] = html_print_image($img_src . '_ok.png', true, '', $only_src);
$result['warning'] = html_print_image($img_src . '_warning.png', true, '', $only_src);
$result['ok'] = html_print_image($img_src . '_ok.png', true, '', $only_src);
$result['normal'] = html_print_image($img_src . '.png', true, '', $only_src);
echo json_encode($result);
return;
}
$id_visual_console = get_parameter('id_visual_console', null);
// WARNING: CHECK THE ENTIRE FUNCTIONALITY
@ -96,8 +115,6 @@ $id_agent = get_parameter('id_agent', null);
$id_metaconsole = get_parameter('id_metaconsole', null);
$id_group = (int)get_parameter('id_group', 0);
$id_custom_graph = get_parameter('id_custom_graph', null);
$height_module_graph = get_parameter('id_custom_graph', null);
$width_module_graph = get_parameter('id_custom_graph', null);
$border_width = get_parameter('border_width', 0);
$border_color = get_parameter('border_color', '');
$fill_color = get_parameter('fill_color', '');
@ -111,7 +128,6 @@ $line_width = (int)get_parameter('line_width', 0);
$line_color = get_parameter('line_color', '');
$get_element_status = get_parameter('get_element_status', 0);
$get_image_path_status = get_parameter('get_image_path_status', 0);
$enable_link = get_parameter('enable_link', 1);
@ -437,13 +453,13 @@ switch ($action) {
$values['id_layout_linked'] = $map_linked;
}
switch ($type) {
// -- line_item --
// -- line_item ------------------------------------
case 'handler_start':
case 'handler_end':
// ---------------
$values['border_width'] = $line_width;
$values['border_color'] = $line_color;
break;
// -------------------------------------------------
case 'box_item':
$values['border_width'] = $border_width;
$values['border_color'] = $border_color;
@ -799,6 +815,7 @@ switch ($action) {
}
break;
}
$idData = db_process_sql_insert('tlayout_data', $values);
$return = array();
@ -905,19 +922,4 @@ if ($get_element_status) {
return;
}
if ($get_image_path_status) {
$img_src = get_parameter("img_src");
$only_src = get_parameter("only_src", 0);
$result = array();
$result['bad'] = html_print_image($img_src . '_bad.png', true, '', $only_src);
$result['ok'] = html_print_image($img_src . '_ok.png', true, '', $only_src);
$result['warning'] = html_print_image($img_src . '_warning.png', true, '', $only_src);
$result['ok'] = html_print_image($img_src . '_ok.png', true, '', $only_src);
$result['normal'] = html_print_image($img_src . '.png', true, '', $only_src);
echo json_encode($result);
}
?>

View File

@ -192,9 +192,20 @@ class Tree {
}
protected function getAgentCountersSql ($agent_table) {
global $config;
$columns = $this->getAgentCounterColumnsSql($agent_table);
$columns = "SELECT $columns FROM dual LIMIT 1";
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$columns = "SELECT $columns FROM dual LIMIT 1";
break;
case "oracle":
$columns = "SELECT $columns FROM dual WHERE rownum <= 1";
break;
}
return $columns;
}
@ -237,7 +248,7 @@ class Tree {
// Agents join
$agents_join = "";
if (!empty($agent_search_filter) || !empty($agent_status_filter)) {
$agents_join = "INNER JOIN tagente AS ta
$agents_join = "INNER JOIN tagente ta
ON ta.disabled = 0
AND tam.id_agente = ta.id_agente
$agent_search_filter
@ -288,13 +299,13 @@ class Tree {
if (!empty($module_search_filter) || !empty($module_status_filter)) {
if (!empty($module_status_filter)) {
$module_status_join = "INNER JOIN tagente_estado AS tae
$module_status_join = "INNER JOIN tagente_estado tae
ON tam.id_agente_modulo IS NOT NULL
AND tam.id_agente_modulo = tae.id_agente_modulo
$module_status_filter";
}
$modules_join = "INNER JOIN tagente_modulo AS tam
$modules_join = "INNER JOIN tagente_modulo tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
$module_search_filter
@ -302,7 +313,7 @@ class Tree {
}
if (empty($module_status_join)) {
$module_status_join = "LEFT JOIN tagente_estado AS tae
$module_status_join = "LEFT JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo";
}
@ -311,15 +322,13 @@ class Tree {
switch ($rootType) {
case 'group':
// ACL Group
$user_groups_str = "-1";
$group_acl = "";
if (!$this->strictACL) {
if (!empty($this->userGroups)) {
$user_groups_str = implode(",", array_keys($this->userGroups));
$group_acl = "AND ta.id_grupo IN ($user_groups_str)";
}
else {
$group_acl = "AND ta.id_grupo = -1";
}
$group_acl = "AND ta.id_grupo IN ($user_groups_str)";
}
else {
if (!empty($this->acltags)) {
@ -333,16 +342,10 @@ class Tree {
if (!empty($groups)) {
if (array_search(0, $groups) === false) {
$user_groups_str = implode(",", $groups);
$group_acl = " AND ta.id_grupo IN ($user_groups_str) ";
}
}
else {
$group_acl = "AND ta.id_grupo = -1";
}
}
else {
$group_acl = "AND ta.id_grupo = -1";
}
$group_acl = "AND ta.id_grupo IN ($user_groups_str)";
}
switch ($type) {
@ -356,63 +359,50 @@ class Tree {
$order_fields = 'tg.nombre ASC, tg.id_grupo ASC';
if (! defined('METACONSOLE')) {
// Add the agent counters to the columns
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tagente AS ta
LEFT JOIN tagente_modulo AS tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
$module_search_filter
$module_status_join
WHERE ta.disabled = 0
AND ta.id_grupo = tg.id_grupo
$group_acl
$agent_search_filter
$agent_status_filter";
$counter_columns = $this->getAgentCounterColumnsSql($agent_table);
if (!empty($counter_columns))
$columns .= ", $counter_columns";
$sql = "SELECT $columns
FROM tgrupo AS tg
LEFT JOIN tagente AS ta
LEFT JOIN tagente_modulo AS tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
$module_search_filter
$module_status_join
ON ta.disabled = 0
AND tg.id_grupo = ta.id_grupo
$group_acl
$agent_search_filter
$agent_status_filter
GROUP BY tg.id_grupo
ORDER BY $order_fields";
// Groups SQL
if ($item_for_count === false) {
$sql = "SELECT $columns
FROM tgrupo tg
WHERE tg.id_grupo IN ($user_groups_str)
ORDER BY $order_fields";
}
// Counters SQL
else {
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tagente ta
LEFT JOIN tagente_modulo tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
$module_search_filter
$module_status_join
WHERE ta.disabled = 0
AND ta.id_grupo = $item_for_count
$group_acl
$agent_search_filter
$agent_status_filter";
$sql = $this->getAgentCountersSql($agent_table);
}
}
// Metaconsole
else {
// Add the agent counters to the columns
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tmetaconsole_agent AS ta
WHERE ta.disabled = 0
AND ta.id_grupo = tg.id_grupo
$group_acl
$agent_search_filter
$agent_status_filter";
$counter_columns = $this->getAgentCounterColumnsSql($agent_table);
if (!empty($counter_columns))
$columns .= ", $counter_columns";
$sql = "SELECT $columns
FROM tgrupo AS tg
LEFT JOIN tagente AS ta
ON ta.disabled = 0
AND tg.id_grupo = ta.id_grupo
$group_acl
$agent_search_filter
$agent_status_filter
GROUP BY tg.id_grupo
ORDER BY $order_fields";
// Groups SQL
if ($item_for_count === false) {
$sql = "SELECT $columns
FROM tgrupo tg
WHERE tg.id_grupo IN ($user_groups_str)
ORDER BY $order_fields";
}
// Counters SQL
else {
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tmetaconsole_agent ta
WHERE ta.disabled = 0
AND ta.id_grupo = $item_for_count
$group_acl
$agent_search_filter
$agent_status_filter";
$sql = $this->getAgentCountersSql($agent_table);
}
}
}
else {
@ -421,11 +411,15 @@ class Tree {
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$group_by_fields = 'ta.id_agente, ta.nombre,
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$sql = "SELECT $columns
FROM tagente AS ta
LEFT JOIN tagente_modulo AS tam
FROM tagente ta
LEFT JOIN tagente_modulo tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
$module_search_filter
@ -435,7 +429,7 @@ class Tree {
$group_acl
$agent_search_filter
$agent_status_filter
GROUP BY ta.id_agente
GROUP BY $group_by_fields
ORDER BY $order_fields";
}
else {
@ -446,13 +440,12 @@ class Tree {
$order_fields = 'ta.nombre ASC, ta.id_tagente ASC';
$sql = "SELECT $columns
FROM tmetaconsole_agent AS ta
FROM tmetaconsole_agent ta
WHERE ta.disabled = 0
AND ta.id_grupo = $rootID
$group_acl
$agent_search_filter
$agent_status_filter
GROUP BY ta.id_tagente
ORDER BY $order_fields";
}
}
@ -464,9 +457,9 @@ class Tree {
$order_fields = 'tam.nombre ASC, tam.id_agente_modulo ASC';
$sql = "SELECT $columns
FROM tagente_modulo AS tam
FROM tagente_modulo tam
$module_status_join
INNER JOIN tagente AS ta
INNER JOIN tagente ta
ON ta.disabled = 0
AND tam.id_agente = ta.id_agente
AND ta.id_grupo = $rootID
@ -476,7 +469,6 @@ class Tree {
WHERE tam.disabled = 0
AND tam.id_agente = $parent
$module_search_filter
GROUP BY tam.id_agente_modulo
ORDER BY $order_fields";
break;
}
@ -535,39 +527,40 @@ class Tree {
}
$columns = 'tt.id_tag AS id, tt.name AS name';
$group_by_fields = 'tt.id_tag, tt.name';
$order_fields = 'tt.name ASC, tt.id_tag ASC';
// Tags SQL
if ($item_for_count === false) {
$sql = "SELECT $columns
FROM ttag AS tt
INNER JOIN ttag_module AS ttm
FROM ttag tt
INNER JOIN ttag_module ttm
ON tt.id_tag = ttm.id_tag
INNER JOIN tagente_modulo AS tam
INNER JOIN tagente_modulo tam
ON tam.disabled = 0
AND ttm.id_agente_modulo = tam.id_agente_modulo
$module_search_filter
$module_status_join
INNER JOIN tagente AS ta
INNER JOIN tagente ta
ON ta.disabled = 0
AND tam.id_agente = ta.id_agente
$group_acl
$agent_search_filter
$agent_status_filter
$tag_filter
GROUP BY tt.id_tag
GROUP BY $group_by_fields
ORDER BY $order_fields";
}
// Counters SQL
else {
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tagente AS ta
INNER JOIN tagente_modulo AS tam
FROM tagente ta
INNER JOIN tagente_modulo tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
$module_search_filter
$module_status_join
INNER JOIN ttag_module AS ttm
INNER JOIN ttag_module ttm
ON tam.id_agente_modulo = ttm.id_agente_modulo
AND ttm.id_tag = $item_for_count
WHERE ta.disabled = 0
@ -582,23 +575,27 @@ class Tree {
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$group_by_fields = 'ta.id_agente, ta.nombre,
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$sql = "SELECT $columns
FROM tagente AS ta
INNER JOIN tagente_modulo AS tam
FROM tagente ta
INNER JOIN tagente_modulo tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
$module_search_filter
$module_status_join
INNER JOIN ttag_module AS ttm
INNER JOIN ttag_module ttm
ON tam.id_agente_modulo = ttm.id_agente_modulo
AND ttm.id_tag = $rootID
WHERE ta.disabled = 0
$group_acl
$agent_search_filter
$agent_status_filter
GROUP BY ta.id_agente
GROUP BY $group_by_fields
ORDER BY $order_fields";
}
break;
@ -609,12 +606,12 @@ class Tree {
$order_fields = 'tam.nombre ASC, tam.id_agente_modulo ASC';
$sql = "SELECT $columns
FROM tagente_modulo AS tam
INNER JOIN ttag_module AS ttm
FROM tagente_modulo tam
INNER JOIN ttag_module ttm
ON tam.id_agente_modulo = ttm.id_agente_modulo
AND ttm.id_tag = $rootID
$module_status_join
INNER JOIN tagente AS ta
INNER JOIN tagente ta
ON ta.disabled = 0
AND tam.id_agente = ta.id_agente
$group_acl
@ -623,7 +620,6 @@ class Tree {
WHERE tam.disabled = 0
AND tam.id_agente = $parent
$module_search_filter
GROUP BY tam.id_agente_modulo
ORDER BY $order_fields";
break;
}
@ -644,26 +640,27 @@ class Tree {
case 'os':
if (empty($rootID) || $rootID == -1) {
$columns = 'tos.id_os AS id, tos.name AS name, tos.icon_name AS os_icon';
$group_by_fields = 'tos.id_os, tos.name, tos.icon_name';
$order_fields = 'tos.icon_name ASC, tos.id_os ASC';
// OS SQL
if ($item_for_count === false) {
$sql = "SELECT $columns
FROM tconfig_os AS tos
INNER JOIN tagente AS ta
FROM tconfig_os tos
INNER JOIN tagente ta
ON ta.disabled = 0
AND ta.id_os = tos.id_os
$agent_search_filter
$agent_status_filter
$group_acl
$modules_join
GROUP BY tos.id_os
GROUP BY $group_by_fields
ORDER BY $order_fields";
}
// Counters SQL
else {
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tagente AS ta
FROM tagente ta
$modules_join
WHERE ta.disabled = 0
AND ta.id_os = $item_for_count
@ -678,17 +675,21 @@ class Tree {
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$group_by_fields = 'ta.id_agente, ta.nombre,
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$sql = "SELECT $columns
FROM tagente AS ta
FROM tagente ta
$modules_join
WHERE ta.disabled = 0
AND ta.id_os = $rootID
$group_acl
$agent_search_filter
$agent_status_filter
GROUP BY ta.id_agente
GROUP BY $group_by_fields
ORDER BY $order_fields";
}
break;
@ -702,9 +703,9 @@ class Tree {
$agent_filter = "AND ta.id_agente = $parent";
$sql = "SELECT $columns
FROM tagente_modulo AS tam
FROM tagente_modulo tam
$module_status_join
INNER JOIN tagente AS ta
INNER JOIN tagente ta
ON ta.disabled = 0
AND tam.id_agente = ta.id_agente
$os_filter
@ -714,7 +715,6 @@ class Tree {
WHERE tam.disabled = 0
$agent_filter
$module_search_filter
GROUP BY tam.id_agente_modulo
ORDER BY $order_fields";
break;
}
@ -735,31 +735,32 @@ class Tree {
case 'module_group':
if (empty($rootID) || $rootID == -1) {
$columns = 'tmg.id_mg AS id, tmg.name AS name';
$group_by_fields = 'tmg.id_mg, tmg.name';
$order_fields = 'tmg.name ASC, tmg.id_mg ASC';
// Module groups SQL
if ($item_for_count === false) {
$sql = "SELECT $columns
FROM tmodule_group AS tmg
INNER JOIN tagente_modulo AS tam
FROM tmodule_group tmg
INNER JOIN tagente_modulo tam
ON tam.disabled = 0
AND tam.id_module_group = tmg.id_mg
$module_search_filter
$module_status_join
INNER JOIN tagente AS ta
INNER JOIN tagente ta
ON ta.disabled = 0
AND tam.id_agente = ta.id_agente
$group_acl
$agent_search_filter
$agent_status_filter
GROUP BY tmg.id_mg
GROUP BY $group_by_fields
ORDER BY $order_fields";
}
// Counters SQL
else {
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tagente AS ta
INNER JOIN tagente_modulo AS tam
FROM tagente ta
INNER JOIN tagente_modulo tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
AND tam.id_module_group = $item_for_count
@ -777,11 +778,15 @@ class Tree {
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$group_by_fields = 'ta.id_agente, ta.nombre,
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$sql = "SELECT $columns
FROM tagente AS ta
INNER JOIN tagente_modulo AS tam
FROM tagente ta
INNER JOIN tagente_modulo tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
AND tam.id_module_group = $rootID
@ -791,7 +796,7 @@ class Tree {
$group_acl
$agent_search_filter
$agent_status_filter
GROUP BY ta.id_agente
GROUP BY $group_by_fields
ORDER BY $order_fields";
}
break;
@ -800,14 +805,14 @@ class Tree {
$columns = 'tam.id_agente_modulo AS id, tam.nombre AS name,
tam.id_tipo_modulo, tam.id_modulo, tae.estado, tae.datos';
$order_fields = 'tam.nombre ASC, tam.id_agente_modulo ASC';
$module_group_filter = "AND tam.id_module_group = $rootID";
$agent_filter = "AND tam.id_agente = $parent";
$sql = "SELECT $columns
FROM tagente_modulo AS tam
FROM tagente_modulo tam
$module_status_join
INNER JOIN tagente AS ta
INNER JOIN tagente ta
ON ta.disabled = 0
AND tam.id_agente = ta.id_agente
$group_acl
@ -817,7 +822,6 @@ class Tree {
$agent_filter
$module_group_filter
$module_search_filter
GROUP BY tam.id_agente_modulo
ORDER BY $order_fields";
break;
}
@ -832,19 +836,19 @@ class Tree {
else {
$group_acl = "AND ta.id_grupo = -1";
}
switch ($type) {
// Get the agents of a module
case 'module':
if (empty($rootID) || $rootID == -1) {
$columns = 'tam.nombre AS name';
$order_fields = 'tam.nombre ASC';
// Modules SQL
if ($item_for_count === false) {
$sql = "SELECT $columns
FROM tagente_modulo AS tam
INNER JOIN tagente AS ta
FROM tagente_modulo tam
INNER JOIN tagente ta
ON ta.disabled = 0
AND tam.id_agente = ta.id_agente
$group_acl
@ -859,8 +863,8 @@ class Tree {
// Counters SQL
else {
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tagente AS ta
INNER JOIN tagente_modulo AS tam
FROM tagente ta
INNER JOIN tagente_modulo tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
AND tam.nombre = '$item_for_count'
@ -879,8 +883,12 @@ class Tree {
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$group_by_fields = 'ta.id_agente, ta.nombre,
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$symbols = ' !"#$%&\'()*+,./:;<=>?@[\\]^{|}~';
$name = $rootID;
for ($i = 0; $i < strlen($symbols); $i++) {
@ -889,10 +897,10 @@ class Tree {
substr($symbols, $i, 1), $name);
}
$name = io_safe_input($name);
$sql = "SELECT $columns
FROM tagente AS ta
INNER JOIN tagente_modulo AS tam
FROM tagente ta
INNER JOIN tagente_modulo tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
AND tam.nombre = '$name'
@ -903,7 +911,7 @@ class Tree {
$group_acl
$agent_search_filter
$agent_status_filter
GROUP BY ta.id_agente
GROUP BY $group_by_fields
ORDER BY $order_fields";
}
break;
@ -912,7 +920,7 @@ class Tree {
$columns = 'tam.id_agente_modulo AS id, tam.nombre AS name,
tam.id_tipo_modulo, tam.id_modulo, tae.estado, tae.datos';
$order_fields = 'tam.nombre ASC, tam.id_agente_modulo ASC';
$symbols = ' !"#$%&\'()*+,./:;<=>?@[\\]^{|}~';
$name = $rootID;
for ($i = 0; $i < strlen($symbols); $i++) {
@ -921,13 +929,13 @@ class Tree {
substr($symbols, $i, 1), $name);
}
$name = io_safe_input($name);
$module_name_filter = "AND tam.nombre = '$name'";
$agent_filter = "AND tam.id_agente = $parent";
// We need the agents table
if (empty($agents_join)) {
$agents_join = "INNER JOIN tagente AS ta
$agents_join = "INNER JOIN tagente ta
ON ta.disabled = 0
AND tam.id_agente = ta.id_agente
$group_acl";
@ -935,11 +943,11 @@ class Tree {
else {
$agents_join .= " $group_acl";
}
$sql = "SELECT $columns
FROM tagente_modulo AS tam
FROM tagente_modulo tam
$module_status_join
INNER JOIN tagente AS ta
INNER JOIN tagente ta
ON ta.disabled = 0
AND tam.id_agente = ta.id_agente
$group_acl
@ -948,7 +956,6 @@ class Tree {
$module_name_filter
$module_group_filter
$module_search_filter
GROUP BY tam.id_agente_modulo
ORDER BY $order_fields";
break;
}
@ -962,7 +969,7 @@ class Tree {
return $sql;
}
// Override this method
protected function getSqlExtended ($item_for_count, $type, $rootType, $parent, $rootID,
$agent_search_filter, $agent_status_filter, $agents_join,
@ -970,7 +977,7 @@ class Tree {
$module_status_join) {
return false;
}
protected function getItems ($item_for_count = false) {
$sql = $this->getSql($item_for_count);
if (empty($sql))
@ -1953,6 +1960,13 @@ class Tree {
foreach ($items as $key => $item) {
if (empty($item['parent'])) {
$counters = $this->getCounters($item['id']);
if (!empty($counters)) {
foreach ($counters as $type => $value) {
$item[$type] = $value;
}
}
unset($items[$key]);
$items_tmp = array();
$processed_item = $this->getProcessedItem($item, false, $items, $items_tmp, true);

View File

@ -22,7 +22,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC150616';
$build_version = 'PC150624';
$pandora_version = 'v6.0dev';
// Do not overwrite default timezone set if defined.
@ -255,6 +255,9 @@ switch ($config["dbtype"]) {
}
break;
case "oracle":
if (!isset($config['quote_string'])) {
$config['db_quote_string'] = "'";
}
break;
}
//======================================================================

View File

@ -120,11 +120,13 @@ function mysql_db_get_value ($field, $table, $field_search = 1, $condition = 1,
if ($result === false)
return false;
if ($field[0] == '`')
$field = str_replace ('`', '', $field);
$row = array_shift($result);
$value = array_shift($row);
if ($value === null)
return false;
return $result[0][$field];
return $value;
}
/**
@ -395,7 +397,7 @@ function mysql_encapsule_fields_with_same_name_to_instructions($field) {
*
* @return mixed Value of first column of the first row. False if there were no row.
*/
function mysql_db_get_value_filter ($field, $table, $filter, $where_join = 'AND') {
function mysql_db_get_value_filter ($field, $table, $filter, $where_join = 'AND', $search_history_db = false) {
if (! is_array ($filter) || empty ($filter))
return false;
@ -407,14 +409,18 @@ function mysql_db_get_value_filter ($field, $table, $filter, $where_join = 'AND'
$field, $table,
db_format_array_where_clause_sql ($filter, $where_join));
$result = db_get_all_rows_sql ($sql);
$result = db_get_all_rows_sql ($sql, $search_history_db);
if ($result === false)
return false;
$fieldClean = str_replace('`', '', $field);
$row = array_shift($result);
$value = array_shift($row);
return $result[0][$fieldClean];
if ($value === null)
return false;
return $value;
}
/**
@ -610,8 +616,13 @@ function mysql_db_get_value_sql($sql, $dbconnection = false) {
if ($result === false)
return false;
foreach ($result[0] as $f)
return $f;
$row = array_shift($result);
$value = array_shift($row);
if ($value === null)
return false;
return $value;
}
/**
@ -1099,4 +1110,67 @@ function mysql_get_fields($table) {
return db_get_all_rows_sql("SHOW COLUMNS FROM " . $table);
}
/**
* Process a file with an oracle schema sentences.
* Based on the function which installs the pandoradb.sql schema.
*
* @param string $path File path.
* @param bool $handle_error Whether to handle the mysql_query errors or throw an exception.
*
* @return bool Return the final status of the operation.
*/
function mysql_db_process_file ($path, $handle_error = true) {
global $config;
if (file_exists($path)) {
$file_content = file($path);
$query = "";
// Begin the transaction
mysql_db_process_sql_begin();
foreach ($file_content as $sql_line) {
if (trim($sql_line) != "" && strpos($sql_line, "--") === false) {
$query .= $sql_line;
if (preg_match("/;[\040]*\$/", $sql_line)) {
if (!$result = mysql_query($query)) {
// Error. Rollback the transaction
mysql_db_process_sql_rollback();
$error_message = mysql_error();
// Handle the error
if ($handle_error) {
$backtrace = debug_backtrace();
$error = sprintf('%s (\'%s\') in <strong>%s</strong> on line %d',
$error_message, $query, $backtrace[0]['file'], $backtrace[0]['line']);
db_add_database_debug_trace ($query, $error_message);
set_error_handler('db_sql_error_handler');
trigger_error($error);
restore_error_handler();
return false;
}
// Throw an exception with the error message
else {
throw new Exception($error_message);
}
}
$query = "";
}
}
}
// No errors. Commit the transaction
mysql_db_process_sql_commit();
return true;
}
else {
return false;
}
}
?>

View File

@ -14,7 +14,7 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
function oracle_connect_db($host = null, $db = null, $user = null, $pass = null, $port = null) {
function oracle_connect_db($host = null, $db = null, $user = null, $pass = null, $port = null, $new_connection = true) {
global $config;
if ($host === null)
@ -30,7 +30,11 @@ function oracle_connect_db($host = null, $db = null, $user = null, $pass = null,
// Non-persistent connection: This will help to avoid mysql errors like "has gone away" or locking problems
// If you want persistent connections change it to oci_pconnect().
$connect_id = oci_new_connect($user, $pass, '//' . $host . ':' . $port . '/' . $db);
if ($new_connection)
$connect_id = oci_new_connect($user, $pass, '//' . $host . ':' . $port . '/' . $db);
else
$connect_id = oci_connect($user, $pass, '//' . $host . ':' . $port . '/' . $db);
if (! $connect_id) {
return false;
}
@ -90,15 +94,13 @@ function oracle_db_get_value ($field, $table, $field_search = 1, $condition = 1,
if ($result === false)
return false;
if ($field[0] == '`')
$field = str_replace ('`', '', $field);
$row = array_shift($result);
$value = array_shift($row);
if (!isset($result[0][$field])) {
return reset($result[0]);
}
else {
return $result[0][$field];
}
if ($value === null)
return false;
return $value;
}
/**
@ -229,40 +231,32 @@ function oracle_db_process_sql($sql, $rettype = "affected_rows", $dbconnection =
}
else {
$id = 0;
$parse_query = explode(' ',trim(preg_replace('/\s\s+/',' ',$sql)));
$table_name = preg_replace('/\((\w*|,\w*)*\)|\(\w*|,\w*/','',preg_replace('/\s/','',$parse_query[2]));
$type = explode(' ',strtoupper(trim($sql)));
$parse_query = explode(' ', trim(preg_replace('/\s\s+/', ' ', $sql)));
$table_name = preg_replace('/\((\w*|,\w*)*\)|\(\w*|,\w*/', '', preg_replace('/\s/', '', $parse_query[2]));
$type = explode(' ', strtoupper(trim($sql)));
$start = microtime (true);
if ($dbconnection !== '') {
if ($type[0] == 'INSERT') {
$query = oci_parse($dbconnection, 'begin insert_id(:table_name, :sql, :out); end;');
}
// Prevent execution of insert_id stored procedure
else if ($type[0] == '/INSERT') {
$query = oci_parse($dbconnection, substr($sql,1));
}
else {
$query = oci_parse($dbconnection, $sql);
}
if (empty($dbconnection)) {
$dbconnection = $config['dbconnection'];
}
if ($type[0] == 'INSERT') {
$query = oci_parse($dbconnection, 'BEGIN insert_id(:table_name, :sql, :out); END;');
}
// Prevent execution of insert_id stored procedure
else if ($type[0] == '/INSERT') {
$query = oci_parse($dbconnection, substr($sql,1));
}
else {
if ($type[0] == 'INSERT') {
$query = oci_parse($config['dbconnection'], 'begin insert_id(:table_name, :sql, :out); end;');
}
// Prevent execution of insert_id stored procedure
else if ($type[0] == '/INSERT') {
$query = oci_parse($config['dbconnection'], substr($sql,1));
}
else {
$query = oci_parse($config['dbconnection'], $sql);
}
$query = oci_parse($dbconnection, $sql);
}
//If query is an insert retrieve Id field
if ($type[0] == 'INSERT') {
oci_bind_by_name($query,":table_name", $table_name ,32);
oci_bind_by_name($query,":sql", $sql, 1000);
oci_bind_by_name($query,":out", $id, 32);
oci_bind_by_name($query, ":table_name", $table_name, 32);
oci_bind_by_name($query, ":sql", $sql, -1);
oci_bind_by_name($query, ":out", $id, 32);
}
if (!$autocommit) {
@ -273,9 +267,14 @@ function oracle_db_process_sql($sql, $rettype = "affected_rows", $dbconnection =
}
$time = microtime (true) - $start;
$config['oracle_error_query'] = null;
if ($result === false) {
$backtrace = debug_backtrace ();
$e = oci_error($query);
$config['oracle_error_query'] = $query;
$error = sprintf ('%s (\'%s\') in <strong>%s</strong> on line %d',
htmlentities($e['message'], ENT_QUOTES), $sql, $backtrace[0]['file'], $backtrace[0]['line']);
db_add_database_debug_trace ($sql, htmlentities($e['message'], ENT_QUOTES));
@ -453,6 +452,8 @@ function oracle_encapsule_fields_with_same_name_to_instructions($field) {
if (is_string($return)) {
if ($return[0] !== '"') {
// The columns declared without quotes are converted to uppercase in oracle.
// A column named asd is equal to asd, ASD or "ASD", but no to "asd".
$return = '"' . $return . '"';
}
}
@ -489,7 +490,7 @@ function oracle_encapsule_fields_with_same_name_to_instructions($field) {
*
* @return mixed Value of first column of the first row. False if there were no row.
*/
function oracle_db_get_value_filter ($field, $table, $filter, $where_join = 'AND') {
function oracle_db_get_value_filter ($field, $table, $filter, $where_join = 'AND', $search_history_db = false) {
if (! is_array ($filter) || empty ($filter))
return false;
@ -500,14 +501,18 @@ function oracle_db_get_value_filter ($field, $table, $filter, $where_join = 'AND
$sql = sprintf ("SELECT * FROM (SELECT %s FROM %s WHERE %s) WHERE rownum < 2",
$field, $table,
db_format_array_where_clause_sql ($filter, $where_join));
$result = db_get_all_rows_sql ($sql);
$result = db_get_all_rows_sql ($sql, $search_history_db);
if ($result === false)
return false;
$fieldClean = str_replace('`', '', $field);
$row = array_shift($result);
$value = array_shift($row);
return $result[0][$fieldClean];
if ($value === null)
return false;
return $value;
}
/**
@ -646,16 +651,28 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi
else {
if ($value[0] == ">") {
$value = substr($value,1,strlen($value)-1);
$query .= sprintf ("%s > '%s'", $field, $value);
if (is_nan($value))
$query .= sprintf ("%s > '%s'", $field, $value);
else
$query .= sprintf ("%s > %s", $field, $value);
}
else if ($value[0] == "<") {
if ($value[1] == ">") {
$value = substr($value,2,strlen($value)-2);
$query .= sprintf ("%s <> '%s'", $field, $value);
if (is_nan($value))
$query .= sprintf ("%s <> '%s'", $field, $value);
else
$query .= sprintf ("%s <> %s", $field, $value);
}
else {
$value = substr($value,1,strlen($value)-1);
$query .= sprintf ("%s < '%s'", $field, $value);
if (is_nan($value))
$query .= sprintf ("%s < '%s'", $field, $value);
else
$query .= sprintf ("%s < %s", $field, $value);
}
}
else if ($value[0] == '%') {
@ -851,6 +868,7 @@ function oracle_recode_query ($sql, $values, $join = 'AND', $return = true) {
return $result;
}
else {
$result = oracle_db_process_sql($result);
if ($result !== false) {
for ($i=0; $i < count($result); $i++) {
@ -876,8 +894,13 @@ function oracle_db_get_value_sql($sql, $dbconnection = false) {
if ($result === false)
return false;
foreach ($result[0] as $f)
return $f;
$row = array_shift($result);
$value = array_shift($row);
if ($value === null)
return false;
return $value;
}
/**
@ -1355,7 +1378,13 @@ function oracle_safe_sql_string($string) {
* @return string Return the string error.
*/
function oracle_db_get_last_error() {
$ora_erno = oci_error();
global $config;
if (empty($config['oracle_error_query'])) {
return null;
}
$ora_erno = oci_error($config['oracle_error_query']);
return $ora_erno['message'];
}
@ -1479,4 +1508,114 @@ function oracle_db_get_table_count($sql, $search_history_db = false) {
return $count;
}
/**
* Process a file with an oracle schema sentences.
* Based on the function which installs the pandoradb.sql schema.
*
* @param string $path File path.
* @param bool $handle_error Whether to handle the oci_execute errors or throw an exception.
*
* @return bool Return the final status of the operation.
*/
function oracle_db_process_file ($path, $handle_error = true) {
global $config;
if (file_exists($path)) {
$file_content = file($path);
$query = "";
$plsql_block = false;
// Begin the transaction
oracle_db_process_sql_begin();
$datetime_tz_format = oci_parse($connection, 'alter session set NLS_TIMESTAMP_TZ_FORMAT =\'YYYY-MM-DD HH24:MI:SS\'');
$datetime_format = oci_parse($connection, 'alter session set NLS_TIMESTAMP_FORMAT =\'YYYY-MM-DD HH24:MI:SS\'');
$date_format = oci_parse($connection, 'alter session set NLS_DATE_FORMAT =\'YYYY-MM-DD HH24:MI:SS\'');
$decimal_separator = oci_parse($connection, 'alter session set NLS_NUMERIC_CHARACTERS =\',.\'');
oci_execute($datetime_tz_format);
oci_execute($datetime_format);
oci_execute($date_format);
oci_execute($decimal_separator);
oci_free_statement($datetime_tz_format);
oci_free_statement($datetime_format);
oci_free_statement($date_format);
oci_free_statement($decimal_separator);
foreach ($file_content as $sql_line) {
$clean_line = trim($sql_line);
$comment = preg_match("/^(\s|\t)*--.*$/", $clean_line);
if ($comment) {
continue;
}
if (empty($clean_line)) {
continue;
}
//Support for PL/SQL blocks
if (preg_match("/^BEGIN$/", $clean_line)) {
$query .= $clean_line . ' ';
$plsql_block = true;
}
else{
$query .= $clean_line;
}
//Check query's end with a back slash and any returns in the end of line or if it's a PL/SQL block 'END;;' string
if ((preg_match("/;[\040]*\$/", $clean_line) && !$plsql_block) ||
(preg_match("/^END;;[\040]*\$/", $clean_line) && $plsql_block)) {
$plsql_block = false;
//Execute and clean buffer
//Delete the last semicolon from current query
$query = substr($query, 0, strlen($query) - 1);
$sql = oci_parse($config['dbconnection'], $query);
$result = oci_execute($sql, OCI_NO_AUTO_COMMIT);
if (!$result) {
// Error. Rollback the transaction
oracle_db_process_sql_rollback();
$e = oci_error($sql);
// Handle the error
if ($handle_error) {
$backtrace = debug_backtrace();
$error = sprintf('%s (\'%s\') in <strong>%s</strong> on line %d',
htmlentities($e['message'], ENT_QUOTES), $query, $backtrace[0]['file'], $backtrace[0]['line']);
db_add_database_debug_trace ($query, htmlentities($e['message'], ENT_QUOTES));
set_error_handler('db_sql_error_handler');
trigger_error($error);
restore_error_handler();
return false;
}
// Throw an exception with the error message
else {
throw new Exception($e['message']);
}
}
$query = "";
oci_free_statement($sql);
}
}
// No errors. Commit the transaction
oracle_db_process_sql_commit();
return true;
}
else {
return false;
}
}
function oracle_format_float_to_php($val) {
return floatval(str_replace(',', '.', $val));
}
?>

View File

@ -72,15 +72,13 @@ function postgresql_db_get_value ($field, $table, $field_search = 1, $condition
if ($result === false)
return false;
if ($field[0] == '`')
$field = str_replace ('`', '', $field);
$row = array_shift($result);
$value = array_shift($row);
if (!isset($result[0][$field])) {
return reset($result[0]);
}
else {
return $result[0][$field];
}
if ($value === null)
return false;
return $value;
}
/**
@ -404,7 +402,7 @@ function postgresql_encapsule_fields_with_same_name_to_instructions($field) {
*
* @return mixed Value of first column of the first row. False if there were no row.
*/
function postgresql_db_get_value_filter ($field, $table, $filter, $where_join = 'AND') {
function postgresql_db_get_value_filter ($field, $table, $filter, $where_join = 'AND', $search_history_db = false) {
if (! is_array ($filter) || empty ($filter))
return false;
@ -416,33 +414,21 @@ function postgresql_db_get_value_filter ($field, $table, $filter, $where_join =
if (strstr($field, "(") === false) {
//It is a field.
$field = '"' . $field . '"';
$is_a_function = false;
}
else {
//It is a function.
$is_a_function = true;
}
$sql = sprintf ("SELECT %s FROM \"%s\" WHERE %s LIMIT 1",
$field, $table,
db_format_array_where_clause_sql ($filter, $where_join));
$result = db_get_all_rows_sql ($sql);
$result = db_get_all_rows_sql ($sql, $search_history_db);
if ($result === false)
$row = array_shift($result);
$value = array_shift($row);
if ($value === null)
return false;
if (!$is_a_function) {
$fieldClean = str_replace('"', '', $field);
$fieldClean = str_replace('`', '', $fieldClean);
}
else {
//Extract the name of function.
$temp = explode('(', $field);
$fieldClean = strtolower(trim($temp[0]));
}
return $result[0][$fieldClean];
return $value;
}
/**
@ -634,8 +620,13 @@ function postgresql_db_get_value_sql($sql, $dbconnection = false) {
if ($result === false)
return false;
foreach ($result[0] as $f)
return $f;
$row = array_shift($result);
$value = array_shift($row);
if ($value === null)
return false;
return $value;
}
/**

View File

@ -2205,7 +2205,7 @@ function get_news($arguments) {
case "oracle":
$sql = sprintf("SELECT subject,timestamp,text,author
FROM tnews
WHERE rownum <= %limit AND id_group IN (%s) AND
WHERE rownum <= %s AND id_group IN (%s) AND
modal = %s AND
(expire = 0 OR (expire = 1 AND expire_timestamp > '%s'))
ORDER BY timestamp DESC", $limit, $id_group, $modal, $current_datetime);
@ -2318,12 +2318,11 @@ function clear_pandora_error_for_header() {
function set_pandora_error_for_header($message, $title = null) {
global $config;
if (!isset($config["alert_cnt"])) {
$config["alert_cnt"] = 0;
}
if (!isset($_SESSION["alert_msg"])) {
$_SESSION["alert_msg"] = "";
}
if (!isset($config['alert_cnt']))
$config['alert_cnt'] = 0;
if (!isset($_SESSION['alert_msg']))
$_SESSION['alert_msg'] = array();
$message_config = array();
if (isset($title))
@ -2331,10 +2330,32 @@ function set_pandora_error_for_header($message, $title = null) {
$message_config['message'] = $message;
$message_config['no_close'] = true;
$config['alert_cnt']++;
$_SESSION['alert_msg'][] = array('type' => 'error', 'message' => $message_config);
}
function get_pandora_error_for_header() {
$result = '';
$config["alert_cnt"]++;
$_SESSION["alert_msg"] .= ui_print_error_message($message_config,
'', true);
if (isset($_SESSION['alert_msg']) && is_array($_SESSION['alert_msg'])) {
foreach ($_SESSION['alert_msg'] as $key => $value) {
if (!isset($value['type']) || !isset($value['message']))
continue;
switch ($value['type']) {
case 'error':
$result .= ui_print_error_message($value['message'], '', true);
break;
case 'info':
$result .= ui_print_info_message($value['message'], '', true);
break;
default:
break;
}
}
}
return $result;
}
function set_if_defined (&$var, $test) {
@ -2358,4 +2379,61 @@ function set_unless_defined (&$var, $default) {
return false;
}
}
function set_when_empty (&$var, $default) {
if (empty($var)) {
$var = $default;
return true;
}
else {
return false;
}
}
function sort_by_column (&$array_ref, $column_parameter) {
global $column;
$column = $column_parameter;
if (!empty($column)) {
usort($array_ref, function ($a, $b) {
global $column;
return strcmp($a[$column], $b[$column]);
});
}
}
function array2XML($data, $root = null, $xml = NULL) {
if ($xml == null) {
$xml = simplexml_load_string(
"<?xml version='1.0' encoding='UTF-8'?>\n<" . $root . " />");
}
foreach($data as $key => $value) {
if (is_numeric($key)) {
$key = "item_" . $key;
}
if (is_array($value)) {
$node = $xml->addChild($key);
array2XML($value, $root, $node);
}
else {
$value = htmlentities($value);
if (!is_numeric($value) && !is_bool($value)) {
if (!empty($value)) {
$xml->addChild($key, $value);
}
}
else {
$xml->addChild($key, $value);
}
}
}
return html_entity_decode($xml->asXML());
}
?>

View File

@ -1100,10 +1100,10 @@ function agents_get_modules ($id_agent = null, $details = false,
array_push ($fields, $field.' = \''.$value.'\'');
break;
case "oracle":
if (is_int ($value) ||is_float ($value)||is_double ($value))
if (is_int ($value) || is_float ($value) || is_double ($value))
array_push ($fields, $field.' = '.$value.'');
else
array_push ($fields, $field.' = "'.$value.'"');
array_push ($fields, $field.' = \''.$value.'\'');
break;
}
}
@ -1119,27 +1119,7 @@ function agents_get_modules ($id_agent = null, $details = false,
$details = "nombre";
}
else {
if ($config['dbtype'] == 'oracle') {
$details_new = array();
if (is_array($details)) {
foreach ($details as $detail) {
if ($detail == 'nombre')
$details_new[] = 'dbms_lob.substr(nombre,4000,1) as nombre';
else
$details_new[] = $detail;
}
}
else {
if ($details == 'nombre')
$details_new = 'dbms_lob.substr(nombre,4000,1) as nombre';
else
$details_new = $details;
}
$details = io_safe_input ($details);
}
else
$details = io_safe_input ($details);
$details = io_safe_input ($details);
}
//$where .= " AND id_policy_module = 0 ";
@ -1150,30 +1130,14 @@ function agents_get_modules ($id_agent = null, $details = false,
$where .= "\n\n" . $where_tags;
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf ('SELECT %s%s
FROM tagente_modulo
WHERE
%s
ORDER BY nombre',
($details != '*' && $indexed) ? 'id_agente_modulo,' : '',
io_safe_output(implode (",", (array) $details)),
$where);
break;
case "oracle":
$sql = sprintf ('SELECT %s%s
FROM tagente_modulo
WHERE
%s
ORDER BY dbms_lob.substr(nombre, 4000, 1)',
($details != '*' && $indexed) ? 'id_agente_modulo,' : '',
io_safe_output(implode (",", (array) $details)),
$where);
break;
}
$sql = sprintf ('SELECT %s%s
FROM tagente_modulo
WHERE
%s
ORDER BY nombre',
($details != '*' && $indexed) ? 'id_agente_modulo,' : '',
io_safe_output(implode (",", (array) $details)),
$where);
$result = db_get_all_rows_sql ($sql);
@ -1717,7 +1681,7 @@ function agents_delete_agent ($id_agents, $disableACL = false) {
//Alert
db_process_delete_temp ("talert_template_modules",
"id_agent_module", $where_modules);
"id_agent_module", $where_modules, true);
//Events (up/down monitors)
// Dont delete here, could be very time-exausting, let the daily script
@ -1726,11 +1690,11 @@ function agents_delete_agent ($id_agents, $disableACL = false) {
//Graphs, layouts, reports & networkmapenterprise
db_process_delete_temp ("tgraph_source",
"id_agent_module", $where_modules);
"id_agent_module", $where_modules, true);
db_process_delete_temp ("tlayout_data",
"id_agente_modulo", $where_modules);
"id_agente_modulo", $where_modules, true);
db_process_delete_temp ("treport_content",
"id_agent_module", $where_modules);
"id_agent_module", $where_modules, true);
if (enterprise_installed()) {
$nodes = db_get_all_rows_filter(
"tnetworkmap_enterprise_nodes",
@ -1740,9 +1704,9 @@ function agents_delete_agent ($id_agents, $disableACL = false) {
}
foreach ($nodes as $node) {
db_process_delete_temp ("tnetworkmap_enterprise_relation_nodes",
db_process_delete_temp ("tnetworkmap_ent_rel_nodes",
"parent", $node['id']);
db_process_delete_temp ("tnetworkmap_enterprise_relation_nodes",
db_process_delete_temp ("tnetworkmap_ent_rel_nodes",
"child", $node['id']);
}
@ -1779,7 +1743,7 @@ function agents_delete_agent ($id_agents, $disableACL = false) {
// tagente_datos_inc
// Dont delete here, this records are deleted later, in database script
// db_process_delete_temp ("tagente_datos_inc", "id_agente_modulo", $where_modules);
// db_process_delete_temp ("tagente_datos_inc", "id_agente_modulo", $where_modules, true);
// Delete remote configuration
if (enterprise_installed()) {
@ -2197,6 +2161,8 @@ function agents_update_gis($idAgente, $latitude, $longitude, $altitude,
* @return array A list of network interfaces information by agents.
*/
function agents_get_network_interfaces ($agents = false, $agents_filter = false) {
global $config;
if ($agents === false) {
$filter = false;
if ($agents_filter !== false) {
@ -2238,9 +2204,14 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false)
$columns = array(
"id_agente_modulo",
"nombre",
"descripcion",
"ip_target"
);
if ($config['dbtype'] == 'oracle')
$columns[] = 'TO_CHAR(descripcion) AS descripcion';
else
$columns[] = 'descripcion';
$filter = " id_agente = $agent_id AND disabled = 0 AND id_tipo_modulo IN (".implode(",", $accepted_module_types).") AND nombre LIKE 'ifOperStatus_%'";
$modules = agents_get_modules($agent_id, $columns, $filter, true, false);
@ -2279,7 +2250,7 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false)
$ip_target = "--";
// Trying to get something like an IP from the description
if (preg_match ("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $module_description, $matches)
if (preg_match ("/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/", $module_description, $matches)
|| preg_match ("/(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:?)|\2))(?4){5}((?4){2}|(25[0-5]|
(2[0-4]|1\d|[1-9])?\d)(\.(?7)){3})/i", $module_description, $matches) && $matches[0]) {

View File

@ -96,11 +96,11 @@ function alerts_get_alerts($id_group = 0, $free_search = "", $status = "all", $s
}
$sql .= '
FROM talert_template_modules AS t0
INNER JOIN talert_templates AS t1
INNER JOIN talert_templates t1
ON t0.id_alert_template = t1.id
INNER JOIN tagente_modulo AS t2
INNER JOIN tagente_modulo t2
ON t0.id_agent_module = t2.id_agente_modulo
INNER JOIN tagente AS t3
INNER JOIN tagente t3
ON t2.id_agente = t3.id_agente
WHERE 1=1
' . $status_query . ' ' . $standby_query . ' ' . $group_query . '
@ -662,30 +662,38 @@ function alerts_get_alert_templates ($filter = false, $fields = false) {
function alerts_get_alert_template ($id_alert_template) {
global $config;
$alert_templates = false;
$id_alert_template = safe_int ($id_alert_template, 1);
if (empty ($id_alert_template))
return false;
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
return db_get_row ('talert_templates', 'id', $id_alert_template);
break;
case "oracle":
$fields_select = db_get_all_rows_sql('SELECT column_name
FROM user_tab_columns
WHERE table_name = \'TALERT_TEMPLATES\'
AND column_name NOT IN (\'TIME_FROM\',\'TIME_TO\')');
foreach ($fields_select as $field_select) {
$select_field[] = $field_select['column_name'];
}
$select_stmt = implode(',', $select_field);
return db_get_row_sql("SELECT $select_stmt,
to_char(time_from, 'hh24:mi:ss') AS time_from,
to_char(time_to, 'hh24:mi:ss') AS time_to
FROM talert_templates");
break;
if (!empty ($id_alert_template)) {
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$alert_templates = db_get_row ('talert_templates', 'id', $id_alert_template);
break;
case "oracle":
$sql = "SELECT column_name
FROM user_tab_columns
WHERE table_name = 'TALERT_TEMPLATES'
AND column_name NOT IN ('TIME_FROM','TIME_TO')";
$fields_select = db_get_all_rows_sql($sql);
$column_names = array_map(function($item) {
return $item['column_name'];
}, $fields_select);
$column_names_str = implode(',', $column_names);
$sql = "SELECT $column_names_str,
to_char(time_from, 'hh24:mi:ss') AS time_from,
to_char(time_to, 'hh24:mi:ss') AS time_to
FROM talert_templates
WHERE id = $id_alert_template";
$alert_templates = db_get_row_sql($sql);
break;
}
}
return $alert_templates;
}
/**

View File

@ -742,10 +742,10 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType) {
$modules = db_get_all_rows_sql('SELECT *
FROM (SELECT id_agente_modulo as module_id_agent_modulo ' . $module_additional_columns . '
FROM tagente_modulo
WHERE id_agente = ' . $agent['agent_id'] . ') AS t1
WHERE id_agente = ' . $agent['agent_id'] . ') t1
INNER JOIN (SELECT id_agente_modulo as module_id_agent_modulo ' . $estado_additional_columns . '
FROM tagente_estado
WHERE id_agente = ' . $agent['agent_id'] . ') AS t2
WHERE id_agente = ' . $agent['agent_id'] . ') t2
ON t1.module_id_agent_modulo = t2.module_id_agent_modulo');
if ($modules === false) $modules = array();
@ -766,14 +766,14 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType) {
$alerts = db_get_all_rows_sql('SELECT t1.id_agent_module as alert_id_agent_module ' . $alert_additional_columns . '
FROM (SELECT * FROM talert_template_modules
WHERE id_agent_module = ' . $module['module_id_agent_modulo'] . ') AS t1
INNER JOIN talert_templates AS t2
WHERE id_agent_module = ' . $module['module_id_agent_modulo'] . ') t1
INNER JOIN talert_templates t2
ON t1.id_alert_template = t2.id
LEFT JOIN talert_template_module_actions AS t3
LEFT JOIN talert_template_module_actions t3
ON t1.id = t3.id_alert_template_module
LEFT JOIN talert_actions AS t4
LEFT JOIN talert_actions t4
ON t3.id_alert_action = t4.id
LEFT JOIN talert_commands AS t5
LEFT JOIN talert_commands t5
ON t4.id_alert_command = t5.id');
if ($alerts === false) $alerts = array();
@ -981,10 +981,10 @@ function get_module_properties($id_module, $fields, $separator, $returnType, $re
$modules = db_get_all_rows_sql('SELECT *
FROM (SELECT id_agente_modulo as module_id_agent_modulo ' . $module_additional_columns . '
FROM tagente_modulo
WHERE id_agente_modulo = ' . $id_module . ') AS t1
WHERE id_agente_modulo = ' . $id_module . ') t1
INNER JOIN (SELECT id_agente_modulo as module_id_agent_modulo ' . $estado_additional_columns . '
FROM tagente_estado
WHERE id_agente_modulo = ' . $id_module . ') AS t2
WHERE id_agente_modulo = ' . $id_module . ') t2
ON t1.module_id_agent_modulo = t2.module_id_agent_modulo');
if ($modules === false) $modules = array();
@ -5940,8 +5940,8 @@ function api_set_new_event($trash1, $trash2, $other, $trash3) {
}
else {
$idAlert = db_get_value_sql("SELECT t1.id
FROM talert_template_modules AS t1
INNER JOIN talert_templates AS t2
FROM talert_template_modules t1
INNER JOIN talert_templates t2
ON t1.id_alert_template = t2.id
WHERE t1.id_agent_module = 1
AND t2.name LIKE '" . $other['data'][7] . "'");
@ -6476,10 +6476,10 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
if (defined ('METACONSOLE')) {
$sql = "SELECT *,
(SELECT t2.nombre
FROM tgrupo AS t2
FROM tgrupo t2
WHERE t2.id_grupo = " . $table_events . ".id_grupo) AS group_name,
(SELECT t2.icon
FROM tgrupo AS t2
FROM tgrupo t2
WHERE t2.id_grupo = " . $table_events . ".id_grupo) AS group_icon
FROM " . $table_events . "
WHERE 1=1 " . $sql_post . "
@ -6489,13 +6489,13 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
else {
$sql = "SELECT *,
(SELECT t1.nombre
FROM tagente AS t1
FROM tagente t1
WHERE t1.id_agente = tevento.id_agente) AS agent_name,
(SELECT t2.nombre
FROM tgrupo AS t2
FROM tgrupo t2
WHERE t2.id_grupo = tevento.id_grupo) AS group_name,
(SELECT t2.icon
FROM tgrupo AS t2
FROM tgrupo t2
WHERE t2.id_grupo = tevento.id_grupo) AS group_icon,
(SELECT tmodule.name
FROM tmodule
@ -6515,13 +6515,13 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
//TODO TOTAL
$sql = "SELECT *,
(SELECT t1.nombre
FROM tagente AS t1
FROM tagente t1
WHERE t1.id_agente = tevento.id_agente) AS agent_name,
(SELECT t2.nombre
FROM tgrupo AS t2
FROM tgrupo t2
WHERE t2.id_grupo = tevento.id_grupo) AS group_name,
(SELECT t2.icon
FROM tgrupo AS t2
FROM tgrupo t2
WHERE t2.id_grupo = tevento.id_grupo) AS group_icon,
(SELECT tmodule.name
FROM tmodule
@ -6542,13 +6542,13 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
$sql = "SELECT *,
(SELECT t1.nombre
FROM tagente AS t1
FROM tagente t1
WHERE t1.id_agente = tevento.id_agente) AS agent_name,
(SELECT t2.nombre
FROM tgrupo AS t2
FROM tgrupo t2
WHERE t2.id_grupo = tevento.id_grupo) AS group_name,
(SELECT t2.icon
FROM tgrupo AS t2
FROM tgrupo t2
WHERE t2.id_grupo = tevento.id_grupo) AS group_icon,
(SELECT tmodule.name
FROM tmodule

View File

@ -51,7 +51,7 @@ function config_update_value ($token, $value) {
if (!isset ($config[$token])) {
$config[$token] = $value;
return (bool) config_create_value ($token, $value);
return (bool) config_create_value ($token, io_safe_input($value));
}
/* If it has not changed */
@ -59,9 +59,10 @@ function config_update_value ($token, $value) {
return true;
$config[$token] = $value;
$value = io_safe_output($value);
$result = db_process_sql_update ('tconfig',
array ('value' => $value),
array ('value' => io_safe_input($value)),
array ('token' => $token));
if ($result === 0)
@ -119,7 +120,7 @@ function config_update_config () {
case 'general':
if (!config_update_value ('language', (string) get_parameter ('language')))
$error_update[] = __('Language code for Pandora');
if (!config_update_value ('remote_config', io_safe_input((string) get_parameter ('remote_config'))))
if (!config_update_value ('remote_config', (string) get_parameter ('remote_config')))
$error_update[] = __('Remote config directory');
if (!config_update_value ('loginhash_pwd', io_input_password((string) get_parameter ('loginhash_pwd'))))
$error_update[] = __('Auto login (hash) password');
@ -130,7 +131,7 @@ function config_update_config () {
$error_update[] = __('Automatic check for updates');
if (!config_update_value ('https', (bool) get_parameter ('https')))
$error_update[] = __('Enforce https');
if (!config_update_value ('attachment_store', io_safe_input((string) get_parameter ('attachment_store'))))
if (!config_update_value ('attachment_store', (string) get_parameter ('attachment_store')))
$error_update[] = __('Attachment store');
if (!config_update_value ('list_ACL_IPs_for_API', (string) get_parameter('list_ACL_IPs_for_API')))
$error_update[] = __('IP list with API access');
@ -209,6 +210,8 @@ function config_update_config () {
if (!config_update_value ('show_events_in_local', (string)get_parameter('show_events_in_local')))
$error_update[] = __('Show events list in local console (read only)');
}
if (!config_update_value ('replication_dbengine', (string)get_parameter('replication_dbengine')))
$error_update[] = __('Replication DB engine');
if (!config_update_value ('replication_dbhost', (string)get_parameter('replication_dbhost')))
$error_update[] = __('Replication DB host');
if (!config_update_value ('replication_dbname', (string)get_parameter('replication_dbname')))
@ -411,7 +414,7 @@ function config_update_config () {
$error_update[] = __('Show QR code header');
if (!config_update_value ('status_images_set', (string) get_parameter ('status_images_set')))
$error_update[] = __('Status icon set');
if (!config_update_value ('fontpath', io_safe_input((string) get_parameter ('fontpath'))))
if (!config_update_value ('fontpath', (string) get_parameter ('fontpath')))
$error_update[] = __('Font path');
if (!config_update_value ('font_size', get_parameter('font_size')))
$error_update[] = __('Font size');
@ -449,7 +452,7 @@ function config_update_config () {
$error_update[] = __('Fixed menu');
if (!config_update_value ('paginate_module', get_parameter('paginate_module')))
$error_update[] = __('Paginate module');
if (!config_update_value ('graphviz_bin_dir', io_safe_input(get_parameter('graphviz_bin_dir'))))
if (!config_update_value ('graphviz_bin_dir', get_parameter('graphviz_bin_dir')))
$error_update[] = __('Custom graphviz directory');
if (!config_update_value ('networkmap_max_width', get_parameter('networkmap_max_width')))
$error_update[] = __('Networkmap max width');
@ -625,7 +628,7 @@ function config_update_config () {
enterprise_include_once('include/functions_policies.php');
$enterprise = enterprise_include_once ('include/functions_skins.php');
if ($enterprise !== ENTERPRISE_NOT_HOOK) {
$config['relative_path'] = get_parameter('relative_path', io_safe_input($config['relative_path']));
$config['relative_path'] = get_parameter('relative_path', $config['relative_path']);
}
}
@ -653,7 +656,7 @@ function config_process_config () {
if (isset ($config['homeurl']) && (strlen($config['homeurl']) > 0)) {
if ($config['homeurl'][0] != '/') {
$config['homeurl'] = '/'.io_safe_input($config['homeurl']);
$config['homeurl'] = '/'.$config['homeurl'];
}
}
@ -774,6 +777,10 @@ function config_process_config () {
config_update_value ('replication_interval', 120);
}
if (!isset ($config["replication_dbengine"])) {
config_update_value ('replication_dbengine', 'mysql');
}
if (!isset ($config["replication_dbhost"])) {
config_update_value ('replication_dbhost', "");
}
@ -866,14 +873,14 @@ function config_process_config () {
//after the first uses.
if (!is_dir($config['attachment_store'])) {
config_update_value('attachment_store',
io_safe_input($config['homedir']) . '/attachment');
$config['homedir'] . '/attachment');
}
}
if (!isset ($config['fontpath'])) {
config_update_value('fontpath',
io_safe_input($config['homedir']) . '/include/fonts/smallfont.ttf');
$config['homedir'] . '/include/fonts/smallfont.ttf');
}
if (!isset ($config['style'])) {

View File

@ -271,18 +271,18 @@ function db_get_value($field, $table, $field_search = 1, $condition = 1, $search
*
* @return mixed Value of first column of the first row. False if there were no row.
*/
function db_get_value_filter ($field, $table, $filter, $where_join = 'AND') {
function db_get_value_filter ($field, $table, $filter, $where_join = 'AND', $search_history_db = false) {
global $config;
switch ($config["dbtype"]) {
case "mysql":
return mysql_db_get_value_filter($field, $table, $filter, $where_join);
return mysql_db_get_value_filter($field, $table, $filter, $where_join, $search_history_db);
break;
case "postgresql":
return postgresql_db_get_value_filter($field, $table, $filter, $where_join);
return postgresql_db_get_value_filter($field, $table, $filter, $where_join, $search_history_db);
break;
case "oracle":
return oracle_db_get_value_filter($field, $table, $filter, $where_join);
return oracle_db_get_value_filter($field, $table, $filter, $where_join, $search_history_db);
break;
}
}
@ -641,7 +641,7 @@ function db_process_sql($sql, $rettype = "affected_rows", $dbconnection = '', $c
return @postgresql_db_process_sql($sql, $rettype, $dbconnection, $cache, $status);
break;
case "oracle":
return @oracle_db_process_sql($sql, $rettype, $dbconnection, $cache, $status, $autocommit);
return oracle_db_process_sql($sql, $rettype, $dbconnection, $cache, $status, $autocommit);
break;
}
}
@ -848,10 +848,11 @@ function db_format_array_where_clause_sql ($values, $join = 'AND', $prefix = fal
* @param string Table name
* @param string Field of the filter condition
* @param string Value of the filter
* @param bool The value will be appended without quotes
*
* @result Rows deleted or false if something goes wrong
*/
function db_process_delete_temp ($table, $row, $value) {
function db_process_delete_temp ($table, $row, $value, $custom_value = false) {
global $error; //Globalize the errors variable
global $config;
@ -861,8 +862,8 @@ function db_process_delete_temp ($table, $row, $value) {
$result = db_process_sql_delete ($table, $row.' = '.$value);
break;
case "oracle":
if (is_int ($value) || is_bool ($value) ||
is_float ($value) || is_double ($value)) {
if ($custom_value || is_int ($value) || is_bool ($value) ||
is_float ($value) || is_double ($value)) {
$result = oracle_db_process_sql_delete_temp ($table, $row . ' = ' . $value);
}
else {
@ -1208,4 +1209,30 @@ function db_search_in_history_db ($utimestamp) {
return $search_in_history_db;
}
/**
* Process a file with an oracle schema sentences.
* Based on the function which installs the pandoradb.sql schema.
*
* @param string $path File path.
* @param bool $handle_error Whether to handle the oci_execute errors or throw an exception.
*
* @return bool Return the final status of the operation.
*/
function db_process_file ($path, $handle_error = true) {
global $config;
switch ($config["dbtype"]) {
case "mysql":
return mysql_db_process_file($path, $handle_error);
break;
case "postgresql":
// Not supported
//return postgresql_db_process_file($path, $handle_error);
break;
case "oracle":
return oracle_db_process_file($path, $handle_error);
break;
}
}
?>

View File

@ -184,33 +184,26 @@ function events_get_events_grouped($sql_post, $offset = 0,
case "oracle":
if ($total) {
$sql = "SELECT COUNT(*)
FROM $table te
WHERE 1=1 " . $sql_post . "
GROUP BY estado, to_char(evento), id_agentmodule" . $groupby_extra . ") b ";
FROM $table te
WHERE 1=1 $sql_post
GROUP BY estado, to_char(evento), id_agentmodule" . $groupby_extra . ") b ";
}
else {
$set = array();
$set['limit'] = $pagination;
$set['offset'] = $offset;
// TODO: Remove duplicate user comments
$sql = "SELECT a.*, b.event_rep, b.timestamp_rep
FROM (SELECT * FROM $table WHERE 1=1 " . $sql_post . ") a,
(SELECT MAX (id_evento) AS id_evento, to_char(evento) AS evento,
id_agentmodule, COUNT(*) AS event_rep,
LISTAGG(user_comment, '') AS user_comment, MAX(utimestamp) AS timestamp_rep,
LISTAGG(id_evento, '') AS similar_ids,
MIN(utimestamp) AS timestamp_rep_min,
(SELECT owner_user FROM $table WHERE id_evento = MAX(te.id_evento)) owner_user,
(SELECT id_usuario FROM $table WHERE id_evento = MAX(te.id_evento)) id_usuario,
(SELECT id_agente FROM $table WHERE id_evento = MAX(te.id_evento)) id_agente,
(SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity,
(SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp
FROM $table te
WHERE 1=1 " . $sql_post . "
GROUP BY estado, to_char(evento), id_agentmodule" . $groupby_extra . ") b
WHERE a.id_evento=b.id_evento AND
to_char(a.evento)=to_char(b.evento)
AND a.id_agentmodule=b.id_agentmodule";
$sql = "SELECT ta.*, tb.event_rep, tb.timestamp_rep, tb.timestamp_rep_min, tb.user_comments, tb.similar_ids
FROM $table ta
INNER JOIN (SELECT MAX(id_evento) AS id_evento, COUNT(id_evento) AS event_rep,
MAX(utimestamp) AS timestamp_rep, MIN(utimestamp) AS timestamp_rep_min,
TAB_TO_STRING(CAST(COLLECT(TO_CHAR(user_comment) ORDER BY id_evento ASC) AS t_varchar2_tab), '<br>') AS user_comments,
TAB_TO_STRING(CAST(COLLECT(CAST(id_evento AS VARCHAR2(4000)) ORDER BY id_evento ASC) AS t_varchar2_tab)) AS similar_ids
FROM $table te
WHERE 1=1 $sql_post
GROUP BY estado, to_char(evento), id_agentmodule$groupby_extra) tb
ON ta.id_evento = tb.id_evento
ORDER BY tb.timestamp_rep DESC";
$sql = oracle_recode_query ($sql, $set);
}
break;
@ -223,6 +216,13 @@ function events_get_events_grouped($sql_post, $offset = 0,
return reset($events[0]);
}
else {
// Override the column 'user_comment' with the column 'user_comments' when oracle
if (!empty($events) && $config["dbtype"] == "oracle") {
array_walk($events, function(&$value, $key) {
set_if_defined($value['user_comments'], $value['user_comments']);
});
}
return $events;
}
}
@ -740,8 +740,7 @@ function events_create_event ($event, $id_group, $id_agent, $status = 0,
critical_instructions, warning_instructions,
unknown_instructions, source, tags, custom_data,
server_id)
VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d,
ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (' . SECONDS_1DAY . ')),
VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d, UNIX_TIMESTAMP,
"%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s",
"%s", "%s", %d)',
$id_agent, $id_group, $event, $status, $id_user,
@ -762,8 +761,7 @@ function events_create_event ($event, $id_group, $id_agent, $status = 0,
critical_instructions, warning_instructions,
unknown_instructions, source, tags, custom_data)
VALUES (%d, %d, "%s", NOW(), %d, UNIX_TIMESTAMP(NOW()),
"%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s",
"%s", "%s")',
"%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", "%s")',
$id_agent, $id_group, $event, $status, $id_user,
$event_type, $priority, $id_agent_module, $id_aam,
$critical_instructions, $warning_instructions,
@ -778,24 +776,21 @@ function events_create_event ($event, $id_group, $id_agent, $status = 0,
unknown_instructions, source, tags, custom_data)
VALUES (%d, %d, "%s", NOW(), %d,
ceil(date_part(\'epoch\', CURRENT_TIMESTAMP)), "%s",
"%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s",
"%s")',
"%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", "%s")',
$id_agent, $id_group, $event, $status, $id_user,
$event_type, $priority, $id_agent_module, $id_aam,
$critical_instructions, $warning_instructions,
$unknown_instructions, $source, $tags, $custom_data);
break;
case "oracle":
$sql = sprintf ('
INSERT INTO ' . $table_events . ' (id_agente, id_grupo, evento,
$sql = sprintf ("
INSERT INTO " . $table_events . " (id_agente, id_grupo, evento,
timestamp, estado, utimestamp, id_usuario,
event_type, criticity, id_agentmodule, id_alert_am,
critical_instructions, warning_instructions,
unknown_instructions, source, tags, custom_data)
VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d,
ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (' . SECONDS_1DAY . ')),
"%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s",
"%s", "%s")',
VALUES (%d, %d, '%s', CURRENT_TIMESTAMP, %d, UNIX_TIMESTAMP,
'%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s')",
$id_agent, $id_group, $event, $status, $id_user,
$event_type, $priority, $id_agent_module, $id_aam,
$critical_instructions, $warning_instructions,
@ -852,11 +847,12 @@ function events_print_event_table ($filter = "", $limit = 10, $width = 440, $ret
if ($result === false) {
if ($return) {
$returned = ui_print_info_message ( __('No events'),'',true );
$returned = ui_print_info_message (__('No events'), '', true);
return $returned;
}
else
echo ui_print_info_message ( __('No events') );
else {
echo ui_print_info_message (__('No events'));
}
}
else {
$table = new stdClass();
@ -1281,12 +1277,12 @@ function events_get_group_events_steps ($begin, &$result, $id_group, $period, $d
$sql = sprintf ('SELECT *,
(SELECT t2.nombre
FROM tagente AS t2
FROM tagente t2
WHERE t2.id_agente = t3.id_agente) AS agent_name,
(SELECT t2.fullname
FROM tusuario AS t2
FROM tusuario t2
WHERE t2.id_user = t3.id_usuario) AS user_name
FROM tevento AS t3
FROM tevento t3
WHERE utimestamp > %d AND utimestamp <= %d
AND id_grupo IN (%s) ' . $sql_where . '
ORDER BY utimestamp ASC',
@ -2603,10 +2599,10 @@ function events_get_count_events_by_agent ($id_group, $period, $date,
$sql = sprintf ('SELECT id_agente,
(SELECT t2.nombre
FROM tagente AS t2
FROM tagente t2
WHERE t2.id_agente = t3.id_agente) AS agent_name,
COUNT(*) AS count
FROM tevento AS t3
FROM tevento t3
WHERE utimestamp > %d AND utimestamp <= %d
AND id_grupo IN (%s) ' . $sql_where . '
GROUP BY id_agente',
@ -2692,10 +2688,10 @@ function events_get_count_events_validated_by_user ($filter, $period, $date,
$sql = sprintf ('SELECT id_usuario,
(SELECT t2.fullname
FROM tusuario AS t2
FROM tusuario t2
WHERE t2.id_user = t3.id_usuario) AS user_name,
COUNT(*) AS count
FROM tevento AS t3
FROM tevento t3
WHERE utimestamp > %d AND utimestamp <= %d
%s ' . $sql_where . '
GROUP BY id_usuario',
@ -2811,14 +2807,14 @@ function events_get_count_events_by_criticity ($filter, $period, $date,
*
* @return array An array with all the events happened.
*/
function events_get_count_events_validated ($filter, $period, $date,
function events_get_count_events_validated ($filter, $period = null, $date = null,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_search = false) {
global $config;
$sql_filter = ' 1=1 ';
$sql_filter = ' AND 1=1 ';
if (isset($filter['id_group'])) {
$id_group = groups_safe_acl ($config["id_user"], $filter['id_group'], "AR");
@ -2835,9 +2831,25 @@ function events_get_count_events_validated ($filter, $period, $date,
sprintf(' AND id_agente = %d ', $filter['id_agent']);
}
$datelimit = $date - $period;
$date_filter = '';
if (!empty($date) && !empty($period)) {
$datelimit = $date - $period;
$date_filter .= sprintf (' AND utimestamp > %d AND utimestamp <= %d ',
$datelimit, $date);
}
else if (!empty($period)) {
$date = time();
$datelimit = $date - $period;
$date_filter .= sprintf (' AND utimestamp > %d AND utimestamp <= %d ',
$datelimit, $date);
}
else if (!empty($date)) {
$date_filter .= sprintf (' AND utimestamp <= %d ', $date);
}
$sql_where = ' AND 1 = 1 ';
$sql_where = ' AND 1=1 ';
$criticities = array();
if ($filter_event_critical) {
$criticities[] = 4;
@ -2873,17 +2885,20 @@ function events_get_count_events_validated ($filter, $period, $date,
if ($rows == false)
$rows = array();
$return = array();
$return[__('Validated')] = 0;
$return[__('Not validated')] = 0;
foreach ($rows as $row) {
if ($row['estado'] == 1) {
$return[__('Validated')] += $row['count'];
$return = array_reduce($rows, function($carry, $item) {
$status = (int) $item['estado'];
$count = (int) $item['count'];
if ($status === 1) {
$carry[__('Validated')] += $count;
}
else {
$return[__('Not validated')] += $row['count'];
else if ($status === 0) {
$carry[__('Not validated')] += $count;
}
}
return $carry;
}, array(__('Validated') => 0, __('Not validated') => 0));
return $return;
}

View File

@ -84,18 +84,19 @@ function gis_print_map($idDiv, $iniZoom, $latCenter, $lonCenter, $baselayers, $c
echo "var baselayer = null;";
foreach ($baselayers as $baselayer) {
echo "baselayer = {
bb_bottom: null,
bb_left: null,
bb_right: null,
bb_top: null,
gmap_type: null,
image_height: null,
image_width: null,
num_zoom_levels: null,
name: null,
type: null,
url: null};";
echo "baselayer = {";
echo "bb_bottom: null,";
echo "bb_left: null,";
echo "bb_right: null,";
echo "bb_top: null,";
echo "gmap_type: null,";
echo "image_height: null,";
echo "image_width: null,";
echo "num_zoom_levels: null,";
echo "name: null,";
echo "type: null,";
echo "url: null";
echo "};";
echo "baselayer['type'] = '" . $baselayer['typeBaseLayer'] . "';";
echo "baselayer['name'] = '" . $baselayer['name'] . "';";
@ -122,33 +123,32 @@ function gis_print_map($idDiv, $iniZoom, $latCenter, $lonCenter, $baselayers, $c
echo "baselayerList.push(baselayer);";
}
echo "js_printMap(idDiv, initialZoom, centerLatitude, centerLongitude,
baselayerList, controlsList)";
echo "js_printMap(idDiv, initialZoom, centerLatitude, centerLongitude, baselayerList, controlsList);";
echo "</script>";
?>
<script type="text/javascript">
$(document).ready(function() {
setInterval(
function() {
function() {
$("img")
.filter(function() { return this.src.match(/mapcnt3/);})
.css('display', 'none');
$("img")
.filter(function() { return this.src.match(/cb_scout2/);})
.css('display', 'none');
$(".gm-style-mtc").css('display', 'none');
$(".olControlMousePosition").css("background", "white");
}
$("img")
.filter(function() { return this.src.match(/mapcnt3/);})
.css('display', 'none');
$("img")
.filter(function() { return this.src.match(/cb_scout2/);})
.css('display', 'none');
$(".gm-style-mtc").css('display', 'none');
$(".olControlMousePosition").css("background", "white");
}
,3000);
,3000);
});
</script>
<?php
}
@ -201,50 +201,50 @@ function gis_make_layer($name, $visible = true, $dot = null, $idLayer = null, $p
var long_lat = featureData.long_lat;
var popup;
var img_src= null;
var parameter = Array();
parameter.push ({name: "page", value: "include/ajax/skins.ajax"});
parameter.push ({name: "get_image_path", value: "1"});
parameter.push ({name: "img_src", value: "images/spinner.gif"});
var img_src = null;
jQuery.ajax ({
type: 'POST',
url: "<?php echo ui_get_full_url('ajax.php', false, false, false, false); ?>",
data: parameter,
async: false,
timeout: 10000,
data: {
page: "include/ajax/skins.ajax",
get_image_path: 1,
img_src: "images/spinner.gif"
},
type: 'GET',
dataType: 'html',
success: function (data) {
img_src = data;
}
});
popup = new OpenLayers.Popup.FramedCloud('cloud00',
long_lat,
null,
'<div class="cloudContent' + featureData.id + '" style="text-align: center;">' + img_src + '</div>',
null,
true,
function () { popup.destroy(); });
feature.popup = popup;
map.addPopup(popup);
jQuery.ajax ({
data: "page=operation/gis_maps/ajax"
+ "&opt=" + featureData.type
+ "&id=" + featureData.id
+ "&hash=<?php echo $hash; ?>"
+ "&id_user=<?php echo $config["id_user"]; ?>"
+ "&map_id=<?php echo $id_map; ?>",
type: "GET",
dataType: 'json',
url: "<?php echo ui_get_full_url('ajax.php', false, false, false, false); ?>",
timeout: 10000,
success: function (data) {
if (data.correct) {
$('.cloudContent' + featureData.id).css('text-align', 'left');
popup = new OpenLayers.Popup.FramedCloud('cloud00',
long_lat,
null,
'<div class="cloudContent' + featureData.id + '" style="text-align: center;">' + img_src + '</div>',
null,
true,
function () { popup.destroy(); });
feature.popup = popup;
map.addPopup(popup);
jQuery.ajax ({
url: "<?php echo ui_get_full_url('ajax.php', false, false, false, false); ?>",
data: {
page: "operation/gis_maps/ajax",
opt: featureData.type,
id: featureData.id,
hash: "<?php echo $hash; ?>",
id_user: "<?php echo $config['id_user']; ?>",
map_id: <?php echo (int)$id_map; ?>
},
type: "GET",
dataType: 'json',
success: function (data) {
if (data.correct) {
$('.cloudContent' + featureData.id).css('text-align', 'left');
$('.cloudContent' + featureData.id).html(data.content);
popup.updateSize();
}
}
}
});
}
});
}
@ -334,7 +334,6 @@ function gis_activate_ajax_refresh($layers = null, $lastTimeOfData = null, $publ
type: "GET",
dataType: 'json',
url: "ajax.php",
timeout: 10000,
success: function (data) {
if (data.correct) {
content = $.evalJSON(data.content);
@ -430,9 +429,7 @@ function gis_add_agent_point($layerName, $pointName, $lat, $lon, $icon = null, $
<?php
if ($icon != null) {
//echo "js_addPointExtent('$layerName', '$pointName', $lon, $lat, '$icon', $width, $height, $point_id, '$type_string', $status);";
echo "js_addAgentPointExtent('$layerName',
'$pointName', $lon, $lat, '$icon', $width,
$height, $point_id, '$type_string', $status, $idParent);";
echo "js_addAgentPointExtent('$layerName', '$pointName', $lon, $lat, '$icon', $width, $height, $point_id, '$type_string', $status, $idParent);";
}
else {
//echo "js_addPoint('$layerName', '$pointName', $lon, $lat, $point_id, '$type_string', $status);";
@ -462,12 +459,13 @@ function gis_get_agents_layer($idLayer, $fields = null) {
$select = implode(',',$fields);
}
$agents = db_get_all_rows_sql('SELECT ' . $select . '
FROM tagente
WHERE id_agente IN (
SELECT tagente_id_agente
FROM tgis_map_layer_has_tagente
WHERE tgis_map_layer_id_tmap_layer = ' . $idLayer . ');');
$sql = "SELECT $select
FROM tagente
WHERE id_agente IN (
SELECT tagente_id_agente
FROM tgis_map_layer_has_tagente
WHERE tgis_map_layer_id_tmap_layer = $idLayer)";
$agents = db_get_all_rows_sql($sql);
if ($agents !== false) {
foreach ($agents as $index => $agent) {
@ -478,7 +476,6 @@ function gis_get_agents_layer($idLayer, $fields = null) {
return array();
}
return $agents;
}
@ -505,10 +502,12 @@ function gis_get_maps() {
* @return An array of arrays of configuration parameters
*/
function gis_get_map_conf($idMap) {
$mapConfs= db_get_all_rows_sql('SELECT tconn.*, trel.default_map_connection
FROM tgis_map_connection AS tconn, tgis_map_has_tgis_map_connection AS trel
WHERE trel.tgis_map_connection_id_tmap_connection = tconn.id_tmap_connection
AND trel.tgis_map_id_tgis_map = ' . $idMap);
$sql = 'SELECT tconn.*, trel.default_map_connection
FROM tgis_map_connection tconn, tgis_map_has_tgis_map_con trel
WHERE trel.tgis_map_con_id_tmap_con = tconn.id_tmap_connection
AND trel.tgis_map_id_tgis_map = ' . $idMap;
$mapConfs = db_get_all_rows_sql($sql);
return $mapConfs;
}
@ -517,9 +516,10 @@ function gis_get_map_connection($idMapConnection) {
}
function gis_get_layers($idMap) {
$layers = db_get_all_rows_sql('SELECT *
FROM tgis_map_layer
WHERE tgis_map_id_tgis_map = ' . $idMap);
$sql = 'SELECT *
FROM tgis_map_layer
WHERE tgis_map_id_tgis_map = ' . $idMap;
$layers = db_get_all_rows_sql($sql);
return $layers;
}
@ -527,12 +527,12 @@ function gis_get_layers($idMap) {
function gis_get_agent_icon_map($idAgent, $state = false, $status = null) {
global $config;
$row = db_get_row_sql('
SELECT id_grupo, icon_path
FROM tagente
WHERE id_agente = ' . $idAgent);
$sql = 'SELECT id_grupo, icon_path
FROM tagente
WHERE id_agente = ' . $idAgent;
$row = db_get_row_sql($sql);
if (($row['icon_path'] === null) || (strlen($row['icon_path']) == 0)) {
if ($row['icon_path'] === null || strlen($row['icon_path']) == 0) {
if ($config['gis_default_icon'] != "") {
$icon = "images/gis_map/icons/" . $config['gis_default_icon'];
}
@ -609,12 +609,12 @@ function gis_add_path($layerName, $idAgent, $lastPosition = null, $history_time
}
}
$listPoints = db_get_all_rows_sql('SELECT *
FROM tgis_data_history
WHERE
tagente_id_agente = ' . $idAgent . ' AND
' . $where . '
ORDER BY end_timestamp ASC');
$sql = "SELECT *
FROM tgis_data_history
WHERE tagente_id_agente = $idAgent
AND $where
ORDER BY end_timestamp ASC";
$listPoints = db_get_all_rows_sql($sql);
//If the agent is empty the history
if ($listPoints === false) {
@ -731,7 +731,7 @@ function gis_delete_map($idMap) {
}
}
db_process_sql_delete('tgis_map_layer', array('tgis_map_id_tgis_map' => $idMap));
db_process_sql_delete('tgis_map_has_tgis_map_connection', array('tgis_map_id_tgis_map' => $idMap));
db_process_sql_delete('tgis_map_has_tgis_map_con', array('tgis_map_id_tgis_map' => $idMap));
db_process_sql_delete('tgis_map', array('id_tgis_map' => $idMap));
$numMaps = db_get_num_rows('SELECT * FROM tgis_map');
@ -741,7 +741,7 @@ function gis_delete_map($idMap) {
/**
* Save the map into DB, tgis_map and with id_map save the connetions in
* tgis_map_has_tgis_map_connection, and with id_map save the layers in
* tgis_map_has_tgis_map_con, and with id_map save the layers in
* tgis_map_layer and witch each id_layer save the agent in this layer in
* table tgis_map_layer_has_tagente.
*
@ -783,10 +783,10 @@ function gis_save_map($map_name, $map_initial_longitude, $map_initial_latitude,
db_process_sql_update('tgis_map', array('default_map' => 1), array('id_tgis_map' => $idMap));
foreach ($map_connection_list as $map_connection) {
db_process_sql_insert('tgis_map_has_tgis_map_connection',
db_process_sql_insert('tgis_map_has_tgis_map_con',
array(
'tgis_map_id_tgis_map' => $idMap,
'tgis_map_connection_id_tmap_connection' => $map_connection['id_conection'],
'tgis_map_con_id_tmap_con' => $map_connection['id_conection'],
'default_map_connection' => $map_connection['default']
)
);
@ -834,20 +834,22 @@ function gis_update_map($idMap, $map_name, $map_initial_longitude, $map_initial_
),
array('id_tgis_map' => $idMap));
db_process_sql_delete('tgis_map_has_tgis_map_connection', array('tgis_map_id_tgis_map' => $idMap));
db_process_sql_delete('tgis_map_has_tgis_map_con', array('tgis_map_id_tgis_map' => $idMap));
foreach ($map_connection_list as $map_connection) {
db_process_sql_insert('tgis_map_has_tgis_map_connection',
db_process_sql_insert('tgis_map_has_tgis_map_con',
array(
'tgis_map_id_tgis_map' => $idMap,
'tgis_map_connection_id_tmap_connection' => $map_connection['id_conection'],
'tgis_map_con_id_tmap_con' => $map_connection['id_conection'],
'default_map_connection' => $map_connection['default']
)
);
}
$listOldIdLayers = db_get_all_rows_sql('SELECT id_tmap_layer
FROM tgis_map_layer WHERE tgis_map_id_tgis_map = ' . $idMap);
$sql = 'SELECT id_tmap_layer
FROM tgis_map_layer
WHERE tgis_map_id_tgis_map = ' . $idMap;
$listOldIdLayers = db_get_all_rows_sql($sql);
if ($listOldIdLayers == false)
$listOldIdLayers = array();
@ -888,8 +890,6 @@ function gis_update_map($idMap, $map_name, $map_initial_longitude, $map_initial_
);
}
if (array_key_exists('layer_agent_list', $layer)) {
if (count($layer['layer_agent_list']) > 0) {
foreach ($layer['layer_agent_list'] as $agent_name) {
@ -904,7 +904,6 @@ function gis_update_map($idMap, $map_name, $map_initial_longitude, $map_initial_
}
}
}
}
//Delete layers that not carry the $arrayLayers
@ -922,7 +921,11 @@ function gis_update_map($idMap, $map_name, $map_initial_longitude, $map_initial_
* @result: An array with all the configuration parameters
*/
function gis_get_conection_conf($idConnection) {
$confParameters = db_get_row_sql('SELECT * FROM tgis_map_connection WHERE id_tmap_connection = ' . $idConnection);
$sql = 'SELECT *
FROM tgis_map_connection
WHERE id_tmap_connection = ' . $idConnection;
$confParameters = db_get_row_sql($sql);
return $confParameters;
}
@ -939,18 +942,17 @@ function gis_get_conection_conf($idConnection) {
* @return boolean True ok and false fail.
*/
function gis_get_agent_map($agent_id, $heigth, $width, $show_history = false, $centerInAgent = true, $history_time = SECONDS_1DAY) {
$defaultMap = db_get_all_rows_sql("
SELECT t1.*, t3.conection_name, t3.connection_type,
t3.conection_data, t3.num_zoom_levels
FROM tgis_map AS t1,
tgis_map_has_tgis_map_connection AS t2,
tgis_map_connection AS t3
WHERE t1.default_map = 1
AND t2.tgis_map_id_tgis_map = t1.id_tgis_map
AND t2.default_map_connection = 1
AND t3.id_tmap_connection = t2.tgis_map_connection_id_tmap_connection");
$sql = "SELECT t1.*, t3.conection_name, t3.connection_type,
t3.conection_data, t3.num_zoom_levels
FROM tgis_map t1,
tgis_map_has_tgis_map_con t2,
tgis_map_connection t3
WHERE t1.default_map = 1
AND t2.tgis_map_id_tgis_map = t1.id_tgis_map
AND t2.default_map_connection = 1
AND t3.id_tmap_connection = t2.tgis_map_con_id_tmap_con";
$defaultMap = db_get_all_rows_sql($sql);
if ($defaultMap === false) {
return false;
@ -1180,49 +1182,66 @@ function gis_validate_map_data($map_name, $map_zoom_level,
function gis_get_map_data($idMap) {
global $config;
$idMap = (int) $idMap;
$returnVar = array();
$map = db_get_row('tgis_map', 'id_tgis_map', $idMap);
if (empty($map))
return $returnVar;
$connections = false;
switch ($config["dbtype"]) {
case "mysql":
$connections = db_get_all_rows_sql('SELECT t1.tgis_map_connection_id_tmap_connection AS id_conection,
t1.default_map_connection AS `default`, (
SELECT t2.num_zoom_levels
FROM tgis_map_connection AS t2
WHERE t2.id_tmap_connection = t1.tgis_map_connection_id_tmap_connection) AS num_zoom_levels
FROM tgis_map_has_tgis_map_connection AS t1
WHERE t1.tgis_map_id_tgis_map = '. $map['id_tgis_map']);
$sql = "SELECT t1.tgis_map_con_id_tmap_con AS id_conection
t1.default_map_connection AS `default`,
SUM(t2.num_zoom_levels) AS num_zoom_levels
FROM tgis_map_has_tgis_map_con t1
INNER JOIN tgis_map_connection t2
ON t1.tgis_map_con_id_tmap_con = t2.id_tmap_connection
WHERE t1.tgis_map_id_tgis_map = $idMap
GROUP BY t1.tgis_map_con_id_tmap_con, t1.default_map_connection";
$connections = db_get_all_rows_sql($sql);
break;
case "postgresql":
case "oracle":
$connections = db_get_all_rows_sql('SELECT t1.tgis_map_connection_id_tmap_connection AS id_conection,
t1.default_map_connection AS "default", (
SELECT t2.num_zoom_levels
FROM tgis_map_connection AS t2
WHERE t2.id_tmap_connection = t1.tgis_map_connection_id_tmap_connection) AS num_zoom_levels
FROM tgis_map_has_tgis_map_connection AS t1
WHERE t1.tgis_map_id_tgis_map = '. $map['id_tgis_map']);
$sql = "SELECT t1.tgis_map_con_id_tmap_con AS id_conection
t1.default_map_connection AS \"default\",
SUM(t2.num_zoom_levels) AS num_zoom_levels
FROM tgis_map_has_tgis_map_con t1
INNER JOIN tgis_map_connection t2
ON t1.tgis_map_con_id_tmap_con = t2.id_tmap_connection
WHERE t1.tgis_map_id_tgis_map = $idMap
GROUP BY t1.tgis_map_con_id_tmap_con, t1.default_map_connection";
$connections = db_get_all_rows_sql($sql);
break;
}
$layers = db_get_all_rows_sql('SELECT id_tmap_layer, layer_name,
tgrupo_id_grupo AS layer_group, view_layer AS layer_visible
FROM tgis_map_layer
WHERE tgis_map_id_tgis_map = ' . $map['id_tgis_map'] . '
ORDER BY layer_stack_order ASC;');
$sql = "SELECT id_tmap_layer, layer_name,
tgrupo_id_grupo AS layer_group,
view_layer AS layer_visible
FROM tgis_map_layer
WHERE tgis_map_id_tgis_map = $idMap
ORDER BY layer_stack_order ASC";
$layers = db_get_all_rows_sql($sql);
if ($layers === false) $layers = array();
foreach ($layers as $index => $layer) {
$agents = db_get_all_rows_sql('SELECT nombre
FROM tagente
WHERE id_agente IN (
SELECT tagente_id_agente
FROM tgis_map_layer_has_tagente
WHERE tgis_map_layer_id_tmap_layer = ' . $layer['id_tmap_layer'] . ')');
if ($agents !== false)
$layers[$index]['layer_agent_list'] = $agents;
else
$layers[$index]['layer_agent_list'] = array();
if (!isset($layer['id_tmap_layer']))
continue;
$id_tmap_layer = (int) $layer['id_tmap_layer'];
$sql = "SELECT nombre
FROM tagente
WHERE id_agente IN (
SELECT tagente_id_agente
FROM tgis_map_layer_has_tagente
WHERE tgis_map_layer_id_tmap_layer = $id_tmap_layer)";
$agents = db_get_all_rows_sql($sql);
if ($agents === false) $agents = array();
$layers[$index]['layer_agent_list'] = $agents;
}
$returnVar['map'] = $map;

View File

@ -1792,6 +1792,7 @@ function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) {
global $config;
global $graphic_type;
$filter = array();
if ($id_agent < 1) {
$query = "";
@ -1799,18 +1800,9 @@ function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) {
else {
$modules = agents_get_modules($id_agent);
$module_ids = array_keys($modules);
if (!empty($module_ids)) {
$module_ids_str = implode(",", $module_ids);
if (empty($module_ids_str))
$module_ids_str = "0";
}
else {
$module_ids_str = "0";
}
$query = sprintf (" AND id_agente_modulo IN (%s)", $module_ids_str);
if (!empty($module_ids))
$filter['id_agente_modulo'] = $module_ids;
}
// All data (now)
@ -1829,101 +1821,73 @@ function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) {
$time_3months = $time_now - SECONDS_3MONTHS;
$query_error = false;
// Data from 1 day ago
$sql_1day = sprintf("SELECT COUNT(*)
+ (SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp >= %d %s)
+ (SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp >= %d %s)
FROM tagente_datos
WHERE utimestamp > %d %s",
$time_1day, $query,
$time_1day, $query,
$time_1day, $query);
$num_1day = db_get_sql($sql_1day);
$filter['utimestamp'] = '>' . $time_1day;
$num_1day = 0;
$num_1day += (int) db_get_value_filter('COUNT(*)', 'tagente_datos', $filter);
$num_1day += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_string', $filter);
$num_1day += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_log4x', $filter);
if ($num_1day !== false) {
// Data from 1 week ago
$sql_1week = sprintf("SELECT COUNT(*)
+ (SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp >= %d %s)
+ (SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp >= %d %s)
FROM tagente_datos
WHERE utimestamp >= %d %s",
$time_1week, $query,
$time_1week, $query,
$time_1week, $query);
$num_1week = db_get_sql($sql_1week);
$filter['utimestamp'] = '>' . $time_1week;
$num_1week = 0;
$num_1week += (int) db_get_value_filter('COUNT(*)', 'tagente_datos', $filter);
$num_1week += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_string', $filter);
$num_1week += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_log4x', $filter);
if ($num_1week !== false) {
// Data from 1 month ago
$sql_1month = sprintf("SELECT COUNT(*)
+ (SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp >= %d %s)
+ (SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp >= %d %s)
FROM tagente_datos
WHERE utimestamp >= %d %s",
$time_1month, $query,
$time_1month, $query,
$time_1month, $query);
$num_1month = db_get_sql($sql_1month);
$filter['utimestamp'] = '>' . $time_1month;
$num_1month = 0;
$num_1month += (int) db_get_value_filter('COUNT(*)', 'tagente_datos', $filter);
$num_1month += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_string', $filter);
$num_1month += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_log4x', $filter);
if ($num_1month !== false) {
// Data from 3 months ago
$sql_3months = sprintf("SELECT COUNT(*)
+ (SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp >= %d %s)
+ (SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp >= %d %s)
FROM tagente_datos
WHERE utimestamp >= %d %s",
$time_3months, $query,
$time_3months, $query,
$time_3months, $query);
$num_3months = db_get_sql($sql_3months);
$filter['utimestamp'] = '>' . $time_3months;
$num_3months = 0;
$num_3months += (int) db_get_value_filter('COUNT(*)', 'tagente_datos', $filter);
$num_3months += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_string', $filter);
$num_3months += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_log4x', $filter);
if ($num_3months !== false) {
// All data
$sql_all = sprintf("SELECT COUNT(*)
+ (SELECT COUNT(*)
FROM tagente_datos_string
WHERE 1=1 %s)
+ (SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE 1=1 %s)
FROM tagente_datos
WHERE 1=1 %s",
$query, $query, $query);
$num_all = db_get_sql($sql_all);
unset($filter['utimestamp']);
if (empty($filter)) {
$num_all = 0;
$num_all += (int) db_get_value_sql('SELECT COUNT(*) FROM tagente_datos');
$num_all += (int) db_get_value_sql('SELECT COUNT(*) FROM tagente_datos_string');
$num_all += (int) db_get_value_sql('SELECT COUNT(*) FROM tagente_datos_log4x');
}
else {
$num_all = 0;
$num_all += (int) db_get_value_filter('COUNT(*)', 'tagente_datos', $filter);
$num_all += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_string', $filter);
$num_all += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_log4x', $filter);
}
if ($num_all !== false) {
$num_older = $num_all - $num_3months;
if ($config['history_db_enabled'] == 1) {
// All data in common and history database
$sql_all_w_history = sprintf("SELECT COUNT(*)
+ (SELECT COUNT(*)
FROM tagente_datos_string
WHERE 1=1 %s)
+ (SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE 1=1 %s)
FROM tagente_datos
WHERE 1=1 %s",
$query, $query, $query);
$num_all_w_history = db_get_sql($sql_all_w_history, 0, true);
if (empty($filter)) {
$num_all_w_history = 0;
$num_all_w_history += (int) db_get_value_sql('SELECT COUNT(*) FROM tagente_datos', true);
$num_all_w_history += (int) db_get_value_sql('SELECT COUNT(*) FROM tagente_datos_string', true);
$num_all_w_history += (int) db_get_value_sql('SELECT COUNT(*) FROM tagente_datos_log4x', true);
}
else {
$num_all_w_history = 0;
$num_all_w_history += (int) db_get_value_filter('COUNT(*)', 'tagente_datos', $filter, 'AND', true);
$num_all_w_history += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_string', $filter, 'AND', true);
$num_all_w_history += (int) db_get_value_filter('COUNT(*)', 'tagente_datos_log4x', $filter, 'AND', true);
}
if ($num_all_w_history !== false) {
$num_history = $num_all_w_history - $num_all;
} else {
@ -1945,7 +1909,7 @@ function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) {
} else {
$query_error = true;
}
// Error
if ($query_error || $num_older < 0 || ($config['history_db_enabled'] == 1 && $num_history < 0)
|| (empty($num_1day) && empty($num_1week) && empty($num_1month)
@ -2438,22 +2402,21 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta =
//is required if both DISTINCT() and COUNT() are in the statement
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf ('SELECT DISTINCT(id_agente) AS id_agente,
COUNT(id_agente) AS count'.$field_extra.'
FROM '.$event_table.'
WHERE 1=1 %s %s
GROUP BY id_agente'.$groupby_extra.'
ORDER BY count DESC LIMIT 8', $url, $tags_condition);
break;
case "postgresql":
case "oracle":
$sql = sprintf ('SELECT DISTINCT(id_agente) AS id_agente,
id_grupo, COUNT(id_agente) AS count'.$field_extra.'
FROM '.$event_table.'
WHERE 1=1 %s %s
WHERE rownum <= 8 %s %s
GROUP BY id_agente, id_grupo'.$groupby_extra.'
ORDER BY count DESC LIMIT 8', $url, $tags_condition);
ORDER BY count DESC', $url, $tags_condition);
break;
}
@ -2740,6 +2703,17 @@ function graph_custom_sql_graph ($id, $width, $height,
}
}
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
break;
case "oracle":
$sql = str_replace(";", "", $sql);
break;
}
$data_result = db_get_all_rows_sql ($sql);
if (($config['metaconsole'] == 1) && defined('METACONSOLE'))

View File

@ -1265,7 +1265,7 @@ function groups_get_agents_counter ($group, $agent_filter = array(), $module_fil
$module_status_array = array_unique($module_status_array);
$status_str = implode(",", $module_status_array);
$module_status_filter = "INNER JOIN tagente_estado AS tae
$module_status_filter = "INNER JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo
AND tae.estado IN ($status_str)";
}
@ -1276,8 +1276,8 @@ function groups_get_agents_counter ($group, $agent_filter = array(), $module_fil
// Realtime
if ($realtime) {
$sql = "SELECT DISTINCT ta.id_agente
FROM tagente AS ta
INNER JOIN tagente_modulo AS tam
FROM tagente ta
INNER JOIN tagente_modulo tam
ON ta.id_agente = tam.id_agente
AND tam.disabled = 0
$module_name_filter
@ -1436,7 +1436,7 @@ function groups_get_agents_counter ($group, $agent_filter = array(), $module_fil
}
$sql = "SELECT COUNT(DISTINCT ta.id_agente)
FROM tagente AS ta
FROM tagente ta
WHERE ta.disabled = 0
$agent_name_filter
$status_filter
@ -1738,11 +1738,11 @@ function groups_get_monitors_counter ($group, $agent_filter = array(), $module_f
if ($realtime) {
$sql = "SELECT COUNT(DISTINCT tam.id_agente_modulo)
FROM tagente_modulo AS tam
INNER JOIN tagente_estado AS tae
FROM tagente_modulo tam
INNER JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo
$modules_clause
INNER JOIN tagente AS ta
INNER JOIN tagente ta
ON tam.id_agente = ta.id_agente
AND ta.disabled = 0
$agent_name_filter
@ -1786,7 +1786,7 @@ function groups_get_monitors_counter ($group, $agent_filter = array(), $module_f
$status_columns_str = implode(",", $status_columns_array);
$sql = "SELECT SUM($status_columns_str)
FROM tagente AS ta
FROM tagente ta
WHERE ta.disabled = 0
$agent_name_filter
$agents_clause
@ -2305,7 +2305,7 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
SELECT *
FROM tgrupo
WHERE id_grupo IN (" . $user_groups_ids . ")
ORDER BY nombre COLLATE utf8_general_ci ASC");
ORDER BY nombre ASC");
break;
}
}

View File

@ -1442,6 +1442,9 @@ function html_print_table (&$table, $return = false) {
}
if (empty ($table->border)) {
if (empty($table)) {
$table = new stdClass();
}
$table->border = '0';
}
@ -1858,7 +1861,7 @@ function html_print_image ($src, $return = false, $options = false,
}
// New way to show the force_title (cleaner and better performance)
$output .= 'title="'.io_safe_input_html($options["title"]).'" ';
$output .= 'data-title="'.io_safe_input_html($options["title"]).'" ';
$output .= 'data-use_title_for_force_title="1" ';
}

View File

@ -1988,10 +1988,10 @@ function modules_get_relations ($params = array()) {
$sql = "SELECT DISTINCT tmr.id, tmr.module_a, tmr.module_b,
tmr.disable_update
FROM tmodule_relationship AS tmr,
tagente_modulo AS tam,
tagente AS ta,
ttipo_modulo AS ttm
FROM tmodule_relationship tmr,
tagente_modulo tam,
tagente ta,
ttipo_modulo ttm
WHERE ";
$agent_filter = "";
@ -2135,8 +2135,12 @@ function modules_get_count_datas($id_agent_module, $date_init, $date_end) {
$date_end = strtotime($date_end);
}
$first_date = modules_get_first_contact_date($id_agent_module);
if ($date_init < $first_date) {
$date_init = $first_date;
}
@ -2210,14 +2214,9 @@ function modules_get_first_contact_date($id_agent_module) {
// TODO FOR OTHER KIND OF DATA
$sql = "
SELECT utimestamp
FROM tagente_datos
WHERE id_agente_modulo = " . (int)($id_agent_module) . "
ORDER BY utimestamp ASC
LIMIT 1";
$first_date = db_get_sql($sql, 0, $config['history_db_enabled']);
$first_date = db_get_value('utimestamp', 'tagente_datos',
'id_agente_modulo', $id_agent_module,
$config['history_db_enabled']);
return $first_date;
}

View File

@ -253,7 +253,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
break;
case "oracle":
$filter[] =
'(upper(nombre) LIKE upper("%' . $text_filter . '%"))';
'(upper(nombre) LIKE upper(\'%' . $text_filter . '%\'))';
break;
}
}
@ -663,7 +663,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0,
break;
case "oracle":
$filter[] =
'(upper(nombre) LIKE upper("%' . $text_filter . '%"))';
'(upper(nombre) LIKE upper(\'%' . $text_filter . '%\'))';
break;
}
}

View File

@ -743,10 +743,14 @@ function reporting_SLA($report, $content, $type = 'dinamic',
//Get the sla_value in % and store it on $sla_value
$sla_value = reporting_get_agentmodule_sla(
$sla['id_agent_module'], $content['period'],
$sla['sla_min'], $sla['sla_max'],
$report["datetime"], $content,
$content['time_from'], $content['time_to']);
$sla['id_agent_module'],
$content['period'],
$sla['sla_min'],
$sla['sla_max'],
$report["datetime"],
$content,
$content['time_from'],
$content['time_to']);
if (($config ['metaconsole'] == 1) && defined('METACONSOLE')) {
//Restore db connection
@ -798,9 +802,21 @@ function reporting_SLA($report, $content, $type = 'dinamic',
$sla['id_agent_module']);
$data['module'] = modules_get_agentmodule_name(
$sla['id_agent_module']);
$data['max'] = $sla['sla_max'];
$data['min'] = $sla['sla_min'];
$data['sla_limit'] = $sla['sla_limit'];
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$data['max'] = $sla['sla_max'];
$data['min'] = $sla['sla_min'];
$data['sla_limit'] = $sla['sla_limit'];
break;
case "oracle":
$data['max'] = oracle_format_float_to_php($sla['sla_max']);
$data['min'] = oracle_format_float_to_php($sla['sla_min']);
$data['sla_limit'] = oracle_format_float_to_php($sla['sla_limit']);
break;
}
$data['sla_value_unknown'] = 0;
$data['sla_status'] = 0;
@ -1194,14 +1210,6 @@ function reporting_event_top_n($report, $content, $type = 'dinamic',
}
$avg = $avg / $i;
unset($table_summary);
$table_summary->width = '99%';
$table_summary->data = array ();
$table_summary->head = array ();
$table_summary->head[0] = __('Min Value');
$table_summary->head[1] = __('Average Value');
$table_summary->head[2] = __('Max Value');
$return['resume']['min']['value'] = $min;
$return['resume']['min']['formated_value'] = format_for_graph($min, 2);
@ -2368,10 +2376,21 @@ function reporting_group_configuration($report, $content) {
if ($content['id_group'] == 0) {
$sql = "SELECT * FROM tagente;";
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = "SELECT * FROM tagente;";
break;
case "oracle":
$sql = "SELECT * FROM tagente";
break;
}
}
else {
$sql = "SELECT * FROM tagente WHERE id_grupo=" . $content['id_group'];
$sql = "
SELECT *
FROM tagente
WHERE id_grupo=" . $content['id_group'];
}
$agents_list = db_get_all_rows_sql($sql);
@ -2382,7 +2401,17 @@ function reporting_group_configuration($report, $content) {
foreach ($agents_list as $agent) {
$content_agent = $content;
$content_agent['id_agent'] = $agent['id_agente'];
$agent_report = reporting_agent_configuration($report, $content_agent);
// Restore the connection to metaconsole
// because into the function reporting_agent_configuration
// connect to metaconsole.
if ($config['metaconsole']) {
metaconsole_restore_db();
}
$agent_report = reporting_agent_configuration(
$report, $content_agent);
$return['data'][] = $agent_report['data'];
}
@ -2564,7 +2593,7 @@ function reporting_alert_report_group($report, $content) {
FROM talert_actions
WHERE id IN (SELECT id_alert_action
FROM talert_template_module_actions
WHERE id_alert_template_module = ' . $alert['id_alert_template'] . ');');
WHERE id_alert_template_module = ' . $alert['id_alert_template'] . ')');
if (!empty($actions)) {
$row = db_get_row_sql('SELECT id_alert_action
@ -2668,11 +2697,27 @@ function reporting_alert_report_agent($report, $content) {
array('id' => $alert['id_alert_template']));
$actions = db_get_all_rows_sql('SELECT name
FROM talert_actions
WHERE id IN (SELECT id_alert_action
FROM talert_template_module_actions
WHERE id_alert_template_module = ' . $alert['id_alert_template'] . ');');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$actions = db_get_all_rows_sql('SELECT name
FROM talert_actions
WHERE id IN (SELECT id_alert_action
FROM talert_template_module_actions
WHERE id_alert_template_module = ' . $alert['id_alert_template'] . ');');
break;
case "oracle":
$actions = db_get_all_rows_sql('SELECT name
FROM talert_actions
WHERE id IN (SELECT id_alert_action
FROM talert_template_module_actions
WHERE id_alert_template_module = ' . $alert['id_alert_template'] . ')');
break;
}
if (!empty($actions)) {
$row = db_get_row_sql('SELECT id_alert_action
@ -2705,10 +2750,13 @@ function reporting_alert_report_agent($report, $content) {
$data_row['fired'] = array();
$firedTimes = get_module_alert_fired(
$content['id_agent_module'],
$alert['id_agent_module'],
$alert['id_alert_template'],
(int) $content['period'],
(int) $report["datetime"]);
if (empty($firedTimes)) {
$firedTimes = array();
}
@ -2756,10 +2804,26 @@ function reporting_alert_report_module($report, $content) {
$return["description"] = $content["description"];
$return["date"] = reporting_get_date_text($report, $content);
$alerts = db_get_all_rows_sql('SELECT *, t1.id as id_alert_template_module
FROM talert_template_modules AS t1
INNER JOIN talert_templates AS t2 ON t1.id_alert_template = t2.id
WHERE id_agent_module = ' . $content['id_agent_module']);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$alerts = db_get_all_rows_sql('
SELECT *, t1.id as id_alert_template_module
FROM talert_template_modules t1
INNER JOIN talert_templates t2
ON t1.id_alert_template = t2.id
WHERE id_agent_module = ' . $content['id_agent_module']);
break;
case "oracle":
$alerts = db_get_all_rows_sql('
SELECT t1.*, t2.*, t1.id as id_alert_template_module
FROM talert_template_modules t1
INNER JOIN talert_templates t2
ON t1.id_alert_template = t2.id
WHERE id_agent_module = ' . $content['id_agent_module']);
break;
}
if ($alerts === false) {
$alerts = array();
@ -2773,11 +2837,26 @@ function reporting_alert_report_module($report, $content) {
$data_row['template'] = db_get_value_filter('name',
'talert_templates', array('id' => $alert['id_alert_template']));
$actions = db_get_all_rows_sql('SELECT name
FROM talert_actions
WHERE id IN (SELECT id_alert_action
FROM talert_template_module_actions
WHERE id_alert_template_module = ' . $alert['id_alert_template_module'] . ');');
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$actions = db_get_all_rows_sql('SELECT name
FROM talert_actions
WHERE id IN (SELECT id_alert_action
FROM talert_template_module_actions
WHERE id_alert_template_module = ' . $alert['id_alert_template_module'] . ');');
break;
case "oracle":
$actions = db_get_all_rows_sql('SELECT name
FROM talert_actions
WHERE id IN (SELECT id_alert_action
FROM talert_template_module_actions
WHERE id_alert_template_module = ' . $alert['id_alert_template_module'] . ')');
break;
}
if (!empty($actions)) {
$row = db_get_row_sql('SELECT id_alert_action
@ -2814,6 +2893,9 @@ function reporting_alert_report_module($report, $content) {
$alert['id_alert_template_module'],
(int) $content['period'],
(int) $report["datetime"]);
if (empty($firedTimes)) {
$firedTimes = array();
}
@ -4078,6 +4160,18 @@ function reporting_general($report, $content) {
$data['value'] = null;
}
else {
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
break;
case "oracle":
if (preg_match("/[0-9]+,[0-9]E+[+-][0-9]+/", $d)) {
$d = oracle_format_float_to_php($d);
}
break;
}
if (!is_numeric($d)) {
$data['value'] = $d;
}
@ -4531,6 +4625,7 @@ function reporting_get_group_detailed_event ($id_group, $period = 0,
$date = get_system_time ();
}
$table = new stdClass();
$table->width = '99%';
$table->align = array();
@ -4657,17 +4752,6 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0,
$date = get_system_time ();
}
$table->width = '99%';
$table->data = array ();
$table->head = array ();
$table->head[0] = __('Status');
$table->head[1] = __('Event name');
$table->head[2] = __('Event type');
$table->head[3] = __('Criticity');
$table->head[4] = __('Count');
$table->head[5] = __('Timestamp');
$table->style[0] = 'text-align: center;';
$table->style[4] = 'text-align: center;';
$events = array ();
@ -4772,23 +4856,7 @@ function reporting_get_agents_detailed_event ($id_agents, $period = 0,
$date = get_system_time ();
}
$table->width = '99%';
$table->align = array();
$table->align[0] = 'center';
$table->align[1] = 'center';
$table->align[3] = 'center';
$table->data = array ();
$table->head = array ();
$table->head[0] = __('Status');
$table->head[1] = __('Count');
$table->head[2] = __('Name');
$table->head[3] = __('Type');
$table->head[4] = __('Criticity');
$table->head[5] = __('Val. by');
$table->head[6] = __('Timestamp');
$events = array ();
@ -5286,7 +5354,7 @@ function reporting_get_stats_alerts($data, $links = false) {
$table_al->rowclass[] = '';
$table_al->data[] = $tdata;
if(!defined('METACONSOLE')) {
if (!defined('METACONSOLE')) {
$output = '<fieldset class="databox tactical_set">
<legend>' .
__('Defined and fired alerts') .
@ -5294,11 +5362,14 @@ function reporting_get_stats_alerts($data, $links = false) {
html_print_table($table_al, true) . '</fieldset>';
}
else {
// Remove the defined alerts cause with the new cache table is difficult to retrieve them
unset($table_al->data[0][0], $table_al->data[0][1]);
$table_al->class = "tactical_view";
$table_al->style = array();
$output = '<fieldset class="tactical_set">
<legend>' .
__('Defined and fired alerts') .
__('Fired alerts') .
'</legend>' .
html_print_table($table_al, true) . '</fieldset>';
}
@ -5561,7 +5632,30 @@ function reporting_get_agentmodule_data_average ($id_agent_module, $period=0, $d
$period = $date - $previous_data['utimestamp'];
}
}
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
// Do none
break;
case "oracle":
$previous_data['datos'] =
oracle_format_float_to_php($previous_data['datos']);
break;
}
foreach ($interval_data as $data) {
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
// Do none
break;
case "oracle":
$data['datos'] =
oracle_format_float_to_php($data['datos']);
break;
}
if (! $uncompressed_module) {
$total += $previous_data['datos'] * ($data['utimestamp'] - $previous_data['utimestamp']);
$previous_data = $data;
@ -5636,7 +5730,8 @@ function reporting_get_agentmodule_mttr ($id_agent_module, $period = 0, $date =
if ($interval_data === false) $interval_data = array ();
// Get previous data
$previous_data = modules_get_previous_data ($id_agent_module, $datelimit);
$previous_data = modules_get_previous_data(
$id_agent_module, $datelimit);
if ($previous_data !== false) {
$previous_data['utimestamp'] = $datelimit;
array_unshift ($interval_data, $previous_data);
@ -5664,6 +5759,18 @@ function reporting_get_agentmodule_mttr ($id_agent_module, $period = 0, $date =
$critical_period = 0;
$first_data = array_shift ($interval_data);
$previous_utimestamp = $first_data['utimestamp'];
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
// Do none
break;
case "oracle":
$first_data['datos'] =
oracle_format_float_to_php($first_data['datos']);
break;
}
if ((($critical_max > $critical_min AND ($first_data['datos'] > $critical_max OR $first_data['datos'] < $critical_min))) OR
($critical_max <= $critical_min AND $first_data['datos'] < $critical_min)) {
$previous_status = 1;
@ -5675,6 +5782,17 @@ function reporting_get_agentmodule_mttr ($id_agent_module, $period = 0, $date =
}
foreach ($interval_data as $data) {
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
// Do none
break;
case "oracle":
$data['datos'] =
oracle_format_float_to_php($data['datos']);
break;
}
// Previous status was critical
if ($previous_status == 1) {
$critical_period += $data['utimestamp'] - $previous_utimestamp;
@ -5777,6 +5895,18 @@ function reporting_get_agentmodule_mtbf ($id_agent_module, $period = 0, $date =
$critical_period = 0;
$first_data = array_shift ($interval_data);
$previous_utimestamp = $first_data['utimestamp'];
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
// Do none
break;
case "oracle":
$first_data['datos'] =
oracle_format_float_to_php($first_data['datos']);
break;
}
if ((($critical_max > $critical_min AND ($first_data['datos'] > $critical_max OR $first_data['datos'] < $critical_min))) OR
($critical_max <= $critical_min AND $first_data['datos'] < $critical_min)) {
$previous_status = 1;
@ -5793,6 +5923,17 @@ function reporting_get_agentmodule_mtbf ($id_agent_module, $period = 0, $date =
$critical_period += $data['utimestamp'] - $previous_utimestamp;
}
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
// Do none
break;
case "oracle":
$data['datos'] =
oracle_format_float_to_php($data['datos']);
break;
}
// Re-calculate previous status for the next data
if ((($critical_max > $critical_min AND ($data['datos'] > $critical_max OR $data['datos'] < $critical_min))) OR
($critical_max <= $critical_min AND $data['datos'] < $critical_min)) {
@ -6490,34 +6631,70 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
*/
function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_date, $end_date, $check_services = false) {
global $config;
if (empty($id_agent_module))
return false;
require_once ($config['homedir'] . '/include/functions_planned_downtimes.php');
$malformed_planned_downtimes = planned_downtimes_get_malformed();
if (empty($malformed_planned_downtimes))
$malformed_planned_downtimes = array();
$sql_downtime = "SELECT DISTINCT(tpdr.id), tpdr.*
FROM (
SELECT tpd.*
FROM tplanned_downtime tpd, tplanned_downtime_agents tpda, tagente_modulo tam
WHERE tpd.id = tpda.id_downtime
AND tpda.all_modules = 1
AND tpda.id_agent = tam.id_agente
AND tam.id_agente_modulo = $id_agent_module
UNION ALL
SELECT tpd.*
FROM tplanned_downtime tpd, tplanned_downtime_modules tpdm
WHERE tpd.id = tpdm.id_downtime
AND tpdm.id_agent_module = $id_agent_module
) tpdr
ORDER BY tpdr.id";
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$tpdr_description = "tpdr.description";
break;
case "oracle":
$tpdr_description = "to_char(tpdr.description)";
break;
}
$sql_downtime = "
SELECT DISTINCT(tpdr.id),
tpdr.name,
" . $tpdr_description . ",
tpdr.date_from,
tpdr.date_to,
tpdr.executed,
tpdr.id_group,
tpdr.only_alerts,
tpdr.monday,
tpdr.tuesday,
tpdr.wednesday,
tpdr.thursday,
tpdr.friday,
tpdr.saturday,
tpdr.sunday,
tpdr.periodically_time_from,
tpdr.periodically_time_to,
tpdr.periodically_day_from,
tpdr.periodically_day_to,
tpdr.type_downtime,
tpdr.type_execution,
tpdr.type_periodicity,
tpdr.id_user
FROM (
SELECT tpd.*
FROM tplanned_downtime tpd, tplanned_downtime_agents tpda, tagente_modulo tam
WHERE tpd.id = tpda.id_downtime
AND tpda.all_modules = 1
AND tpda.id_agent = tam.id_agente
AND tam.id_agente_modulo = $id_agent_module
UNION ALL
SELECT tpd.*
FROM tplanned_downtime tpd, tplanned_downtime_modules tpdm
WHERE tpd.id = tpdm.id_downtime
AND tpdm.id_agent_module = $id_agent_module
) tpdr
ORDER BY tpdr.id";
$downtimes = db_get_all_rows_sql($sql_downtime);
if ($downtimes == false) {
$downtimes = array();
}
@ -6534,7 +6711,7 @@ function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_dat
$downtime_dates[] = $dates;
}
else if ($downtime_type == 'periodically') {
// If a planned downtime have malformed dates, its intervals aren't taken account
$downtime_malformed = false;
foreach ($malformed_planned_downtimes as $malformed_planned_downtime) {
@ -6547,28 +6724,28 @@ function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_dat
continue;
}
// If a planned downtime have malformed dates, its intervals aren't taken account
$downtime_time_from = $downtime['periodically_time_from'];
$downtime_time_to = $downtime['periodically_time_to'];
$downtime_hour_from = date("H", strtotime($downtime_time_from));
$downtime_minute_from = date("i", strtotime($downtime_time_from));
$downtime_second_from = date("s", strtotime($downtime_time_from));
$downtime_hour_to = date("H", strtotime($downtime_time_to));
$downtime_minute_to = date("i", strtotime($downtime_time_to));
$downtime_second_to = date("s", strtotime($downtime_time_to));
if ($downtime_periodicity == "monthly") {
$downtime_day_from = $downtime['periodically_day_from'];
$downtime_day_to = $downtime['periodically_day_to'];
$date_aux = strtotime(date("Y-m-01", $start_date));
$year_aux = date("Y", $date_aux);
$month_aux = date("m", $date_aux);
$end_year = date("Y", $end_date);
$end_month = date("m", $end_date);
while ($year_aux < $end_year || ($year_aux == $end_year && $month_aux <= $end_month)) {
if ($downtime_day_from > $downtime_day_to) {
@ -6576,7 +6753,7 @@ function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_dat
$dates['date_from'] = strtotime("$year_aux-$month_aux-$downtime_day_from $downtime_hour_from:$downtime_minute_from:$downtime_second_from");
$dates['date_to'] = strtotime(date("Y-m-t H:i:s", strtotime("$year_aux-$month_aux-28 23:59:59")));
$downtime_dates[] = $dates;
$dates = array();
if ($month_aux + 1 <= 12) {
$dates['date_from'] = strtotime("$year_aux-".($month_aux + 1)."-01 00:00:00");
@ -6592,14 +6769,14 @@ function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_dat
if ($downtime_day_from == $downtime_day_to && strtotime($downtime_time_from) > strtotime($downtime_time_to)) {
$date_aux_from = strtotime("$year_aux-$month_aux-$downtime_day_from $downtime_hour_from:$downtime_minute_from:$downtime_second_from");
$max_day_num = date('t', $date_aux);
$dates = array();
$dates['date_from'] = strtotime("$year_aux-$month_aux-$downtime_day_from $downtime_hour_from:$downtime_minute_from:$downtime_second_from");
$dates['date_to'] = strtotime("$year_aux-$month_aux-$downtime_day_from 23:59:59");
$downtime_dates[] = $dates;
if ($downtime_day_to + 1 > $max_day_num) {
$dates = array();
if ($month_aux + 1 <= 12) {
$dates['date_from'] = strtotime("$year_aux-".($month_aux + 1)."-01 00:00:00");
@ -6625,7 +6802,7 @@ function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_dat
$downtime_dates[] = $dates;
}
}
$month_aux++;
if ($month_aux > 12) {
$month_aux = 1;
@ -6643,7 +6820,7 @@ function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_dat
$active_days[4] = ($downtime['thursday'] == 1) ? true : false;
$active_days[5] = ($downtime['friday'] == 1) ? true : false;
$active_days[6] = ($downtime['saturday'] == 1) ? true : false;
while ($date_aux <= $end_date) {
$weekday_num = date('w', $date_aux);
@ -6651,15 +6828,15 @@ function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_dat
$day_num = date('d', $date_aux);
$month_num = date('m', $date_aux);
$year_num = date('Y', $date_aux);
$max_day_num = date('t', $date_aux);
if (strtotime($downtime_time_from) > strtotime($downtime_time_to)) {
$dates = array();
$dates['date_from'] = strtotime("$year_num-$month_num-$day_num $downtime_hour_from:$downtime_minute_from:$downtime_second_from");
$dates['date_to'] = strtotime("$year_num-$month_num-$day_num 23:59:59");
$downtime_dates[] = $dates;
$dates = array();
if ($day_num + 1 > $max_day_num) {
if ($month_num + 1 > 12) {
@ -6684,20 +6861,20 @@ function reporting_get_planned_downtimes_intervals ($id_agent_module, $start_dat
$downtime_dates[] = $dates;
}
}
$date_aux += SECONDS_1DAY;
}
}
}
}
if ($check_services) {
enterprise_include_once("include/functions_services.php");
if (function_exists("services_get_planned_downtimes_intervals")) {
services_get_planned_downtimes_intervals($downtime_dates, $start_date, $end_date, false, $id_agent_module);
}
}
return $downtime_dates;
}
@ -6803,7 +6980,30 @@ function reporting_get_agentmodule_data_max ($id_agent_module, $period=0, $date
}
}
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
// Do none
break;
case "oracle":
$max = oracle_format_float_to_php($max);
break;
}
foreach ($interval_data as $data) {
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
// Do none
break;
case "oracle":
$data['datos'] =
oracle_format_float_to_php($data['datos']);
break;
}
if ($data['datos'] > $max) {
$max = $data['datos'];
}
@ -6879,7 +7079,28 @@ function reporting_get_agentmodule_data_min ($id_agent_module, $period=0, $date
// Set initial conditions
$min = $interval_data[0]['datos'];
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
// Do none
break;
case "oracle":
$min = oracle_format_float_to_php($min);
break;
}
foreach ($interval_data as $data) {
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
// Do none
break;
case "oracle":
$data['datos'] =
oracle_format_float_to_php($data['datos']);
break;
}
if ($data['datos'] < $min) {
$min = $data['datos'];
}
@ -6974,6 +7195,17 @@ function reporting_get_agentmodule_data_sum ($id_agent_module,
}
foreach ($interval_data as $data) {
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
// Do none
break;
case "oracle":
$data['datos'] =
oracle_format_float_to_php($data['datos']);
break;
}
if ($uncompressed_module) {
$total += $data['datos'];
}
@ -7000,6 +7232,8 @@ function reporting_get_agentmodule_data_sum ($id_agent_module,
* agent modules selected.
*/
function reporting_get_planned_downtimes ($start_date, $end_date, $id_agent_modules = false) {
global $config;
$start_time = date("H:i:s", $start_date);
$end_time = date("H:i:s", $end_date);
@ -7103,35 +7337,69 @@ function reporting_get_planned_downtimes ($start_date, $end_date, $id_agent_modu
$id_agent_modules_str = implode(",", $id_agent_modules);
$sql_downtime = "SELECT DISTINCT(tpdr.id), tpdr.*
FROM (
SELECT tpd.*
FROM tplanned_downtime tpd, tplanned_downtime_agents tpda, tagente_modulo tam
WHERE (tpd.id = tpda.id_downtime
AND tpda.all_modules = 1
AND tpda.id_agent = tam.id_agente
AND tam.id_agente_modulo IN ($id_agent_modules_str))
AND ((type_execution = 'periodically'
AND $periodically_condition)
OR (type_execution = 'once'
AND ((date_from >= '$start_date' AND date_to <= '$end_date')
OR (date_from <= '$start_date' AND date_to >= '$end_date')
OR (date_from <= '$start_date' AND date_to >= '$start_date')
OR (date_from <= '$end_date' AND date_to >= '$end_date'))))
UNION ALL
SELECT tpd.*
FROM tplanned_downtime tpd, tplanned_downtime_modules tpdm
WHERE (tpd.id = tpdm.id_downtime
AND tpdm.id_agent_module IN ($id_agent_modules_str))
AND ((type_execution = 'periodically'
AND $periodically_condition)
OR (type_execution = 'once'
AND ((date_from >= '$start_date' AND date_to <= '$end_date')
OR (date_from <= '$start_date' AND date_to >= '$end_date')
OR (date_from <= '$start_date' AND date_to >= '$start_date')
OR (date_from <= '$end_date' AND date_to >= '$end_date'))))
) tpdr
ORDER BY tpdr.id";
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$tpdr_description = "tpdr.description";
break;
case "oracle":
$tpdr_description = "to_char(tpdr.description)";
break;
}
$sql_downtime = "
SELECT
DISTINCT(tpdr.id),
tpdr.name,
" . $tpdr_description . ",
tpdr.date_from,
tpdr.date_to,
tpdr.executed,
tpdr.id_group,
tpdr.only_alerts,
tpdr.monday,
tpdr.tuesday,
tpdr.wednesday,
tpdr.thursday,
tpdr.friday,
tpdr.saturday,
tpdr.sunday,
tpdr.periodically_time_from,
tpdr.periodically_time_to,
tpdr.periodically_day_from,
tpdr.periodically_day_to,
tpdr.type_downtime,
tpdr.type_execution,
tpdr.type_periodicity,
tpdr.id_user
FROM (
SELECT tpd.*
FROM tplanned_downtime tpd, tplanned_downtime_agents tpda, tagente_modulo tam
WHERE (tpd.id = tpda.id_downtime
AND tpda.all_modules = 1
AND tpda.id_agent = tam.id_agente
AND tam.id_agente_modulo IN ($id_agent_modules_str))
AND ((type_execution = 'periodically'
AND $periodically_condition)
OR (type_execution = 'once'
AND ((date_from >= '$start_date' AND date_to <= '$end_date')
OR (date_from <= '$start_date' AND date_to >= '$end_date')
OR (date_from <= '$start_date' AND date_to >= '$start_date')
OR (date_from <= '$end_date' AND date_to >= '$end_date'))))
UNION ALL
SELECT tpd.*
FROM tplanned_downtime tpd, tplanned_downtime_modules tpdm
WHERE (tpd.id = tpdm.id_downtime
AND tpdm.id_agent_module IN ($id_agent_modules_str))
AND ((type_execution = 'periodically'
AND $periodically_condition)
OR (type_execution = 'once'
AND ((date_from >= '$start_date' AND date_to <= '$end_date')
OR (date_from <= '$start_date' AND date_to >= '$end_date')
OR (date_from <= '$start_date' AND date_to >= '$start_date')
OR (date_from <= '$end_date' AND date_to >= '$end_date'))))
) tpdr
ORDER BY tpdr.id";
}
else {
$sql_downtime = "SELECT *
@ -7225,16 +7493,25 @@ function reporting_get_agentmodule_sla_day ($id_agent_module, $period = 0, $min_
}
}
if (count($days) > 0) {
$sql .= ' AND DAYOFWEEK(FROM_UNIXTIME(utimestamp)) NOT IN (' . implode(',', $days) . ')';
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
if (count($days) > 0) {
$sql .= ' AND DAYOFWEEK(FROM_UNIXTIME(utimestamp)) NOT IN (' . implode(',', $days) . ')';
}
if ($timeFrom < $timeTo) {
$sql .= ' AND (TIME(FROM_UNIXTIME(utimestamp)) >= "' . $timeFrom . '" AND TIME(FROM_UNIXTIME(utimestamp)) <= "'. $timeTo . '")';
}
elseif ($timeFrom > $timeTo) {
$sql .= ' AND (TIME(FROM_UNIXTIME(utimestamp)) >= "' . $timeFrom . '" OR TIME(FROM_UNIXTIME(utimestamp)) <= "'. $timeTo . '")';
}
break;
case "oracle":
break;
}
if ($timeFrom < $timeTo) {
$sql .= ' AND (TIME(FROM_UNIXTIME(utimestamp)) >= "' . $timeFrom . '" AND TIME(FROM_UNIXTIME(utimestamp)) <= "'. $timeTo . '")';
}
elseif ($timeFrom > $timeTo) {
$sql .= ' AND (TIME(FROM_UNIXTIME(utimestamp)) >= "' . $timeFrom . '" OR TIME(FROM_UNIXTIME(utimestamp)) <= "'. $timeTo . '")';
}
$sql .= ' ORDER BY utimestamp ASC';
$interval_data = db_get_all_rows_sql ($sql, $search_in_history_db);
@ -7409,10 +7686,16 @@ function reporting_get_agentmodule_sla_array ($id_agent_module, $period = 0, $mi
if ($timeFrom != $timeTo) {
if ($timeFrom < $timeTo) {
$sql .= ' AND (TIME(FROM_UNIXTIME(utimestamp)) >= "' . $timeFrom . '" AND TIME(FROM_UNIXTIME(utimestamp)) <= "'. $timeTo . '")';
$sql .= ' AND (TIME(FROM_UNIXTIME(utimestamp)) >= \'' .
$timeFrom . '\'
AND TIME(FROM_UNIXTIME(utimestamp)) <= \'' .
$timeTo . '\')';
}
elseif ($timeFrom > $timeTo) {
$sql .= ' AND (TIME(FROM_UNIXTIME(utimestamp)) >= "' . $timeFrom . '" OR TIME(FROM_UNIXTIME(utimestamp)) <= "'. $timeTo . '")';
$sql .= ' AND (TIME(FROM_UNIXTIME(utimestamp)) >= \'' .
$timeFrom . '\'
OR TIME(FROM_UNIXTIME(utimestamp)) <= \''.
$timeTo . '\')';
}
}

View File

@ -325,6 +325,7 @@ function reporting_html_SLA($table, $item, $mini) {
$table->data['planned_downtime']['cell'] = html_print_table($table1, true);
}
$table1 = new stdClass();
$table1->width = '99%';
$table1->align = array();
@ -380,7 +381,7 @@ function reporting_html_SLA($table, $item, $mini) {
$table->data['sla']['cell'] = html_print_table($table1, true);
if (!empty($item['charts'])) {
$table1 = null;
$table1 = new stdClass();
$table1->width = '99%';
$table1->data = array ();
@ -403,6 +404,7 @@ function reporting_html_top_n($table, $item) {
$table->data['top_n']['cell'] = $item['failed'];
}
else {
$table1 = new stdClass();
$table1->width = '99%';
$table1->align = array();
@ -439,7 +441,7 @@ function reporting_html_top_n($table, $item) {
}
if (!empty($item['resume'])) {
$table1 = null;
$table1 = new stdClass();
$table1->width = '99%';
$table1->align = array();
@ -474,6 +476,7 @@ function reporting_html_event_report_group($table, $item) {
$table->data['events']['cell'] = $item['failed'];
}
else {
$table1 = new stdClass();
$table1->width = '99%';
$table1->align = array();
@ -552,7 +555,7 @@ function reporting_html_event_report_group($table, $item) {
if (!empty($item['chart']['by_agent'])) {
$table1 = null;
$table1 = new stdClass();
$table1->width = '99%';
$table1->head = array ();
$table1->head[0] = __('Events by agent');
@ -564,7 +567,7 @@ function reporting_html_event_report_group($table, $item) {
}
if (!empty($item['chart']['by_user_validator'])) {
$table1 = null;
$table1 = new stdClass();
$table1->width = '99%';
$table1->head = array ();
$table1->head[0] = __('Events by user validator');
@ -576,7 +579,7 @@ function reporting_html_event_report_group($table, $item) {
}
if (!empty($item['chart']['by_criticity'])) {
$table1 = null;
$table1 = new stdClass();
$table1->width = '99%';
$table1->head = array ();
$table1->head[0] = __('Events by criticity');
@ -588,7 +591,7 @@ function reporting_html_event_report_group($table, $item) {
}
if (!empty($item['chart']['validated_vs_unvalidated'])) {
$table1 = null;
$table1 = new stdClass();
$table1->width = '99%';
$table1->head = array ();
$table1->head[0] = __('Events validated vs unvalidated');
@ -610,6 +613,7 @@ function reporting_html_event_report_module($table, $item) {
$table->data['events']['cell'] = $item['failed'];
}
else {
$table1 = new stdClass();
$table1->width = '99%';
$table1->data = array ();
$table1->head = array ();
@ -802,28 +806,30 @@ function reporting_html_agent_module($table, $item) {
"</th>";
}
foreach ($item['data'] as $row) {
$table_data .= "<tr style='height: 35px;'>";
switch ($row['agent_status']) {
case 4: // Alert fired status
case AGENT_STATUS_ALERT_FIRED:
$rowcolor = COL_ALERTFIRED;
$textcolor = '#000';
break;
case 1: // Critical status
case AGENT_STATUS_CRITICAL:
$rowcolor = COL_CRITICAL;
$textcolor = '#FFF';
break;
case 2: // Warning status
case AGENT_STATUS_WARNING:
$rowcolor = COL_WARNING;
$textcolor = '#000';
break;
case 0: // Normal status
case AGENT_STATUS_NORMAL:
$rowcolor = COL_NORMAL;
$textcolor = '#FFF';
break;
case 3:
case -1:
default: // Unknown status
case AGENT_STATUS_UNKNOWN:
case AGENT_STATUS_ALL:
default:
$rowcolor = COL_UNKNOWN;
$textcolor = '#FFF';
break;
@ -837,50 +843,50 @@ function reporting_html_agent_module($table, $item) {
html_print_image($file_name, true,
array('title' => $row['agent_name'])) . "</td>";
foreach ($row['modules'] as $module) {
foreach ($row['modules'] as $module_name => $module) {
if (is_null($module)) {
$table_data .= "<td style='background-color: #DDD;'></td>";
}
else {
$table_data .= "<td style='text-align: center; background-color: #DDD;'>";
switch ($module) {
case 0:
case AGENT_STATUS_NORMAL:
$table_data .= ui_print_status_image(
'module_ok.png',
__("%s in %s : NORMAL",
$module['name'],
$module_name,
$row['agent_name']),
true, array('width' => '20px', 'height' => '20px'));
break;
case 1:
case AGENT_STATUS_CRITICAL:
$table_data .= ui_print_status_image(
'module_critical.png',
__("%s in %s : CRITICAL",
$module['name'],
$module_name,
$row['agent_name']),
true, array('width' => '20px', 'height' => '20px'));
break;
case 2:
case AGENT_STATUS_WARNING:
$table_data .= ui_print_status_image(
'module_warning.png',
__("%s in %s : WARNING",
$module['name'],
$module_name,
$row['agent_name']),
true, array('width' => '20px', 'height' => '20px'));
break;
case 3:
case AGENT_STATUS_UNKNOWN:
$table_data .= ui_print_status_image(
'module_unknown.png',
__("%s in %s : UNKNOWN",
$module['name'],
$module_name,
$row['agent_name']),
true, array('width' => '20px', 'height' => '20px'));
break;
case 4:
case AGENT_STATUS_ALERT_FIRED:
$table_data .= ui_print_status_image(
'module_alertsfired.png',
__("%s in %s : ALERTS FIRED",
$module['name'],
$module_name,
$row['agent_name']),
true, array('width' => '20px', 'height' => '20px'));
break;
@ -1070,6 +1076,7 @@ function reporting_html_group_report($table, $item) {
function reporting_html_event_report_agent($table, $item) {
global $config;
$table1 = new stdClass();
$table1->width = '99%';
$table1->align = array();
@ -1143,7 +1150,7 @@ function reporting_html_event_report_agent($table, $item) {
$table->data['event_list']['cell'] = html_print_table($table1, true);
if (!empty($item['chart']['by_user_validator'])) {
$table1 = null;
$table1 = new stdClass();
$table1->width = '99%';
$table1->head = array ();
$table1->head[0] = __('Events validated by user');
@ -1155,7 +1162,7 @@ function reporting_html_event_report_agent($table, $item) {
}
if (!empty($item['chart']['by_criticity'])) {
$table1 = null;
$table1 = new stdClass();
$table1->width = '99%';
$table1->head = array ();
$table1->head[0] = __('Events by criticity');
@ -1167,7 +1174,7 @@ function reporting_html_event_report_agent($table, $item) {
}
if (!empty($item['chart']['validated_vs_unvalidated'])) {
$table1 = null;
$table1 = new stdClass();
$table1->width = '99%';
$table1->head = array ();
$table1->head[0] = __('Amount events validated');
@ -1204,11 +1211,13 @@ function reporting_html_database_serialized($table, $item) {
function reporting_html_group_configuration($table, $item) {
$table1 = new stdClass();
$table1->width = '100%';
$table1->head = array ();
$table1->data = array ();
$cell = "";
foreach ($item['data'] as $agent) {
$table2 = new stdClass();
$table2->width = '100%';
$table2->data = array ();
reporting_html_agent_configuration($table2, array('data' => $agent));
@ -1324,6 +1333,7 @@ function reporting_html_alert_report_agent($table, $item) {
$table->colspan['alerts']['cell'] = 3;
$table->cellstyle['alerts']['cell'] = 'text-align: left;';
$table1 = new stdClass();
$table1->width = '99%';
$table1->head = array ();
$table1->head['module'] = __('Module');
@ -1360,6 +1370,7 @@ function reporting_html_alert_report_module($table, $item) {
$table->colspan['alerts']['cell'] = 3;
$table->cellstyle['alerts']['cell'] = 'text-align: left;';
$table1 = new stdClass();
$table1->width = '99%';
$table1->head = array ();
$table1->head['template'] = __('Template');
@ -1407,6 +1418,7 @@ function reporting_html_monitor_report($table, $item, $mini) {
$table->colspan['module']['cell'] = 3;
$table->cellstyle['module']['cell'] = 'text-align: center;';
$table1 = new stdClass();
$table1->width = '99%';
$table1->head = array ();
$table1->data = array ();
@ -1446,6 +1458,7 @@ function reporting_html_agent_configuration(&$table, $item) {
$table->colspan['agent']['cell'] = 3;
$table->cellstyle['agent']['cell'] = 'text-align: left;';
$table1 = new stdClass();
$table1->width = '99%';
$table1->head = array ();
$table1->head['name'] = __('Agent name');
@ -1610,6 +1623,7 @@ function reporting_html_text(&$table, $item) {
function reporting_html_availability(&$table, $item) {
if (!empty($item["data"])) {
$table1 = new stdClass();
$table1->width = '99%';
$table1->data = array ();
$table1->head = array ();
@ -1699,6 +1713,7 @@ function reporting_html_general(&$table, $item) {
if (!empty($item["data"])) {
switch ($item['subtype']) {
case REPORT_GENERAL_NOT_GROUP_BY_AGENT:
$table1 = new stdClass();
$table1->width = '99%';
$table1->data = array ();
$table1->head = array ();
@ -1714,10 +1729,19 @@ function reporting_html_general(&$table, $item) {
$table1->style[3] = 'text-align: left';
foreach ($item['data'] as $row) {
$table1->data[] = array(
$row['agent'],
$row['module'],
$row['value']);
if ($item['date']['period'] != 0) {
$table1->data[] = array(
$row['agent'],
$row['module'],
$row['operator'],
$row['value']);
}
else {
$table1->data[] = array(
$row['agent'],
$row['module'],
$row['value']);
}
}
break;
case REPORT_GENERAL_GROUP_BY_AGENT:
@ -1762,6 +1786,7 @@ function reporting_html_general(&$table, $item) {
}
if ($item['resume'] && !empty($item["data"])) {
$table_summary = new stdClass();
$table_summary->width = '99%';
$table_summary->data = array ();
@ -1802,6 +1827,7 @@ function reporting_html_sql(&$table, $item) {
else {
$first = true;
$table2 = new stdClass();
$table2->class = 'databox';
$table2->width = '100%';

View File

@ -524,10 +524,10 @@ function tags_get_agents($id_tag, $id_policy_module = 0) {
FROM tagente
WHERE id_agente IN (
SELECT t1.id_agente
FROM tagente_modulo AS t1
FROM tagente_modulo t1
WHERE t1.id_agente_modulo IN (
SELECT t2.id_agente_modulo
FROM ttag_module AS t2
FROM ttag_module t2
WHERE id_tag = " . $id_tag . "
AND id_policy_module = " . $id_policy_module . "))");
@ -924,14 +924,29 @@ function tags_get_user_tags($id_user = false, $access = 'AR') {
return array();
}
$query = sprintf("
SELECT count(*)
FROM tusuario_perfil, tperfil
WHERE tperfil.id_perfil = tusuario_perfil.id_perfil
AND tusuario_perfil.id_usuario = '%s'
AND tperfil.%s = 1
AND tags <> ''",
$id_user, $acl_column);
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$query = sprintf("
SELECT count(*)
FROM tusuario_perfil, tperfil
WHERE tperfil.id_perfil = tusuario_perfil.id_perfil
AND tusuario_perfil.id_usuario = '%s'
AND tperfil.%s = 1
AND tags <> ''",
$id_user, $acl_column);
break;
case "oracle":
$query = sprintf("
SELECT count(*)
FROM tusuario_perfil, tperfil
WHERE tperfil.id_perfil = tusuario_perfil.id_perfil
AND tusuario_perfil.id_usuario = '%s'
AND tperfil.%s = 1
AND dbms_lob.getlength(tags) > 0",
$id_user, $acl_column);
break;
}
$profiles_without_tags = db_get_value_sql($query);
@ -1435,7 +1450,7 @@ function tags_get_agents_counter ($id_tag, $groups_and_tags = array(), $agent_fi
$module_status_array = array_unique($module_status_array);
$status_str = implode(",", $module_status_array);
$module_status_filter = "INNER JOIN tagente_estado AS tae
$module_status_filter = "INNER JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo
AND tae.estado IN ($status_str)";
}
@ -1445,13 +1460,13 @@ function tags_get_agents_counter ($id_tag, $groups_and_tags = array(), $agent_fi
$count = 0;
if ($realtime) {
$sql = "SELECT DISTINCT ta.id_agente
FROM tagente AS ta
INNER JOIN tagente_modulo AS tam
FROM tagente ta
INNER JOIN tagente_modulo tam
ON ta.id_agente = tam.id_agente
AND tam.disabled = 0
$module_name_filter
$module_status_filter
INNER JOIN ttag_module AS ttm
INNER JOIN ttag_module ttm
ON ttm.id_tag = $id_tag
AND tam.id_agente_modulo = ttm.id_agente_modulo
WHERE ta.disabled = 0
@ -1608,13 +1623,13 @@ function tags_get_agents_counter ($id_tag, $groups_and_tags = array(), $agent_fi
}
$sql = "SELECT COUNT(DISTINCT ta.id_agente)
FROM tagente AS ta
INNER JOIN tagente_modulo AS tam
FROM tagente ta
INNER JOIN tagente_modulo tam
ON ta.id_agente = tam.id_agente
AND tam.disabled = 0
$module_name_filter
$module_status_filter
INNER JOIN ttag_module AS ttm
INNER JOIN ttag_module ttm
ON ttm.id_tag = $id_tag
AND tam.id_agente_modulo = ttm.id_agente_modulo
WHERE ta.disabled = 0
@ -1898,14 +1913,14 @@ function tags_get_monitors_counter ($id_tag, $groups_and_tags = array(), $agent_
}
$sql = "SELECT COUNT(DISTINCT tam.id_agente_modulo)
FROM tagente_modulo AS tam
INNER JOIN tagente_estado AS tae
FROM tagente_modulo tam
INNER JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo
$modules_clause
INNER JOIN ttag_module AS ttm
INNER JOIN ttag_module ttm
ON ttm.id_tag = $id_tag
AND tam.id_agente_modulo = ttm.id_agente_modulo
INNER JOIN tagente AS ta
INNER JOIN tagente ta
ON tam.id_agente = ta.id_agente
AND ta.disabled = 0
$agent_name_filter

View File

@ -57,6 +57,7 @@ function treeview_printModuleTable($id_module, $server_data = false) {
$table = new StdClass();
$table->width = "100%";
$table->class = "databox data";
$table->style = array();
$table->style['title'] = 'font-weight: bold;';
$table->head = array();

View File

@ -2980,7 +2980,6 @@ function ui_print_agent_autocomplete_input($parameters) {
data: inputs.join ("&"),
type: "POST",
url: action="' . $javascript_ajax_page . '",
timeout: 10000,
dataType: "json",
success: function (data) {
if (' . ((int)$add_none_module) . ') {
@ -3150,7 +3149,6 @@ function ui_print_agent_autocomplete_input($parameters) {
data: data_params,
type: "POST",
url: action="' . $javascript_ajax_page . '",
timeout: 10000,
dataType: "json",
success: function (data) {
cache_' . $input_name . '[term] = data; //Save the cache
@ -3363,7 +3361,6 @@ function ui_print_agent_autocomplete_input($parameters) {
data: data_params,
type: "POST",
url: action="' . $javascript_ajax_page . '",
timeout: 10000,
dataType: "json",
success: function (data) {
if (data.length == 0) {

View File

@ -24,11 +24,23 @@ function update_manager_get_config_values() {
global $build_version;
global $pandora_version;
$license = db_get_value(
db_encapsule_fields_with_same_name_to_instructions('value'),
'tupdate_settings',
db_encapsule_fields_with_same_name_to_instructions('key'),
'customer_key');
switch ($config["dbtype"]) {
case "postgresql":
case "mysql":
$license = db_get_value(
db_encapsule_fields_with_same_name_to_instructions('value'),
'tupdate_settings',
db_encapsule_fields_with_same_name_to_instructions('key'),
'customer_key');
break;
case 'oracle':
$license = db_get_value(
'value',
'tupdate_settings',
'key',
'customer_key');
break;
}
$limit_count = db_get_value_sql("SELECT count(*) FROM tagente");
@ -485,18 +497,20 @@ function update_manager_set_current_package($current_package) {
$token = 'current_package';
}
$value = db_get_value('`value`',
'tupdate_settings', '`key`', $token);
$col_value = db_encapsule_fields_with_same_name_to_instructions('value');
$col_key = db_encapsule_fields_with_same_name_to_instructions('key');
$value = db_get_value($col_value,
'tupdate_settings', $col_key, $token);
if ($value === false) {
db_process_sql_insert('tupdate_settings',
array('`value`' => $current_package,
'`key`' => $token));
array($col_value => $current_package, $col_key => $token));
}
else {
db_process_sql_update('tupdate_settings',
array('`value`' => $current_package),
array('`key`' => $token));
array($col_value => $current_package),
array($col_key => $token));
}
}
@ -510,11 +524,25 @@ function update_manager_get_current_package() {
$token = 'current_package';
}
$current_update = db_get_value(
db_encapsule_fields_with_same_name_to_instructions('value'),
'tupdate_settings',
db_encapsule_fields_with_same_name_to_instructions('key'),
$token);
switch ($config["dbtype"]) {
case "postgresql":
case "mysql":
$current_update = db_get_value(
db_encapsule_fields_with_same_name_to_instructions('value'),
'tupdate_settings',
db_encapsule_fields_with_same_name_to_instructions('key'),
$token);
break;
case "oracle":
$current_update = db_get_value(
'value',
'tupdate_settings',
'key',
$token);
break;
}
if ($current_update === false) {
$current_update = 0;

View File

@ -2088,11 +2088,15 @@ function visual_map_create_internal_name_item($label = null, $type, $image, $age
}
function visual_map_get_items_parents($idVisual) {
$items = db_get_all_rows_sql(sprintf("SELECT * FROM tlayout_data where id_layout = %s order by label",$idVisual));
//$items = db_get_all_fields_in_table('tlayout_data',array('id_layout' => $idVisual));
// Avoid the sort by 'label' in the query cause oracle cannot sort by columns with CLOB type
$items = db_get_all_rows_filter('tlayout_data', array('id_layout' => $idVisual));
if ($items == false) {
$items = array();
}
else {
// Sort by label
sort_by_column($items, 'label');
}
$return = array();
foreach ($items as $item) {

View File

@ -0,0 +1,132 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 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.
// Don't use authentication methods.
// This file only uses data retrieved in a request.
require_once ("../../include/config.php");
require_once ("../../include/functions.php");
global $config;
// Get data
$type = (string) get_parameter('type', 'csv');
$data = (string) get_parameter('data');
$data = json_decode(io_safe_output($data), true);
$default_filename = 'data_exported - ' . date($config['date_format']);
$filename = (string) get_parameter('filename', $default_filename);
$filename = io_safe_output($filename);
// Using first-class functions to avoid namespace conflicts
// Type: 'csv'
/* $data = array(
* 'head' => array(<column>,<column>,...,<column>),
* 'data' => array(
* array(<data>,<data>,...,<data>),
* array(<data>,<data>,...,<data>),
* ...,
* array(<data>,<data>,...,<data>),
* )
* );
*/
$output_csv = function ($data, $filename) {
$separator = (string) get_parameter('separator', ';');
$excel_encoding = (bool) get_parameter('excel_encoding', false);
// CSV Output
header ('Content-Type: text/csv; charset=UTF-8');
header ('Content-Disposition: attachment; filename="'.$filename.'.csv"');
// Header
if (!isset($data['head']) || !isset($data['data']))
throw new Exception(__('An error occured exporting the data'));
$head_line = implode($separator, $data['head']);
echo $head_line . "\n";
// Item / data
foreach ($data['data'] as $items) {
$line = implode($separator, $items);
if ($excel_encoding)
echo mb_convert_encoding($line, 'UTF-16LE', 'UTF-8') . "\n";
else
echo $line . "\n";
}
};
// Type: 'json'
/* $data = array(
* array(
* 'key' => <value>,
* 'key' => <value>,
* ...,
* 'key' => <value>
* ),
* array(
* 'key' => <value>,
* 'key' => <value>,
* ...,
* 'key' => <value>
* ),
* ...,
* array(
* 'key' => <value>,
* 'key' => <value>,
* ...,
* 'key' => <value>
* )
* );
*/
$output_json = function ($data, $filename) {
// JSON Output
header ('Content-Type: application/json; charset=UTF-8');
header ('Content-Disposition: attachment; filename="'.$filename.'.json"');
if (version_compare(PHP_VERSION, '5.4.0', '>='))
$json = json_encode($data, JSON_PRETTY_PRINT);
else
$json = json_encode($data);
if ($json !== false)
echo $json;
};
try {
if (!$data)
throw new Exception(__('An error occured exporting the data'));
ob_end_clean();
switch ($type) {
case 'json':
$output_json($data, $filename);
break;
case 'csv':
default:
$output_csv($data, $filename);
break;
}
}
catch (Exception $e) {
die($e->getMessage());
}
exit;
?>

File diff suppressed because it is too large Load Diff

View File

@ -285,7 +285,7 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend,
$threshold = true;
}
$nbuttons = 2;
$nbuttons = 3;
if ($threshold) {
$nbuttons++;
@ -301,10 +301,16 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend,
"padding: 4px 4px 4px 4px'>
<a href='javascript:'><img id='menu_cancelzoom_$graph_id' src='".$homeurl."images/zoom_cross.disabled.png' alt='".__('Cancel zoom')."' title='".__('Cancel zoom')."'></a>";
if ($threshold) {
$return .= "<a href='javascript:'><img id='menu_threshold_$graph_id' src='".$homeurl."images/chart_curve_threshold.png' alt='".__('Warning and Critical thresholds')."' title='".__('Warning and Critical thresholds')."'></a>";
$return .= " <a href='javascript:'><img id='menu_threshold_$graph_id' src='".$homeurl."images/chart_curve_threshold.png' alt='".__('Warning and Critical thresholds')."' title='".__('Warning and Critical thresholds')."'></a>";
}
$return .= "<a href='javascript:'><img id='menu_overview_$graph_id' src='".$homeurl."images/chart_curve_overview.png' alt='".__('Overview graph')."' title='".__('Overview graph')."'></a>
</div>";
$return .= " <a href='javascript:'><img id='menu_overview_$graph_id' src='".$homeurl."images/chart_curve_overview.png' alt='".__('Overview graph')."' title='".__('Overview graph')."'></a>";
// Export buttons
$return .= " <a href='javascript:'><img id='menu_export_csv_$graph_id' src='".$homeurl."images/csv.png' alt='".__('Export to CSV')."' title='".__('Export to CSV')."'></a>";
// Button disabled. This feature works, but seems that is not useful enough to the final users.
//$return .= " <a href='javascript:'><img id='menu_export_json_$graph_id' src='".$homeurl."images/json.png' alt='".__('Export to JSON')."' title='".__('Export to JSON')."'></a>";
$return .= "</div>";
}
$extra_width = (int)($width / 3);

View File

@ -185,7 +185,7 @@ function forced_title_callback() {
// into their 'data' prop, the element title will be used for the
// content.
if ($(this).data("use_title_for_force_title")) {
var title = $(this).prop("title");
var title = $(this).data("title");
}
else {
var title = $('#forced_title_'+img_id).html();

View File

@ -159,7 +159,6 @@ function show_response_dialog(event_id, response_id, response) {
data: params.join ("&"),
type: 'POST',
url: action=ajax_file,
timeout: 10000,
dataType: 'html',
success: function (data) {
$("#event_response_window").hide ()

View File

@ -665,8 +665,6 @@ function load_plugin_macros_fields(row_model_id) {
data: params.join ("&"),
type: 'POST',
url: action = get_php_value('absolute_homeurl') + "ajax.php",
async: false,
timeout: 10000,
dataType: 'json',
success: function (data) {
// Delete all the macro fields

View File

@ -15,96 +15,68 @@
// GNU General Public License for more details.
function mysql_session_open ($save_path, $session_name) {
function pandora_session_open ($save_path, $session_name) {
return true;
}
function mysql_session_close() {
function pandora_session_close() {
return true;
}
function mysql_session_read ($SessionID) {
function pandora_session_read ($session_id) {
$session_id = addslashes($session_id);
$session_data = db_get_value('data', 'tsessions_php', 'id_session', $session_id);
$SessionID = addslashes($SessionID);
$sql = "
SELECT data
FROM tsessions_php
WHERE id_session = '$SessionID'";
$session_data = db_process_sql($sql);
if (count($session_data) == 1) {
return $session_data[0]['data'];
}
else {
if (!empty($session_data))
return $session_data;
else
return false;
}
}
function mysql_session_write ($SessionID, $val) {
function pandora_session_write ($session_id, $data) {
$session_id = addslashes($session_id);
$SessionID = addslashes($SessionID);
$val = addslashes($val);
$values = array();
$values['last_active'] = time();
$sql = "
SELECT COUNT(*)
FROM tsessions_php
WHERE id_session = '$SessionID'";
if (!empty($data))
$values['data'] = addslashes($data);
$SessionExists = db_process_sql ($sql);
$session_exists = (bool) db_get_value('COUNT(id_session)', 'tsessions_php', 'id_session', $session_id);
$session_exists = $SessionExists[0]['COUNT(*)'];
if ($session_exists == 0) {
$now = time();
$retval_write = db_process_sql_insert('tsessions_php',
array('id_session' => $SessionID,
'last_active' => $now,
'data' => $val));
if (!$session_exists) {
$values['id_session'] = $session_id;
$retval_write = db_process_sql_insert('tsessions_php', $values);
}
else {
$now = time();
$retval_write = db_process_sql_update('tsessions_php',
array('last_active' => $now, 'data' => $val),
array('id_session' => $SessionID));
$retval_write = db_process_sql_update('tsessions_php', $values, array('id_session' => $session_id));
}
return $retval_write;
}
function mysql_session_destroy ($SessionID) {
$SessionID = addslashes($SessionID);
function pandora_session_destroy ($session_id) {
$session_id = addslashes($session_id);
$retval = (bool) db_process_sql_delete('tsessions_php', array('id_session' => $session_id));
$retval = db_process_sql ("
DELETE
FROM tsessions_php
WHERE id_session = '$SessionID'");
return $retval;
}
function mysql_session_gc ($maxlifetime = 300) {
function pandora_session_gc ($max_lifetime = 300) {
global $config;
if (isset($config['session_timeout'])) {
$maxlifetime = $config['session_timeout'];
$max_lifetime = $config['session_timeout'];
}
$CutoffTime = time() - $maxlifetime;
$time_limit = time() - $max_lifetime;
$retval = (bool) db_process_sql_delete('tsessions_php', array('last_active' => "<" . $time_limit));
$retval = db_process_sql("
DELETE
FROM tsessions_php
WHERE last_active < $CutoffTime");
return $retval;
}
$resultado_handler = session_set_save_handler (
'mysql_session_open',
'mysql_session_close',
'mysql_session_read',
'mysql_session_write',
'mysql_session_destroy',
'mysql_session_gc');
$result_handler = session_set_save_handler ('pandora_session_open', 'pandora_session_close', 'pandora_session_read', 'pandora_session_write', 'pandora_session_destroy', 'pandora_session_gc');
?>

View File

@ -63,7 +63,7 @@
<div style='height: 10px'>
<?php
$version = '6.0dev';
$build = '150616';
$build = '150624';
$banner = "v$version Build $build";
error_reporting(0);
@ -283,6 +283,21 @@ function parse_oracle_dump($connection, $url, $debug = false) {
$query = "";
$plsql_block = false;
$datetime_tz_format = oci_parse($connection, 'alter session set NLS_TIMESTAMP_TZ_FORMAT =\'YYYY-MM-DD HH24:MI:SS\'');
$datetime_format = oci_parse($connection, 'alter session set NLS_TIMESTAMP_FORMAT =\'YYYY-MM-DD HH24:MI:SS\'');
$date_format = oci_parse($connection, 'alter session set NLS_DATE_FORMAT =\'YYYY-MM-DD HH24:MI:SS\'');
$decimal_separator = oci_parse($connection, 'alter session set NLS_NUMERIC_CHARACTERS =\',.\'');
oci_execute($datetime_tz_format);
oci_execute($datetime_format);
oci_execute($date_format);
oci_execute($decimal_separator);
oci_free_statement($datetime_tz_format);
oci_free_statement($datetime_format);
oci_free_statement($date_format);
oci_free_statement($decimal_separator);
foreach ($file_content as $sql_line) {
$clean_line = trim($sql_line);
$comment = preg_match("/^(\s|\t)*--.*$/", $clean_line);
@ -547,6 +562,9 @@ function install_step2() {
else if (PHP_OS == "NetBSD") {
$res += check_exists ("/usr/pkg/bin/twopi","Graphviz Binary");
}
else if ( substr(PHP_OS, 0, 3) == 'WIN' ) {
$res += check_exists ("..\\..\\..\\Graphviz\\bin\\twopi.exe", "Graphviz Binary");
}
else {
$res += check_exists ("/usr/bin/twopi","Graphviz Binary");
}

View File

@ -307,9 +307,9 @@ if (empty($id_groups)) {
else {
$whereAlertSimple .= ' AND id_agent_module IN (
SELECT tam.id_agente_modulo
FROM tagente_modulo AS tam
FROM tagente_modulo tam
WHERE tam.id_agente IN (SELECT ta.id_agente
FROM tagente AS ta
FROM tagente ta
WHERE ta.id_grupo IN (' . implode(',', $id_groups) . '))) ';
}
@ -319,11 +319,11 @@ $options_simple = array('offset' => $offset_simple,
'limit' => $config['block_size'], 'order' => $order);
$filter_alert = array();
if($filter_standby == 'standby_on') {
if ($filter_standby == 'standby_on') {
$filter_alert['disabled'] = $filter;
$filter_alert['standby'] = '1';
}
else if($filter_standby == 'standby_off') {
else if ($filter_standby == 'standby_off') {
$filter_alert['disabled'] = $filter;
$filter_alert['standby'] = '0';
}
@ -562,13 +562,8 @@ $table->data = array ();
$rowPair = true;
$iterator = 0;
foreach ($alerts['alerts_simple'] as $alert) {
if ($rowPair)
$table->rowclass[$iterator] = 'rowPair';
else
$table->rowclass[$iterator] = 'rowOdd';
$rowPair = !$rowPair;
array_push ($table->data, ui_format_alert_row ($alert, $print_agent, $url, 'font-size: 7pt;'));
$row = ui_format_alert_row ($alert, $print_agent, $url, 'font-size: 7pt;');
$table->data[] = $row;
}
if (!empty ($table->data)) {
@ -613,43 +608,36 @@ ui_require_jquery_file('cluetip');
?>
<script type="text/javascript">
$(document).ready (function () {
$("a.template_details").cluetip ({
arrows: true,
attribute: 'href',
cluetipClass: 'default'
}).click (function () {
return false;
$(document).ready (function () {
$("a.template_details").cluetip ({
arrows: true,
attribute: 'href',
cluetipClass: 'default'
}).click (function () {
return false;
});
});
if ($('#ag_group').val() != 0) {
$("#tag_filter").css('display', 'none');
$("#table2-0-4").css('display', 'none');
}
});
$('table.alert-status-filter #ag_group').change (function () {
var strict_user = $("#text-strict_user_hidden").val();
var is_meta = $("#text-is_meta_hidden").val();
$('#ag_group').change (function () {
strict_user = $("#text-strict_user_hidden").val();
is_meta = $("#text-is_meta_hidden").val();
if (($(this).val() != 0) && (strict_user != 0)) {
$("table.alert-status-filter #tag_filter").hide();
if (is_meta) {
$("table.alert-status-filter #table1-0-4").hide();
} else {
$("table.alert-status-filter #table2-0-4").hide();
}
} else {
$("#tag_filter").show();
if (is_meta) {
$("table.alert-status-filter #table1-0-4").show();
} else {
$("table.alert-status-filter #table2-0-4").show();
}
}
}).change();
if (($("#ag_group").val() != 0) && (strict_user != 0)) {
$("#tag_filter").css('display', 'none');
if (is_meta) {
$("#table1-0-4").css('display', 'none');
}
else {
$("#table2-0-4").css('display', 'none');
}
}
else {
$("#tag_filter").css('display', '');
if (is_meta) {
$("#table1-0-4").css('display', '');
}
else {
$("#table2-0-4").css('display', '');
}
}
}).change();
</script>

View File

@ -53,10 +53,10 @@ if (is_ajax ()) {
case "mysql":
$sql = sprintf ("SELECT t1.id, t1.name,
(SELECT COUNT(t2.id)
FROM talert_templates AS t2
FROM talert_templates t2
WHERE t2.id = %d
AND t2.id_alert_action = t1.id) as 'sort_order'
FROM talert_actions AS t1
FROM talert_actions t1
WHERE id_group IN (%s)
ORDER BY sort_order DESC", $id_template, $filter_groups);
break;
@ -73,10 +73,10 @@ if (is_ajax ()) {
case "postgresql":
$sql = sprintf ("SELECT t1.id, t1.name,
(SELECT COUNT(t2.id)
FROM talert_templates AS t2
FROM talert_templates t2
WHERE t2.id = %d
AND t2.id_alert_action = t1.id) as sort_order
FROM talert_actions AS t1
FROM talert_actions t1
WHERE id_group IN (%s)
ORDER BY sort_order DESC", $id_template, $filter_groups);
break;

View File

@ -169,9 +169,7 @@ ui_toggle($html_toggle,
data: parameters,
type: 'POST',
url: "ajax.php",
timeout: 10000,
dataType: 'html',
async: false,
success: function (data) {
$("#module_list_loading").hide();
@ -205,9 +203,7 @@ ui_toggle($html_toggle,
data: parameters,
type: 'POST',
url: "ajax.php",
timeout: 10000,
dataType: 'html',
async: false,
success: function (data) {
$("#module_list_loading").hide();
@ -244,9 +240,7 @@ ui_toggle($html_toggle,
data: parameters,
type: 'POST',
url: "ajax.php",
timeout: 10000,
dataType: 'html',
async: false,
success: function (data) {
$("#module_list_loading").hide();
@ -288,9 +282,7 @@ ui_toggle($html_toggle,
data: parameters,
type: 'POST',
url: "ajax.php",
timeout: 10000,
dataType: 'html',
async: false,
success: function (data) {
$("#module_list_loading").hide();

View File

@ -286,8 +286,6 @@ echo "</div>";
dataType: "json",
type: "POST",
url: "ajax.php",
async: false,
timeout: 10000,
success: function (data) {
$(".loading_save").hide();
if (data.correct) {

View File

@ -109,8 +109,16 @@ else {
io_safe_output($config['graphviz_bin_dir'] . "/")
:
"";
$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
if ($is_windows) {
$graphviz_path = str_replace("/", "\\", $graphviz_path );
$filter = $filter . '.exe';
}
$cmd = escapeshellarg($graphviz_path.$filter) . " -Tcmapx " . escapeshellarg("-o$filename_map") . " -Tpng ". escapeshellarg("-o$filename_img") . " " . escapeshellarg($filename_dot);
$cmd = escapeshellarg($graphviz_path.$filter) . " -Tcmapx " .
escapeshellarg("-o$filename_map") . " -Tpng ".
escapeshellarg("-o$filename_img") . " " .
escapeshellarg($filename_dot);
$result = system ($cmd);
fclose ($fh);
unlink ($filename_dot);
@ -128,7 +136,10 @@ if ($result !== false) {
return;
}
echo "<div style='text-align:center'>";
$image_url = str_replace(realpath(io_safe_output($config['homedir'])), "", realpath($filename_img));
if ($is_windows)
$image_url = str_replace('\\',"/",str_replace($config['homedir'], "", $filename_img));
else
$image_url = str_replace(realpath(io_safe_output($config['homedir'])), "", realpath($filename_img));
html_print_image ($image_url, false, array ("alt" => __('Network map'), "usemap" => "#networkmap"));
echo "</div>";
require ($filename_map);

View File

@ -114,13 +114,20 @@ else {
io_safe_output($config['graphviz_bin_dir'] . "/")
:
"";
$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
if ($is_windows) {
$graphviz_path = str_replace("/", "\\", $graphviz_path );
$filename_map = str_replace("/", "\\", $filename_map );
$filename_img = str_replace("/", "\\", $filename_img );
$filename_dot = str_replace("/", "\\", $filename_dot );
$filter = $filter . '.exe';
}
$cmd = escapeshellarg($graphviz_path . $filter) .
" -Tcmapx " . escapeshellarg("-o$filename_map") .
" -Tpng ". escapeshellarg("-o$filename_img") .
" " . escapeshellarg($filename_dot);
$result = system ($cmd);
fclose ($fh);
unlink ($filename_dot);
//~ html_debug_print($cmd);

Some files were not shown because too many files have changed in this diff Show More