summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-09-13 15:40:27 +0200
committerSimon Rettberg2016-09-13 15:40:27 +0200
commit93144b641bfd186d0c27d82757ca203990dab30f (patch)
treec12ec372e2a8a2026a3b9c4872f027d8670f4c70
parentskip rooms without manager ip because that trips pvsmgr. (diff)
downloadslx-admin-93144b641bfd186d0c27d82757ca203990dab30f.tar.gz
slx-admin-93144b641bfd186d0c27d82757ca203990dab30f.tar.xz
slx-admin-93144b641bfd186d0c27d82757ca203990dab30f.zip
[statistics/locations] Fix query for getting machines for a location
-rw-r--r--modules-available/locations/page.inc.php4
-rw-r--r--modules-available/statistics/inc/filter.inc.php4
2 files changed, 4 insertions, 4 deletions
diff --git a/modules-available/locations/page.inc.php b/modules-available/locations/page.inc.php
index 5f3c87dd..1bf33dda 100644
--- a/modules-available/locations/page.inc.php
+++ b/modules-available/locations/page.inc.php
@@ -438,8 +438,8 @@ class Page_Locations extends Page
$count = $online = $used = 0;
if (Module::get('statistics') !== false) {
$mres = Database::simpleQuery("SELECT lastseen, logintime FROM machine"
- . " INNER JOIN subnet ON (INET_ATON(machine.clientip) BETWEEN startaddr AND endaddr)"
- . " WHERE (subnet.locationid = :lid AND machine.locationid IS NULL) OR machine.locationid = :lid", array('lid' => $locationId));
+ . " LEFT JOIN subnet ON (INET_ATON(machine.clientip) BETWEEN startaddr AND endaddr AND machine.locationid IS NULL)"
+ . " WHERE (subnet.locationid = :lid) OR (machine.locationid = :lid)", array('lid' => $locationId));
$DL = time() - 605;
while ($row = $mres->fetch(PDO::FETCH_ASSOC)) {
$count++;
diff --git a/modules-available/statistics/inc/filter.inc.php b/modules-available/statistics/inc/filter.inc.php
index b35075bc..03dba6c3 100644
--- a/modules-available/statistics/inc/filter.inc.php
+++ b/modules-available/statistics/inc/filter.inc.php
@@ -217,10 +217,10 @@ class LocationFilter extends Filter
$joins[] = 'LEFT JOIN subnet s ON (INET_ATON(machine.clientip) BETWEEN s.startaddr AND s.endaddr)';
return 'machine.locationid IS NULL AND s.locationid IS NULL';
} else {
- $joins[] = ' INNER JOIN subnet ON (INET_ATON(clientip) BETWEEN startaddr AND endaddr) ';
+ $joins[] = ' LEFT JOIN subnet ON (INET_ATON(clientip) BETWEEN startaddr AND endaddr AND machine.locationid IS NULL) ';
$args['lid'] = $this->argument;
$neg = $this->operator == '=' ? '' : 'NOT';
- return "$neg ((subnet.locationid = :lid AND machine.locationid IS NULL) OR machine.locationid = :lid)";
+ return "$neg ((subnet.locationid = :lid) OR (machine.locationid = :lid))";
}
}
}