summaryrefslogtreecommitdiffstats
path: root/modules-available/rebootcontrol/pages/subnet.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/rebootcontrol/pages/subnet.inc.php')
-rw-r--r--modules-available/rebootcontrol/pages/subnet.inc.php26
1 files changed, 17 insertions, 9 deletions
diff --git a/modules-available/rebootcontrol/pages/subnet.inc.php b/modules-available/rebootcontrol/pages/subnet.inc.php
index cbd5d8f2..a6d8d837 100644
--- a/modules-available/rebootcontrol/pages/subnet.inc.php
+++ b/modules-available/rebootcontrol/pages/subnet.inc.php
@@ -24,7 +24,7 @@ class SubPage
User::assertPermission('subnet.edit');
$cidr = Request::post('cidr', Request::REQUIRED, 'string');
$range = IpUtil::parseCidr($cidr);
- if ($range === false) {
+ if ($range === null) {
Message::addError('invalid-cidr', $cidr);
return;
}
@@ -106,6 +106,7 @@ class SubPage
{
User::assertPermission('subnet.*');
$nets = [];
+ $c2c = Property::get(RebootControl::KEY_SCAN_CLIENT_TO_CLIENT);
$res = Database::simpleQuery('SELECT subnetid, start, end, fixed, isdirect,
nextdirectcheck, lastseen, seencount, Count(hxs.hostid) AS jumphostcount, Count(sxs.srcid) AS sourcecount
FROM reboot_subnet s
@@ -114,12 +115,15 @@ class SubPage
GROUP BY subnetid, start, end
ORDER BY start ASC, end DESC');
$deadline = strtotime('-60 days');
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ foreach ($res as $row) {
$row['cidr'] = IpUtil::rangeToCidr($row['start'], $row['end']);
$row['lastseen_s'] = Util::prettyTime($row['lastseen']);
if ($row['lastseen'] && $row['lastseen'] < $deadline) {
$row['lastseen_class'] = 'text-danger';
}
+ if (!$c2c) {
+ $row['sourcecount'] = '-';
+ }
$nets[] = $row;
}
$data = ['subnets' => $nets];
@@ -145,20 +149,24 @@ class SubPage
ORDER BY h.host ASC', ['id' => $id]);
// Mark those assigned to the current subnet
$jh = [];
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ foreach ($res as $row) {
$row['checked'] = $row['subnetid'] === null ? '' : 'checked';
$jh[] = $row;
}
$subnet['jumpHosts'] = $jh;
- // Get list of all subnets that can broadcast into this one
- $res = Database::simpleQuery('SELECT s.start, s.end FROM reboot_subnet s
+ $c2c = Property::get(RebootControl::KEY_SCAN_CLIENT_TO_CLIENT);
+ if ($c2c) {
+ // Get list of all subnets that can broadcast into this one
+ $res = Database::simpleQuery('SELECT s.start, s.end FROM reboot_subnet s
INNER JOIN reboot_subnet_x_subnet sxs ON (s.subnetid = sxs.srcid AND sxs.dstid = :id AND sxs.reachable = 1)
ORDER BY s.start ASC', ['id' => $id]);
- $sn = [];
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $sn[] = ['cidr' => IpUtil::rangeToCidr($row['start'], $row['end'])];
+ $sn = [];
+ foreach ($res as $row) {
+ $sn[] = ['cidr' => IpUtil::rangeToCidr($row['start'], $row['end'])];
+ }
+ $subnet['sourceNets'] = $sn;
+ $subnet['showC2C'] = true;
}
- $subnet['sourceNets'] = $sn;
Permission::addGlobalTags($subnet['perms'], null, ['subnet.flag', 'jumphost.view', 'jumphost.assign-subnet']);
Render::addTemplate('subnet-edit', $subnet);
}