]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
ovpnclients.dat: Add table header.
authorStefan Schantl <stefan.schantl@ipfire.org>
Mon, 13 Apr 2020 07:45:38 +0000 (09:45 +0200)
committerArne Fitzenreiter <arne_f@ipfire.org>
Fri, 1 May 2020 19:13:28 +0000 (19:13 +0000)
The header will be dynamically generated, according the items which will
be displayed.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
html/cgi-bin/logs.cgi/ovpnclients.dat

index b601fd292a96c226e6a4d64faa6be4293c7cb57d..33d6d871768b3ee14508c6a86559c699e1f3c540 100755 (executable)
@@ -243,7 +243,21 @@ my $lines = 0;
 
 print "<table width='100%' class='tbl'>";
 
-my $col="";
+my $col = "bgcolor='$color{'color20'}'";
+
+       print "<tr>\n";
+               print "<td width='40%' $col><b>$Lang::tr{'ovpn connection name'}</b></td>\n";
+
+       if ($cgiparams{'CONNECTION_NAME'}) {
+               print "<td width='20%' $col><b>$Lang::tr{'connected'}</b></td>\n";
+               print "<td width='20%' $col><b>$Lang::tr{'disconnected'}</b></td>\n";
+               print "<td width='10%' $col><b>$Lang::tr{'recieved'}</b></td>\n";
+               print "<td width='10%' $col><b>$Lang::tr{'sent'}</b></td>\n";
+       } else {
+               print "<td $col><b>$Lang::tr{'total connection time'}</b>\n";
+       }
+
+       print "</tr>\n";
 
 while(my @row = $statement_handle->fetchrow_array()) {
        # Assign some nice to read variable names for the DB fields.
@@ -253,23 +267,29 @@ while(my @row = $statement_handle->fetchrow_array()) {
        my $connection_bytes_recieved = &General::formatBytes($row[3]);
        my $connection_bytes_sent = &General::formatBytes($row[4]);
 
-       # Colorize columns. 
+       # Colorize columns.
        if ($lines % 2) {
+               $col="bgcolor='$color{'color20'}'";
+       } else {
                $col="bgcolor='$color{'color22'}'";
+       }
+
+       print "<tr>\n";
+               print "<td width='40%' $col>$connection_name</td>\n";
+
+       if ($cgiparams{'CONNECTION_NAME'}) {
+               print "<td width='20%' $col>$connection_open_time</td>\n";
+               print "<td width='20%' $col>$connection_close_time</td>\n";
+               print "<td width='10%' $col>$connection_bytes_recieved</td>\n";
+               print "<td width='10%' $col>$connection_bytes_sent</td>\n";
        } else {
-               $col="bgcolor='$color{'color20'}'";
+               # Convert total connection time into human-readable format.
+               my $total_time = &General::format_time($row[1]);
+
+               print "<td $col>$total_time</td>\n";
        }
 
-print <<END
-       <tr>
-               <td width="40%" align="left" $col>$connection_name</td>
-               <td width="20%" align="center" $col>$connection_open_time</td>
-               <td width="20%" align="center" $col>$connection_close_time</td>
-               <td width="10%" align="center" $col>$connection_bytes_recieved</td>
-               <td width="10%" align="center" $col>$connection_bytes_sent</td>
-       </tr>
-END
-;
+       print "</tr>\n";
 
        # Increase lines count.
        $lines++;