From: Michael Tremer Date: Mon, 25 May 2020 09:17:29 +0000 (+0100) Subject: openvpn: Create database schema if not exists X-Git-Tag: v2.25-core145~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=75bb55e716f57667d6a34a99f15fc0cdacc1081b;p=ipfire-2.x.git openvpn: Create database schema if not exists Signed-off-by: Michael Tremer Signed-off-by: Arne Fitzenreiter --- diff --git a/html/cgi-bin/logs.cgi/ovpnclients.dat b/html/cgi-bin/logs.cgi/ovpnclients.dat index 2009990ec8..a064893a1a 100755 --- a/html/cgi-bin/logs.cgi/ovpnclients.dat +++ b/html/cgi-bin/logs.cgi/ovpnclients.dat @@ -95,6 +95,21 @@ unless ($to_datestring ge $from_datestring) { $errormessage = "$Lang::tr{'error the to date has to be later than the from date'}"; } +# Initialise database +my $cursor = $database_handle->prepare(" + CREATE TABLE IF NOT EXISTS sessions( + common_name TEXT NOT NULL, + connected_at TEXT NOT NULL, + disconnected_at TEXT, + bytes_received INTEGER, + bytes_sent INTEGER + ); + + -- Create index for speeding up searches + CREATE INDEX IF NOT EXISTS sessions_common_name ON sessions(common_name); +"); +$cursor->execute(); + my $database_query = qq( SELECT common_name, SUM(