bugfix: the feature of remembering last opened tab of realm page is now working
update: UI: ports/IPs/nets highlighting enhancements
bugfix: UI: pager in ipv4net shows appropriate page when IP is highlighted
+ bugfix: create IPv4 network button, if pressed to open in a new window, was redirecting the parent window, too
+ bugfix: when searching for IP not belonging to any known network, the ugly assertion failed page was shown.
+ update: links to ports added to object search results
+ update: custom rearch results provided by users' plugins now supported
0.18.7
bugfix: adjust 802.1Q command generation
bugfix: fixed telnet session hanging in NX-OS4 connector
);
$ret = array();
foreach ($byname as $row)
- $ret[] = spotEntity ('ipv4net', $row['id']);
+ $ret[$row['id']] = spotEntity ('ipv4net', $row['id']);
return $ret;
}
);
$ret = array();
foreach ($byname as $row)
- $ret[] = spotEntity ('ipv6net', $row['id']);
+ $ret[$row['id']] = spotEntity ('ipv6net', $row['id']);
return $ret;
}
$result = usePreparedSelectBlade ($query, $qparams);
$ret = array();
while ($row = $result->fetch (PDO::FETCH_ASSOC))
- $ret[] = $row;
+ $ret[$row['ip']] = $row;
return $ret;
}
$result = usePreparedSelectBlade ($query, $qparams);
$ret = array();
while ($row = $result->fetch (PDO::FETCH_ASSOC))
- $ret[] = $row;
+ $ret[$row['ip']] = $row;
return $ret;
}
);
$ret = array();
foreach ($byname as $row)
- $ret[] = spotEntity ('ipv4rspool', $row['id']);
+ $ret[$row['id']] = spotEntity ('ipv4rspool', $row['id']);
return $ret;
}
);
$ret = array();
foreach ($byname as $row)
- $ret[] = spotEntity ('ipv4vs', $row['id']);
+ $ret[$row['id']] = spotEntity ('ipv4vs', $row['id']);
return $ret;
}
$terms,
'user_name'
);
- // Filter out dupes.
- foreach ($byUsername as $res1)
- foreach (array_keys ($byRealname) as $key2)
- if ($res1['user_id'] == $byRealname[$key2]['user_id'])
- {
- unset ($byRealname[$key2]);
- continue 2;
- }
- $ret = array_merge ($byUsername, $byRealname);
- // Set realm, so it's renderable.
- foreach (array_keys ($ret) as $key)
- $ret[$key]['realm'] = 'user';
+ // Merge it together, if duplicates persist, byUsername wins
+ foreach (array ($byRealname, $byUsername) as $array)
+ foreach ($array as $user)
+ {
+ $user['realm'] = 'user';
+ $ret[$user['user_id']] = $user;
+ }
return $ret;
}
}
$ret = array();
foreach (array_merge ($byName, $byComment) as $row)
- $ret[] = spotEntity ('file', $row['id']);
+ $ret[$row['id']] = spotEntity ('file', $row['id']);
return $ret;
}
}
$ret = array();
foreach (array_merge ($byName, $byComment) as $row)
- $ret[] = spotEntity ('rack', $row['id']);
+ $ret[$row['id']] = spotEntity ('rack', $row['id']);
return $ret;
}
1
);
foreach ($byID as $row)
- $ret[] = $row['domain_id'] . '-' . $row['vlan_id'];
+ {
+ $vlan_ck = $row['domain_id'] . '-' . $row['vlan_id'];
+ $ret[$vlan_ck] = $vlan_ck;
+ }
}
else
{
foreach ($byDescr as $row)
{
$vlan_ck = $row['domain_id'] . '-' . $row['vlan_id'];
- if (!in_array ($vlan_ck, $ret))
- $ret[] = $vlan_ck;
+ $ret[$vlan_ck] = $vlan_ck;
}
}
return $ret;
return implode (', ', array_fill (0, $count, '?'));
}
-// returns search results as an array with 'nhits', 'lasthit', 'summary' keys
+// returns search results as an array keyed with realm name
// groups found entities by realms in 'summary'
function searchEntitiesByText ($terms)
{
- $result = array
- (
- 'nhits' => 0,
- 'lasthit' => NULL,
- 'summary' => array(),
- );
- $nhits = &$result['nhits'];
- $lasthit = &$result['lasthit'];
- $summary = &$result['summary'];
-
+ $summary = array();
$ipv6 = new IPv6Address;
+
if (preg_match (RE_IP4_ADDR, $terms))
// Search for IPv4 address.
{
- if (NULL !== getIPv4AddressNetworkId ($terms))
- {
- $nhits++;
- $lasthit = 'ipv4addressbydq';
- $summary['ipv4addressbydq'][] = $terms;
- }
+ if ($net_id = getIPv4AddressNetworkId ($terms))
+ $summary['ipv4addressbydq'][$terms] = array ('net_id' => $net_id, 'ip' => $terms);
+
}
elseif ($ipv6->parse ($terms))
// Search for IPv6 address
{
- if (NULL !== $net_id = getIPv6AddressNetworkId ($ipv6))
- {
- $nhits++;
- $lasthit = 'ipv6addressbydq';
- $summary['ipv6addressbydq'][] = array ('net_id' => $net_id, 'ip' => $ipv6);
- }
+ if ($net_id = getIPv6AddressNetworkId ($ipv6))
+ $summary['ipv6addressbydq'][$net_id] = array ('net_id' => $net_id, 'ip' => $ipv6);
}
elseif (preg_match (RE_IP4_NET, $terms))
// Search for IPv4 network
{
list ($base, $len) = explode ('/', $terms);
- if (NULL !== ($tmp = getIPv4AddressNetworkId ($base, $len + 1)))
- {
- $nhits++;
- $lasthit = 'ipv4network';
- $summary['ipv4network'][] = spotEntity ('ipv4net', $tmp);
- }
+ if (NULL !== ($net_id = getIPv4AddressNetworkId ($base, $len + 1)))
+ $summary['ipv4network'][$net_id] = spotEntity('ipv4net', $net_id);
}
elseif (preg_match ('@(.*)/(\d+)$@', $terms, $matches) && $ipv6->parse ($matches[1]))
// Search for IPv6 network
{
- if (NULL !== ($tmp = getIPv6AddressNetworkId ($ipv6, $matches[2] + 1)))
- {
- $nhits++;
- $lasthit = 'ipv6network';
- $summary['ipv6network'][] = spotEntity ('ipv6net', $tmp);
- }
+ if (NULL !== ($net_id = getIPv6AddressNetworkId ($ipv6, $matches[2] + 1)))
+ $summary['ipv6network'][$net_id] = spotEntity('ipv6net', $net_id);
}
else
// Search for objects, addresses, networks, virtual services and RS pools by their description.
{
$tmp = getObjectSearchResults ($terms);
if (count ($tmp))
- {
- $nhits += count ($tmp);
- $lasthit = 'object';
$summary['object'] = $tmp;
- }
$tmp = getIPv4AddressSearchResult ($terms);
if (count ($tmp))
- {
- $nhits += count ($tmp);
- $lasthit = 'ipv4addressbydescr';
$summary['ipv4addressbydescr'] = $tmp;
- }
$tmp = getIPv6AddressSearchResult ($terms);
if (count ($tmp))
- {
- $nhits += count ($tmp);
- $lasthit = 'ipv6addressbydescr';
$summary['ipv6addressbydescr'] = $tmp;
- }
$tmp = getIPv4PrefixSearchResult ($terms);
if (count ($tmp))
- {
- $nhits += count ($tmp);
- $lasthit = 'ipv4network';
$summary['ipv4network'] = $tmp;
- }
$tmp = getIPv6PrefixSearchResult ($terms);
if (count ($tmp))
- {
- $nhits += count ($tmp);
- $lasthit = 'ipv6network';
$summary['ipv6network'] = $tmp;
- }
$tmp = getIPv4RSPoolSearchResult ($terms);
if (count ($tmp))
- {
- $nhits += count ($tmp);
- $lasthit = 'ipv4rspool';
$summary['ipv4rspool'] = $tmp;
- }
$tmp = getIPv4VServiceSearchResult ($terms);
if (count ($tmp))
- {
- $nhits += count ($tmp);
- $lasthit = 'ipv4vs';
$summary['ipv4vs'] = $tmp;
- }
$tmp = getAccountSearchResult ($terms);
if (count ($tmp))
- {
- $nhits += count ($tmp);
- $lasthit = 'user';
$summary['user'] = $tmp;
- }
$tmp = getFileSearchResult ($terms);
if (count ($tmp))
- {
- $nhits += count ($tmp);
- $lasthit = 'file';
$summary['file'] = $tmp;
- }
$tmp = getRackSearchResult ($terms);
if (count ($tmp))
- {
- $nhits += count ($tmp);
- $lasthit = 'rack';
$summary['rack'] = $tmp;
- }
- if (count ($tmp = getVLANSearchResult ($terms)))
- {
- $nhits += count ($tmp);
- $lasthit = 'vlan';
+ $tmp = getVLANSearchResult ($terms);
+ if (count ($tmp))
$summary['vlan'] = $tmp;
- }
}
- return $result;
+ return $summary;
}
?>
renderSearchResults ($terms, $results);
}
-function renderSearchResults ($terms, $results)
+function renderSearchResults ($terms, $summary)
{
- $nhits = &$results['nhits'];
- $lasthit = &$results['lasthit'];
- $summary = &$results['summary'];
-
+ // calculate the number of found objects
+ $nhits = 0;
+ foreach ($summary as $realm => $list)
+ $nhits += count ($list);
+
if ($nhits == 0)
echo "<center><h2>Nothing found for '${terms}'</h2></center>";
elseif ($nhits == 1)
{
- $record = current ($summary[$lasthit]);
- switch ($lasthit)
+ $realm = key ($summary);
+ $record = current (current ($summary));
+ switch ($realm)
{
case 'ipv4addressbydq':
- $parentnet = getIPv4AddressNetworkId ($record);
- if ($parentnet !== NULL)
- echo "<script language='Javascript'>document.location='index.php?page=ipv4net&tab=default&id=${parentnet}&hl_ipv4_addr=${record}';//</script>";
- else
- echo "<script language='Javascript'>document.location='index.php?page=ipaddress&ip=${record}';//</script>";
+ if ($record['net_id'] !== NULL)
+ echo "<script language='Javascript'>document.location='index.php?page=ipv4net&tab=default&id=${record['net_id']}&hl_ipv4_addr=${record['ip']}';//</script>";
break;
case 'ipv6addressbydq':
$v6_ip_dq = $record['ip']->format();
- echo "<script language='Javascript'>document.location='index.php?page=ipv6net&tab=default&id=${record['net_id']}&hl_ipv6_addr=${v6_ip_dq}';//</script>";
+ if ($record['net_id'] !== NULL)
+ echo "<script language='Javascript'>document.location='index.php?page=ipv6net&tab=default&id=${record['net_id']}&hl_ipv6_addr=${v6_ip_dq}';//</script>";
break;
case 'ipv4addressbydescr':
$parentnet = getIPv4AddressNetworkId ($record['ip']);
if ($parentnet !== NULL)
echo "<script language='Javascript'>document.location='index.php?page=ipv4net&tab=default&id=${parentnet}&hl_ipv4_addr=${record['ip']}';//</script>";
- else
- echo "<script language='Javascript'>document.location='index.php?page=ipaddress&ip=${record['ip']}';//</script>";
break;
case 'ipv6addressbydescr':
$v6_ip = new IPv6Address ($record['ip']);
$parentnet = getIPv6AddressNetworkId ($v6_ip);
if ($parentnet !== NULL)
echo "<script language='Javascript'>document.location='index.php?page=ipv4net&tab=default&id=${parentnet}&hl_ipv6_addr=${v6_ip_dq}';//</script>";
- else
- echo "<script language='Javascript'>document.location='index.php?page=ipaddress&ip=${v6_ip_dq}';//</script>";
break;
case 'ipv4network':
echo "<script language='Javascript'>document.location='index.php?page=ipv4net";
foreach ($object['ports'] as $port)
if ($port['id'] == $port_id)
{
- echo "<tr><td>port ${port['name']}:</td>";
+ $port_href = '<a href="' . makeHref (array
+ (
+ 'page' => 'object',
+ 'object_id' => $object['id'],
+ 'hl_port_id' => $port_id
+ )) . '">port ' . $port['name'] . '</a>';
+ echo "<tr><td>${port_href}:</td>";
echo "<td class=tdleft>${text}</td></tr>";
break; // next reason
}
echo '</table>';
finishPortlet();
break;
+ default: // you can use that in your plugins to add some non-standard search results
+ startPortlet($where);
+ echo $what;
+ finishPortlet();
}
}
}
}
echo "<tr class=row_${order}><td>";
echo '<a href="' . makeHrefProcess (array ('op' => 'del', 'type1' => $pair['type1'], 'type2' => $pair['type2'])) . '">';
- printImageHREF ('delete', 'remove pair', TRUE);
+ printImageHREF ('delete', 'remove pair');
echo "</a></td><td class=tdleft>${pair['type1name']}</td><td class=tdleft>${pair['type2name']}</td></tr>";
}
if (getConfigVar ('ADDNEW_AT_TOP') != 'yes')
'tab' => 'newrange',
'set-prefix' => $formatted,
)) . '">';
- printImageHREF ('knight', 'create network here', TRUE);
+ printImageHREF ('knight', 'create network here');
echo '</a>';
}
}
}
echo "<tr class=row_${order}><td>";
echo '<a href="' . makeHrefProcess (array ('op' => 'del', 'iif_id' => $record['iif_id'], 'oif_id' => $record['oif_id'])) . '">';
- printImageHREF ('delete', 'remove pair', TRUE);
+ printImageHREF ('delete', 'remove pair');
echo "</a></td><td class=tdleft>${record['iif_name']}</td><td class=tdleft>${record['oif_name']}</td></tr>";
}
if (getConfigVar ('ADDNEW_AT_TOP') != 'yes')