diff --git a/api/Database/Layer/pgsql.php b/api/Database/Layer/pgsql.php index 917295d..8c04011 100644 --- a/api/Database/Layer/pgsql.php +++ b/api/Database/Layer/pgsql.php @@ -67,7 +67,7 @@ function querySearchData($layerHelper) if(isset($layerHelper['fields']['distinct'])) { - $layerHelper['values'][] = "DISTINCT ON (".$layerHelper['fields']['distinct'].")"; + $layerHelper['values'][] = "DISTINCT ".$layerHelper['fields']['distinct']." "; } if(isset($layerHelper['fields']['md5msg']) && $layerHelper['fields']['md5msg'] == true) diff --git a/api/Database/PDOConnector.php b/api/Database/PDOConnector.php index 4c630d4..4f73a71 100644 --- a/api/Database/PDOConnector.php +++ b/api/Database/PDOConnector.php @@ -90,7 +90,7 @@ function dbconnect_node($node) { $dbstring = DATABASE_DRIVER.":host=".$host.(($dbport) ? ";port=".$dbport : "" ).";dbname=".$dbname; $this->connection = new PDO($dbstring, $dbusername, $dbpassword); if(DATABASE_DRIVER == "mysql") $this->executeQuery('SET time_zone = "+00:00";'); - else if(DATABASE_DRIVER == "pgsql") $this->executeQuery('SET TIME ZONE ‘0′'); + //else if(DATABASE_DRIVER == "pgsql") $this->executeQuery('SET TIME ZONE ‘0′'); } catch (PDOException $e){ try { diff --git a/api/RestApi/Search.php b/api/RestApi/Search.php index 6ca1272..e252795 100644 --- a/api/RestApi/Search.php +++ b/api/RestApi/Search.php @@ -433,6 +433,10 @@ public function doSearchMessagesData($timestamp, $param, $full = false, $count = $search['node'] = getVar('node', NULL, $param['search'], 'string'); $search['proto'] = getVar('proto', NULL, $param['search'], 'string'); $search['family'] = getVar('family', NULL, $param['search'], 'string'); + $search['custom_field1'] = getVar('custom_field1', NULL, $param['search'], 'string'); + $search['custom_field2'] = getVar('custom_field2', NULL, $param['search'], 'string'); + $search['custom_field2'] = getVar('custom_field3', NULL, $param['search'], 'string'); + $and_or = getVar('orand', NULL, $param['search'], 'string'); $b2b = getVar('b2b', false, $param['search'], 'bool'); @@ -637,6 +641,9 @@ public function doExportMessagesData($timestamp, $param, $full = false, $count = $search['node'] = getVar('node', NULL, $param['search'], 'string'); $search['proto'] = getVar('proto', NULL, $param['search'], 'string'); $search['family'] = getVar('family', NULL, $param['search'], 'string'); + $search['custom_field1'] = getVar('custom_field1', NULL, $param['search'], 'string'); + $search['custom_field2'] = getVar('custom_field2', NULL, $param['search'], 'string'); + $search['custom_field2'] = getVar('custom_field3', NULL, $param['search'], 'string'); $and_or = getVar('orand', NULL, $param['search'], 'string'); $b2b = getVar('b2b', false, $param['search'], 'bool'); @@ -1793,8 +1800,11 @@ function getSIPCflow($data, &$hosts, &$info, &$uac, &$hostcount, &$rtpinfo, $mes $src_id = $data->source_ip.":".$data->source_port; $dst_id = $data->destination_ip.":".$data->destination_port; - if(!isset($hosts[$src_id])) { $hosts[$src_id] = $hostcount; $hostcount+=$host_step; } - if(!isset($hosts[$dst_id])) { $hosts[$dst_id] = $hostcount; $hostcount+=$host_step; } + $src_id_complete = $data->source_ip.":".$data->source_port."-".$data->node; + $dst_id_complete = $data->destination_ip.":".$data->destination_port."-".$data->node; + + if(!isset($hosts[$src_id_complete])) { $hosts[$src_id_complete] = $hostcount; $hostcount+=$host_step; } + if(!isset($hosts[$dst_id_complete])) { $hosts[$dst_id_complete] = $hostcount; $hostcount+=$host_step; } $ssrc = ":".$data->source_port; @@ -1966,7 +1976,7 @@ function getSIPCflow($data, &$hosts, &$info, &$uac, &$hostcount, &$rtpinfo, $mes $calldata["msg_color"] = $msgcol; /*IF */ - if($hosts[$src_id] > $hosts[$dst_id]) $calldata["destination"] = 2; + if($hosts[$src_id_complete] > $hosts[$dst_id_complete]) $calldata["destination"] = 2; else $calldata["destination"] = 1; return $calldata; @@ -2533,8 +2543,46 @@ private function applyHostsAliases(&$data) { // Apply source_alias if (isset($alias_cache[$key])) $alias = $alias_cache[$key]; else { + if (preg_match('/(.*):(.*)-(.*)/', $key, $matches)) { + $key_ip_address = $matches[1]; + $key_port = $matches[2]; + $key_node = $matches[3]; + + if (isset($alias_cache[$key_ip_address . ":" . $key_port . "-" . $key_node])) { + $alias = $alias_cache[$key_ip_address . ":" . $key_port . "-" . $key_node]; + } + else if (isset($alias_cache[$key_ip_address . ":" . $key_port . "-*"])) { + $alias = $alias_cache[$key_ip_address . ":" . $key_port . "-*"]; + } + else if (isset($alias_cache[$key_ip_address . ":" . $key_port])) { + $alias = $alias_cache[$key_ip_address . ":" . $key_port]; + } + else if (isset($alias_cache[$key_ip_address])) { + $alias = $alias_cache[$key_ip_address]; + } + else { + $alias = $key_ip_address.":".$key_port; + } + } + // port was omitted in alias: + else if (preg_match('/(.*)-(.*)/', $key, $matches)) { + $key_ip_address = $matches[1]; + $key_node = $matches[2]; + if (isset($alias_cache[$key_ip_address . "-" . $key_node])) { + $alias = $alias_cache[$key_ip_address . "-" . $key_node]; + } + else if (isset($alias_cache[$key_ip_address . "-*"])) { + $alias = $alias_cache[$key_ip_address . "-*"]; + } + else if (isset($alias_cache[$key_ip_address])) { + $alias = $alias_cache[$key_ip_address]; + } + else { + $alias = $key_ip_address; + } + } // extract IP address from $key: - if (preg_match('/(.*):.*/', $key, $matches)) { + else if (preg_match('/(.*):.*/', $key, $matches)) { $key_ip_address = $matches[1]; if (isset($alias_cache[$key_ip_address])) { $alias = $alias_cache[$key_ip_address]; diff --git a/sql/schema_configuration.sql b/sql/schema_configuration.sql index af25f58..a435e33 100644 --- a/sql/schema_configuration.sql +++ b/sql/schema_configuration.sql @@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS `alias` ( UNIQUE KEY `id` (`id`), UNIQUE KEY `host_2` (`ip`,`port`,`capture_id`), KEY `host` (`ip`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `alias` @@ -45,7 +45,7 @@ CREATE TABLE IF NOT EXISTS `group` ( `gid` int(10) NOT NULL DEFAULT 0, `name` varchar(100) NOT NULL DEFAULT '', UNIQUE KEY `gid` (`gid`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `group` @@ -89,7 +89,7 @@ CREATE TABLE IF NOT EXISTS `node` ( UNIQUE KEY `id` (`id`), UNIQUE KEY `host_2` (`host`), KEY `host` (`host`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `node` @@ -118,7 +118,7 @@ CREATE TABLE IF NOT EXISTS `setting` ( UNIQUE KEY `uid_2` (`uid`,`param_name`), KEY `param_name` (`param_name`), KEY `uid` (`uid`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 ; +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ; -- -- Dumping data for table `setting` @@ -149,7 +149,7 @@ CREATE TABLE IF NOT EXISTS `user` ( PRIMARY KEY (`uid`), UNIQUE KEY `login` (`username`), UNIQUE KEY `username` (`username`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `user`