mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 11:43:25 +02:00
OpenVPN: Fix query when selecting sessions only
Previously some sessions were selected which did not qualify for the search. Signed-off-by: Michael Tremer <michael.tremer@ipfire.org> Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
This commit is contained in:
committed by
Arne Fitzenreiter
parent
3e10b3de4a
commit
70e1d58745
@@ -107,27 +107,31 @@ my $database_query = qq(
|
|||||||
ELSE DATETIME('$from_datestring', 'localtime', 'start of day')
|
ELSE DATETIME('$from_datestring', 'localtime', 'start of day')
|
||||||
END
|
END
|
||||||
), 'utc')
|
), 'utc')
|
||||||
)
|
) AS duration
|
||||||
FROM sessions
|
FROM sessions
|
||||||
WHERE
|
WHERE
|
||||||
disconnected_at IS NULL
|
(
|
||||||
OR
|
disconnected_at IS NULL
|
||||||
DATETIME(disconnected_at, 'localtime') > DATETIME('$from_datestring', 'localtime', 'start of day')
|
OR
|
||||||
OR
|
DATETIME(disconnected_at, 'localtime') > DATETIME('$from_datestring', 'localtime', 'start of day')
|
||||||
|
)
|
||||||
|
AND
|
||||||
DATETIME(connected_at, 'localtime') < DATETIME('$to_datestring', 'localtime', 'start of day', '+86399 seconds')
|
DATETIME(connected_at, 'localtime') < DATETIME('$to_datestring', 'localtime', 'start of day', '+86399 seconds')
|
||||||
GROUP BY common_name
|
GROUP BY common_name
|
||||||
ORDER BY common_name;
|
ORDER BY common_name, duration DESC;
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($cgiparams{'CONNECTION_NAME'}) {
|
if ($cgiparams{'CONNECTION_NAME'}) {
|
||||||
$database_query = qq(
|
$database_query = qq(
|
||||||
SELECT *
|
SELECT * FROM sessions
|
||||||
FROM sessions
|
|
||||||
WHERE
|
WHERE
|
||||||
common_name = '$cgiparams{"CONNECTION_NAME"}' AND (
|
common_name = '$cgiparams{"CONNECTION_NAME"}'
|
||||||
DATETIME(disconnected_at, 'localtime') > DATETIME('$from_datestring', 'localtime', 'start of day')
|
AND (
|
||||||
OR
|
DATETIME(disconnected_at, 'localtime') > DATETIME('$from_datestring', 'localtime', 'start of day')
|
||||||
DATETIME(connected_at, 'localtime') < DATETIME('$to_datestring', 'localtime', 'start of day', '+86399 seconds'));
|
AND
|
||||||
|
DATETIME(connected_at, 'localtime') < DATETIME('$to_datestring', 'localtime', 'start of day', '+86399 seconds')
|
||||||
|
)
|
||||||
|
ORDER BY connected_at;
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user