Skip to content

Commit

Permalink
vnstat.cgi: add options for selecting which interfaces are shown or h…
Browse files Browse the repository at this point in the history
…idden from the index page without disabling access to all interface specific page when the database has more than one interface
  • Loading branch information
vergoh committed Apr 17, 2024
1 parent 54d4c90 commit 03ca79a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
page when the database has more than one interface
- Add option for selecting which image output is used on the index page
when the database has more than one interface
- Add options for selecting which interfaces are shown or hidden from the
index page without disabling access to all interface specific page when
the database has more than one interface
- Harmonize layout style between pages


Expand Down
18 changes: 16 additions & 2 deletions examples/vnstat.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ my $darkmode = '0';
# page auto refresh interval in seconds, set 0 to disable
my $pagerefresh = '0';

# interfaces to be shown on the index page when more than one interface exists, regular expression, leave empty to disable filter
my $indexshowninterfaces = '';

# interfaces to be hidden from the index page when more than one interface exists, regular expression, leave empty to disable filter
my $indexhiddeninterfaces = '';

# number of images to show per row on the index page when more than one interface exists, set '0' for auto fit
my $indeximagesperrow = '1';

# image output to use on index page when more than one interface exists
# image output to use on the index page when more than one interface exists
my $indeximageoutput = 'hs';

# cgi script file name for httpd
Expand Down Expand Up @@ -158,10 +164,18 @@ $cssbody
</head>
HEADER
print "<body>\n<br>\n";
my $interfacesshown = 0;
my $lineended = 0;
for my $i (0..$#interfaces) {
if (length($indexshowninterfaces) > 0 && $interfaces[${i}] !~ /$indexshowninterfaces/) {
next;
}
if (length($indexhiddeninterfaces) > 0 && $interfaces[${i}] =~ /$indexhiddeninterfaces/) {
next;
}
print "<a href=\"${scriptname}?${i}-f\"><img src=\"${scriptname}?${i}-$indeximageoutput\" alt=\"$interfaces[${i}]\"></a>";
if ($indeximagesperrow > 0 && ($i + 1) % $indeximagesperrow == 0) {
$interfacesshown++;
if ($indeximagesperrow > 0 && $interfacesshown % $indeximagesperrow == 0) {
print "<br>\n";
$lineended = 1;
} else {
Expand Down

0 comments on commit 03ca79a

Please sign in to comment.