[10/19] ovpnclients.dat: Display error when the to date is not later than the from date.

Message ID 20200413074550.2735-10-stefan.schantl@ipfire.org
State Accepted
Commit 0f195a5305b1bfb2ea650e4a5079b446bb8ccc74
Headers show
Series [01/19] openvpn: Add WUI page for client usage statistics | expand

Commit Message

Stefan Schantl April 13, 2020, 7:45 a.m. UTC
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 html/cgi-bin/logs.cgi/ovpnclients.dat | 5 +++++
 langs/en/cgi-bin/en.pl                | 1 +
 2 files changed, 6 insertions(+)

Patch

diff --git a/html/cgi-bin/logs.cgi/ovpnclients.dat b/html/cgi-bin/logs.cgi/ovpnclients.dat
index b84c2b8d7..a83a0bca9 100755
--- a/html/cgi-bin/logs.cgi/ovpnclients.dat
+++ b/html/cgi-bin/logs.cgi/ovpnclients.dat
@@ -90,6 +90,11 @@  my $database_handle = DBI->connect("DBI:SQLite:dbname=$database", "", "", { Rais
 my $from_datestring = sprintf '%04d-%02d-%02d', ($cgiparams{"FROM_YEAR"}, $cgiparams{"FROM_MONTH"}, $cgiparams{"FROM_DAY"});
 my $to_datestring = sprintf '%04d-%02d-%02d', ($cgiparams{"TO_YEAR"}, $cgiparams{"TO_MONTH"}, $cgiparams{"TO_DAY"});
 
+# Check if the to datestring is later than the from datestring.
+unless ($to_datestring ge $from_datestring) {
+	$errormessage = "$Lang::tr{'error the to date has to be later than the from date'}";
+}
+
 my $database_query = qq(
 	SELECT
         common_name, SUM(
diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl
index 171d24937..3d07473e7 100644
--- a/langs/en/cgi-bin/en.pl
+++ b/langs/en/cgi-bin/en.pl
@@ -1012,6 +1012,7 @@ 
 'error config' => 'Could not open /var/ipfire/ovpn/config/ZERINA.ovpn !',
 'error external access' => 'Could not open /var/ipfire/xtaccess/config (external acccess could not be granted)!',
 'error messages' => 'Error messages',
+'error the to date has to be later than the from date' => 'The to date has to be later than the from date!',
 'esp encryption' => 'ESP Encryption:',
 'esp grouptype' => 'ESP Grouptype:',
 'esp integrity' => 'ESP Integrity:',